Merge branch 'geoapi-3.1'.
Contains upgrade of `EPSGFactory` for reading EPSG database version 12.
diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..aaf336f
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,22 @@
+#
+# Configuration file for Apache SIS project.
+#
+# Documentation: https://s.apache.org/asfyaml
+# Active setting: https://gitbox.apache.org/schemes.cgi?sis-site
+#
+github:
+ description: Java language library for developing geospatial applications following OGC/ISO standards.
+ homepage: https://sis.apache.org/
+ labels:
+ - java
+ - geospatial
+ - standards
+notifications:
+ commits: commits@sis.apache.org
+ issues: dev@sis.apache.org
+ issues_status: issues@sis.apache.org
+ issues_comment: issues@sis.apache.org
+ pullrequests: dev@sis.apache.org
+ pullrequests_status: issues@sis.apache.org
+ pullrequests_comment: issues@sis.apache.org
+ jira_options: worklog
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index aab14f3..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,4 +0,0 @@
-[submodule "geoapi/snapshot"]
- path = geoapi/snapshot
- url = https://github.com/opengeospatial/geoapi
- branch = 3.1.x
diff --git a/NOTICE b/NOTICE
index e31e488..acd2096 100644
--- a/NOTICE
+++ b/NOTICE
@@ -7,7 +7,7 @@
The Javadoc contains documentation from the Open Geospatial Consortium (OGC®)
specifications (https://www.ogc.org/standards/), also known as OpenGIS®.
-Apache SIS depends on GeoAPI published by OGC under Apache 2.0 license.
+Apache SIS depends on GeoAPI published by OGC under BSD-style license.
https://www.ogc.org/about-ogc/policies/software-licenses/
Apache SIS depends on JSR-385 (API only) published under BSD license.
diff --git a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/Dependency.java b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/Dependency.java
index 6900186..0103875 100644
--- a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/Dependency.java
+++ b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/Dependency.java
@@ -71,14 +71,12 @@
Map.entry("database", "non-free:sis-embedded-data"), // Optional.
Map.entry("gui", "application:sis-javafx"), // Optional.
Map.entry("cql", "core:sis-cql"), // Incubator.
- Map.entry("geometry", "core:sis-geometry"), // Incubator.
Map.entry("storage.shapefile", "storage:sis-shapefile"),
Map.entry("storage.geoheif", "storage:sis-geoheif"),
Map.entry("storage.gsf", "storage:sis-gsf"),
Map.entry("storage.gdal", "storage:sis-gdal"),
Map.entry("storage.geopackage", "storage:sis-geopackage"),
Map.entry("storage.coveragejson", "storage:sis-coveragejson"),
- Map.entry("portrayal.map", "core:sis-portrayal-map"),
Map.entry("webapp", "application:sis-webapp")
);
diff --git a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJAR.java b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJAR.java
index 8863453..f6468c5 100644
--- a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJAR.java
+++ b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJAR.java
@@ -47,7 +47,7 @@
*
* @todo should be specified in a property.
*/
- private static final String GEOAPI_VERSION = "3.1-SNAPSHOT";
+ private static final String GEOAPI_VERSION = "3.0.2";
/**
* Attributes where values are class names. Those attributes can be assigned
diff --git a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJavadoc.java b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJavadoc.java
index 00a55a2..b5d31bf 100644
--- a/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJavadoc.java
+++ b/buildSrc/src/main/java/org/apache/sis/buildtools/gradle/ModularJavadoc.java
@@ -69,7 +69,7 @@
"todo:a:\"TODO:\"");
options.links(
"https://docs.oracle.com/en/java/javase/11/docs/api",
- "http://www.geoapi.org/snapshot/javadoc",
+ "http://www.geoapi.org/3.0/javadoc",
"https://openjfx.io/javadoc/21/",
"http://unitsofmeasurement.github.io/unit-api/site/apidocs");
/*
diff --git a/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst b/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst
index 05fe6dc..1959531 100644
--- a/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst
+++ b/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst
@@ -79,8 +79,10 @@
Formula
GCP
GCPCollection
+GeneralDerivedCRS
GeneralParameterDescriptor
GeneralParameterValue
+GeocentricCRS
GeodeticCRS
GeodeticDatum
GeographicBoundingBox
diff --git a/endorsed/build.gradle.kts b/endorsed/build.gradle.kts
index ffd4adc..9a0f2f3 100644
--- a/endorsed/build.gradle.kts
+++ b/endorsed/build.gradle.kts
@@ -97,7 +97,6 @@
*/
var srcDir = file("src") // Must be the same as the hard-coded value in `BuildHelper.java`.
tasks.compileJava {
- dependsOn(":geoapi:rebuild")
options.release.set(11) // The version of both Java source code and compiled byte code.
}
tasks.compileTestJava {
diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/IdentifierCommand.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/IdentifierCommand.java
index b048d9a..3f80b9f 100644
--- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/IdentifierCommand.java
+++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/IdentifierCommand.java
@@ -36,6 +36,10 @@
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.util.resources.Vocabulary;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.DefaultMetadata;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
+
/**
* The "identifier" sub-command.
@@ -126,11 +130,11 @@
}
if (metadata != null) {
final List<Row> rows;
- if (metadata instanceof Metadata) {
+ if (metadata instanceof DefaultMetadata) {
rows = new ArrayList<>();
- final Identifier id = ((Metadata) metadata).getMetadataIdentifier();
- if (id != null) {
- CharSequence desc = id.getDescription();
+ final Identifier id = ((DefaultMetadata) metadata).getMetadataIdentifier();
+ if (id instanceof DefaultIdentifier) {
+ CharSequence desc = ((DefaultIdentifier) id).getDescription();
if (desc == null && !files.isEmpty()) {
final Object c = files.get(0);
if (c instanceof CharSequence) {
diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java
index 7d87734..810cfc1 100644
--- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java
+++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java
@@ -82,8 +82,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.geometry.MismatchedDimensionException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.apache.sis.referencing.DefaultObjectDomain;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -356,7 +357,7 @@
printHeader(Vocabulary.Keys.Destination); printNameAndIdentifier(getEffectiveCRS(true), false);
printHeader(Vocabulary.Keys.Operations); printOperations(operation, false);
outHeader.nextLine();
- printDomainOfValidity(operation.getDomains());
+ printDomainOfValidity(Legacy.getDomains(operation));
printAccuracy(CRS.getLinearAccuracy(operation));
if (options.containsKey(Option.VERBOSE)) {
printDetails();
@@ -499,8 +500,8 @@
*
* <blockquote>Canada - onshore and offshore</blockquote>
*/
- private void printDomainOfValidity(final Collection<ObjectDomain> domains) throws IOException {
- for (final ObjectDomain domain : domains) {
+ private void printDomainOfValidity(final Collection<DefaultObjectDomain> domains) throws IOException {
+ for (final DefaultObjectDomain domain : domains) {
final Extent extent = domain.getDomainOfValidity();
final InternationalString description = extent.getDescription();
if (description != null) {
diff --git a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
index 65c9b47..cfd7d2d 100644
--- a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
+++ b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
@@ -24,8 +24,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCaseWithLogs;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.junit.jupiter.api.Disabled;
/**
@@ -47,8 +47,9 @@
* @throws Exception if an error occurred while creating the command.
*/
@Test
+ @Disabled("Requires GeoAPI 3.1")
public void testNetCDF() throws Exception {
- final URL url = TestData.NETCDF_2D_GEOGRAPHIC.location();
+ final URL url = new URL("Cube2D_geographic_packed.nc"); // TestData.NETCDF_2D_GEOGRAPHIC.location();
var test = new MetadataCommand(0, new String[] {CommandRunner.TEST, url.toString()});
test.run();
verifyNetCDF("Metadata", test.outputBuffer.toString());
@@ -73,8 +74,9 @@
* @throws Exception if an error occurred while creating the command.
*/
@Test
+ @Disabled("Requires GeoAPI 3.1")
public void testFormatXML() throws Exception {
- final URL url = TestData.NETCDF_2D_GEOGRAPHIC.location();
+ final URL url = new URL("Cube2D_geographic_packed.nc") ; // TestData.NETCDF_2D_GEOGRAPHIC.location();
var test = new MetadataCommand(0, new String[] {CommandRunner.TEST, url.toString(), "--format", "XML"});
test.run();
verifyNetCDF("<?xml", test.outputBuffer.toString());
diff --git a/endorsed/src/org.apache.sis.feature/main/module-info.java b/endorsed/src/org.apache.sis.feature/main/module-info.java
index e557fb2..74df053 100644
--- a/endorsed/src/org.apache.sis.feature/main/module-info.java
+++ b/endorsed/src/org.apache.sis.feature/main/module-info.java
@@ -41,12 +41,16 @@
exports org.apache.sis.filter;
exports org.apache.sis.index.tree;
- exports org.apache.sis.filter.privy to
+ exports org.apache.sis.pending.geoapi.filter to
org.apache.sis.storage,
org.apache.sis.storage.sql,
org.apache.sis.storage.shapefile, // In the "incubator" sub-project.
- org.apache.sis.cql, // In the "incubator" sub-project.
- org.apache.sis.portrayal.map; // In the "incubator" sub-project.
+ org.apache.sis.portrayal;
+
+ exports org.apache.sis.filter.privy to
+ org.apache.sis.storage,
+ org.apache.sis.storage.sql,
+ org.apache.sis.storage.shapefile; // In the "incubator" sub-project.
exports org.apache.sis.filter.sqlmm to
org.apache.sis.geometry; // In the "incubator" sub-project.
@@ -59,28 +63,19 @@
org.apache.sis.storage.shapefile, // In the "incubator" sub-project.
org.apache.sis.storage.gdal, // In the "optional" sub-project.
org.apache.sis.portrayal,
- org.apache.sis.portrayal.map, // In the "incubator" sub-project.
org.apache.sis.gui; // In the "optional" sub-project.
exports org.apache.sis.geometry.wrapper to
- org.apache.sis.geometry, // In the "incubator" sub-project.
org.apache.sis.storage,
org.apache.sis.storage.xml,
org.apache.sis.storage.sql,
org.apache.sis.storage.netcdf,
org.apache.sis.storage.gdal, // In the "optional" sub-project.
- org.apache.sis.storage.shapefile, // In the "incubator" sub-project.
- org.apache.sis.portrayal.map, // In the "incubator" sub-project.
- org.apache.sis.cql; // In the "incubator" sub-project.
+ org.apache.sis.storage.shapefile; // In the "incubator" sub-project.
exports org.apache.sis.geometry.wrapper.j2d to
org.apache.sis.gui; // In the "optional" sub-project.
- exports org.apache.sis.geometry.wrapper.jts to
- org.apache.sis.geometry, // In the "incubator" sub-project.
- org.apache.sis.portrayal.map, // In the "incubator" sub-project.
- org.apache.sis.cql; // In the "incubator" sub-project.
-
exports org.apache.sis.coverage.privy to
org.apache.sis.storage,
org.apache.sis.storage.netcdf,
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/BandedCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/BandedCoverage.java
index e735e1b..68de7fe 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/BandedCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/BandedCoverage.java
@@ -23,10 +23,6 @@
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.coverage.PointOutsideCoverageException;
-
/**
* A coverage where all sample values at a given location can be provided in an array of primitive type.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CannotEvaluateException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CannotEvaluateException.java
new file mode 100644
index 0000000..9dbc699
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CannotEvaluateException.java
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+
+/**
+ * Thrown when a quantity can not be evaluated.
+ *
+ * <div class="note"><b>Upcoming API change:</b>
+ * this class may move to GeoAPI in a future version. If that move happens,
+ * the {@code org.apache.sis.coverage} package name would become {@code org.opengis.coverage}.</div>
+ */
+public class CannotEvaluateException extends RuntimeException {
+ /**
+ * Creates an exception with no message.
+ */
+ public CannotEvaluateException() {
+ super();
+ }
+
+ /**
+ * Creates an exception with the specified message.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public CannotEvaluateException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates an exception with the specified message.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ * @param cause the cause for this exception. The cause is saved
+ * for later retrieval by the {@link #getCause()} method.
+ */
+ public CannotEvaluateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CategoryList.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CategoryList.java
index 2738250..6484b3d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CategoryList.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CategoryList.java
@@ -758,7 +758,7 @@
} else {
ArgumentChecks.ensureDimensionMatches("ptDst", 1, ptDst);
}
- ptDst.setCoordinate(0, transform(ptSrc.getCoordinate(0)));
+ ptDst.setOrdinate(0, transform(ptSrc.getOrdinate(0)));
return ptDst;
}
@@ -769,7 +769,7 @@
public final Matrix derivative(final DirectPosition point) throws TransformException {
ArgumentChecks.ensureNonNull("point", point);
ArgumentChecks.ensureDimensionMatches("point", 1, point);
- return new Matrix1(derivative(point.getCoordinate(0)));
+ return new Matrix1(derivative(point.getOrdinate(0)));
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CoverageCombiner.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CoverageCombiner.java
index 4c43a50..3645c18 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CoverageCombiner.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/CoverageCombiner.java
@@ -43,9 +43,6 @@
import static org.apache.sis.util.privy.Numerics.saturatingAdd;
import static org.apache.sis.util.privy.Numerics.saturatingSubtract;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
-
/**
* Combines an arbitrary number of coverages into a single one.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/MismatchedCoverageRangeException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/MismatchedCoverageRangeException.java
index a9cc4d1..92d18e3 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/MismatchedCoverageRangeException.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/MismatchedCoverageRangeException.java
@@ -24,7 +24,7 @@
* @author Martin Desruisseaux (Geomatys)
* @version 1.0
*
- * @see org.opengis.coordinate.MismatchedDimensionException
+ * @see org.opengis.geometry.MismatchedDimensionException
*
* @since 1.0
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/PointOutsideCoverageException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/PointOutsideCoverageException.java
new file mode 100644
index 0000000..e464db6
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/PointOutsideCoverageException.java
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+
+/**
+ * Thrown when an evaluate method is invoked for a location outside the domain of the coverage.
+ *
+ * <div class="note"><b>Upcoming API change:</b>
+ * this class may move to GeoAPI in a future version. If that move happens,
+ * the {@code org.apache.sis.coverage} package name would become {@code org.opengis.coverage}.</div>
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ */
+public class PointOutsideCoverageException extends CannotEvaluateException {
+ /**
+ * Creates an exception with no message.
+ */
+ public PointOutsideCoverageException() {
+ super();
+ }
+
+ /**
+ * Creates an exception with the specified message.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public PointOutsideCoverageException(final String message) {
+ super(message);
+ }
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/RegionOfInterest.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/RegionOfInterest.java
index 0515a91..b32195e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/RegionOfInterest.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/RegionOfInterest.java
@@ -111,7 +111,7 @@
}
crsToGrid = MathTransforms.bidimensional(tr);
} catch (IllegalArgumentException | FactoryException e) {
- throw new TransformException(e);
+ throw new TransformException(null, e);
}
return crsToGrid.createTransformedShape(geometry);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SampleDimension.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SampleDimension.java
index c082297..a27b44b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SampleDimension.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SampleDimension.java
@@ -44,9 +44,6 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.Names;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.IdentifiedType;
-
/**
* Describes the data values in a coverage (the range). For a raster, a sample dimension is a band.
@@ -66,7 +63,7 @@
* In this example, sample values in range [10…210] define a quantitative category, while all others categories are qualitative.
*
* <h2>Relationship with metadata</h2>
- * This class provides the same information as ISO 19115 {@link org.opengis.metadata.content.SampleDimension},
+ * This class provides the same information as ISO 19115 {@code org.opengis.metadata.content.SampleDimension},
* 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.
*
@@ -79,12 +76,9 @@
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Alexis Manin (Geomatys)
* @version 1.5
- *
- * @see org.opengis.metadata.content.SampleDimension
- *
* @since 1.0
*/
-public class SampleDimension implements IdentifiedType, Serializable {
+public class SampleDimension implements Serializable {
/**
* Serial number for inter-operability with different versions.
*/
@@ -215,7 +209,6 @@
*
* @see org.opengis.metadata.content.RangeDimension#getSequenceIdentifier()
*/
- @Override
public GenericName getName() {
return name;
}
@@ -229,7 +222,6 @@
*
* @since 1.5
*/
- @Override
public InternationalString getDefinition() {
for (Category category : categories) {
if (category.isQuantitative()) {
@@ -541,7 +533,7 @@
*
* <p>A <dfn>quantitative category</dfn> is a range of sample values associated to numbers with units of measurement.
* For example, 10 = 1.0°C, 11 = 1.1°C, 12 = 1.2°C, <i>etc</i>. A quantitative category has a
- * {@linkplain org.opengis.metadata.content.SampleDimension#getTransferFunctionType() transfer function}
+ * transfer function
* (typically a scale factor and an offset) for converting sample values to values expressed
* in the unit of measurement.</p>
*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SubspaceNotSpecifiedException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SubspaceNotSpecifiedException.java
index 6b589dc..c328917 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SubspaceNotSpecifiedException.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/SubspaceNotSpecifiedException.java
@@ -16,9 +16,6 @@
*/
package org.apache.sis.coverage;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
-
/**
* Thrown when an operation can only be applied on a subspace of a multi-dimensional coverage,
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/BufferedGridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/BufferedGridCoverage.java
index e410566..02d7b82 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/BufferedGridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/BufferedGridCoverage.java
@@ -37,10 +37,10 @@
import org.apache.sis.util.collection.Cache;
import org.apache.sis.image.DataType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.coverage.PointOutsideCoverageException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -351,7 +351,7 @@
return null;
}
throw new PointOutsideCoverageException(
- gc.pointOutsideCoverage(getCoverage().gridGeometry.extent), point);
+ gc.pointOutsideCoverage(getCoverage().gridGeometry.extent));
}
/*
* Following should never overflow, otherwise BufferedGridCoverage
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ConvertedGridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
index 72b5631..5a5f5c8 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
@@ -32,8 +32,8 @@
import org.apache.sis.image.DataType;
import org.apache.sis.image.ImageProcessor;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git 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
index 6a7eef4..bb6c3d5 100644
--- 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
@@ -45,9 +45,9 @@
import org.apache.sis.referencing.operation.transform.TransformSeparator;
import org.apache.sis.util.logging.Logging;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.coverage.PointOutsideCoverageException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -369,11 +369,10 @@
} catch (ArithmeticException | IndexOutOfBoundsException | DisjointExtentException ex) {
if (!nullIfOutside) {
throw (PointOutsideCoverageException) new PointOutsideCoverageException(
- gc.pointOutsideCoverage(gridGeometry.extent), point).initCause(ex);
+ gc.pointOutsideCoverage(gridGeometry.extent)).initCause(ex);
}
}
} catch (PointOutsideCoverageException ex) {
- ex.setOffendingLocation(point);
throw ex;
} catch (RuntimeException | FactoryException | TransformException ex) {
throw new CannotEvaluateException(ex.getMessage(), ex);
@@ -456,7 +455,7 @@
if (result != position) {
// Should not happen, but be paranoiac.
final double[] coordinates = position.coordinates;
- System.arraycopy(result.getCoordinates(), 0, coordinates, 0, coordinates.length);
+ System.arraycopy(result.getCoordinate(), 0, coordinates, 0, coordinates.length);
}
/*
* In most cases, the work of this method ends here. The remaining code in this method
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionAppender.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionAppender.java
index 1264dfc..a35e1a6 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionAppender.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionAppender.java
@@ -24,9 +24,9 @@
import org.apache.sis.feature.internal.Resources;
import org.apache.sis.coverage.SubspaceNotSpecifiedException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
-import org.apache.sis.util.ArgumentChecks;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
/**
@@ -162,7 +162,9 @@
if (sliceExtent != null) {
final int sourceDim = source.getGridGeometry().getDimension();
final int dimension = dimToAdd.getDimension() + sourceDim;
- ArgumentChecks.ensureDimensionMatches("sliceExtent", dimension, sliceExtent);
+ if (dimension != sliceExtent.getDimension()) {
+ throw new MismatchedDimensionException();
+ }
for (int i=sourceDim; i<dimension; i++) {
final long size = sliceExtent.getSize(i);
if (size != 1) {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionReducer.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionReducer.java
index 29fd52d..f79348b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionReducer.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionReducer.java
@@ -83,7 +83,7 @@
}
final GeneralDirectPosition position = new GeneralDirectPosition(reducedCRS);
for (int i=0; i < dimensions.length; i++) {
- position.coordinates[i] = target.getCoordinate(dimensions[i]);
+ position.coordinates[i] = target.getOrdinate(dimensions[i]);
}
return position;
}
@@ -101,7 +101,7 @@
final GeneralEnvelope envelope = new GeneralEnvelope(reducedCRS);
for (int i=0; i < dimensions.length; i++) {
final int s = dimensions[i];
- envelope.setRange(i, lowerCorner.getCoordinate(s), upperCorner.getCoordinate(s));
+ envelope.setRange(i, lowerCorner.getOrdinate(s), upperCorner.getOrdinate(s));
}
return envelope;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
index 51fe89b..2d1750d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
@@ -43,9 +43,9 @@
import org.apache.sis.referencing.operation.transform.TransformSeparator;
import org.apache.sis.referencing.operation.transform.PassThroughTransform;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.PointOutsideCoverageException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -650,7 +650,7 @@
while (++dim == removedAxis) {
removedAxis = toRemovedDimension(++remCounter);
}
- reduced.coordinates[i] = source.getCoordinate(dim);
+ reduced.coordinates[i] = source.getOrdinate(dim);
}
return reduced;
}
@@ -940,7 +940,6 @@
Objects.requireNonNull(point);
final GridExtent extent = sourceGeometry.getExtent();
final int sourceDim = extent.getDimension();
- ArgumentChecks.ensureDimensionMatches("slicePoint", sourceDim, extent);
final Map<Integer,Long> slices = new HashMap<>();
for (int dim=0; dim < sourceDim; dim++) {
final long low = extent.getLow (dim);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DomainLinearizer.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DomainLinearizer.java
index 4a0aea9..dab8ead 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DomainLinearizer.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DomainLinearizer.java
@@ -193,7 +193,7 @@
if (cause instanceof TransformException) {
throw (TransformException) cause;
}
- throw new TransformException(e);
+ throw new TransformException(e.getMessage(), e);
}
return gg;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/EvaluatorWrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/EvaluatorWrapper.java
index 12e7e65..0e26e69 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/EvaluatorWrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/EvaluatorWrapper.java
@@ -20,8 +20,8 @@
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.operation.TransformException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git 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
index 3f7ed38..ff597fd 100644
--- 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
@@ -26,10 +26,10 @@
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.PointOutsideCoverageException;
-import org.opengis.coverage.grid.GridCoordinates;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -54,7 +54,7 @@
*
* @since 1.1
*/
-public class FractionalGridCoordinates implements GridCoordinates, Serializable {
+public class FractionalGridCoordinates implements Serializable {
/**
* For cross-version compatibility.
*/
@@ -93,7 +93,6 @@
*
* @return the number of dimensions.
*/
- @Override
public int getDimension() {
return coordinates.length;
}
@@ -108,7 +107,6 @@
* @throws ArithmeticException if a coordinate value is outside the range
* of values representable as a 64-bits integer value.
*/
- @Override
public long[] getCoordinateValues() {
final long[] indices = new long[coordinates.length];
for (int i=0; i<indices.length; i++) {
@@ -131,7 +129,6 @@
* @throws ArithmeticException if the coordinate value is outside the range
* of values representable as a 64-bits integer value.
*/
- @Override
public long getCoordinateValue(final int dimension) {
final double value = coordinates[dimension];
/*
@@ -169,7 +166,6 @@
* @throws ArithmeticException if this method cannot store the given grid coordinate
* without precision lost.
*/
- @Override
public void setCoordinateValue(final int dimension, final long value) {
if ((coordinates[dimension] = value) != value) {
throw new ArithmeticException(Resources.format(Resources.Keys.UnconvertibleGridCoordinate_2, "double", value));
@@ -247,7 +243,7 @@
if (bounds != null) {
final int bd = bounds.getDimension();
if (bd != dimension) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, "bounds", dimension, bd));
}
}
@@ -382,10 +378,26 @@
}
/**
+ * Returns the direct position, which is this object itself.
+ */
+ @Override
+ public DirectPosition getDirectPosition() {
+ return this;
+ }
+
+ /**
+ * Grid coordinates have no coordinate reference system.
+ */
+ @Override
+ public CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return null;
+ }
+
+ /**
* Returns all coordinate values.
*/
@Override
- public double[] getCoordinates() {
+ public double[] getCoordinate() {
return coordinates.clone();
}
@@ -393,7 +405,7 @@
* Returns the coordinate value at the given dimension.
*/
@Override
- public double getCoordinate(int dimension) {
+ public double getOrdinate(int dimension) {
return coordinates[dimension];
}
@@ -401,7 +413,7 @@
* Sets the coordinate value at the given dimension.
*/
@Override
- public void setCoordinate(final int dimension, final double value) {
+ public void setOrdinate(final int dimension, final double value) {
coordinates[dimension] = value;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoordinatesView.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoordinatesView.java
index 5288541..d8e064a 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoordinatesView.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoordinatesView.java
@@ -19,18 +19,18 @@
import java.util.Arrays;
import java.util.Objects;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.GridCoordinates;
-import org.apache.sis.util.resources.Errors;
-
/**
* A view over the low or high grid envelope coordinates.
* This is not a general-purpose grid coordinates since it assumes a {@link GridExtent} coordinates layout.
*
+ * <h2>Upcoming API generalization</h2>
+ * this class may implement the {@code GridCoordinates} interface in a future Apache SIS version.
+ * This is pending GeoAPI update.
+ *
* @author Martin Desruisseaux (Geomatys)
*/
-final class GridCoordinatesView implements GridCoordinates {
+final class GridCoordinatesView {
/**
* A reference to the coordinate array of the enclosing grid envelope.
*/
@@ -53,7 +53,6 @@
/**
* Returns the number of dimension.
*/
- @Override
public final int getDimension() {
return coordinates.length >>> 1;
}
@@ -61,7 +60,6 @@
/**
* Returns all coordinate values.
*/
- @Override
public final long[] getCoordinateValues() {
return Arrays.copyOfRange(coordinates, offset, offset + getDimension());
}
@@ -69,7 +67,6 @@
/**
* Returns the coordinate value for the specified dimension.
*/
- @Override
public final long getCoordinateValue(final int index) {
return coordinates[offset + Objects.checkIndex(index, getDimension())];
}
@@ -77,10 +74,9 @@
/**
* Do not allow modification of grid coordinates since they are backed by {@link GridExtent}.
*/
- @Override
- public void setCoordinateValue(final int index, long value) {
- throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, "GridCoordinates"));
- }
+// public void setCoordinateValue(final int index, long value) {
+// throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, "GridCoordinates"));
+// }
/**
* Returns a string representation of this grid coordinates for debugging purpose.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage.java
index c224df7..b8f1c84 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage.java
@@ -44,9 +44,9 @@
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.util.resources.Vocabulary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
/**
@@ -503,7 +503,7 @@
* @throws DisjointExtentException if the given extent does not intersect this grid coverage.
* @throws CannotEvaluateException if this method cannot produce the rendered image for another reason.
*/
- public abstract RenderedImage render(GridExtent sliceExtent) throws CannotEvaluateException;
+ public abstract RenderedImage render(GridExtent sliceExtent);
/**
* Returns a string representation of this grid coverage for debugging purpose.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
index 555faae..6770160 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
@@ -55,10 +55,10 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.coverage.PointOutsideCoverageException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -530,10 +530,9 @@
return null;
}
throw (PointOutsideCoverageException) new PointOutsideCoverageException(
- gc.pointOutsideCoverage(gridGeometry.extent), point).initCause(ex);
+ gc.pointOutsideCoverage(gridGeometry.extent)).initCause(ex);
}
} catch (PointOutsideCoverageException ex) {
- ex.setOffendingLocation(point);
throw ex;
} catch (RuntimeException | FactoryException | TransformException ex) {
throw new CannotEvaluateException(ex.getMessage(), ex);
@@ -573,7 +572,7 @@
final int expected = gridGeometry.getDimension();
final int dimension = sliceExtent.getDimension();
if (expected != dimension) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, "sliceExtent", expected, dimension));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridDerivation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridDerivation.java
index 7ad8920..dace43f 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridDerivation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridDerivation.java
@@ -56,8 +56,8 @@
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.math.MathFunctions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.PointOutsideCoverageException;
+// Specific to the main branch:
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
index 8df0d67..acb9703 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
@@ -67,12 +67,10 @@
import org.apache.sis.io.TableAppender;
import org.apache.sis.system.Modules;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.coverage.PointOutsideCoverageException;
-import org.opengis.coverage.grid.GridEnvelope;
-import org.opengis.coverage.grid.GridCoordinates;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -89,13 +87,17 @@
* <p>{@code GridExtent} instances are immutable and thread-safe.
* The same instance can be shared by different {@link GridGeometry} instances.</p>
*
+ * <div class="note"><b>Upcoming API generalization:</b>
+ * this class may implement the {@code GridEnvelope} interface in a future Apache SIS version.
+ * This is pending GeoAPI update.</div>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Alexis Manin (Geomatys)
* @author Johann Sorel (Geomatys)
* @version 1.5
* @since 1.0
*/
-public class GridExtent implements GridEnvelope, LenientComparable, Serializable {
+public class GridExtent implements Serializable, LenientComparable {
/**
* Serial number for inter-operability with different versions.
*/
@@ -670,49 +672,12 @@
}
/**
- * Creates a new grid extent as a copy of the given one.
- *
- * @param extent the grid extent to copy.
- * @throws IllegalArgumentException if a coordinate value in the low part is
- * greater than the corresponding coordinate value in the high part.
- *
- * @see #castOrCopy(GridEnvelope)
- */
- protected GridExtent(final GridEnvelope extent) {
- final int dimension = extent.getDimension();
- coordinates = allocate(dimension);
- for (int i=0; i<dimension; i++) {
- coordinates[i] = extent.getLow(i);
- coordinates[i + dimension] = extent.getHigh(i);
- }
- types = (extent instanceof GridExtent) ? ((GridExtent) extent).types : null;
- validateCoordinates();
- }
-
- /**
- * Returns the given grid extent as a {@code GridExtent} implementation.
- * If the given extent is already a {@code GridExtent} instance or is null, then it is returned as-is.
- * Otherwise a new extent is created using the {@linkplain #GridExtent(GridEnvelope) copy constructor}.
- *
- * @param extent the grid extent to cast or copy, or {@code null}.
- * @return the grid extent as a {@code GridExtent}, or {@code null} if the given extent was null.
- */
- public static GridExtent castOrCopy(final GridEnvelope extent) {
- if (extent == null || extent instanceof GridExtent) {
- return (GridExtent) extent;
- } else {
- return new GridExtent(extent);
- }
- }
-
- /**
* Returns the number of dimensions.
*
* @return the number of dimensions.
*
* @see #selectDimensions(int[])
*/
- @Override
public final int getDimension() {
return coordinates.length >>> 1;
}
@@ -770,8 +735,7 @@
*
* @see #getLow(int)
*/
- @Override
- public GridCoordinates getLow() {
+ GridCoordinatesView getLow() {
return new GridCoordinatesView(coordinates, 0);
}
@@ -783,8 +747,7 @@
*
* @see #getHigh(int)
*/
- @Override
- public GridCoordinates getHigh() {
+ GridCoordinatesView getHigh() {
return new GridCoordinatesView(coordinates, getDimension());
}
@@ -796,11 +759,9 @@
* @throws IndexOutOfBoundsException if the given index is negative or is equal or greater
* than the {@linkplain #getDimension() grid dimension}.
*
- * @see #getLow()
* @see #getHigh(int)
* @see #withRange(int, long, long)
*/
- @Override
public long getLow(final int index) {
return coordinates[Objects.checkIndex(index, getDimension())];
}
@@ -813,11 +774,9 @@
* @throws IndexOutOfBoundsException if the given index is negative or is equal or greater
* than the {@linkplain #getDimension() grid dimension}.
*
- * @see #getHigh()
* @see #getLow(int)
* @see #withRange(int, long, long)
*/
- @Override
public long getHigh(final int index) {
final int dimension = getDimension();
return coordinates[Objects.checkIndex(index, dimension) + dimension];
@@ -896,7 +855,6 @@
* @see #getHigh(int)
* @see #resize(long...)
*/
- @Override
public long getSize(final int index) {
final int dimension = getDimension();
Objects.checkIndex(index, dimension);
@@ -1246,7 +1204,7 @@
if (gridToCRS != null && Matrices.isAffine(gridToCRS)) try {
envelope.setCoordinateReferenceSystem(GridExtentCRS.forExtentAlone(gridToCRS, getAxisTypes()));
} catch (FactoryException e) {
- throw new TransformException(e);
+ throw new TransformException(e.getMessage(), e);
}
return envelope;
}
@@ -1781,10 +1739,10 @@
*/
final GridExtent sliceByRatio(final DirectPosition slicePoint, final double sliceRatio, final int[] dimensionsToKeep) {
for (int i=slicePoint.getDimension(); --i >= 0;) {
- slicePoint.setCoordinate(i, Math.fma(sliceRatio, getSize(i, true), getLow(i)));
+ slicePoint.setOrdinate(i, Math.fma(sliceRatio, getSize(i, true), getLow(i)));
}
for (int i=0; i<dimensionsToKeep.length; i++) {
- slicePoint.setCoordinate(dimensionsToKeep[i], Double.NaN);
+ slicePoint.setOrdinate(dimensionsToKeep[i], Double.NaN);
}
return slice(slicePoint, null);
}
@@ -1809,7 +1767,7 @@
final int n = slicePoint.getDimension();
final int m = getDimension();
for (int k=0; k<n; k++) {
- double p = slicePoint.getCoordinate(k);
+ double p = slicePoint.getOrdinate(k);
if (!Double.isNaN(p)) {
final long c = Math.round(p);
final int i = (modifiedDimensions != null) ? modifiedDimensions[k] : k;
@@ -1821,7 +1779,7 @@
final var b = new StringBuilder();
for (int j=0; j<n; j++) {
if (j != 0) b.append(", ");
- p = slicePoint.getCoordinate(j);
+ p = slicePoint.getOrdinate(j);
if (Double.isNaN(p)) b.append("NaN");
else b.append(Math.round(p));
}
@@ -2099,7 +2057,7 @@
final int n = coordinates.length;
final int m = n >>> 1;
if (n != other.coordinates.length) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, param, m, other.getDimension()));
}
// First condition below is a fast check for a common case.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
index ce159e2..0db5fec 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
@@ -61,9 +61,6 @@
import org.apache.sis.util.iso.Types;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* Builder for coordinate reference system which is derived from the coverage CRS by the inverse
@@ -183,9 +180,9 @@
final var properties = new HashMap<String,Object>(8);
properties.put(IdentifiedObject.NAME_KEY, METHOD.getName());
properties.put(DefaultConversion.LOCALE_KEY, locale);
- properties.put(ObjectDomain.SCOPE_KEY, SCOPE);
+ properties.put(Conversion.SCOPE_KEY, SCOPE);
gg.getGeographicExtent().ifPresent((domain) -> {
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY,
+ properties.put(Conversion.DOMAIN_OF_VALIDITY_KEY,
new DefaultExtent(null, domain, null, null));
});
final ParameterValueGroup params = METHOD.getParameters().createValue();
@@ -298,7 +295,7 @@
abbreviation = "t"; direction = AxisDirection.FUTURE; hasTime = true;
} else {
abbreviation = abbreviation(target);
- direction = AxisDirection.UNSPECIFIED;
+ direction = AxisDirections.UNSPECIFIED;
hasOther = true;
}
/*
@@ -310,7 +307,7 @@
final CoordinateSystemAxis previous = axes[k];
if (previous != null) {
if (direction.equals(AxisDirections.absolute(previous.getDirection()))) {
- direction = AxisDirection.UNSPECIFIED;
+ direction = AxisDirections.UNSPECIFIED;
hasOther = true;
}
if (abbreviation.equals(previous.getAbbreviation())) {
@@ -333,7 +330,7 @@
if (axes[j] == null) {
final String name = Vocabulary.forLocale(locale).getString(Vocabulary.Keys.Dimension_1, j);
final String abbreviation = abbreviation(j);
- axes[j] = axis(csFactory, name, abbreviation, AxisDirection.UNSPECIFIED);
+ axes[j] = axis(csFactory, name, abbreviation, AxisDirections.UNSPECIFIED);
}
}
/*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
index 4ab9128..48e7f0c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
@@ -84,8 +84,8 @@
import org.apache.sis.xml.NilReason;
import static org.apache.sis.referencing.CRS.findOperation;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -581,7 +581,7 @@
if (extent != null) {
final int dimension = extent.getDimension();
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, "extent", expected, dimension));
}
}
@@ -1083,7 +1083,7 @@
}
return env;
} catch (FactoryException e) {
- throw new TransformException(e);
+ throw new TransformException(null, e);
}
throw incomplete(bitmask, errorKey);
}
@@ -1183,7 +1183,7 @@
if (isEnvelopeUndefined()) {
throw incomplete(ORIGIN, Resources.Keys.UnspecifiedTransform);
}
- return getEnvelope().getLowerCorner().getCoordinates();
+ return getEnvelope().getLowerCorner().getCoordinate();
}
final double[] origin = new double[cornerToCRS.getTargetDimensions()];
final Matrix matrix = MathTransforms.getMatrix(cornerToCRS);
@@ -1817,7 +1817,7 @@
try {
tr = finder.inverse();
} catch (FactoryException e) {
- throw new TransformException(e);
+ throw new TransformException(e.getMessage(), e);
}
return MathTransforms.concatenate(getGridToCRS(anchor), tr);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/PixelInCell.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/PixelInCell.java
index b9771e9..74c450b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/PixelInCell.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/PixelInCell.java
@@ -19,9 +19,6 @@
import java.util.Optional;
import org.opengis.metadata.spatial.PixelOrientation;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-
/**
* Whether a "grid to real world" transform gives the coordinates of the cell corner or cell center.
@@ -35,7 +32,7 @@
*
* @since 1.5
*/
-public enum PixelInCell implements ControlledVocabulary {
+public enum PixelInCell {
/**
* "Real world" coordinates give the location of the cell center.
*
@@ -113,22 +110,10 @@
*
* @return all names of this constant. This array is never null and never empty.
*/
- @Override
public String[] names() {
if (this == CELL_CENTER) {
return new String[] {name(), identifier, "cell centre"};
}
return new String[] {name(), identifier};
}
-
- /**
- * Returns the enumeration of the same kind as this item.
- * This is equivalent to {@link #values()}.
- *
- * @return the enumeration of the same kind as this item.
- */
- @Override
- public ControlledVocabulary[] family() {
- return values();
- }
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
index 4e543b4..6feab7e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
@@ -40,8 +40,8 @@
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.referencing.operation.matrix.Matrices;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/TranslatedGridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
index 26225bd..e6d915d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
@@ -18,8 +18,8 @@
import java.awt.image.RenderedImage;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/CommonDomainFinder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/CommonDomainFinder.java
index fc65631..f3d3a39 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/CommonDomainFinder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/CommonDomainFinder.java
@@ -36,8 +36,8 @@
import org.apache.sis.util.Numbers;
import org.apache.sis.util.privy.Numerics;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -166,7 +166,7 @@
return;
}
// Arbitrary criterion (may be revisited in any future version).
- if (fallback == null && expected.getLow().equals(actual.getLow())) {
+ if (fallback == null && sameLow(expected, actual)) {
location = expected;
fallback = item;
}
@@ -183,6 +183,15 @@
}
}
+ private static boolean sameLow(final GridExtent e1, final GridExtent e2) {
+ final int dim = e1.getDimension();
+ if (dim != e2.getDimension()) return false;
+ for (int i=0; i<dim; i++) {
+ if (e1.getLow(i) != e2.getLow(i)) return false;
+ }
+ return true;
+ }
+
/**
* Given a grid geometry with the desired "grid to CRS", saves its index in {@link #sourceOfGridToCRS}.
* This method updates all previously computed translations for making them relative to the new reference.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAssociation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAssociation.java
index eec56f1..8f27632 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAssociation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAssociation.java
@@ -23,14 +23,6 @@
import org.opengis.metadata.quality.DataQuality;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.MultiValuedPropertyException;
-
/**
* An instance of an {@linkplain DefaultAssociationRole feature association role} containing the associated feature.
@@ -53,7 +45,7 @@
*
* @since 0.5
*/
-public abstract class AbstractAssociation extends Field<Feature> implements FeatureAssociation, Cloneable, Serializable {
+public abstract class AbstractAssociation extends Field<AbstractFeature> implements Cloneable, Serializable {
/**
* For cross-version compatibility.
*/
@@ -62,17 +54,16 @@
/**
* Information about the association.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final FeatureAssociationRole role;
+ final DefaultAssociationRole role;
/**
* Creates a new association of the given role.
*
* @param role information about the association.
*
- * @see #create(FeatureAssociationRole)
+ * @see #create(DefaultAssociationRole)
*/
- protected AbstractAssociation(final FeatureAssociationRole role) {
+ protected AbstractAssociation(final DefaultAssociationRole role) {
this.role = role;
}
@@ -84,7 +75,7 @@
*
* @see DefaultAssociationRole#newInstance()
*/
- public static AbstractAssociation create(final FeatureAssociationRole role) {
+ public static AbstractAssociation create(final DefaultAssociationRole role) {
return isSingleton(role.getMaximumOccurs())
? new SingletonAssociation(role)
: new MultiValuedAssociation(role);
@@ -97,15 +88,15 @@
* @param value the initial value (may be {@code null}).
* @return the new association.
*/
- static AbstractAssociation create(final FeatureAssociationRole role, final Object value) {
+ static AbstractAssociation create(final DefaultAssociationRole role, final Object value) {
return isSingleton(role.getMaximumOccurs())
- ? new SingletonAssociation(role, (Feature) value)
+ ? new SingletonAssociation(role, (AbstractFeature) value)
: new MultiValuedAssociation(role, value);
}
/**
* Returns the name of this association as defined by its {@linkplain #getRole() role}.
- * This convenience method delegates to {@link FeatureAssociationRole#getName()}.
+ * This convenience method delegates to {@link DefaultAssociationRole#getName()}.
*
* @return the association name specified by its role.
*/
@@ -117,10 +108,12 @@
/**
* Returns information about the association.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.AssociationRole}. This change is pending GeoAPI revision.</div>
+ *
* @return information about the association.
*/
- @Override
- public FeatureAssociationRole getRole() {
+ public DefaultAssociationRole getRole() {
return role;
}
@@ -129,13 +122,16 @@
* the common case where the {@linkplain DefaultAssociationRole#getMaximumOccurs() maximum number} of
* features is restricted to 1 or 0.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.Feature}. This change is pending GeoAPI revision.</div>
+ *
* @return the associated feature (may be {@code null}).
- * @throws MultiValuedPropertyException if this association contains more than one value.
+ * @throws IllegalStateException if this association contains more than one value.
*
* @see AbstractFeature#getPropertyValue(String)
*/
@Override
- public abstract Feature getValue() throws MultiValuedPropertyException;
+ public abstract AbstractFeature getValue() throws IllegalStateException;
/**
* Returns all features, or an empty collection if none.
@@ -148,13 +144,16 @@
* @return the features in a <em>live</em> collection.
*/
@Override
- public Collection<Feature> getValues() {
+ public Collection<AbstractFeature> getValues() {
return super.getValues();
}
/**
* Sets the associated feature.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the argument type may be changed
+ * to {@code org.opengis.feature.Feature}. This change is pending GeoAPI revision.</div>
+ *
* <h4>Validation</h4>
* The number of validations performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance reasons
@@ -162,24 +161,24 @@
* A more exhaustive verification can be performed by invoking the {@link #quality()} method.
*
* @param value the new value, or {@code null}.
- * @throws InvalidPropertyValueException if the given feature is not valid for this association.
+ * @throws IllegalArgumentException if the given feature is not valid for this association.
*
* @see AbstractFeature#setPropertyValue(String, Object)
*/
@Override
- public abstract void setValue(final Feature value) throws InvalidPropertyValueException;
+ public abstract void setValue(final AbstractFeature value) throws IllegalArgumentException;
/**
* Sets the features. All previous values are replaced by the given collection.
*
* <p>The default implementation ensures that the given collection contains at most one element,
- * then delegates to {@link #setValue(Feature)}.</p>
+ * then delegates to {@link #setValue(AbstractFeature)}.</p>
*
* @param values the new values.
- * @throws InvalidPropertyValueException if the given collection contains too many elements.
+ * @throws IllegalArgumentException if the given collection contains too many elements.
*/
@Override
- public void setValues(final Collection<? extends Feature> values) throws InvalidPropertyValueException {
+ public void setValues(final Collection<? extends AbstractFeature> values) throws IllegalArgumentException {
super.setValues(values);
}
@@ -187,9 +186,9 @@
* Ensures that storing a feature of the given type is valid for an association
* expecting the given base type.
*/
- final void ensureValid(final FeatureType base, final FeatureType type) {
+ final void ensureValid(final DefaultFeatureType base, final DefaultFeatureType type) {
if (base != type && !DefaultFeatureType.maybeAssignableFrom(base, type)) {
- throw new InvalidPropertyValueException(
+ throw new IllegalArgumentException(
Resources.format(Resources.Keys.IllegalFeatureType_3, getName(), base.getName(), type.getName()));
}
}
@@ -224,7 +223,7 @@
@Override
public String toString() {
final String pt = DefaultAssociationRole.getTitleProperty(role);
- final Iterator<Feature> it = getValues().iterator();
+ final Iterator<AbstractFeature> it = getValues().iterator();
return FieldType.toString(isDeprecated(role), "FeatureAssociation", role.getName(),
DefaultAssociationRole.getValueTypeName(role), new Iterator<Object>()
{
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAttribute.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAttribute.java
index 13449f7..46a2f43 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAttribute.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractAttribute.java
@@ -29,12 +29,6 @@
import org.opengis.metadata.maintenance.ScopeCode;
import org.apache.sis.util.Classes;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.MultiValuedPropertyException;
-
/**
* An instance of an {@linkplain DefaultAttributeType attribute type} containing the value of an attribute in a feature.
@@ -76,7 +70,7 @@
*
* @since 0.5
*/
-public abstract class AbstractAttribute<V> extends Field<V> implements Attribute<V>, Serializable {
+public abstract class AbstractAttribute<V> extends Field<V> implements Serializable {
/**
* For cross-version compatibility.
*/
@@ -85,8 +79,7 @@
/**
* Information about the attribute (base Java class, domain of values, <i>etc.</i>).
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final AttributeType<V> type;
+ final DefaultAttributeType<V> type;
/**
* Other attributes that describes this attribute, or {@code null} if not yet created.
@@ -101,16 +94,16 @@
*
* @see #characteristics()
*/
- private transient Map<String,Attribute<?>> characteristics;
+ private transient Map<String,AbstractAttribute<?>> characteristics;
/**
* Creates a new attribute of the given type.
*
* @param type information about the attribute (base Java class, domain of values, <i>etc.</i>).
*
- * @see #create(AttributeType)
+ * @see #create(DefaultAttributeType)
*/
- protected AbstractAttribute(final AttributeType<V> type) {
+ protected AbstractAttribute(final DefaultAttributeType<V> type) {
this.type = type;
}
@@ -124,7 +117,7 @@
*
* @see DefaultAttributeType#newInstance()
*/
- public static <V> AbstractAttribute<V> create(final AttributeType<V> type) {
+ public static <V> AbstractAttribute<V> create(final DefaultAttributeType<V> type) {
return isSingleton(type.getMaximumOccurs())
? new SingletonAttribute<>(type)
: new MultiValuedAttribute<>(type);
@@ -139,7 +132,7 @@
* @param value the initial value (may be {@code null}).
* @return the new attribute.
*/
- static <V> AbstractAttribute<V> create(final AttributeType<V> type, final Object value) {
+ static <V> AbstractAttribute<V> create(final DefaultAttributeType<V> type, final Object value) {
return isSingleton(type.getMaximumOccurs())
? new SingletonAttribute<>(type, value)
: new MultiValuedAttribute<>(type, value);
@@ -153,9 +146,9 @@
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
- final Attribute<?>[] characterizedBy;
+ final AbstractAttribute<?>[] characterizedBy;
if (characteristics instanceof CharacteristicMap) {
- characterizedBy = characteristics.values().toArray(Attribute[]::new);
+ characterizedBy = characteristics.values().toArray(AbstractAttribute[]::new);
} else {
characterizedBy = null;
}
@@ -172,7 +165,7 @@
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
try {
- final Attribute<?>[] characterizedBy = (Attribute<?>[]) in.readObject();
+ final AbstractAttribute<?>[] characterizedBy = (AbstractAttribute<?>[]) in.readObject();
if (characterizedBy != null) {
characteristics = newCharacteristicsMap();
Collections.addAll(characteristics.values(), characterizedBy);
@@ -185,7 +178,7 @@
/**
* Returns the name of this attribute as defined by its {@linkplain #getType() type}.
- * This convenience method delegates to {@link AttributeType#getName()}.
+ * This convenience method delegates to {@link DefaultAttributeType#getName()}.
*
* @return the attribute name specified by its type.
*/
@@ -197,10 +190,12 @@
/**
* Returns information about the attribute (base Java class, domain of values, <i>etc.</i>).
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.AttributeType}. This change is pending GeoAPI revision.</div>
+ *
* @return information about the attribute.
*/
- @Override
- public AttributeType<V> getType() {
+ public DefaultAttributeType<V> getType() {
return type;
}
@@ -210,12 +205,12 @@
* of attribute values is restricted to 1 or 0.
*
* @return the attribute value (may be {@code null}).
- * @throws MultiValuedPropertyException if this attribute contains more than one value.
+ * @throws IllegalStateException if this attribute contains more than one value.
*
* @see AbstractFeature#getPropertyValue(String)
*/
@Override
- public abstract V getValue() throws MultiValuedPropertyException;
+ public abstract V getValue() throws IllegalStateException;
/**
* Returns all attribute values, or an empty collection if none.
@@ -242,13 +237,13 @@
* A more exhaustive verification can be performed by invoking the {@link #quality()} method.
*
* @param value the new value, or {@code null} for removing all values from this attribute.
- * @throws InvalidPropertyValueException if this method verifies argument validity and the given value
+ * @throws IllegalArgumentException if this method verifies argument validity and the given value
* does not met the attribute constraints.
*
* @see AbstractFeature#setPropertyValue(String, Object)
*/
@Override
- public abstract void setValue(final V value) throws InvalidPropertyValueException;
+ public abstract void setValue(final V value) throws IllegalArgumentException;
/**
* Sets the attribute values. All previous values are replaced by the given collection.
@@ -257,10 +252,10 @@
* then delegates to {@link #setValue(Object)}.</p>
*
* @param values the new values.
- * @throws InvalidPropertyValueException if the given collection contains too many elements.
+ * @throws IllegalArgumentException if the given collection contains too many elements.
*/
@Override
- public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException {
+ public void setValues(final Collection<? extends V> values) throws IllegalArgumentException {
super.setValues(values);
}
@@ -339,9 +334,8 @@
*
* @see DefaultAttributeType#characteristics()
*/
- @Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
- public Map<String,Attribute<?>> characteristics() {
+ public Map<String,AbstractAttribute<?>> characteristics() {
if (characteristics == null) {
characteristics = newCharacteristicsMap();
}
@@ -353,13 +347,13 @@
* This method does not store the new map in the {@link #characteristics} field;
* it is caller responsibility to do so if desired.
*/
- private Map<String,Attribute<?>> newCharacteristicsMap() {
+ private Map<String,AbstractAttribute<?>> newCharacteristicsMap() {
if (type instanceof DefaultAttributeType<?>) {
- Map<String, AttributeType<?>> map = ((DefaultAttributeType<?>) type).characteristics();
+ Map<String, DefaultAttributeType<?>> map = type.characteristics();
if (!map.isEmpty()) {
if (!(map instanceof CharacteristicTypeMap)) {
- final Collection<AttributeType<?>> types = map.values();
- map = CharacteristicTypeMap.create(type, types.toArray(AttributeType<?>[]::new));
+ final Collection<DefaultAttributeType<?>> types = map.values();
+ map = CharacteristicTypeMap.create(type, types.toArray(DefaultAttributeType<?>[]::new));
}
return new CharacteristicMap(this, (CharacteristicTypeMap) map);
}
@@ -372,7 +366,7 @@
* Contrarily to {@link #characteristics()}, this method does not create the map. This method
* is suitable when then caller only wants to read the map and does not plan to write anything.
*/
- final Map<String,Attribute<?>> characteristicsReadOnly() {
+ final Map<String,AbstractAttribute<?>> characteristicsReadOnly() {
return (characteristics != null) ? characteristics : Collections.emptyMap();
}
@@ -467,7 +461,7 @@
if (characteristics != null && !characteristics.isEmpty()) {
buffer.append(System.lineSeparator());
String separator = "└─ characteristics: ";
- for (final Map.Entry<String,Attribute<?>> entry : characteristics.entrySet()) {
+ for (final Map.Entry<String,AbstractAttribute<?>> entry : characteristics.entrySet()) {
buffer.append(separator).append(entry.getKey()).append('=').append(entry.getValue().getValue());
separator = ", ";
}
@@ -492,7 +486,7 @@
@SuppressWarnings({"CloneInNonCloneableClass", "unchecked"})
public AbstractAttribute<V> clone() throws CloneNotSupportedException {
final AbstractAttribute<V> clone = (AbstractAttribute<V>) super.clone();
- final Map<String,Attribute<?>> c = clone.characteristics;
+ final Map<String,AbstractAttribute<?>> c = clone.characteristics;
if (c instanceof CharacteristicMap) {
clone.characteristics = ((CharacteristicMap) c).clone();
}
diff --git 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
index 1ac4334..6cc3b37 100644
--- 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
@@ -34,20 +34,6 @@
import org.apache.sis.util.privy.CheckedArrayList;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-
/**
* An instance of a {@linkplain DefaultFeatureType feature type} containing values for a real-world phenomena.
@@ -69,8 +55,8 @@
* </ul>
*
* <h2>Operations</h2>
- * Properties that are instances of {@link Operation} are usually not stored in {@code Feature} instances.
- * Instead, the {@link Operation#apply Operation.apply(…)} method is invoked every times that the property
+ * Properties that are instances of {@code Operation} are usually not stored in {@code Feature} instances.
+ * Instead, the {@link AbstractOperation#apply Operation.apply(…)} method is invoked every times that the property
* value is requested. {@code AbstractFeature} does not cache operation results.
* Those results are usually read-only, but may be writable under the conditions documented in
* {@link #setOperationValue(String, Object)}.
@@ -93,7 +79,7 @@
*
* @since 0.5
*/
-public abstract class AbstractFeature implements Feature, Serializable {
+public abstract class AbstractFeature implements Serializable {
/**
* For cross-version compatibility.
*/
@@ -109,8 +95,7 @@
/**
* Information about the feature (name, characteristics, <i>etc.</i>).
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final FeatureType type;
+ final DefaultFeatureType type;
/**
* Creates a new feature of the given type.
@@ -119,7 +104,7 @@
*
* @see DefaultFeatureType#newInstance()
*/
- protected AbstractFeature(final FeatureType type) {
+ protected AbstractFeature(final DefaultFeatureType type) {
this.type = Objects.requireNonNull(type);
}
@@ -134,10 +119,12 @@
/**
* Returns information about the feature (name, characteristics, <i>etc.</i>).
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.FeatureType}. This change is pending GeoAPI revision.</div>
+ *
* @return information about the feature.
*/
- @Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return type;
}
@@ -162,15 +149,17 @@
* Implementers are encouraged to override this method if they can provide a more efficient implementation.
* Note that this is already the case when using implementations created by {@link DefaultFeatureType#newInstance()}.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div>
+ *
* @param name the property name.
* @return the property of the given name (never {@code null}).
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*
* @see #getPropertyValue(String)
* @see DefaultFeatureType#getProperty(String)
*/
- @Override
- public Property getProperty(final String name) throws PropertyNotFoundException {
+ public Object getProperty(final String name) throws IllegalArgumentException {
return PropertyView.create(this, type.getProperty(name));
}
@@ -205,21 +194,23 @@
* Implementers are encouraged to override this method if they can provide a better implementation.
* Note that this is already the case when using implementations created by {@link DefaultFeatureType#newInstance()}.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the argument may be changed
+ * to {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div>
+ *
* @param property the property to set.
- * @throws PropertyNotFoundException if the name of the given property is not a property name of this feature.
- * @throws InvalidPropertyValueException if the value of the given property is not valid.
+ * @throws IllegalArgumentException if the name of the given property is not a property name of this feature.
+ * @throws IllegalArgumentException if the value of the given property is not valid.
* @throws IllegalArgumentException if the property cannot be set for another reason.
*
* @see #setPropertyValue(String, Object)
*/
- @Override
- public void setProperty(final Property property) throws IllegalArgumentException {
- final String name = property.getName().toString();
- verifyPropertyType(name, property);
- if (property instanceof Attribute<?> && !Containers.isNullOrEmpty(((Attribute<?>) property).characteristics())) {
+ public void setProperty(final Object property) throws IllegalArgumentException {
+ final String name = ((Property) property).getName().toString();
+ verifyPropertyType(name, (Property) property);
+ if (property instanceof AbstractAttribute<?> && !Containers.isNullOrEmpty(((AbstractAttribute<?>) property).characteristics())) {
throw new IllegalArgumentException(Resources.format(Resources.Keys.CanNotAssignCharacteristics_1, name));
}
- setPropertyValue(name, property.getValue());
+ setPropertyValue(name, ((Property) property).getValue());
}
/**
@@ -231,11 +222,11 @@
* @return a {@code Property} wrapping the given value.
*/
final Property createProperty(final String name, final Object value) {
- final PropertyType pt = type.getProperty(name);
- if (pt instanceof AttributeType<?>) {
- return AbstractAttribute.create((AttributeType<?>) pt, value);
- } else if (pt instanceof FeatureAssociationRole) {
- return AbstractAssociation.create((FeatureAssociationRole) pt, value);
+ final AbstractIdentifiedType pt = type.getProperty(name);
+ if (pt instanceof DefaultAttributeType<?>) {
+ return AbstractAttribute.create((DefaultAttributeType<?>) pt, value);
+ } else if (pt instanceof DefaultAssociationRole) {
+ return AbstractAssociation.create((DefaultAssociationRole) pt, value);
} else {
// Should never happen, unless the user gave us some mutable FeatureType.
throw new CorruptedObjectException(Errors.format(Errors.Keys.UnknownType_1, pt));
@@ -247,15 +238,15 @@
*
* @param name the name of the property to create.
* @return a {@code Property} of the given name.
- * @throws PropertyNotFoundException if the given argument is not the name of an attribute or
+ * @throws IllegalArgumentException if the given argument is not the name of an attribute or
* feature association of this feature.
*/
- final Property createProperty(final String name) throws PropertyNotFoundException {
- final PropertyType pt = type.getProperty(name);
- if (pt instanceof AttributeType<?>) {
- return ((AttributeType<?>) pt).newInstance();
- } else if (pt instanceof FeatureAssociationRole) {
- return ((FeatureAssociationRole) pt).newInstance();
+ final Property createProperty(final String name) throws IllegalArgumentException {
+ final AbstractIdentifiedType pt = type.getProperty(name);
+ if (pt instanceof DefaultAttributeType<?>) {
+ return ((DefaultAttributeType<?>) pt).newInstance();
+ } else if (pt instanceof DefaultAssociationRole) {
+ return ((DefaultAssociationRole) pt).newInstance();
} else {
throw new IllegalArgumentException(unsupportedPropertyType(pt.getName()));
}
@@ -266,14 +257,14 @@
*
* @see #getOperationValue(String)
*/
- final Property getOperationResult(final String name) {
+ final Object getOperationResult(final String name) {
/*
* The (Operation) cast below should never fail (unless the DefaultFeatureType in not really immutable,
* which would be a contract violation) because all callers shall ensure that this method is invoked in
* a context where the following assertion holds.
*/
- assert DefaultFeatureType.OPERATION_INDEX.equals(((DefaultFeatureType) type).indices().get(name)) : name;
- return ((Operation) type.getProperty(name)).apply(this, null);
+ assert DefaultFeatureType.OPERATION_INDEX.equals(type.indices().get(name)) : name;
+ return ((AbstractOperation) type.getProperty(name)).apply(this, null);
}
/**
@@ -282,14 +273,14 @@
*
* @param name the name of the property for which to get the default value.
* @return the default value for the {@code Property} of the given name.
- * @throws PropertyNotFoundException if the given argument is not an attribute or association name of this feature.
+ * @throws IllegalArgumentException if the given argument is not an attribute or association name of this feature.
*/
- final Object getDefaultValue(final String name) throws PropertyNotFoundException {
- final PropertyType pt = type.getProperty(name);
- if (pt instanceof AttributeType<?>) {
- return getDefaultValue((AttributeType<?>) pt);
- } else if (pt instanceof FeatureAssociationRole) {
- final int maximumOccurs = ((FeatureAssociationRole) pt).getMaximumOccurs();
+ final Object getDefaultValue(final String name) throws IllegalArgumentException {
+ final AbstractIdentifiedType pt = type.getProperty(name);
+ if (pt instanceof DefaultAttributeType<?>) {
+ return getDefaultValue((DefaultAttributeType<?>) pt);
+ } else if (pt instanceof DefaultAssociationRole) {
+ final int maximumOccurs = ((DefaultAssociationRole) pt).getMaximumOccurs();
return maximumOccurs > 1 ? Collections.EMPTY_LIST : null; // No default value for associations.
} else {
throw new IllegalArgumentException(unsupportedPropertyType(pt.getName()));
@@ -299,7 +290,7 @@
/**
* Returns the default value to be returned by {@link #getPropertyValue(String)} for the given attribute type.
*/
- private static <V> Object getDefaultValue(final AttributeType<V> attribute) {
+ private static <V> Object getDefaultValue(final DefaultAttributeType<V> attribute) {
final V defaultValue = attribute.getDefaultValue();
if (Field.isSingleton(attribute.getMaximumOccurs())) {
return defaultValue;
@@ -320,10 +311,10 @@
* <table class="sis">
* <caption>Class of returned value</caption>
* <tr><th>Property type</th> <th>max. occurs</th> <th>Method invoked</th> <th>Return type</th></tr>
- * <tr><td>{@link AttributeType}</td> <td>0 or 1</td> <td>{@link Attribute#getValue()}</td> <td>{@link Object}</td></tr>
- * <tr><td>{@code AttributeType}</td> <td>2 or more</td> <td>{@link Attribute#getValues()}</td> <td>{@code Collection<?>}</td></tr>
- * <tr><td>{@link FeatureAssociationRole}</td> <td>0 or 1</td> <td>{@link FeatureAssociation#getValue()}</td> <td>{@link Feature}</td></tr>
- * <tr><td>{@code FeatureAssociationRole}</td> <td>2 or more</td> <td>{@link FeatureAssociation#getValues()}</td> <td>{@code Collection<Feature>}</td></tr>
+ * <tr><td>{@code AttributeType}</td> <td>0 or 1</td> <td>{@code Attribute.getValue()}</td> <td>{@link Object}</td></tr>
+ * <tr><td>{@code AttributeType}</td> <td>2 or more</td> <td>{@code Attribute.getValues()}</td> <td>{@code Collection<?>}</td></tr>
+ * <tr><td>{@code FeatureAssociationRole}</td> <td>0 or 1</td> <td>{@code FeatureAssociation.getValue()}</td> <td>{@code Feature}</td></tr>
+ * <tr><td>{@code FeatureAssociationRole}</td> <td>2 or more</td> <td>{@code FeatureAssociation.getValues()}</td> <td>{@code Collection<Feature>}</td></tr>
* </table>
*
* <div class="note"><b>Note:</b> “max. occurs” is the {@linkplain DefaultAttributeType#getMaximumOccurs() maximum
@@ -345,15 +336,14 @@
* @param name the property name.
* @return value of the specified property, or the
* {@linkplain DefaultAttributeType#getDefaultValue() default value} (which may be {@code null}} if none.
- * @throws PropertyNotFoundException if the given argument is not an attribute or association name of this feature.
+ * @throws IllegalArgumentException if the given argument is not an attribute or association name of this feature.
*
* @see AbstractAttribute#getValue()
*/
- @Override
- public Object getPropertyValue(final String name) throws PropertyNotFoundException {
+ public Object getPropertyValue(final String name) throws IllegalArgumentException {
final Object value = getValueOrFallback(name, MISSING);
if (value != MISSING) return value;
- throw new PropertyNotFoundException(propertyNotFound(type, getName(), name));
+ throw new IllegalArgumentException(propertyNotFound(type, getName(), name));
}
/**
@@ -367,13 +357,12 @@
*
* @param name the attribute name.
* @param value the new value for the given attribute (may be {@code null}).
- * @throws PropertyNotFoundException if the given name is not an attribute or association name of this feature.
+ * @throws IllegalArgumentException if the given name is not an attribute or association name of this feature.
* @throws ClassCastException if the value is not assignable to the expected value class.
- * @throws InvalidPropertyValueException if the given value is not valid for a reason other than its type.
+ * @throws IllegalArgumentException if the given value is not valid for a reason other than its type.
*
* @see AbstractAttribute#setValue(Object)
*/
- @Override
public abstract void setPropertyValue(final String name, final Object value) throws IllegalArgumentException;
/**
@@ -383,7 +372,7 @@
* {@snippet lang="java" :
* try {
* return getPropertyValue(name);
- * } catch (PropertyNotFoundException ignore) {
+ * } catch (IllegalArgumentException ignore) {
* return missingPropertyFallback
* }
* }
@@ -400,7 +389,6 @@
*
* @since 1.1
*/
- @Override
public abstract Object getValueOrFallback(final String name, Object missingPropertyFallback);
/**
@@ -425,21 +413,21 @@
* }
*
* @param name the name of the operation to execute. The caller is responsible to ensure that the
- * property type for that name is an instance of {@link Operation}.
+ * property type for that name is an instance of {@link AbstractOperation}.
* @return the result value of the given operation, or {@code null} if none.
*
* @since 0.8
*/
protected Object getOperationValue(final String name) {
- final Operation operation = (Operation) type.getProperty(name);
+ final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
if (operation instanceof LinkOperation) {
return getPropertyValue(((LinkOperation) operation).referentName);
}
- final Property result = operation.apply(this, null);
- if (result instanceof Attribute<?>) {
- return getAttributeValue((Attribute<?>) result);
- } else if (result instanceof FeatureAssociation) {
- return getAssociationValue((FeatureAssociation) result);
+ final Object result = operation.apply(this, null);
+ if (result instanceof AbstractAttribute<?>) {
+ return getAttributeValue((AbstractAttribute<?>) result);
+ } else if (result instanceof AbstractAssociation) {
+ return getAssociationValue((AbstractAssociation) result);
} else {
return null;
}
@@ -452,23 +440,23 @@
* but the {@linkplain FeatureOperations#link link} and
* {@linkplain FeatureOperations#compound compound} operations (for instances) do.
* Whether an operation is writable or not depends on whether the computed {@link Property}
- * supports {@link Attribute#setValue(Object)} or {@link FeatureAssociation#setValue(Feature)}.
+ * supports {@link AbstractAttribute#setValue(Object)} or {@link AbstractAssociation#setValue(Feature)}.
*
* @param name the name of the operation to execute. The caller is responsible to ensure that the
- * property type for that name is an instance of {@link Operation}.
+ * property type for that name is an instance of {@link AbstractOperation}.
* @param value the value to assign to the result of the named operation.
* @throws IllegalStateException if the operation of the given name does not accept assignment.
*
* @since 0.8
*/
protected void setOperationValue(final String name, final Object value) {
- final Operation operation = (Operation) type.getProperty(name);
+ final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
if (operation instanceof LinkOperation) {
setPropertyValue(((LinkOperation) operation).referentName, value);
} else {
- final Property result = operation.apply(this, null);
- if (result != null) {
- setPropertyValue(result, value);
+ final Object result = operation.apply(this, null);
+ if (result instanceof Property) {
+ setPropertyValue((Property) result, value);
} else {
throw new IllegalStateException(Resources.format(Resources.Keys.CanNotSetPropertyValue_1, name));
}
@@ -497,23 +485,23 @@
* @param characteristic name of the characteristic of the property of the given name.
* @return value of the specified characteristic on the specified property, or an empty value
* if the property is not an attribute or the attribute has no such characteristic.
- * @throws PropertyNotFoundException if the {@code property} argument is not the name of a property of this feature.
+ * @throws IllegalArgumentException if the {@code property} argument is not the name of a property of this feature.
*
* @since 1.5
*/
public Optional<?> getCharacteristicValue(final String property, final String characteristic)
- throws PropertyNotFoundException
+ throws IllegalArgumentException
{
- Property p = getProperty(property);
- if (p instanceof Attribute<?>) {
- var attribute = (Attribute<?>) p;
- Attribute<?> ca = attribute.characteristics().get(characteristic);
+ Object p = getProperty(property);
+ if (p instanceof AbstractAttribute<?>) {
+ var attribute = (AbstractAttribute<?>) p;
+ AbstractAttribute<?> ca = attribute.characteristics().get(characteristic);
if (ca != null) {
// If the characteristic is present, assume that an explicitly null value is intentional.
return Optional.ofNullable(ca.getValue());
} else {
return Optional.ofNullable(attribute.getType().characteristics().get(characteristic))
- .map(AttributeType::getDefaultValue);
+ .map(DefaultAttributeType::getDefaultValue);
}
}
return Optional.empty();
@@ -523,7 +511,7 @@
* Returns the value of the given attribute, as a singleton or as a collection depending
* on the maximum number of occurrences.
*/
- static Object getAttributeValue(final Attribute<?> property) {
+ static Object getAttributeValue(final AbstractAttribute<?> property) {
return Field.isSingleton(property.getType().getMaximumOccurs()) ? property.getValue() : property.getValues();
}
@@ -531,7 +519,7 @@
* Returns the value of the given association, as a singleton or as a collection depending
* on the maximum number of occurrences.
*/
- static Object getAssociationValue(final FeatureAssociation property) {
+ static Object getAssociationValue(final AbstractAssociation property) {
return Field.isSingleton(property.getRole().getMaximumOccurs()) ? property.getValue() : property.getValues();
}
@@ -539,10 +527,10 @@
* Sets the value of the given property, with some minimal checks.
*/
static void setPropertyValue(final Property property, final Object value) {
- if (property instanceof Attribute<?>) {
- setAttributeValue((Attribute<?>) property, value);
- } else if (property instanceof FeatureAssociation) {
- setAssociationValue((FeatureAssociation) property, value);
+ if (property instanceof AbstractAttribute<?>) {
+ setAttributeValue((AbstractAttribute<?>) property, value);
+ } else if (property instanceof AbstractAssociation) {
+ setAssociationValue((AbstractAssociation) property, value);
} else {
throw new IllegalArgumentException(unsupportedPropertyType(property.getName()));
}
@@ -554,9 +542,9 @@
* use {@link Validator} instead.
*/
@SuppressWarnings("unchecked")
- private static <V> void setAttributeValue(final Attribute<V> attribute, final Object value) {
+ private static <V> void setAttributeValue(final AbstractAttribute<V> attribute, final Object value) {
if (value != null) {
- final AttributeType<V> pt = attribute.getType();
+ final DefaultAttributeType<V> pt = attribute.getType();
final Class<?> base = pt.getValueClass();
if (!base.isInstance(value)) {
Object element = value;
@@ -567,7 +555,7 @@
*/
final Iterator<?> it = ((Collection<?>) value).iterator();
do if (!it.hasNext()) {
- ((Attribute) attribute).setValues((Collection) value);
+ ((AbstractAttribute) attribute).setValues((Collection) value);
return;
} while ((element = it.next()) == null || base.isInstance(element));
// Found an illegal value. Exeption is thrown below.
@@ -575,7 +563,7 @@
throw new ClassCastException(illegalValueClass(pt, base, element)); // `element` cannot be null here.
}
}
- ((Attribute) attribute).setValue(value);
+ ((AbstractAttribute) attribute).setValue(value);
}
/**
@@ -583,24 +571,24 @@
* For a more exhaustive validation, use {@link Validator} instead.
*/
@SuppressWarnings("unchecked")
- private static void setAssociationValue(final FeatureAssociation association, final Object value) {
+ private static void setAssociationValue(final AbstractAssociation association, final Object value) {
if (value != null) {
- final FeatureAssociationRole role = association.getRole();
- final FeatureType base = role.getValueType();
- if (value instanceof Feature) {
- final FeatureType actual = ((Feature) value).getType();
+ final DefaultAssociationRole role = association.getRole();
+ final DefaultFeatureType base = role.getValueType();
+ if (value instanceof AbstractFeature) {
+ final DefaultFeatureType actual = ((AbstractFeature) value).getType();
if (base != actual && !DefaultFeatureType.maybeAssignableFrom(base, actual)) {
- throw new InvalidPropertyValueException(illegalFeatureType(role, base, actual));
+ throw new IllegalArgumentException(illegalFeatureType(role, base, actual));
}
} else if (value instanceof Collection<?>) {
verifyAssociationValues(role, (Collection<?>) value);
- association.setValues((Collection<? extends Feature>) value);
+ association.setValues((Collection<? extends AbstractFeature>) value);
return; // Skip the setter at the end of this method.
} else {
- throw new ClassCastException(illegalValueClass(role, Feature.class, value));
+ throw new ClassCastException(illegalValueClass(role, AbstractFeature.class, value));
}
}
- association.setValue((Feature) value);
+ association.setValue((AbstractFeature) value);
}
/**
@@ -618,7 +606,7 @@
if (value == null) {
return true;
}
- if (previous.getClass() == value.getClass() && !(value instanceof Feature)) {
+ if (previous.getClass() == value.getClass() && !(value instanceof AbstractFeature)) {
return true;
}
}
@@ -632,19 +620,19 @@
* @param property the property to verify.
*/
final void verifyPropertyType(final String name, final Property property) {
- final PropertyType pt, base = type.getProperty(name);
- if (property instanceof Attribute<?>) {
- pt = ((Attribute<?>) property).getType();
- } else if (property instanceof FeatureAssociation) {
- pt = ((FeatureAssociation) property).getRole();
+ final AbstractIdentifiedType pt, base = type.getProperty(name);
+ if (property instanceof AbstractAttribute<?>) {
+ pt = ((AbstractAttribute<?>) property).getType();
+ } else if (property instanceof AbstractAssociation) {
+ pt = ((AbstractAssociation) property).getRole();
} else {
- throw new InvalidPropertyValueException(Resources.format(Resources.Keys.IllegalPropertyType_2, base.getName(), property.getClass()));
+ throw new IllegalArgumentException(Resources.format(Resources.Keys.IllegalPropertyType_2, base.getName(), property.getClass()));
}
if (pt != base) {
if (base == null) {
- throw new PropertyNotFoundException(Resources.format(Resources.Keys.PropertyNotFound_2, getName(), name));
+ throw new IllegalArgumentException(Resources.format(Resources.Keys.PropertyNotFound_2, getName(), name));
} else {
- throw new InvalidPropertyValueException(Resources.format(Resources.Keys.MismatchedPropertyType_1, name));
+ throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedPropertyType_1, name));
}
}
}
@@ -654,14 +642,14 @@
* The returned value is usually the same as the given one, except in the case of collections.
*/
final Object verifyPropertyValue(final String name, final Object value) {
- final PropertyType pt = type.getProperty(name);
- if (pt instanceof AttributeType<?>) {
+ final AbstractIdentifiedType pt = type.getProperty(name);
+ if (pt instanceof DefaultAttributeType<?>) {
if (value != null) {
- return verifyAttributeValue((AttributeType<?>) pt, value);
+ return verifyAttributeValue((DefaultAttributeType<?>) pt, value);
}
- } else if (pt instanceof FeatureAssociationRole) {
+ } else if (pt instanceof DefaultAssociationRole) {
if (value != null) {
- return verifyAssociationValue((FeatureAssociationRole) pt, value);
+ return verifyAssociationValue((DefaultAssociationRole) pt, value);
}
} else {
throw new IllegalArgumentException(unsupportedPropertyType(pt.getName()));
@@ -679,7 +667,7 @@
*
* @param value the value, which shall be non-null.
*/
- private static <T> Object verifyAttributeValue(final AttributeType<T> type, final Object value) {
+ private static <T> Object verifyAttributeValue(final DefaultAttributeType<T> type, final Object value) {
final Class<T> valueClass = type.getValueClass();
final boolean isSingleton = Field.isSingleton(type.getMaximumOccurs());
if (valueClass.isInstance(value)) {
@@ -701,42 +689,42 @@
*
* @param value the value, which shall be non-null.
*/
- private static Object verifyAssociationValue(final FeatureAssociationRole role, final Object value) {
+ private static Object verifyAssociationValue(final DefaultAssociationRole role, final Object value) {
final boolean isSingleton = Field.isSingleton(role.getMaximumOccurs());
- if (value instanceof Feature) {
+ if (value instanceof AbstractFeature) {
/*
* If the user gave us a single value, first verify its validity.
* Then wrap it in a list of 1 element if this property is multi-valued.
*/
- final FeatureType valueType = ((Feature) value).getType();
- final FeatureType base = role.getValueType();
+ final DefaultFeatureType valueType = ((AbstractFeature) value).getType();
+ final DefaultFeatureType base = role.getValueType();
if (base == valueType || DefaultFeatureType.maybeAssignableFrom(base, valueType)) {
- return isSingleton ? value : singletonList(Feature.class, role.getMinimumOccurs(), value);
+ return isSingleton ? value : singletonList(AbstractFeature.class, role.getMinimumOccurs(), value);
} else {
- throw new InvalidPropertyValueException(illegalFeatureType(role, base, valueType));
+ throw new IllegalArgumentException(illegalFeatureType(role, base, valueType));
}
} else if (!isSingleton && value instanceof Collection<?>) {
verifyAssociationValues(role, (Collection<?>) value);
- return CheckedArrayList.castOrCopy((Collection<?>) value, Feature.class);
+ return CheckedArrayList.castOrCopy((Collection<?>) value, AbstractFeature.class);
} else {
- throw new ClassCastException(illegalValueClass(role, Feature.class, value));
+ throw new ClassCastException(illegalValueClass(role, AbstractFeature.class, value));
}
}
/**
* Verifies if all values in the given collection are valid instances of feature for the given association role.
*/
- private static void verifyAssociationValues(final FeatureAssociationRole role, final Collection<?> values) {
- final FeatureType base = role.getValueType();
+ private static void verifyAssociationValues(final DefaultAssociationRole role, final Collection<?> values) {
+ final DefaultFeatureType base = role.getValueType();
int index = 0;
for (final Object value : values) {
ArgumentChecks.ensureNonNullElement("values", index, value);
- if (!(value instanceof Feature)) {
- throw new ClassCastException(illegalValueClass(role, Feature.class, value));
+ if (!(value instanceof AbstractFeature)) {
+ throw new ClassCastException(illegalValueClass(role, AbstractFeature.class, value));
}
- final FeatureType type = ((Feature) value).getType();
+ final DefaultFeatureType type = ((AbstractFeature) value).getType();
if (base != type && !DefaultFeatureType.maybeAssignableFrom(base, type)) {
- throw new InvalidPropertyValueException(illegalFeatureType(role, base, type));
+ throw new IllegalArgumentException(illegalFeatureType(role, base, type));
}
index++;
}
@@ -762,7 +750,7 @@
*/
static String propertyNotFound(final FeatureType type, final Object feature, final String property) {
GenericName ambiguous = null;
- for (final IdentifiedType p : type.getProperties(true)) {
+ for (final AbstractIdentifiedType p : type.getProperties(true)) {
final GenericName next = p.getName();
GenericName name = next;
do {
@@ -780,7 +768,7 @@
/**
* Returns the exception message for a property type which is neither an attribute or an association.
- * This method is invoked after a {@link PropertyType} has been found for the user supplied name,
+ * This method is invoked after a {@code PropertyType} has been found for the user supplied name,
* but that property cannot be stored in or extracted from a {@link Property} instance.
*/
static String unsupportedPropertyType(final GenericName name) {
@@ -792,7 +780,7 @@
*
* @param value the value, which shall be non-null.
*/
- private static String illegalValueClass(final IdentifiedType property, final Class<?> expected, final Object value) {
+ private static String illegalValueClass(final AbstractIdentifiedType property, final Class<?> expected, final Object value) {
return Resources.format(Resources.Keys.IllegalPropertyValueClass_3,
property.getName(), expected, value.getClass());
}
@@ -801,7 +789,7 @@
* Returns the exception message for an association value of wrong type.
*/
private static String illegalFeatureType(
- final FeatureAssociationRole association, final FeatureType expected, final FeatureType actual)
+ final DefaultAssociationRole association, final FeatureType expected, final FeatureType actual)
{
return Resources.format(Resources.Keys.IllegalFeatureType_3,
association.getName(), expected.getName(), actual.getName());
@@ -932,7 +920,7 @@
public int hashCode() {
int code = type.hashCode() * 37;
if (comparisonStart()) try {
- for (final PropertyType pt : type.getProperties(true)) {
+ for (final AbstractIdentifiedType pt : type.getProperties(true)) {
final String name = pt.getName().toString();
if (name != null) { // Paranoiac check.
final Object value = getPropertyValue(name);
@@ -980,7 +968,7 @@
return false;
}
if (comparisonStart()) try {
- for (final PropertyType pt : type.getProperties(true)) {
+ for (final AbstractIdentifiedType pt : type.getProperties(true)) {
final String name = pt.getName().toString();
if (!Objects.equals(getPropertyValue(name), that.getPropertyValue(name))) {
return false;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractIdentifiedType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractIdentifiedType.java
index b714695..95f2e24 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractIdentifiedType.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractIdentifiedType.java
@@ -32,18 +32,20 @@
import org.apache.sis.util.iso.Types;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.IdentifiedType;
-
/**
* Identification and description information inherited by property types and feature types.
*
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code IdentifiedType} interface in a future version.
+ * When such interface will be available, most references to {@code AbstractIdentifiedType} in the API
+ * will be replaced by references to the {@code IdentifiedType} interface.</div>
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
* @since 0.5
*/
-public class AbstractIdentifiedType implements IdentifiedType, Deprecable, Serializable {
+public class AbstractIdentifiedType implements Deprecable, Serializable {
/**
* For cross-version compatibility.
*/
@@ -215,7 +217,7 @@
*/
@SuppressWarnings("this-escape")
protected AbstractIdentifiedType(final Map<String,?> identification) throws IllegalArgumentException {
- final IdentifiedType inheritFrom = Containers.property(identification, INHERIT_FROM_KEY, IdentifiedType.class);
+ final AbstractIdentifiedType inheritFrom = Containers.property(identification, INHERIT_FROM_KEY, AbstractIdentifiedType.class);
Object value = identification.get(NAME_KEY); // Implicit null value check.
if (value == null) {
if (inheritFrom == null || (name = inheritFrom.getName()) == null) {
@@ -234,7 +236,7 @@
description = toInternationalString(identification, DESCRIPTION_KEY, inheritFrom);
value = identification.get(DEPRECATED_KEY);
if (value == null) {
- deprecated = (inheritFrom instanceof Deprecable) ? ((Deprecable) inheritFrom).isDeprecated() : false;
+ deprecated = (inheritFrom != null) && inheritFrom.isDeprecated();
} else if (value instanceof Boolean) {
deprecated = (Boolean) value;
} else {
@@ -252,7 +254,7 @@
* associated to keys starting with the given prefix.
*/
private static InternationalString toInternationalString(
- final Map<String,?> identification, final String prefix, final IdentifiedType inheritFrom)
+ final Map<String,?> identification, final String prefix, final AbstractIdentifiedType inheritFrom)
{
InternationalString i18n = Types.toInternationalString(identification, prefix);
if (i18n == null && inheritFrom != null) {
@@ -308,7 +310,6 @@
*
* @return the type name.
*/
- @Override
public final GenericName getName() {
return name;
}
@@ -318,7 +319,6 @@
*
* @return concise definition of the element.
*/
- @Override
public InternationalString getDefinition() {
return definition;
}
@@ -329,7 +329,6 @@
*
* @return natural language designator for the element.
*/
- @Override
public Optional<InternationalString> getDesignation() {
return Optional.ofNullable(designation);
}
@@ -343,7 +342,6 @@
*
* @return information beyond that required for concise definition of the element, or {@code null} if none.
*/
- @Override
public Optional<InternationalString> getDescription() {
return Optional.ofNullable(description);
}
@@ -433,7 +431,9 @@
* @param index index of the characteristics having the given name.
* @throws IllegalArgumentException if the given name is null or have an empty string representation.
*/
- static String toString(final GenericName name, final IdentifiedType container, final String argument, final int index) {
+ static String toString(final GenericName name, final AbstractIdentifiedType container,
+ final String argument, final int index)
+ {
short key = Errors.Keys.MissingValueForProperty_1;
if (name != null) {
final String s = name.toString();
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java
index 6c76e4c..088a19e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java
@@ -33,17 +33,6 @@
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureOperationException;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-
/**
* Describes the behaviour of a feature type as a function or a method.
@@ -57,8 +46,8 @@
* <div class="note"><b>Example:</b> a mutator operation may raise the height of a dam. This changes
* may affect other properties like the watercourse and the reservoir associated with the dam.</div>
*
- * The value is computed, or the operation is executed, by {@link #apply(Feature, ParameterValueGroup)}.
- * If the value is modifiable, new value can be set by call to {@link Attribute#setValue(Object)}.
+ * The value is computed, or the operation is executed, by {@code apply(Feature, ParameterValueGroup)}.
+ * If the value is modifiable, new value can be set by call to {@code Attribute.setValue(Object)}.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
@@ -67,8 +56,8 @@
*
* @since 0.6
*/
-public abstract class AbstractOperation extends AbstractIdentifiedType implements Operation,
- BiFunction<Feature, ParameterValueGroup, Property>
+public abstract class AbstractOperation extends AbstractIdentifiedType
+ implements BiFunction<AbstractFeature, ParameterValueGroup, Object>
{
/**
* For cross-version compatibility.
@@ -151,16 +140,17 @@
*
* @return description of the input parameters.
*/
- @Override
public abstract ParameterDescriptorGroup getParameters();
/**
* Returns the expected result type, or {@code null} if none.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.IdentifiedType}. This change is pending GeoAPI revision.</div>
+ *
* @return the type of the result, or {@code null} if none.
*/
- @Override
- public abstract IdentifiedType getResult();
+ public abstract AbstractIdentifiedType getResult();
/**
* Executes the operation on the specified feature with the specified parameters.
@@ -169,11 +159,11 @@
* <ul>
* <li>If {@code getResult()} returns {@code null},
* then this method should return {@code null}.</li>
- * <li>If {@code getResult()} returns an instance of {@link AttributeType},
- * then this method shall return an instance of {@link Attribute}
+ * <li>If {@code getResult()} returns an instance of {@code AttributeType},
+ * then this method shall return an instance of {@code Attribute}
* and the {@code Attribute.getType() == getResult()} relation should hold.</li>
- * <li>If {@code getResult()} returns an instance of {@link org.opengis.feature.FeatureAssociationRole},
- * then this method shall return an instance of {@link FeatureAssociation}
+ * <li>If {@code getResult()} returns an instance of {@code FeatureAssociationRole},
+ * then this method shall return an instance of {@code FeatureAssociation}
* and the {@code FeatureAssociation.getRole() == getResult()} relation should hold.</li>
* </ul>
*
@@ -183,15 +173,18 @@
* in the Java language, and may be {@code null} if the operation does not need a feature instance
* (like static methods in the Java language).</div>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the parameter type and return value may
+ * be changed to {@code org.opengis.feature.Feature} and {@code org.opengis.feature.Property} respectively.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param feature the feature on which to execute the operation.
* Can be {@code null} if the operation does not need feature instance.
* @param parameters the parameters to use for executing the operation.
* Can be {@code null} if the operation does not take any parameters.
* @return the operation result, or {@code null} if this operation does not produce any result.
- * @throws FeatureOperationException if the operation execution cannot complete.
*/
@Override
- public abstract Property apply(Feature feature, ParameterValueGroup parameters) throws FeatureOperationException;
+ public abstract Object apply(AbstractFeature feature, ParameterValueGroup parameters);
/**
* Returns the names of feature properties that this operation needs for performing its task.
@@ -221,6 +214,9 @@
* then the entry is ignored. Conversely, if any member of the dependency set is not contained in the
* given map, then the associated dependency is unchanged.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.Operation}. This change is pending GeoAPI revision.</div>
+ *
* <h4>Purpose</h4>
* This method is needed by {@link org.apache.sis.feature.builder.FeatureTypeBuilder} when some properties
* are operations inherited from another feature type. Even if the dependencies are properties of the same
@@ -238,7 +234,7 @@
*
* @since 1.5
*/
- public Operation updateDependencies(final Map<String, PropertyType> dependencies) {
+ public AbstractOperation updateDependencies(final Map<String, AbstractIdentifiedType> dependencies) {
return this;
}
@@ -291,11 +287,11 @@
if (name != null) {
buffer.append('”');
}
- final IdentifiedType result = getResult();
+ final AbstractIdentifiedType result = getResult();
if (result != null) {
final Object type;
- if (result instanceof AttributeType<?>) {
- type = Classes.getShortName(((AttributeType<?>) result).getValueClass());
+ if (result instanceof DefaultAttributeType<?>) {
+ type = Classes.getShortName(((DefaultAttributeType<?>) result).getValueClass());
} else {
type = result.getName();
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AssociationView.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AssociationView.java
index bb406cd..0e037f8 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AssociationView.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AssociationView.java
@@ -19,10 +19,8 @@
import java.util.Collection;
import org.opengis.util.GenericName;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
+// Specific to the main branch:
+import java.util.Objects;
/**
@@ -36,24 +34,30 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-class AssociationView extends PropertyView<Feature> implements FeatureAssociation {
+class AssociationView extends AbstractAssociation {
/**
* For cross-version compatibility.
*/
private static final long serialVersionUID = -148100967531766909L;
/**
- * The role of this association. Must be one of the properties listed in the {@link #feature}.
+ * The feature from which to read and where to write the attribute or association value.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final FeatureAssociationRole role;
+ final AbstractFeature feature;
+
+ /**
+ * The string representation of the property name. This is the value to be given in calls to
+ * {@code Feature.getPropertyValue(String)} and {@code Feature.setPropertyValue(String, Object)}.
+ */
+ final String name;
/**
* Creates a new association which will delegate its work to the given feature.
*/
- private AssociationView(final Feature feature, final FeatureAssociationRole role) {
- super(feature, role.getName().toString());
- this.role = role;
+ private AssociationView(final AbstractFeature feature, final DefaultAssociationRole role) {
+ super(role);
+ this.feature = feature;
+ this.name = role.getName().toString();
}
/**
@@ -63,7 +67,7 @@
* @param role the role of this association. Must be one of the properties listed in the
* {@link #feature} (this is not verified by this constructor).
*/
- static FeatureAssociation create(final Feature feature, final FeatureAssociationRole role) {
+ static AbstractAssociation create(final AbstractFeature feature, final DefaultAssociationRole role) {
if (isSingleton(role.getMaximumOccurs())) {
return new Singleton(feature, role);
} else {
@@ -79,20 +83,24 @@
return role.getName();
}
- /**
- * Returns the role specified at construction time.
- */
@Override
- public final FeatureAssociationRole getRole() {
- return role;
+ public AbstractFeature getValue() {
+ return (AbstractFeature) PropertyView.getValue(feature, name);
}
- /**
- * Returns the class of values.
- */
@Override
- final Class<Feature> getValueClass() {
- return Feature.class;
+ public void setValue(final AbstractFeature value) {
+ PropertyView.setValue(feature, name, value);
+ }
+
+ @Override
+ public Collection<AbstractFeature> getValues() {
+ return PropertyView.getValues(feature, name, AbstractFeature.class);
+ }
+
+ @Override
+ public final void setValues(final Collection<? extends AbstractFeature> values) {
+ PropertyView.setValues(feature, name, values);
}
/**
@@ -109,7 +117,7 @@
/**
* Creates a new association which will delegate its work to the given feature.
*/
- Singleton(final Feature feature, final FeatureAssociationRole role) {
+ Singleton(final AbstractFeature feature, final DefaultAssociationRole role) {
super(feature, role);
}
@@ -117,17 +125,17 @@
* Returns the single value, or {@code null} if none.
*/
@Override
- public Feature getValue() {
- return (Feature) this.feature.getPropertyValue(this.name);
+ public AbstractFeature getValue() {
+ return (AbstractFeature) this.feature.getPropertyValue(this.name);
}
/**
* Sets the value of this association. This method assumes that the
- * {@link Feature#setPropertyValue(String, Object)} implementation
+ * {@code Feature.setPropertyValue(String, Object)} implementation
* will verify the argument type.
*/
@Override
- public void setValue(final Feature value) {
+ public void setValue(final AbstractFeature value) {
this.feature.setPropertyValue(this.name, value);
}
@@ -135,8 +143,30 @@
* Wraps the property value in a set.
*/
@Override
- public Collection<Feature> getValues() {
- return singletonOrEmpty(getValue());
+ public Collection<AbstractFeature> getValues() {
+ return PropertyView.singletonOrEmpty(getValue());
}
}
+
+ @Override
+ public final int hashCode() {
+ return PropertyView.hashCode(feature, name);
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj != null && obj.getClass() == getClass()) {
+ final AssociationView that = (AssociationView) obj;
+ return feature == that.feature && Objects.equals(name, that.name);
+ }
+ return false;
+ }
+
+ @Override
+ public final String toString() {
+ return PropertyView.toString(getClass(), AbstractFeature.class, getName(), getValues());
+ }
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AttributeView.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AttributeView.java
index b0eb039..c576eee 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AttributeView.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AttributeView.java
@@ -21,10 +21,8 @@
import java.util.Collections;
import org.opengis.util.GenericName;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import java.util.Objects;
/**
@@ -41,24 +39,30 @@
* @param <V> the type of attribute values. If the attribute supports multi-occurrences,
* then this is the type of elements (not the collection type).
*/
-class AttributeView<V> extends PropertyView<V> implements Attribute<V> {
+class AttributeView<V> extends AbstractAttribute<V> {
/**
* For cross-version compatibility.
*/
private static final long serialVersionUID = 3617999929561826634L;
/**
- * The type of this attribute. Must be one of the properties listed in the {@link #feature}.
+ * The feature from which to read and where to write the attribute or association value.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final AttributeType<V> type;
+ final AbstractFeature feature;
+
+ /**
+ * The string representation of the property name. This is the value to be given in calls to
+ * {@code Feature.getPropertyValue(String)} and {@code Feature.setPropertyValue(String, Object)}.
+ */
+ final String name;
/**
* Creates a new attribute which will delegate its work to the given feature.
*/
- private AttributeView(final Feature feature, final AttributeType<V> type) {
- super(feature, type.getName().toString());
- this.type = type;
+ private AttributeView(final AbstractFeature feature, final DefaultAttributeType<V> type) {
+ super(type);
+ this.feature = feature;
+ this.name = type.getName().toString();
}
/**
@@ -68,7 +72,7 @@
* @param type the type of this attribute. Must be one of the properties listed in the
* {@link #feature} (this is not verified by this constructor).
*/
- static <V> Attribute<V> create(final Feature feature, final AttributeType<V> type) {
+ static <V> AbstractAttribute<V> create(final AbstractFeature feature, final DefaultAttributeType<V> type) {
if (isSingleton(type.getMaximumOccurs())) {
return new Singleton<>(feature, type);
} else {
@@ -84,27 +88,31 @@
return type.getName();
}
- /**
- * Returns the type specified at construction time.
- */
@Override
- public final AttributeType<V> getType() {
- return type;
+ public V getValue() {
+ return type.getValueClass().cast(PropertyView.getValue(feature, name));
}
- /**
- * Returns the class of values.
- */
@Override
- final Class<V> getValueClass() {
- return type.getValueClass();
+ public void setValue(final V value) {
+ PropertyView.setValue(feature, name, value);
+ }
+
+ @Override
+ public Collection<V> getValues() {
+ return PropertyView.getValues(feature, name, type.getValueClass());
+ }
+
+ @Override
+ public final void setValues(final Collection<? extends V> values) {
+ PropertyView.setValues(feature, name, values);
}
/**
* Returns an empty map since this simple view does not support characteristics.
*/
@Override
- public final Map<String,Attribute<?>> characteristics() {
+ public final Map<String,AbstractAttribute<?>> characteristics() {
return Collections.emptyMap();
}
@@ -125,7 +133,7 @@
/**
* Creates a new attribute which will delegate its work to the given feature.
*/
- Singleton(final Feature feature, final AttributeType<V> type) {
+ Singleton(final AbstractFeature feature, final DefaultAttributeType<V> type) {
super(feature, type);
}
@@ -139,7 +147,7 @@
/**
* Sets the value of this attribute. This method assumes that the
- * {@link Feature#setPropertyValue(String, Object)} implementation
+ * {@code Feature.setPropertyValue(String, Object)} implementation
* will verify the argument type.
*/
@Override
@@ -152,7 +160,29 @@
*/
@Override
public Collection<V> getValues() {
- return singletonOrEmpty(getValue());
+ return PropertyView.singletonOrEmpty(getValue());
}
}
+
+ @Override
+ public final int hashCode() {
+ return PropertyView.hashCode(feature, name);
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj != null && obj.getClass() == getClass()) {
+ final AttributeView<?> that = (AttributeView<?>) obj;
+ return feature == that.feature && Objects.equals(name, that.name);
+ }
+ return false;
+ }
+
+ @Override
+ public final String toString() {
+ return PropertyView.toString(getClass(), type.getValueClass(), getName(), getValues());
+ }
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicMap.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicMap.java
index 8c32f92..8b579e0 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicMap.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicMap.java
@@ -24,12 +24,6 @@
import org.apache.sis.util.privy.AbstractMapEntry;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* Implementation of {@link AbstractAttribute#characteristics()} map.
@@ -37,16 +31,16 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class CharacteristicMap extends AbstractMap<String,Attribute<?>> implements CloneAccess {
+final class CharacteristicMap extends AbstractMap<String,AbstractAttribute<?>> implements CloneAccess {
/**
* The attribute source for which to provide characteristics.
*/
- private final Attribute<?> source;
+ private final AbstractAttribute<?> source;
/**
* Characteristics of the {@code source} attribute, created when first needed.
*/
- Attribute<?>[] characterizedBy;
+ AbstractAttribute<?>[] characterizedBy;
/**
* Description of the attribute characteristics.
@@ -59,7 +53,7 @@
* @param source the attribute which is characterized by {@code characterizedBy}.
* @param types description of the characteristics of {@code source}.
*/
- CharacteristicMap(final Attribute<?> source, final CharacteristicTypeMap types) {
+ CharacteristicMap(final AbstractAttribute<?> source, final CharacteristicTypeMap types) {
this.source = source;
this.types = types;
}
@@ -72,14 +66,14 @@
@Override
public CharacteristicMap clone() throws CloneNotSupportedException {
final CharacteristicMap clone = (CharacteristicMap) super.clone();
- Attribute<?>[] c = clone.characterizedBy;
+ AbstractAttribute<?>[] c = clone.characterizedBy;
if (c != null) {
clone.characterizedBy = c = c.clone();
final Cloner cloner = new Cloner();
for (int i=0; i<c.length; i++) {
- final Attribute<?> attribute = c[i];
+ final AbstractAttribute<?> attribute = c[i];
if (attribute instanceof Cloneable) {
- c[i] = (Attribute<?>) cloner.clone(attribute);
+ c[i] = (AbstractAttribute<?>) cloner.clone(attribute);
}
}
}
@@ -105,7 +99,7 @@
@Override
public boolean isEmpty() {
if (characterizedBy != null) {
- for (final Attribute<?> attribute : characterizedBy) {
+ for (final AbstractAttribute<?> attribute : characterizedBy) {
if (attribute != null) {
return false;
}
@@ -121,7 +115,7 @@
public int size() {
int n = 0;
if (characterizedBy != null) {
- for (final Attribute<?> attribute : characterizedBy) {
+ for (final AbstractAttribute<?> attribute : characterizedBy) {
if (attribute != null) {
n++;
}
@@ -134,7 +128,7 @@
* Returns the attribute characteristic for the given name, or {@code null} if none.
*/
@Override
- public Attribute<?> get(final Object key) {
+ public AbstractAttribute<?> get(final Object key) {
if (characterizedBy != null) {
final Integer index = types.indices.get(key);
if (index != null) {
@@ -148,11 +142,11 @@
* Removes the attribute characteristic for the given name.
*/
@Override
- public Attribute<?> remove(final Object key) {
+ public AbstractAttribute<?> remove(final Object key) {
if (characterizedBy != null) {
final Integer index = types.indices.get(key);
if (index != null) {
- final Attribute<?> previous = characterizedBy[index];
+ final AbstractAttribute<?> previous = characterizedBy[index];
characterizedBy[index] = null;
return previous;
}
@@ -165,12 +159,12 @@
*
* @param key the name for which to get the characteristic index.
* @return the index for the characteristic of the given name.
- * @throws PropertyNotFoundException if the given key is not the name of a characteristic in this map.
+ * @throws IllegalArgumentException if the given key is not the name of a characteristic in this map.
*/
private int indexOf(final String key) {
final Integer index = types.indices.get(key);
if (index == null) {
- throw new PropertyNotFoundException(Resources.format(
+ throw new IllegalArgumentException(Resources.format(
Resources.Keys.CharacteristicsNotFound_2, source.getName(), key));
}
return index;
@@ -184,12 +178,12 @@
* @param index index of the expected attribute type.
* @param type the actual attribute type.
*/
- final void verifyAttributeType(final int index, final AttributeType<?> type) {
- final AttributeType<?> expected = types.characterizedBy[index];
+ final void verifyAttributeType(final int index, final DefaultAttributeType<?> type) {
+ final DefaultAttributeType<?> expected = types.characterizedBy[index];
if (!expected.equals(type)) {
final GenericName en = expected.getName();
final GenericName an = type.getName();
- throw new InvalidPropertyValueException(String.valueOf(en).equals(String.valueOf(an))
+ throw new IllegalArgumentException(String.valueOf(en).equals(String.valueOf(an))
? Resources.format(Resources.Keys.MismatchedPropertyType_1, en)
: Resources.format(Resources.Keys.CanNotSetCharacteristics_2, en.push(source.getName()), an));
}
@@ -202,13 +196,13 @@
* @throws IllegalArgumentException if the given key is not the name of a characteristic in this map.
*/
@Override
- public Attribute<?> put(final String key, final Attribute<?> value) {
+ public AbstractAttribute<?> put(final String key, final AbstractAttribute<?> value) {
final int index = indexOf(key);
verifyAttributeType(index, value.getType());
if (characterizedBy == null) {
- characterizedBy = new Attribute<?>[types.characterizedBy.length];
+ characterizedBy = new AbstractAttribute<?>[types.characterizedBy.length];
}
- final Attribute<?> previous = characterizedBy[index];
+ final AbstractAttribute<?> previous = characterizedBy[index];
characterizedBy[index] = value;
return previous;
}
@@ -225,7 +219,7 @@
protected boolean addKey(final String name) {
final int index = indexOf(name);
if (characterizedBy == null) {
- characterizedBy = new Attribute<?>[types.characterizedBy.length];
+ characterizedBy = new AbstractAttribute<?>[types.characterizedBy.length];
}
if (characterizedBy[index] == null) {
characterizedBy[index] = types.characterizedBy[index].newInstance();
@@ -243,13 +237,13 @@
* @throws IllegalStateException if another characteristic already exists for the characteristic name.
*/
@Override
- protected boolean addValue(final Attribute<?> value) {
+ protected boolean addValue(final AbstractAttribute<?> value) {
final int index = indexOf(value.getName().toString());
verifyAttributeType(index, value.getType());
if (characterizedBy == null) {
- characterizedBy = new Attribute<?>[types.characterizedBy.length];
+ characterizedBy = new AbstractAttribute<?>[types.characterizedBy.length];
}
- final Attribute<?> previous = characterizedBy[index];
+ final AbstractAttribute<?> previous = characterizedBy[index];
if (previous == null) {
characterizedBy[index] = value;
return true;
@@ -265,16 +259,16 @@
* Returns an iterator over the entries.
*/
@Override
- protected EntryIterator<String, Attribute<?>> entryIterator() {
+ protected EntryIterator<String, AbstractAttribute<?>> entryIterator() {
if (characterizedBy == null) {
return null;
}
- return new EntryIterator<String, Attribute<?>>() {
+ return new EntryIterator<String, AbstractAttribute<?>>() {
/** Index of the current element to return in the iteration. */
private int index = -1;
/** The element to return, or {@code null} if we reached the end of iteration. */
- private Attribute<?> value;
+ private AbstractAttribute<?> value;
/** Returns {@code true} if there is more entries in the iteration. */
@Override protected boolean next() {
@@ -292,12 +286,12 @@
}
/** Returns the attribute characteristic (never {@code null}). */
- @Override protected Attribute<?> getValue() {
+ @Override protected AbstractAttribute<?> getValue() {
return value;
}
/** Creates and return the next entry. */
- @Override protected Map.Entry<String, Attribute<?>> getEntry() {
+ @Override protected Map.Entry<String, AbstractAttribute<?>> getEntry() {
return new Entry(index, value);
}
@@ -311,17 +305,17 @@
/**
* An entry returned by the {@link CharacteristicMap#entrySet()} iterator.
* The key and value are never null, even in case of concurrent modification.
- * This entry supports the {@link #setValue(Attribute)} operation.
+ * This entry supports the {@code setValue(Attribute)} operation.
*/
- private final class Entry extends AbstractMapEntry<String, Attribute<?>> {
+ private final class Entry extends AbstractMapEntry<String, AbstractAttribute<?>> {
/** Index of the attribute characteristics represented by this entry. */
private final int index;
/** The current attribute value, which is guaranteed to be non-null. */
- private Attribute<?> value;
+ private AbstractAttribute<?> value;
/** Creates a new entry for the characteristic at the given index. */
- Entry(final int index, final Attribute<?> value) {
+ Entry(final int index, final AbstractAttribute<?> value) {
this.index = index;
this.value = value;
}
@@ -332,14 +326,14 @@
}
/** Returns the attribute characteristic (never {@code null}). */
- @Override public Attribute<?> getValue() {
+ @Override public AbstractAttribute<?> getValue() {
return value;
}
/** Sets the attribute characteristic. */
- @Override public Attribute<?> setValue(final Attribute<?> value) {
+ @Override public AbstractAttribute<?> setValue(final AbstractAttribute<?> value) {
verifyAttributeType(index, value.getType());
- final Attribute<?> previous = this.value;
+ final AbstractAttribute<?> previous = this.value;
characterizedBy[index] = value;
this.value = value;
return previous;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicTypeMap.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicTypeMap.java
index 99f9006..58348c7 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicTypeMap.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CharacteristicTypeMap.java
@@ -27,9 +27,6 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.pending.jdk.JDK19;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* Implementation of the map returned by {@link DefaultAttributeType#characteristics()}.
@@ -46,17 +43,17 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class CharacteristicTypeMap extends AbstractMap<String,AttributeType<?>> {
+final class CharacteristicTypeMap extends AbstractMap<String,DefaultAttributeType<?>> {
/**
* For sharing the same {@code CharacteristicTypeMap} instances among the attribute types
* having the same characteristics.
*/
@SuppressWarnings("unchecked")
- private static final WeakValueHashMap<AttributeType<?>[],CharacteristicTypeMap> SHARED =
- new WeakValueHashMap<>((Class) AttributeType[].class);
+ private static final WeakValueHashMap<DefaultAttributeType<?>[],CharacteristicTypeMap> SHARED =
+ new WeakValueHashMap<>((Class) DefaultAttributeType[].class);
/*
- * This class has intentionally no reference to the AttributeType for which we are providing characteristics.
+ * This class has intentionally no reference to the DefaultAttributeType for which we are providing characteristics.
* This allows us to use the same CharacteristicTypeMap instance for various attribute types having the same
* characteristic (e.g. many measurements may have an "accuracy" characteristic).
*/
@@ -65,7 +62,7 @@
* Characteristics of another attribute type (the {@code source} attribute given to the constructor).
* This array shall not be modified.
*/
- final AttributeType<?>[] characterizedBy;
+ final DefaultAttributeType<?>[] characterizedBy;
/**
* The names of attribute types listed in the {@link #characterizedBy} array,
@@ -84,7 +81,7 @@
* @return a map for this given characteristics.
* @throws IllegalArgumentException if two characteristics have the same name.
*/
- static CharacteristicTypeMap create(final AttributeType<?> source, final AttributeType<?>[] characterizedBy) {
+ static CharacteristicTypeMap create(final DefaultAttributeType<?> source, final DefaultAttributeType<?>[] characterizedBy) {
CharacteristicTypeMap map;
synchronized (SHARED) {
map = SHARED.get(characterizedBy);
@@ -106,14 +103,14 @@
* @param characterizedBy characteristics of {@code source}. Should not be empty.
* @throws IllegalArgumentException if two characteristics have the same name.
*/
- private CharacteristicTypeMap(final AttributeType<?> source, final AttributeType<?>[] characterizedBy) {
+ private CharacteristicTypeMap(final DefaultAttributeType<?> source, final DefaultAttributeType<?>[] characterizedBy) {
this.characterizedBy = characterizedBy;
int index = 0;
@SuppressWarnings("LocalVariableHidesMemberVariable")
final Map<String,Integer> indices = JDK19.newHashMap(characterizedBy.length);
final Map<String,Integer> aliases = new HashMap<>();
for (int i=0; i<characterizedBy.length; i++) {
- final AttributeType<?> attribute = characterizedBy[i];
+ final DefaultAttributeType<?> attribute = characterizedBy[i];
ArgumentChecks.ensureNonNullElement("characterizedBy", i, attribute);
GenericName name = attribute.getName();
String key = AbstractIdentifiedType.toString(name, source, "characterizedBy", i);
@@ -178,7 +175,7 @@
*/
@Override
public boolean containsValue(final Object key) {
- for (final AttributeType<?> type : characterizedBy) {
+ for (final DefaultAttributeType<?> type : characterizedBy) {
if (type.equals(key)) {
return true;
}
@@ -190,7 +187,7 @@
* Returns the attribute characteristic for the given name, or {@code null} if none.
*/
@Override
- public AttributeType<?> get(final Object key) {
+ public DefaultAttributeType<?> get(final Object key) {
final Integer index = indices.get(key);
return (index != null) ? characterizedBy[index] : null;
}
@@ -200,13 +197,13 @@
* This is not the iterator returned by public API like {@code Map.entrySet().iterator()}.
*/
@Override
- protected EntryIterator<String, AttributeType<?>> entryIterator() {
- return new EntryIterator<String, AttributeType<?>>() {
+ protected EntryIterator<String, DefaultAttributeType<?>> entryIterator() {
+ return new EntryIterator<String, DefaultAttributeType<?>>() {
/** Index of the next element to return in the iteration. */
private int index;
/** Value of current entry. */
- private AttributeType<?> value;
+ private DefaultAttributeType<?> value;
/**
* Returns {@code true} if there is more entries in the iteration.
@@ -232,7 +229,7 @@
* Returns the attribute characteristic contained in this entry.
*/
@Override
- protected AttributeType<?> getValue() {
+ protected DefaultAttributeType<?> getValue() {
return value;
}
};
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CommonParentFinder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CommonParentFinder.java
index 4c929ac..1686282 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CommonParentFinder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/CommonParentFinder.java
@@ -20,13 +20,10 @@
import java.util.LinkedHashMap;
import java.util.function.Predicate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-
/**
* Finds a feature type common to all given types. This is either one of the given types, or a parent common to all types.
- * A feature <var>F</var> is considered a common parent if <code>F.{@link DefaultFeatureType#isAssignableFrom(FeatureType)
+ * A feature <var>F</var> is considered a common parent if <code>F.{@link DefaultFeatureType#isAssignableFrom(DefaultFeatureType)
* isAssignableFrom}(type)</code> returns {@code true} for all elements <var>type</var> in the given array.
*
* @author Martin Desruisseaux (Geomatys)
@@ -38,16 +35,16 @@
* @param types types for which to find a common type.
* @return a feature type which is assignable from all given types, or {@code null} if none.
*/
- static FeatureType select(final Iterable<? extends FeatureType> types) {
+ static DefaultFeatureType select(final Iterable<? extends DefaultFeatureType> types) {
/*
* Get a set of unique feature types. Since the process done in this method may be relatively costly,
* we want to avoid doing the same work twice. The purpose of Boolean value will be explained later.
*/
- final Map<FeatureType,Boolean> allTypes = new LinkedHashMap<>();
+ final Map<DefaultFeatureType,Boolean> allTypes = new LinkedHashMap<>();
types.forEach((type) -> allTypes.putIfAbsent(type, Boolean.FALSE));
allTypes.remove(null);
int count = allTypes.size();
- final FeatureType[] required = allTypes.keySet().toArray(new FeatureType[count]);
+ final DefaultFeatureType[] required = allTypes.keySet().toArray(new DefaultFeatureType[count]);
/*
* We are going to iterate over the `required` array many times. For performance reason, this array should be as
* short as possible. We can make it shorter by removing any element A which is assignable to another element B,
@@ -55,7 +52,7 @@
* If this simplification results in an array of only one element, we are done.
*/
for (int i=0; i<count; i++) {
- final FeatureType parent = required[i];
+ final DefaultFeatureType parent = required[i];
for (int j=count; --j >= 0;) { // Reverse order so that removed elements do not impact index j.
if (j != i && parent.isAssignableFrom(required[j])) {
System.arraycopy(required, j+1, required, j, --count - j); // If A is assignable from B, remove B.
@@ -81,13 +78,13 @@
* updated after we find that a type {@linkplain #isAssignableFromAll is assignable from
* all required types}.
*/
- private final Map<FeatureType,Boolean> allTypes;
+ private final Map<DefaultFeatureType,Boolean> allTypes;
/**
* The features types which must be assignable to the common parent.
* This array may not contain all feature types given by user, since we try to remove redundant elements.
*/
- private final FeatureType[] required;
+ private final DefaultFeatureType[] required;
/**
* Number of valid elements in the {@link #required} array.
@@ -98,7 +95,7 @@
* Creates a finder for a common parent of the given types.
* Invokes {@link #select()} after construction time for getting the parent.
*/
- private CommonParentFinder(final Map<FeatureType,Boolean> allTypes, final FeatureType[] required, final int count) {
+ private CommonParentFinder(final Map<DefaultFeatureType,Boolean> allTypes, final DefaultFeatureType[] required, final int count) {
this.allTypes = allTypes;
this.required = required;
this.count = count;
@@ -111,9 +108,9 @@
* Returns {@code true} if the given parent candidate is assignable from all required types.
* The feature type to be returned by {@link #select()} must met that condition.
*/
- private boolean isAssignableFromAll(final FeatureType parent) {
+ private boolean isAssignableFromAll(final DefaultFeatureType parent) {
for (int i=0; i<count; i++) {
- final FeatureType type = required[i];
+ final DefaultFeatureType type = required[i];
if (type != parent && !parent.isAssignableFrom(type)) {
return false;
}
@@ -126,8 +123,8 @@
* This method verifies recursively parents of parents, skipping types that have already
* been examined in a previous invocation of this method.
*/
- private void scanParents(final FeatureType type) {
- for (final FeatureType parent : type.getSuperTypes()) {
+ private void scanParents(final DefaultFeatureType type) {
+ for (final DefaultFeatureType parent : type.getSuperTypes()) {
if (allTypes.putIfAbsent(parent, Boolean.FALSE) == null) {
if (isAssignableFromAll(parent)) {
allTypes.put(parent, Boolean.TRUE); // Found a candidate.
@@ -143,9 +140,9 @@
* Invoked when the given feature type is assignable from all required types.
* There is no need to verify the parents since they are not going to be a better match.
*/
- private void skipParents(final FeatureType type) {
+ private void skipParents(final DefaultFeatureType type) {
assert isAssignableFromAll(type);
- for (final FeatureType parent : type.getSuperTypes()) {
+ for (final DefaultFeatureType parent : type.getSuperTypes()) {
if (Boolean.TRUE.equals(allTypes.put(parent, Boolean.FALSE))) {
// If `parent` was previously a candidate, its parents have already been set to `FALSE`.
} else {
@@ -158,11 +155,11 @@
* Invoked after all feature types have been examined. This method removes all features types that
* are not parent of required types, then select the one having the greatest number of properties.
*/
- FeatureType select() {
+ DefaultFeatureType select() {
allTypes.values().removeIf(Predicate.isEqual(Boolean.FALSE));
- FeatureType best = null;
+ DefaultFeatureType best = null;
int numProperties = 0;
- for (final FeatureType type : allTypes.keySet()) {
+ for (final DefaultFeatureType type : allTypes.keySet()) {
final int n = type.getProperties(true).size();
if (best == null || n > numProperties) {
best = type;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAssociationRole.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAssociationRole.java
index 2dbaf6f..46f1591 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAssociationRole.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAssociationRole.java
@@ -28,14 +28,6 @@
import org.apache.sis.feature.internal.Resources;
import org.apache.sis.feature.privy.AttributeConvention;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* Indicates the role played by the association between two features.
@@ -62,7 +54,7 @@
*
* @since 0.5
*/
-public class DefaultAssociationRole extends FieldType implements FeatureAssociationRole {
+public class DefaultAssociationRole extends FieldType {
/**
* For cross-version compatibility.
*/
@@ -80,8 +72,6 @@
* The name of the property to use as a title for the associated feature, or an empty string if none.
* This field is initially null, then computed when first needed.
* This information is used only by {@link AbstractAssociation#toString()} implementation.
- *
- * @see #getTitleProperty(FeatureAssociationRole)
*/
private transient volatile String titleProperty;
@@ -127,7 +117,7 @@
*
* @see org.apache.sis.feature.builder.AssociationRoleBuilder
*/
- public DefaultAssociationRole(final Map<String,?> identification, final FeatureType valueType,
+ public DefaultAssociationRole(final Map<String,?> identification, final DefaultFeatureType valueType,
final int minimumOccurs, final int maximumOccurs)
{
super(identification, minimumOccurs, maximumOccurs);
@@ -215,7 +205,7 @@
* invoking that method on {@code creating} may cause a failure with user code.
* @return {@code true} if this association references a resolved feature type after this method call.
*/
- final boolean resolve(final DefaultFeatureType creating, final Collection<PropertyType> properties) {
+ final boolean resolve(final DefaultFeatureType creating, final Collection<AbstractIdentifiedType> properties) {
final FeatureType type = valueType;
if (type instanceof NamedFeatureType) {
FeatureType resolved = ((NamedFeatureType) type).resolved;
@@ -229,7 +219,7 @@
* this desired feature in an association of the `creating` feature, instead of beeing
* the `creating` feature itself. This is a little bit unusual, but not illegal.
*/
- final List<FeatureType> deferred = new ArrayList<>();
+ final List<DefaultFeatureType> deferred = new ArrayList<>();
resolved = search(creating, properties, name, deferred);
if (resolved == null) {
/*
@@ -263,8 +253,8 @@
* @param deferred where to store {@code FeatureType}s to be eventually used for a deep search.
* @return the feature of the given name, or {@code null} if none.
*/
- private static FeatureType search(final FeatureType feature, Collection<? extends PropertyType> properties,
- final GenericName name, final List<FeatureType> deferred)
+ private static DefaultFeatureType search(final DefaultFeatureType feature, Collection<? extends AbstractIdentifiedType> properties,
+ final GenericName name, final List<DefaultFeatureType> deferred)
{
/*
* Search only in associations declared in the given feature, not in inherited associations.
@@ -274,21 +264,17 @@
if (properties == null) {
properties = feature.getProperties(false);
}
- for (final PropertyType property : properties) {
- if (property instanceof FeatureAssociationRole) {
+ for (final AbstractIdentifiedType property : properties) {
+ if (property instanceof DefaultAssociationRole) {
final FeatureType valueType;
- if (property instanceof DefaultAssociationRole) {
- valueType = ((DefaultAssociationRole) property).valueType;
- if (valueType instanceof NamedFeatureType) {
- continue; // Skip unresolved feature types.
- }
- } else {
- valueType = ((FeatureAssociationRole) property).getValueType();
+ valueType = ((DefaultAssociationRole) property).valueType;
+ if (valueType instanceof NamedFeatureType) {
+ continue; // Skip unresolved feature types.
}
if (name.equals(valueType.getName())) {
- return valueType;
+ return (DefaultFeatureType) valueType;
}
- deferred.add(valueType);
+ deferred.add((DefaultFeatureType) valueType);
}
}
/*
@@ -297,7 +283,7 @@
* but not necessarily the same feature type (may be a subtype). This is equivalent to
* "covariant return type" in the Java language.
*/
- for (FeatureType type : feature.getSuperTypes()) {
+ for (DefaultFeatureType type : feature.getSuperTypes()) {
if (name.equals(type.getName())) {
return type;
}
@@ -310,7 +296,7 @@
}
/**
- * Potentially invoked after {@link #search(FeatureType, Collection, GenericName, List)} for searching
+ * Potentially invoked after {@code search(FeatureType, Collection, GenericName, List)} for searching
* in associations of associations.
*
* <p>Current implementation does not check that there are no duplicated names. Even if we did so,
@@ -318,14 +304,14 @@
* later. We rather put a warning in {@link #DefaultAssociationRole(Map, GenericName, int, int)}
* javadoc.</p>
*
- * @param deferred the feature types collected by {@link #search(FeatureType, Collection, GenericName, List)}.
+ * @param deferred the feature types collected by {@code search(FeatureType, Collection, GenericName, List)}.
* @param name the name of the feature to search.
* @return the feature of the given name, or {@code null} if none.
*/
- private static FeatureType deepSearch(final List<FeatureType> deferred, final GenericName name) {
+ private static DefaultFeatureType deepSearch(final List<DefaultFeatureType> deferred, final GenericName name) {
final Map<FeatureType,Boolean> done = new IdentityHashMap<>(8);
for (int i=0; i<deferred.size();) {
- FeatureType valueType = deferred.get(i++);
+ DefaultFeatureType valueType = deferred.get(i++);
if (done.put(valueType, Boolean.TRUE) == null) {
deferred.subList(0, i).clear(); // Discard previous value for making more room.
valueType = search(valueType, null, name, deferred);
@@ -342,19 +328,20 @@
* Returns the type of feature values.
*
* <p>This method cannot be invoked if {@link #isResolved()} returns {@code false}.
- * However, it is still possible to {@linkplain Features#getValueTypeName(PropertyType)
+ * However, it is still possible to {@linkplain Features#getValueTypeName
* get the associated feature type name}.</p>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.FeatureType}. This change is pending GeoAPI revision.</div>
+ *
* @return the type of feature values.
* @throws IllegalStateException if the feature type has been specified
* {@linkplain #DefaultAssociationRole(Map, GenericName, int, int) only by its name}
* and not yet resolved.
*
* @see #isResolved()
- * @see Features#getValueTypeName(PropertyType)
*/
- @Override
- public final FeatureType getValueType() {
+ public final DefaultFeatureType getValueType() {
/*
* This method shall be final for consistency with other methods in this classes
* which use the `valueType` field directly. Furthermore, this method is invoked
@@ -368,15 +355,16 @@
}
valueType = type;
}
- return type;
+ return (DefaultFeatureType) type;
}
/**
* Returns the name of the feature type. This information is always available
* even when the name has not yet been {@linkplain #resolve resolved}.
*/
- static GenericName getValueTypeName(final FeatureAssociationRole role) {
- return (role instanceof DefaultAssociationRole ? ((DefaultAssociationRole) role).valueType : role.getValueType()).getName();
+ static GenericName getValueTypeName(final DefaultAssociationRole role) {
+ // Method is static for compatibility with branches on GeoAPI snapshots.
+ return role.valueType.getName();
}
/**
@@ -394,34 +382,35 @@
*
* This method should be used only for display purpose, not as a reliable or stable way to get the identifier.
* The heuristic rules implemented in this method may change in any future Apache SIS version.
+ *
+ * <p><b>API note:</b> a non-static method would be more elegant in this "SIS for GeoAPI 3.0" branch.
+ * However this method needs to be static in other SIS branches, because they work with interfaces
+ * rather than SIS implementation. We keep the method static in this branch too for easier merges.</p>
*/
- static String getTitleProperty(final FeatureAssociationRole role) {
- if (role instanceof DefaultAssociationRole) {
- String p = ((DefaultAssociationRole) role).titleProperty; // No synchronization - not a big deal if computed twice.
- if (p != null) {
- return p.isEmpty() ? null : p;
- }
- p = searchTitleProperty(role.getValueType());
- ((DefaultAssociationRole) role).titleProperty = (p != null) ? p : "";
- return p;
+ static String getTitleProperty(final DefaultAssociationRole role) {
+ String p = role.titleProperty; // No synchronization - not a big deal if computed twice.
+ if (p != null) {
+ return p.isEmpty() ? null : p;
}
- return searchTitleProperty(role.getValueType());
+ p = searchTitleProperty(role.getValueType());
+ role.titleProperty = (p != null) ? p : "";
+ return p;
}
/**
- * Implementation of {@link #getTitleProperty(FeatureAssociationRole)} for first search,
+ * Implementation of {@link #getTitleProperty(DefaultAssociationRole)} for first search,
* or for non-SIS {@code FeatureAssociationRole} implementations.
*/
- private static String searchTitleProperty(final FeatureType ft) {
+ private static String searchTitleProperty(final DefaultFeatureType ft) {
String fallback = null;
try {
return ft.getProperty(AttributeConvention.IDENTIFIER).getName().toString();
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
// Ignore.
}
- for (final PropertyType type : ft.getProperties(true)) {
- if (type instanceof AttributeType<?>) {
- final AttributeType<?> pt = (AttributeType<?>) type;
+ for (final AbstractIdentifiedType type : ft.getProperties(true)) {
+ if (type instanceof DefaultAttributeType<?>) {
+ final DefaultAttributeType<?> pt = (DefaultAttributeType<?>) type;
final Class<?> valueClass = pt.getValueClass();
if (CharSequence.class.isAssignableFrom(valueClass) ||
GenericName .class.isAssignableFrom(valueClass) ||
@@ -468,10 +457,9 @@
*
* @return a new association instance.
*
- * @see AbstractAssociation#create(FeatureAssociationRole)
+ * @see AbstractAssociation#create(DefaultAssociationRole)
*/
- @Override
- public FeatureAssociation newInstance() {
+ public AbstractAssociation newInstance() {
return AbstractAssociation.create(this);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAttributeType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAttributeType.java
index 9d53cb2..717a715 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAttributeType.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/DefaultAttributeType.java
@@ -28,10 +28,6 @@
import org.apache.sis.util.Classes;
import org.apache.sis.util.ArgumentChecks;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-
/**
* Definition of an attribute in a feature type.
@@ -45,6 +41,11 @@
* Attribute characterization (discussed below) is similar to {@link java.lang.annotation.Annotation}.
* </div>
*
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code AttributeType} interface in a future version.
+ * When such interface will be available, most references to {@code DefaultAttributeType} in current
+ * API will be replaced by references to the {@code AttributeType} interface.</div>
+ *
* <h2>Value type</h2>
* Attributes can be used for both spatial and non-spatial properties.
* Some examples are:
@@ -102,7 +103,7 @@
*
* @since 0.5
*/
-public class DefaultAttributeType<V> extends FieldType implements AttributeType<V> {
+public class DefaultAttributeType<V> extends FieldType {
/**
* For cross-version compatibility.
*/
@@ -181,7 +182,7 @@
@SuppressWarnings("this-escape") // Okay because used only in package-private class.
public DefaultAttributeType(final Map<String,?> identification, final Class<V> valueClass,
final int minimumOccurs, final int maximumOccurs, final V defaultValue,
- final AttributeType<?>... characterizedBy)
+ final DefaultAttributeType<?>... characterizedBy)
{
super(identification, minimumOccurs, maximumOccurs);
ArgumentChecks.ensureNonNull("valueClass", valueClass);
@@ -214,7 +215,7 @@
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
try {
- final AttributeType<?>[] characterizedBy = (AttributeType<?>[]) in.readObject();
+ final DefaultAttributeType<?>[] characterizedBy = (DefaultAttributeType<?>[]) in.readObject();
if (characterizedBy != null) {
characteristics = CharacteristicTypeMap.create(this, characterizedBy);
}
@@ -228,10 +229,7 @@
* Returns the type of attribute values.
*
* @return the type of attribute values.
- *
- * @see Features#getValueClass(PropertyType)
*/
- @Override
public final Class<V> getValueClass() {
return valueClass;
}
@@ -283,7 +281,6 @@
*
* @return the default value for the attribute, or {@code null} if none.
*/
- @Override
public V getDefaultValue() {
return defaultValue;
}
@@ -305,8 +302,7 @@
*
* @see AbstractAttribute#characteristics()
*/
- @Override
- public Map<String,AttributeType<?>> characteristics() {
+ public Map<String,DefaultAttributeType<?>> characteristics() {
return (characteristics != null) ? characteristics : Collections.emptyMap();
}
@@ -315,10 +311,9 @@
*
* @return a new attribute instance.
*
- * @see AbstractAttribute#create(AttributeType)
+ * @see AbstractAttribute#create(DefaultAttributeType)
*/
- @Override
- public Attribute<V> newInstance() {
+ public AbstractAttribute<V> newInstance() {
return AbstractAttribute.create(this);
}
diff --git 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
index 83e5ce6..fe3fcb2 100644
--- 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
@@ -40,17 +40,6 @@
import org.apache.sis.util.privy.UnmodifiableArrayList;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.Operation;
-import org.opengis.feature.FeatureInstantiationException;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* Abstraction of a real-world phenomena. A {@code FeatureType} instance describes the class of all
@@ -60,6 +49,11 @@
* compared to the Java language, {@code FeatureType} is equivalent to {@link Class} while
* {@code Feature} instances are equivalent to {@link Object} instances of that class.</div>
*
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code FeatureType} interface in a future version.
+ * When such interface will be available, most references to {@code DefaultFeatureType} in the API
+ * will be replaced by references to the {@code FeatureType} interface.</div>
+ *
* <h2>Naming</h2>
* The feature type {@linkplain #getName() name} is mandatory and should be unique. Those names are the main
* criterion used for deciding if a feature type {@linkplain #isAssignableFrom is assignable from} another type.
@@ -92,7 +86,7 @@
*
* <h2>Immutability and thread safety</h2>
* Instances of this class are immutable if all properties ({@link GenericName} and {@link InternationalString}
- * instances) and all arguments ({@link AttributeType} instances) given to the constructor are also immutable.
+ * instances) and all arguments ({@code AttributeType} instances) given to the constructor are also immutable.
* Such immutable instances can be shared by many objects and passed between threads without synchronization.
*
* @author Johann Sorel (Geomatys)
@@ -139,7 +133,7 @@
* any unresolved name (i.e. a {@link DefaultAssociationRole#valueType} specified only be the
* feature type name instead of its actual instance). A value of {@code true} means that all
* names have been resolved. However, a value of {@code false} only means that we are not sure,
- * and that {@link #resolve(FeatureType, Map)} should check again.
+ * and that {@code resolve(FeatureType, Map)} should check again.
*
* <h4>Implementation note</h4>
* Strictly speaking, this field should be declared {@code volatile} since the names could
@@ -155,14 +149,14 @@
*
* @see #getSuperTypes()
*/
- @SuppressWarnings("serial") // Can be various serializable implementations.
- private final Set<FeatureType> superTypes;
+ @SuppressWarnings("serial")
+ private final Set<DefaultFeatureType> superTypes;
/**
- * The names of all parents of this feature type, including parents of parents.
- * This is used for a more efficient implementation of {@link #isAssignableFrom(FeatureType)}.
+ * The names of all parents of this feature type, including parents of parents. This is used
+ * for a more efficient implementation of {@link #isAssignableFrom(DefaultFeatureType)}.
*
- * @see #isAssignableFrom(FeatureType)
+ * @see #isAssignableFrom(DefaultFeatureType)
*/
private transient Set<GenericName> assignableTo;
@@ -174,7 +168,7 @@
* @see #getProperties(boolean)
*/
@SuppressWarnings("serial") // Can be various serializable implementations.
- private final List<PropertyType> properties;
+ private final List<AbstractIdentifiedType> properties;
/**
* All properties, including the ones declared in the super-types.
@@ -182,7 +176,7 @@
*
* @see #getProperties(boolean)
*/
- private transient Collection<PropertyType> allProperties;
+ private transient Collection<AbstractIdentifiedType> allProperties;
/**
* A lookup table for fetching properties by name, including the properties from super-types.
@@ -190,7 +184,7 @@
*
* @see #getProperty(String)
*/
- private transient Map<String, PropertyType> byName;
+ private transient Map<String, AbstractIdentifiedType> byName;
/**
* Indices of properties in an array of properties similar to {@link #properties},
@@ -244,6 +238,12 @@
* </tr>
* </table>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the type of array elements may be
+ * changed to {@code org.opengis.feature.FeatureType} and {@code org.opengis.feature.PropertyType}.
+ * This change is pending GeoAPI revision. In the meantime, make sure that the {@code properties}
+ * array contains only attribute types, association roles or operations, <strong>not</strong> other
+ * feature types since the later are not properties in the ISO sense.</div>
+ *
* @param identification the name and other information to be given to this feature type.
* @param isAbstract if {@code true}, the feature type acts as an abstract super-type.
* @param superTypes the parents of this feature type, or {@code null} or empty if none.
@@ -254,7 +254,7 @@
*/
@SuppressWarnings("this-escape")
public DefaultFeatureType(final Map<String,?> identification, final boolean isAbstract,
- final FeatureType[] superTypes, final PropertyType... properties)
+ final DefaultFeatureType[] superTypes, final AbstractIdentifiedType... properties)
{
super(identification);
ArgumentChecks.ensureNonNull("properties", properties);
@@ -275,9 +275,9 @@
* in case of duplicated values. Opportunistically verify for null values. The same verification could
* be done in the scanPropertiesFrom(…) method, but doing it here produces a less confusing stacktrace.
*/
- final List<PropertyType> sourceProperties = new ArrayList<>(properties.length);
+ final List<AbstractIdentifiedType> sourceProperties = new ArrayList<>(properties.length);
for (int i=0; i<properties.length; i++) {
- final PropertyType property = properties[i];
+ final AbstractIdentifiedType property = properties[i];
ArgumentChecks.ensureNonNullElement("properties", i, property);
sourceProperties.add(property);
}
@@ -286,13 +286,13 @@
switch (size) {
case 0: this.properties = Collections.emptyList(); break;
case 1: this.properties = Collections.singletonList(sourceProperties.get(0)); break;
- default: this.properties = UnmodifiableArrayList.wrap(sourceProperties.toArray(new PropertyType[size])); break;
+ default: this.properties = UnmodifiableArrayList.wrap(sourceProperties.toArray(new AbstractIdentifiedType[size])); break;
}
/*
* Before to resolve cyclic associations, verify that operations depend only on existing properties.
* Note: the `allProperties` collection has been created by computeTransientFields(…) above.
*/
- for (final PropertyType property : allProperties) {
+ for (final AbstractIdentifiedType property : allProperties) {
if (property instanceof AbstractOperation) {
for (final String dependency : ((AbstractOperation) property).getDependencies()) {
if (!byName.containsKey(dependency)) {
@@ -340,17 +340,17 @@
*
* @param properties same content as {@link #properties} (may be the reference to the same list), but
* optionally in a temporarily modifiable list if we want to allow removal of duplicated values.
- * See {@link #scanPropertiesFrom(FeatureType, Collection)} javadoc for more explanation.
+ * See {@code scanPropertiesFrom(FeatureType, Collection)} javadoc for more explanation.
* @throws IllegalArgumentException if two properties have the same name.
*/
- private void computeTransientFields(final List<PropertyType> properties) {
+ private void computeTransientFields(final List<AbstractIdentifiedType> properties) {
final int capacity = Containers.hashMapCapacity(properties.size());
byName = new LinkedHashMap<>(capacity);
indices = new LinkedHashMap<>(capacity);
assignableTo = new HashSet<>(4);
assignableTo.add(super.getName());
scanPropertiesFrom(this, properties);
- allProperties = UnmodifiableArrayList.wrap(byName.values().toArray(PropertyType[]::new));
+ allProperties = UnmodifiableArrayList.wrap(byName.values().toArray(AbstractIdentifiedType[]::new));
/*
* Now check if the feature is simple/complex or dense/sparse. We perform this check after we finished
* to create the list of all properties, because some properties may be overridden and we want to take
@@ -359,16 +359,16 @@
isSimple = true;
int index = 0;
int mandatory = 0; // Count of mandatory properties.
- for (final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
+ for (final Map.Entry<String,AbstractIdentifiedType> entry : byName.entrySet()) {
final int minimumOccurs, maximumOccurs;
- final PropertyType property = entry.getValue();
- if (property instanceof AttributeType<?>) {
- minimumOccurs = ((AttributeType<?>) property).getMinimumOccurs();
- maximumOccurs = ((AttributeType<?>) property).getMaximumOccurs();
+ final AbstractIdentifiedType property = entry.getValue();
+ if (property instanceof DefaultAttributeType<?>) { // Other SIS branches check for AttributeType instead.
+ minimumOccurs = ((DefaultAttributeType<?>) property).getMinimumOccurs();
+ maximumOccurs = ((DefaultAttributeType<?>) property).getMaximumOccurs();
isSimple &= (minimumOccurs == maximumOccurs);
- } else if (property instanceof FeatureAssociationRole) {
- minimumOccurs = ((FeatureAssociationRole) property).getMinimumOccurs();
- maximumOccurs = ((FeatureAssociationRole) property).getMaximumOccurs();
+ } else if (property instanceof FieldType) { // TODO: check for AssociationRole instead (after GeoAPI upgrade).
+ minimumOccurs = ((FieldType) property).getMinimumOccurs();
+ maximumOccurs = ((FieldType) property).getMaximumOccurs();
isSimple = false;
} else {
if (isParameterlessOperation(property)) {
@@ -391,8 +391,8 @@
*
* In the `aliases` map below, null values will be assigned to ambiguous short names.
*/
- final var aliases = new LinkedHashMap<String, PropertyType>();
- for (final PropertyType property : allProperties) {
+ final var aliases = new LinkedHashMap<String, AbstractIdentifiedType>();
+ for (final AbstractIdentifiedType property : allProperties) {
GenericName name = property.getName();
while (name instanceof ScopedName) {
if (name == (name = ((ScopedName) name).tail())) break; // Safety against broken implementations.
@@ -401,8 +401,8 @@
aliases.put(key, aliases.containsKey(key) ? null : property);
}
}
- for (final Map.Entry<String,PropertyType> entry : aliases.entrySet()) {
- final PropertyType property = entry.getValue();
+ for (final Map.Entry<String,AbstractIdentifiedType> entry : aliases.entrySet()) {
+ final AbstractIdentifiedType property = entry.getValue();
if (property != null) {
final String tip = entry.getKey();
if (byName.putIfAbsent(tip, property) == null) {
@@ -448,7 +448,7 @@
* <ul>
* <li>Avoid a call to the user-overrideable {@link #getProperties(boolean)} method
* while this {@code DefaultFeatureType} instance is still under constructor.</li>
- * <li>Allow the {@link #DefaultFeatureType(Map, boolean, FeatureType[], PropertyType[])} constructor
+ * <li>Allow the {@code DefaultFeatureType(Map, boolean, FeatureType[], PropertyType[])} constructor
* to pass a temporary modifiable list that allow element removal.</li>
* </ul>
*
@@ -456,18 +456,20 @@
* @param sourceProperties {@code source.getProperties(false)} (see above method javadoc).
* @throws IllegalArgumentException if two properties have the same name.
*/
- private void scanPropertiesFrom(final FeatureType source, final Collection<? extends PropertyType> sourceProperties) {
- for (final FeatureType parent : source.getSuperTypes()) {
+ private void scanPropertiesFrom(final DefaultFeatureType source,
+ final Collection<? extends AbstractIdentifiedType> sourceProperties)
+ {
+ for (final DefaultFeatureType parent : source.getSuperTypes()) {
if (assignableTo.add(parent.getName())) {
scanPropertiesFrom(parent, parent.getProperties(false));
}
}
int index = -1;
- final Iterator<? extends PropertyType> it = sourceProperties.iterator();
+ final Iterator<? extends AbstractIdentifiedType> it = sourceProperties.iterator();
while (it.hasNext()) {
- final PropertyType property = it.next();
+ final AbstractIdentifiedType property = it.next();
final String name = toString(property.getName(), source, "properties", ++index);
- final PropertyType previous = byName.put(name, property);
+ final AbstractIdentifiedType previous = byName.put(name, property);
if (previous != null) {
if (previous.equals(property)) {
byName.put(name, previous); // Keep the instance declared in super-type.
@@ -487,14 +489,18 @@
* Returns the name of the feature which defines the given property, or {@code null} if not found.
* This method is for information purpose when producing an error message - its implementation does
* not need to be efficient.
+ *
+ * <p><b>API note:</b> a non-static method would be more elegant in this "SIS for GeoAPI 3.0" branch.
+ * However this method needs to be static in other SIS branches, because they work with interfaces
+ * rather than SIS implementation. We keep the method static in this branch too for easier merges.</p>
*/
- private static GenericName ownerOf(final FeatureType type, final Collection<? extends PropertyType> properties,
- final PropertyType toSearch)
+ private static GenericName ownerOf(final DefaultFeatureType type, final Collection<? extends AbstractIdentifiedType> properties,
+ final AbstractIdentifiedType toSearch)
{
if (properties.contains(toSearch)) {
return type.getName();
}
- for (final FeatureType superType : type.getSuperTypes()) {
+ for (final DefaultFeatureType superType : type.getSuperTypes()) {
final GenericName owner = ownerOf(superType, superType.getProperties(false), toSearch);
if (owner != null) {
return owner;
@@ -518,23 +524,18 @@
* @param previous previous results, for avoiding never ending loop.
* @return {@code true} if all names have been resolved.
*/
- private boolean resolve(final FeatureType feature, final Map<FeatureType,Boolean> previous) {
+ private boolean resolve(final DefaultFeatureType feature, final Map<FeatureType,Boolean> previous) {
/*
* The isResolved field is used only as a cache for skipping completely the DefaultFeatureType instance if
* we have determined that there is no unresolved name. If the given argument is not a DefaultFeatureType
* instance, conservatively assumes `isSimple`. It may cause more calculation than needed, but should not
* change the result.
*/
- if (feature instanceof DefaultFeatureType) {
- final var dt = (DefaultFeatureType) feature;
- return dt.isResolved = resolve(dt, dt.properties, previous, dt.isResolved);
- } else {
- return resolve(feature, feature.getProperties(false), previous, feature.isSimple());
- }
+ return feature.isResolved = resolve(feature, feature.properties, previous, feature.isResolved);
}
/**
- * Implementation of {@link #resolve(FeatureType, Map)}, also to be invoked from the constructor.
+ * Implementation of {@code resolve(FeatureType, Map)}, also to be invoked from the constructor.
*
* <p>{@code this} shall be the instance in process of being created, not other instance
* (i.e. recursive method invocations are performed on the same {@code this} instance).</p>
@@ -545,21 +546,19 @@
* @param resolved {@code true} if we already know that all names are resolved.
* @return {@code true} if all names have been resolved.
*/
- private boolean resolve(final FeatureType feature, final Collection<? extends PropertyType> toUpdate,
+ private boolean resolve(final DefaultFeatureType feature, final Collection<? extends AbstractIdentifiedType> toUpdate,
Map<FeatureType,Boolean> previous, boolean resolved)
{
if (!resolved) {
resolved = true;
- for (final FeatureType type : feature.getSuperTypes()) {
+ for (final DefaultFeatureType type : feature.getSuperTypes()) {
resolved &= resolve(type, previous);
}
- for (final PropertyType property : toUpdate) {
- if (property instanceof FeatureAssociationRole) {
- if (property instanceof DefaultAssociationRole) {
- if (!((DefaultAssociationRole) property).resolve(this, properties)) {
- resolved = false;
- continue;
- }
+ for (final AbstractIdentifiedType property : toUpdate) {
+ if (property instanceof DefaultAssociationRole) {
+ if (!((DefaultAssociationRole) property).resolve(this, properties)) {
+ resolved = false;
+ continue;
}
/*
* Resolve recursively the associated features, with a check against infinite recursion.
@@ -567,7 +566,7 @@
* may not be the most accurate answer, but will not cause any more hurt than checking more
* often than necessary.
*/
- final FeatureType valueType = ((FeatureAssociationRole) property).getValueType();
+ final DefaultFeatureType valueType = ((DefaultAssociationRole) property).getValueType();
if (valueType != this) {
if (previous == null) {
previous = new IdentityHashMap<>(8);
@@ -590,11 +589,11 @@
*
* @see #OPERATION_INDEX
*/
- static boolean isParameterlessOperation(final PropertyType type) {
- if (type instanceof Operation) {
- final ParameterDescriptorGroup parameters = ((Operation) type).getParameters();
+ static boolean isParameterlessOperation(final AbstractIdentifiedType type) {
+ if (type instanceof AbstractOperation) {
+ final ParameterDescriptorGroup parameters = ((AbstractOperation) type).getParameters();
return ((parameters == null) || parameters.descriptors().isEmpty())
- && ((Operation) type).getResult() != null;
+ && ((AbstractOperation) type).getResult() != null;
}
return false;
}
@@ -609,7 +608,6 @@
*
* @return {@code true} if the feature type acts as an abstract super-type.
*/
- @Override
public final boolean isAbstract() {
return isAbstract;
}
@@ -629,31 +627,22 @@
*
* @return {@code true} if this feature type contains only simple attributes or operations.
*/
- @Override
public boolean isSimple() {
return isSimple;
}
/**
* Returns {@code true} if the given base type may be the same or a super-type of the given type, using only
- * the name as a criterion. This is a faster check than {@link #isAssignableFrom(FeatureType)}.
+ * the name as a criterion. This is a faster check than {@link #isAssignableFrom(DefaultFeatureType)}.
*
* <p>Performance note: callers should verify that {@code base != type} before to invoke this method.</p>
+ *
+ * <p><b>API note:</b> a non-static method would be more elegant in this "SIS for GeoAPI 3.0" branch.
+ * However this method needs to be static in other SIS branches, because they work with interfaces
+ * rather than SIS implementation. We keep the method static in this branch too for easier merges.</p>
*/
- static boolean maybeAssignableFrom(final FeatureType base, final FeatureType type) {
- if (type instanceof DefaultFeatureType) {
- return ((DefaultFeatureType) type).assignableTo.contains(base.getName());
- }
- // Slower path for non-SIS implementations.
- if (Objects.equals(base.getName(), type.getName())) {
- return true;
- }
- for (final FeatureType superType : type.getSuperTypes()) {
- if (base == superType || maybeAssignableFrom(base, superType)) {
- return true;
- }
- }
- return false;
+ static boolean maybeAssignableFrom(final DefaultFeatureType base, final DefaultFeatureType type) {
+ return type.assignableTo.contains(base.getName());
}
/**
@@ -676,7 +665,7 @@
* @return {@code true} if instances of the given type can be assigned to association of this type.
*/
@Override
- public boolean isAssignableFrom(final FeatureType type) {
+ public boolean isAssignableFrom(final DefaultFeatureType type) {
if (type == this) {
return true; // Optimization for a common case.
}
@@ -687,11 +676,11 @@
* Ensures that all properties defined in this feature type is also defined
* in the given property, and that the former is assignable from the latter.
*/
- for (final Map.Entry<String, PropertyType> entry : byName.entrySet()) {
- final PropertyType other;
+ for (final Map.Entry<String, AbstractIdentifiedType> entry : byName.entrySet()) {
+ final AbstractIdentifiedType other;
try {
other = type.getProperty(entry.getKey());
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
/*
* A property in this FeatureType does not exist in the given FeatureType.
* Catching exceptions is not an efficient way to perform this check, but
@@ -712,22 +701,25 @@
* Returns {@code true} if instances of the {@code other} type are assignable to the given {@code base} type.
* This method does not compare the names — this verification is presumed already done by the caller.
*/
- private static boolean isAssignableIgnoreName(final PropertyType base, final PropertyType other) {
+ private static boolean isAssignableIgnoreName(final AbstractIdentifiedType base, final AbstractIdentifiedType other) {
if (base != other) {
/*
* If the base property is an attribute, then the overriding property shall be either an attribute
* or a parameterless operation producing an attribute. The parameterless operation is considered
* has having a [1…1] multiplicity.
+ *
+ * Note: other SIS branches use AttributeType and FeatureAssociationRole
+ * instead than DefaultAttributeType and DefaultAssociationRole.
*/
- if (base instanceof AttributeType<?>) {
- final AttributeType<?> p0 = (AttributeType<?>) base;
- final AttributeType<?> p1;
- if (other instanceof AttributeType<?>) {
- p1 = (AttributeType<?>) other;
+ if (base instanceof DefaultAttributeType<?>) {
+ final DefaultAttributeType<?> p0 = (DefaultAttributeType<?>) base;
+ final DefaultAttributeType<?> p1;
+ if (other instanceof DefaultAttributeType<?>) {
+ p1 = (DefaultAttributeType<?>) other;
} else if (isParameterlessOperation(other)) {
- final IdentifiedType result = ((Operation) other).getResult();
- if (result instanceof AttributeType<?>) {
- p1 = (AttributeType<?>) result;
+ final AbstractIdentifiedType result = ((AbstractOperation) other).getResult();
+ if (result instanceof DefaultAttributeType<?>) {
+ p1 = (DefaultAttributeType<?>) result;
} else {
return false;
}
@@ -748,15 +740,15 @@
* because an implementation could implement both AttributeType and AssociationRole interfaces.
* This is not recommended, but if it happen we want a behavior as consistent as possible.
*/
- if (base instanceof FeatureAssociationRole) {
- final FeatureAssociationRole p0 = (FeatureAssociationRole) base;
- final FeatureAssociationRole p1;
- if (other instanceof FeatureAssociationRole) {
- p1 = (FeatureAssociationRole) other;
+ if (base instanceof DefaultAssociationRole) {
+ final DefaultAssociationRole p0 = (DefaultAssociationRole) base;
+ final DefaultAssociationRole p1;
+ if (other instanceof DefaultAssociationRole) {
+ p1 = (DefaultAssociationRole) other;
} else if (isParameterlessOperation(other)) {
- final IdentifiedType result = ((Operation) other).getResult();
- if (result instanceof FeatureAssociationRole) {
- p1 = (FeatureAssociationRole) result;
+ final AbstractIdentifiedType result = ((AbstractOperation) other).getResult();
+ if (result instanceof DefaultAssociationRole) {
+ p1 = (DefaultAssociationRole) result;
} else {
return false;
}
@@ -770,8 +762,8 @@
{
return false;
}
- final FeatureType f0 = p0.getValueType();
- final FeatureType f1 = p1.getValueType();
+ final DefaultFeatureType f0 = p0.getValueType();
+ final DefaultFeatureType f1 = p1.getValueType();
if (f0 != f1 && !f0.isAssignableFrom(f1)) {
return false;
}
@@ -781,11 +773,11 @@
* In the special case of parameterless operations, can also be overridden by
* AttributeType or FeatureAssociationRole.
*/
- if (base instanceof Operation) {
- final Operation p0 = (Operation) base;
- final IdentifiedType r1;
- if (other instanceof Operation) {
- final Operation p1 = (Operation) other;
+ if (base instanceof AbstractOperation) {
+ final AbstractOperation p0 = (AbstractOperation) base;
+ final AbstractIdentifiedType r1;
+ if (other instanceof AbstractOperation) {
+ final AbstractOperation p1 = (AbstractOperation) other;
if (!Objects.equals(p0.getParameters(), p1.getParameters())) {
return false;
}
@@ -795,15 +787,14 @@
} else {
return false;
}
- final IdentifiedType r0 = p0.getResult();
+ final AbstractIdentifiedType r0 = p0.getResult();
if (r0 != r1) {
- if (r0 instanceof FeatureType) {
- if (!(r1 instanceof FeatureType) || !((FeatureType) r0).isAssignableFrom((FeatureType) r1)) {
+ if (r0 instanceof DefaultFeatureType) {
+ if (!(r1 instanceof DefaultFeatureType) || !((FeatureType) r0).isAssignableFrom((DefaultFeatureType) r1)) {
return false;
}
- }
- if (r0 instanceof PropertyType) {
- if (!(r1 instanceof PropertyType) || !isAssignableIgnoreName((PropertyType) r0, (PropertyType) r1)) {
+ } else if (r0 != null) {
+ if (r1 == null || !isAssignableIgnoreName(r0, r1)) {
return false;
}
}
@@ -821,6 +812,10 @@
* if we compare {@code FeatureType} to {@link Class} in the Java language, then this method is equivalent
* to {@link Class#getSuperclass()} except that feature types allow multi-inheritance.</div>
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of list elements will be changed to {@code FeatureType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* <h4>API note</h4>
* This method is final because it is invoked (indirectly) by constructors, and invoking a user-overrideable
* method at construction time is not recommended. Furthermore, many Apache SIS methods need guarantees about
@@ -828,9 +823,8 @@
*
* @return the parents of this feature type, or an empty set if none.
*/
- @Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
- public final Set<FeatureType> getSuperTypes() {
+ public final Set<DefaultFeatureType> getSuperTypes() {
return superTypes; // Immutable
}
@@ -840,32 +834,39 @@
* inherited from the {@linkplain #getSuperTypes() super-types} only if {@code includeSuperTypes}
* is {@code true}.
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of list elements will be changed to {@code PropertyType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param includeSuperTypes {@code true} for including the properties inherited from the super-types,
* or {@code false} for returning only the properties defined explicitly in this type.
* @return feature operation, attribute type and association role that carries characteristics of this
* feature type (not including parent types).
*/
@Override
- public Collection<PropertyType> getProperties(final boolean includeSuperTypes) {
+ public Collection<AbstractIdentifiedType> getProperties(final boolean includeSuperTypes) {
return includeSuperTypes ? allProperties : properties;
}
/**
* Returns the attribute, operation or association role for the given name.
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of returned element will be changed to {@code PropertyType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param name the name of the property to search.
* @return the property for the given name, or {@code null} if none.
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*
* @see AbstractFeature#getProperty(String)
*/
- @Override
- public PropertyType getProperty(final String name) throws PropertyNotFoundException {
- final PropertyType pt = byName.get(name);
+ public AbstractIdentifiedType getProperty(final String name) throws IllegalArgumentException {
+ final AbstractIdentifiedType pt = byName.get(name);
if (pt != null) {
return pt;
}
- throw new PropertyNotFoundException(AbstractFeature.propertyNotFound(this, getName(), name));
+ throw new IllegalArgumentException(AbstractFeature.propertyNotFound(this, getName(), name));
}
/**
@@ -886,12 +887,11 @@
* then this method is equivalent to {@link Class#newInstance()}.</div>
*
* @return a new feature instance.
- * @throws FeatureInstantiationException if this feature type {@linkplain #isAbstract() is abstract}.
+ * @throws IllegalStateException if this feature type {@linkplain #isAbstract() is abstract}.
*/
- @Override
- public Feature newInstance() throws FeatureInstantiationException {
+ public AbstractFeature newInstance() throws IllegalStateException {
if (isAbstract) {
- throw new FeatureInstantiationException(Resources.format(Resources.Keys.AbstractFeatureType_1, getName()));
+ throw new IllegalStateException(Resources.format(Resources.Keys.AbstractFeatureType_1, getName()));
}
return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}
diff --git 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
index db9fd2c..a95fe10 100644
--- 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
@@ -25,12 +25,6 @@
import org.apache.sis.util.privy.CloneAccess;
import org.apache.sis.util.privy.Cloner;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Property;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* A feature in which most properties are expected to be provided. This implementation uses a plain array for
@@ -86,15 +80,15 @@
* @param name the property name.
* @return the index for the property of the given name,
* or a negative value if the property is a parameterless operation.
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*/
- private int getIndex(final String name) throws PropertyNotFoundException {
+ private int getIndex(final String name) throws IllegalArgumentException {
final Integer index = indices.get(name);
if (index != null) {
return index;
}
ArgumentChecks.ensureNonNull("name", name);
- throw new PropertyNotFoundException(propertyNotFound(type, getName(), name));
+ throw new IllegalArgumentException(propertyNotFound(type, getName(), name));
}
/**
@@ -102,10 +96,10 @@
*
* @param name the property name.
* @return the property of the given name.
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*/
@Override
- public Property getProperty(final String name) throws PropertyNotFoundException {
+ public Object getProperty(final String name) throws IllegalArgumentException {
// Null value check done by the invoked method.
final int index = getIndex(name);
if (index < 0) {
@@ -138,9 +132,9 @@
* known to this feature, or if the property cannot be set or another reason.
*/
@Override
- public void setProperty(final Property property) throws IllegalArgumentException {
- final String name = property.getName().toString();
- verifyPropertyType(name, property);
+ public void setProperty(final Object property) throws IllegalArgumentException {
+ final String name = ((Property) property).getName().toString();
+ verifyPropertyType(name, (Property) property);
if (!(properties instanceof Property[])) {
wrapValuesInProperties();
}
@@ -194,10 +188,10 @@
if (element != null) {
if (!(properties instanceof Property[])) {
return element; // Most common case.
- } else if (element instanceof Attribute<?>) {
- return getAttributeValue((Attribute<?>) element);
- } else if (element instanceof FeatureAssociation) {
- return getAssociationValue((FeatureAssociation) element);
+ } else if (element instanceof AbstractAttribute<?>) {
+ return getAttributeValue((AbstractAttribute<?>) element);
+ } else if (element instanceof AbstractAssociation) {
+ return getAssociationValue((AbstractAssociation) element);
} else {
throw new IllegalArgumentException(unsupportedPropertyType(((Property) element).getName()));
}
@@ -251,7 +245,7 @@
*/
@Override
public Optional<?> getCharacteristicValue(final String property, final String characteristic)
- throws PropertyNotFoundException
+ throws IllegalArgumentException
{
if (properties instanceof Property[]) {
return super.getCharacteristicValue(property, characteristic);
@@ -323,10 +317,10 @@
for (final Property p : (Property[]) properties) {
code = 31 * code;
final Object value;
- if (p instanceof Attribute<?>) {
- value = getAttributeValue((Attribute<?>) p);
- } else if (p instanceof FeatureAssociation) {
- value = getAssociationValue((FeatureAssociation) p);
+ if (p instanceof AbstractAttribute<?>) {
+ value = getAttributeValue((AbstractAttribute<?>) p);
+ } else if (p instanceof AbstractAssociation) {
+ value = getAssociationValue((AbstractAssociation) p);
} else {
continue;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java
index 349c759..1790920 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java
@@ -39,16 +39,6 @@
import org.apache.sis.referencing.CRS;
import org.apache.sis.pending.jdk.JDK21;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureInstantiationException;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-
/**
* An operation computing the envelope that encompass all geometries found in a list of attributes.
@@ -115,8 +105,8 @@
* a default CRS.
*
* <h4>Performance note</h4>
- * If this array is {@code null}, then {@link Feature#getProperty(String)} does not need to be invoked at all.
- * A null array is a signal that invoking only the cheaper {@link Feature#getPropertyValue(String)} method is
+ * If this array is {@code null}, then {@link AbstractFeature#getProperty(String)} does not need to be invoked at all.
+ * A null array is a signal that invoking only the cheaper {@link AbstractFeature#getPropertyValue(String)} method is
* sufficient. However, this array become non-null as soon as there is at least one CRS characteristic to check.
* We do not distinguish which particular property may have a CRS characteristic because as of Apache SIS 1.0,
* implementations of {@link DenseFeature} and {@link SparseFeature} have a "all of nothing" behavior anyway.
@@ -136,8 +126,7 @@
/**
* The type of the result returned by the envelope operation.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final AttributeType<Envelope> resultType;
+ private final DefaultAttributeType<Envelope> resultType;
/**
* Creates a new operation computing the envelope of features of the given type.
@@ -161,7 +150,7 @@
*/
EnvelopeOperation(final Map<String,?> identification,
CoordinateReferenceSystem targetCRS,
- final PropertyType[] geometryAttributes,
+ final AbstractIdentifiedType[] geometryAttributes,
final EnvelopeOperation inheritFrom)
throws FactoryException
{
@@ -179,7 +168,7 @@
final String propertyName; // Name of `geometryAttributes[i]`, possibly inherited.
final String attributeName; // Name of the property after following the link.
CoordinateReferenceSystem attributeCRS = null;
- final PropertyType property = geometryAttributes[i];
+ final AbstractIdentifiedType property = geometryAttributes[i];
if (property == null && inheritFrom != null) {
/*
* When this constructor is invoked by `updateDependencies(Map)`, a null property means to inherit
@@ -195,7 +184,7 @@
}
}
} else {
- final AttributeType<?> at = Features.toAttribute(property).orElse(null);
+ final DefaultAttributeType<?> at = Features.toAttribute(property).orElse(null);
if (at == null || !Geometries.isKnownType(at.getValueClass())) {
continue; // Not a geometry property. Ignore as per method contract.
}
@@ -211,7 +200,7 @@
* "sis:crs" characteristic. Note that we cannot rely on `attributeCRS` being non-null
* because an attribute may be characterized by a CRS without providing default CRS.
*/
- final AttributeType<?> ct = at.characteristics().get(AttributeConvention.CRS);
+ final DefaultAttributeType<?> ct = at.characteristics().get(AttributeConvention.CRS);
if (ct != null && CoordinateReferenceSystem.class.isAssignableFrom(ct.getValueClass())) {
attributeCRS = (CoordinateReferenceSystem) ct.getDefaultValue(); // May still be null.
characterizedByCRS = true;
@@ -284,7 +273,7 @@
* @return an {@code AttributeType<Envelope>}.
*/
@Override
- public IdentifiedType getResult() {
+ public AbstractIdentifiedType getResult() {
return resultType;
}
@@ -309,9 +298,9 @@
* @return the new operation, or {@code this} if unchanged.
*/
@Override
- public Operation updateDependencies(final Map<String, PropertyType> dependencies) {
+ public AbstractOperation updateDependencies(final Map<String, AbstractIdentifiedType> dependencies) {
boolean foundAny = false;
- final var geometryAttributes = new PropertyType[attributeNames.length];
+ final var geometryAttributes = new AbstractIdentifiedType[attributeNames.length];
for (int i=0; i < geometryAttributes.length; i++) {
foundAny |= (geometryAttributes[i] = dependencies.get(attributeNames[i])) != null;
}
@@ -321,7 +310,7 @@
return FeatureOperations.POOL.unique(op);
}
} catch (FactoryException e) {
- throw new FeatureInstantiationException(e.getMessage(), e);
+ throw new IllegalStateException(e.getMessage(), e);
}
return this;
}
@@ -335,7 +324,7 @@
* @return the envelope of geometries in feature property values.
*/
@Override
- public Property apply(Feature feature, ParameterValueGroup parameters) {
+ public Property apply(AbstractFeature feature, ParameterValueGroup parameters) {
return new Result(feature);
}
@@ -355,7 +344,7 @@
/**
* Creates a new attribute for the given feature.
*/
- Result(final Feature feature) {
+ Result(final AbstractFeature feature) {
super(resultType, feature);
}
@@ -412,7 +401,7 @@
* a CRS characteristic is associated to a particular feature, setting `op` to null
* will cause a new coordinate operation to be searched.
*/
- final var at = ((Attribute<?>) feature.getProperty(attributeNames[i]))
+ final var at = ((AbstractAttribute<?>) feature.getProperty(attributeNames[i]))
.characteristics().get(AttributeConvention.CRS);
final Object geomCRS;
if (at != null && (geomCRS = at.getValue()) != null) {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java
index 5d27304..0449cc2 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java
@@ -26,16 +26,11 @@
import org.apache.sis.filter.privy.FunctionNames;
import org.apache.sis.filter.privy.Visitor;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.feature.Property;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -62,13 +57,12 @@
* The expression to which to delegate the execution of this operation.
*/
@SuppressWarnings("serial") // Not statically typed as serializable.
- final Function<? super Feature, ? extends V> expression;
+ final Function<? super AbstractFeature, ? extends V> expression;
/**
* The type of result of evaluating the expression.
*/
- @SuppressWarnings("serial") // Apache SIS implementations are serializable.
- private final AttributeType<V> resultType;
+ private final DefaultAttributeType<V> resultType;
/**
* The name of all feature properties that are known to be read by the expression.
@@ -86,8 +80,8 @@
* @param resultType type of values computed by the expression.
*/
static <V> AbstractOperation create(final Map<String,?> identification,
- final Function<? super Feature, ? extends V> expression,
- final AttributeType<? super V> resultType)
+ final Function<? super AbstractFeature, ? extends V> expression,
+ final DefaultAttributeType<? super V> resultType)
{
if (expression instanceof ValueReference<?,?>) {
final String xpath = ((ValueReference<?,?>) expression).getXPath();
@@ -102,15 +96,15 @@
* Creates a generic operation when no optimized case has been identifier.
*/
private ExpressionOperation(final Map<String,?> identification,
- final Function<? super Feature, ? extends V> expression,
- final AttributeType<V> resultType)
+ final Function<? super AbstractFeature, ? extends V> expression,
+ final DefaultAttributeType<V> resultType)
{
super(identification);
this.expression = expression;
this.resultType = resultType;
if (expression instanceof Expression<?,?>) {
@SuppressWarnings("unchecked")
- var c = (Expression<Feature,?>) expression; // Cast is okay because we will not pass or request any `Feature` instance.
+ var c = (Expression<AbstractFeature,?>) expression; // Cast is okay because we will not pass or request any `Feature` instance.
dependencies = DependencyFinder.search(c);
} else {
dependencies = Set.of();
@@ -129,7 +123,7 @@
* Returns the expected result type.
*/
@Override
- public IdentifiedType getResult() {
+ public AbstractIdentifiedType getResult() {
return resultType;
}
@@ -151,7 +145,7 @@
* @return the computed property from the given feature.
*/
@Override
- public Property apply(final Feature feature, ParameterValueGroup parameters) {
+ public Property apply(final AbstractFeature feature, ParameterValueGroup parameters) {
return new Result(feature);
}
@@ -168,7 +162,7 @@
/**
* Creates a new attribute for the given feature.
*/
- Result(final Feature feature) {
+ Result(final AbstractFeature feature) {
super(resultType, feature);
}
@@ -205,7 +199,7 @@
* An expression visitor for finding all dependencies of a given expression.
* The dependencies are feature properties read by {@link ValueReference} nodes.
*/
- private static final class DependencyFinder extends Visitor<Feature, Collection<String>> {
+ private static final class DependencyFinder extends Visitor<AbstractFeature, Collection<String>> {
/**
* The unique instance.
*/
@@ -217,7 +211,7 @@
* @param expression the expression for which to get dependencies.
* @return all dependencies recognized by this method.
*/
- static Set<String> search(final Expression<Feature,?> expression) {
+ static Set<String> search(final Expression<AbstractFeature,?> expression) {
final Set<String> dependencies = new HashSet<>();
VISITOR.visit(expression, dependencies);
return Set.copyOf(dependencies);
@@ -228,13 +222,13 @@
*/
private DependencyFinder() {
setLogicalHandlers((f, dependencies) -> {
- final var filter = (LogicalOperator<Feature>) f;
- for (Filter<Feature> child : filter.getOperands()) {
+ final var filter = (LogicalOperator<AbstractFeature>) f;
+ for (Filter<AbstractFeature> child : filter.getOperands()) {
visit(child, dependencies);
}
});
setExpressionHandler(FunctionNames.ValueReference, (e, dependencies) -> {
- final var expression = (ValueReference<Feature,?>) e;
+ final var expression = (ValueReference<AbstractFeature,?>) e;
final String propName = expression.getXPath();
if (!propName.trim().isEmpty()) {
dependencies.add(propName);
@@ -246,8 +240,8 @@
* Fallback for all filters not explicitly handled by the setting applied in the constructor.
*/
@Override
- protected void typeNotFound(final CodeList<?> type, final Filter<Feature> filter, final Collection<String> dependencies) {
- for (final Expression<Feature,?> f : filter.getExpressions()) {
+ protected void typeNotFound(final Enum<?> type, final Filter<AbstractFeature> filter, final Collection<String> dependencies) {
+ for (final Expression<AbstractFeature,?> f : filter.getExpressions()) {
visit(f, dependencies);
}
}
@@ -256,8 +250,8 @@
* Fallback for all expressions not explicitly handled by the setting applied in the constructor.
*/
@Override
- protected void typeNotFound(final String type, final Expression<Feature,?> expression, final Collection<String> dependencies) {
- for (final Expression<Feature,?> p : expression.getParameters()) {
+ protected void typeNotFound(final String type, final Expression<AbstractFeature,?> expression, final Collection<String> dependencies) {
+ for (final Expression<AbstractFeature,?> p : expression.getParameters()) {
visit(p, dependencies);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureFormat.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureFormat.java
index ed04aaa..8401b35 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureFormat.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureFormat.java
@@ -49,18 +49,6 @@
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.math.MathFunctions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.Operation;
-
/**
* Formats {@linkplain AbstractFeature features} or {@linkplain DefaultFeatureType feature types} in a tabular format.
@@ -157,7 +145,7 @@
/**
* Returns the type of objects formatted by this class. This method has to return {@code Object.class}
- * since it is the only common parent to {@link Feature} and {@link FeatureType}.
+ * since it is the only common parent to {@code Feature} and {@link FeatureType}.
*
* @return {@code Object.class}
*/
@@ -224,20 +212,20 @@
public enum Column {
/**
* Natural language designator for the property.
- * This is the character sequence returned by {@link PropertyType#getDesignation()}.
+ * This is the character sequence returned by {@link AbstractIdentifiedType#getDesignation()}.
* This column is omitted if no property has a designation.
*/
DESIGNATION(Vocabulary.Keys.Designation),
/**
* Name of the property.
- * This is the character sequence returned by {@link PropertyType#getName()}.
+ * This is the character sequence returned by {@link AbstractIdentifiedType#getName()}.
*/
NAME(Vocabulary.Keys.Name),
/**
- * Type of property values. This is the type returned by {@link AttributeType#getValueClass()} or
- * {@link FeatureAssociationRole#getValueType()}.
+ * Type of property values. This is the type returned by {@link DefaultAttributeType#getValueClass()} or
+ * {@link DefaultAssociationRole#getValueType()}.
*/
TYPE(Vocabulary.Keys.Type),
@@ -245,21 +233,21 @@
* Cardinality (for attributes) or multiplicity (for attribute types).
* The cardinality is the actual number of attribute values.
* The multiplicity is the minimum and maximum occurrences of attribute values.
- * The multiplicity is made from the numbers returned by {@link AttributeType#getMinimumOccurs()}
- * and {@link AttributeType#getMaximumOccurs()}.
+ * The multiplicity is made from the numbers returned by {@link DefaultAttributeType#getMinimumOccurs()}
+ * and {@link DefaultAttributeType#getMaximumOccurs()}.
*/
CARDINALITY(Vocabulary.Keys.Cardinality),
/**
* Property value (for properties) or default value (for property types).
- * This is the value returned by {@link Attribute#getValue()}, {@link FeatureAssociation#getValue()}
- * or {@link AttributeType#getDefaultValue()}.
+ * This is the value returned by {@link AbstractAttribute#getValue()}, {@link AbstractAssociation#getValue()}
+ * or {@link DefaultAttributeType#getDefaultValue()}.
*/
VALUE(Vocabulary.Keys.Value),
/**
* Other attributes that describes the attribute.
- * This is made from the map returned by {@link Attribute#characteristics()}.
+ * This is made from the map returned by {@link AbstractAttribute#characteristics()}.
* This column is omitted if no property has characteristics.
*/
CHARACTERISTICS(Vocabulary.Keys.Characteristics),
@@ -296,8 +284,8 @@
* The object may be an instance of any of the following types:
*
* <ul>
- * <li>{@link Feature}</li>
- * <li>{@link FeatureType}</li>
+ * <li>{@code Feature}</li>
+ * <li>{@code FeatureType}</li>
* </ul>
*
* @throws IOException if an error occurred while writing to the given appendable.
@@ -309,13 +297,13 @@
/*
* Separate the Feature (optional) and the FeatureType (mandatory) instances.
*/
- final FeatureType featureType;
- final Feature feature;
- if (object instanceof Feature) {
- feature = (Feature) object;
+ final DefaultFeatureType featureType;
+ final AbstractFeature feature;
+ if (object instanceof AbstractFeature) {
+ feature = (AbstractFeature) object;
featureType = feature.getType();
- } else if (object instanceof FeatureType) {
- featureType = (FeatureType) object;
+ } else if (object instanceof DefaultFeatureType) {
+ featureType = (DefaultFeatureType) object;
feature = null;
} else {
throw new IllegalArgumentException(Errors.forLocale(displayLocale)
@@ -332,12 +320,12 @@
boolean hasDesignation = false;
boolean hasCharacteristics = false;
boolean hasDeprecatedTypes = false;
- for (final PropertyType propertyType : featureType.getProperties(true)) {
+ for (final AbstractIdentifiedType propertyType : featureType.getProperties(true)) {
if (!hasDesignation) {
hasDesignation = propertyType.getDesignation().isPresent();
}
- if (!hasCharacteristics && propertyType instanceof AttributeType<?>) {
- hasCharacteristics = !((AttributeType<?>) propertyType).characteristics().isEmpty();
+ if (!hasCharacteristics && propertyType instanceof DefaultAttributeType<?>) {
+ hasCharacteristics = !((DefaultAttributeType<?>) propertyType).characteristics().isEmpty();
}
if (!hasDeprecatedTypes && propertyType instanceof Deprecable) {
hasDeprecatedTypes = ((Deprecable) propertyType).isDeprecated();
@@ -398,26 +386,26 @@
final var buffer = new StringBuffer();
final var dummyFP = new FieldPosition(-1);
final var remarks = new ArrayList<String>();
- for (final PropertyType propertyType : featureType.getProperties(true)) {
+ for (final AbstractIdentifiedType propertyType : featureType.getProperties(true)) {
Object value = null;
int cardinality = -1;
if (feature != null) {
- if (!(propertyType instanceof AttributeType<?>) &&
- !(propertyType instanceof FeatureAssociationRole) &&
+ if (!(propertyType instanceof DefaultAttributeType<?>) &&
+ !(propertyType instanceof DefaultAssociationRole) &&
!DefaultFeatureType.isParameterlessOperation(propertyType))
{
continue;
}
value = feature.getPropertyValue(propertyType.getName().toString());
if (value == null) {
- if (propertyType instanceof AttributeType<?>
- && ((AttributeType<?>) propertyType).getMinimumOccurs() == 0
- && ((AttributeType<?>) propertyType).characteristics().isEmpty())
+ if (propertyType instanceof DefaultAttributeType<?>
+ && ((DefaultAttributeType<?>) propertyType).getMinimumOccurs() == 0
+ && ((DefaultAttributeType<?>) propertyType).characteristics().isEmpty())
{
continue; // If optional, no value and no characteristics, skip the full row.
}
- if (propertyType instanceof FeatureAssociationRole
- && ((FeatureAssociationRole) propertyType).getMinimumOccurs() == 0)
+ if (propertyType instanceof DefaultAssociationRole
+ && ((DefaultAssociationRole) propertyType).getMinimumOccurs() == 0)
{
continue; // If optional and no value, skip the full row.
}
@@ -427,16 +415,12 @@
} else {
cardinality = 1;
}
- } else if (propertyType instanceof AttributeType<?>) {
- value = ((AttributeType<?>) propertyType).getDefaultValue();
- } else if (propertyType instanceof Operation) {
+ } else if (propertyType instanceof DefaultAttributeType<?>) {
+ value = ((DefaultAttributeType<?>) propertyType).getDefaultValue();
+ } else if (propertyType instanceof AbstractOperation) {
buffer.append(" = ");
try {
- if (propertyType instanceof AbstractOperation) {
- ((AbstractOperation) propertyType).formatResultFormula(buffer);
- } else {
- AbstractOperation.defaultFormula(((Operation) propertyType).getParameters(), buffer);
- }
+ ((AbstractOperation) propertyType).formatResultFormula(buffer);
} catch (IOException e) {
throw new UncheckedIOException(e); // Should never happen since we write in a StringBuffer.
}
@@ -446,25 +430,25 @@
final String valueType; // The value to write in the type column.
final Class<?> valueClass; // AttributeType.getValueClass() if applicable.
final int minimumOccurs, maximumOccurs; // Negative values mean no cardinality.
- final IdentifiedType resultType; // Result of operation if applicable.
- if (propertyType instanceof Operation) {
- resultType = ((Operation) propertyType).getResult(); // May be null
+ final AbstractIdentifiedType resultType; // Result of operation if applicable.
+ if (propertyType instanceof AbstractOperation) {
+ resultType = ((AbstractOperation) propertyType).getResult(); // May be null
} else {
resultType = propertyType;
}
- if (resultType instanceof AttributeType<?>) {
- final AttributeType<?> pt = (AttributeType<?>) resultType;
+ if (resultType instanceof DefaultAttributeType<?>) {
+ final DefaultAttributeType<?> pt = (DefaultAttributeType<?>) resultType;
minimumOccurs = pt.getMinimumOccurs();
maximumOccurs = pt.getMaximumOccurs();
valueClass = pt.getValueClass();
valueType = getFormat(Class.class).format(valueClass, buffer, dummyFP).toString();
buffer.setLength(0);
- } else if (resultType instanceof FeatureAssociationRole) {
- final FeatureAssociationRole pt = (FeatureAssociationRole) resultType;
+ } else if (resultType instanceof DefaultAssociationRole) {
+ final DefaultAssociationRole pt = (DefaultAssociationRole) resultType;
minimumOccurs = pt.getMinimumOccurs();
maximumOccurs = pt.getMaximumOccurs();
valueType = toString(DefaultAssociationRole.getValueTypeName(pt));
- valueClass = Feature.class;
+ valueClass = AbstractFeature.class;
} else {
valueType = (resultType != null) ? toString(resultType.getName()) : "";
valueClass = null;
@@ -552,10 +536,10 @@
while (it.hasNext()) {
value = it.next();
if (value != null) {
- if (propertyType instanceof FeatureAssociationRole) {
- final String p = DefaultAssociationRole.getTitleProperty((FeatureAssociationRole) propertyType);
+ if (propertyType instanceof DefaultAssociationRole) {
+ final String p = DefaultAssociationRole.getTitleProperty((DefaultAssociationRole) propertyType);
if (p != null) {
- value = ((Feature) value).getPropertyValue(p);
+ value = ((AbstractFeature) value).getPropertyValue(p);
if (value == null) continue;
}
} else if (format != null && valueClass.isInstance(value)) { // Null safe because of getFormat(valueClass) contract.
@@ -609,10 +593,10 @@
* Characteristics are handled as "attributes of attributes".
*/
case CHARACTERISTICS: {
- if (propertyType instanceof AttributeType<?>) {
+ if (propertyType instanceof DefaultAttributeType<?>) {
int length = 0;
String separator = "";
-format: for (final AttributeType<?> ct : ((AttributeType<?>) propertyType).characteristics().values()) {
+format: for (final DefaultAttributeType<?> ct : ((DefaultAttributeType<?>) propertyType).characteristics().values()) {
/*
* Format the characteristic name. We will append the value(s) later.
* We keep trace of the text length in order to stop formatting if the
@@ -630,9 +614,9 @@
* given by the default value `cv`. Nevertheless we have to check if current
* feature overrides this characteristic.
*/
- final Property cp = feature.getProperty(propertyType.getName().toString());
- if (cp instanceof Attribute<?>) { // Should always be true, but we are paranoiac.
- Attribute<?> ca = ((Attribute<?>) cp).characteristics().get(cn.toString());
+ final Object cp = feature.getProperty(propertyType.getName().toString());
+ if (cp instanceof AbstractAttribute<?>) { // Should always be true, but we are paranoiac.
+ AbstractAttribute<?> ca = ((AbstractAttribute<?>) cp).characteristics().get(cn.toString());
if (ca != null) cv = ca.getValues();
}
}
@@ -716,8 +700,8 @@
text = ((InternationalString) value).toString(displayLocale);
} else if (value instanceof GenericName) {
text = toString((GenericName) value);
- } else if (value instanceof IdentifiedType) {
- text = toString(((IdentifiedType) value).getName());
+ } else if (value instanceof AbstractIdentifiedType) {
+ text = toString(((AbstractIdentifiedType) value).getName());
} else if (value instanceof IdentifiedObject) {
text = IdentifiedObjects.getIdentifierOrName((IdentifiedObject) value);
} else {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureOperations.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureOperations.java
index 1b9bde7..07d883e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureOperations.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureOperations.java
@@ -31,13 +31,8 @@
import org.apache.sis.filter.privy.XPath;
import org.apache.sis.setup.GeometryLibrary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -112,7 +107,7 @@
/**
* The pool of operations or operation dependencies created so far, for sharing exiting instances.
*/
- static final WeakHashSet<PropertyType> POOL = new WeakHashSet<>(PropertyType.class);
+ static final WeakHashSet<AbstractIdentifiedType> POOL = new WeakHashSet<>(AbstractIdentifiedType.class);
/**
* Do not allow instantiation of this class.
@@ -148,13 +143,17 @@
* identified by the {@code referent} argument, the returned property is writable if the referenced
* property is also writable.
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of {@code referent} parameter will be changed to {@code PropertyType}
+ * if and when such interface will be defined in GeoAPI.</div>
+ *
* @param identification the name and other information to be given to the operation.
* @param referent the referenced attribute or feature association.
* @return an operation which is an alias for the {@code referent} property.
*
- * @see Features#getLinkTarget(PropertyType)
+ * @see Features#getLinkTarget(AbstractIdentifiedType)
*/
- public static Operation link(final Map<String,?> identification, final PropertyType referent) {
+ public static AbstractOperation link(final Map<String,?> identification, final AbstractIdentifiedType referent) {
ArgumentChecks.ensureNonNull("referent", referent);
return POOL.unique(new LinkOperation(identification, referent));
}
@@ -185,6 +184,10 @@
* operation, the given string value will be split around the {@code delimiter} and each substring will be
* forwarded to the corresponding single property.
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of {@code singleAttributes} elements will be changed to {@code PropertyType}
+ * if and when such interface will be defined in GeoAPI.</div>
+ *
* @param identification the name and other information to be given to the operation.
* @param delimiter the characters to use as delimiter between each single property value.
* @param prefix characters to use at the beginning of the concatenated string, or {@code null} if none.
@@ -198,8 +201,8 @@
*
* @see <a href="https://en.wikipedia.org/wiki/Compound_key">Compound key on Wikipedia</a>
*/
- public static Operation compound(final Map<String,?> identification, final String delimiter,
- final String prefix, final String suffix, final PropertyType... singleAttributes)
+ public static AbstractOperation compound(final Map<String,?> identification, final String delimiter,
+ final String prefix, final String suffix, final AbstractIdentifiedType... singleAttributes)
{
ArgumentChecks.ensureNonEmpty("delimiter", delimiter);
if (delimiter.indexOf(StringJoinOperation.ESCAPE) >= 0) {
@@ -209,8 +212,8 @@
ArgumentChecks.ensureNonEmpty("singleAttributes", singleAttributes);
if (singleAttributes.length == 1) {
if (Strings.isNullOrEmpty(prefix) && Strings.isNullOrEmpty(suffix)) {
- final PropertyType at = singleAttributes[0];
- if (!(at instanceof FeatureAssociationRole)) {
+ final AbstractIdentifiedType at = singleAttributes[0];
+ if (!(at instanceof DefaultAssociationRole)) {
return link(identification, at);
}
}
@@ -243,6 +246,10 @@
* This operation is read-only. Calls to {@code Attribute.setValue(Envelope)} will result in an
* {@link UnsupportedOperationException} to be thrown.
*
+ * <div class="warning"><b>Warning:</b>
+ * The type of {@code geometryAttributes} elements will be changed to {@code PropertyType}
+ * if and when such interface will be defined in GeoAPI.</div>
+ *
* @param identification the name and other information to be given to the operation.
* @param crs the Coordinate Reference System in which to express the envelope, or {@code null}.
* @param geometryAttributes the operation or attribute type from which to get geometry values.
@@ -250,8 +257,8 @@
* @return an operation which will compute the envelope encompassing all geometries in the given attributes.
* @throws FactoryException if a coordinate operation to the target CRS cannot be created.
*/
- public static Operation envelope(final Map<String,?> identification, final CoordinateReferenceSystem crs,
- final PropertyType... geometryAttributes) throws FactoryException
+ public static AbstractOperation envelope(final Map<String,?> identification, final CoordinateReferenceSystem crs,
+ final AbstractIdentifiedType... geometryAttributes) throws FactoryException
{
ArgumentChecks.ensureNonNull("geometryAttributes", geometryAttributes);
return POOL.unique(new EnvelopeOperation(identification, crs, geometryAttributes, null));
@@ -287,8 +294,8 @@
*
* @since 1.4
*/
- public static Operation groupAsPolyline(final Map<String,?> identification, final GeometryLibrary library,
- final PropertyType components)
+ public static AbstractOperation groupAsPolyline(final Map<String,?> identification, final GeometryLibrary library,
+ final AbstractIdentifiedType components)
{
ArgumentChecks.ensureNonNull("library", library);
ArgumentChecks.ensureNonNull("components", components);
@@ -298,7 +305,7 @@
/**
* Creates an operation which delegates the computation to a given expression.
* The {@code expression} argument should generally be an instance of
- * {@link org.opengis.filter.Expression},
+ * {@link org.apache.sis.filter.Expression},
* but more generic functions are accepted as well.
*
* <h4>Read/write behavior</h4>
@@ -313,9 +320,9 @@
*
* @since 1.4
*/
- public static <V> Operation function(final Map<String,?> identification,
- final Function<? super Feature, ? extends V> expression,
- final AttributeType<? super V> resultType)
+ public static <V> AbstractOperation function(final Map<String,?> identification,
+ final Function<? super AbstractFeature, ? extends V> expression,
+ final DefaultAttributeType<? super V> resultType)
{
ArgumentChecks.ensureNonNull("expression", expression);
ArgumentChecks.ensureNonNull("resultType", resultType);
@@ -342,9 +349,9 @@
*
* @since 1.4
*/
- public static <V> Operation expression(final Map<String,?> identification,
- final Expression<? super Feature, ?> expression,
- final AttributeType<V> resultType)
+ public static <V> AbstractOperation expression(final Map<String,?> identification,
+ final Expression<? super AbstractFeature, ?> expression,
+ final DefaultAttributeType<V> resultType)
{
return function(identification, expression.toValueType(resultType.getValueClass()), resultType);
}
@@ -366,18 +373,18 @@
* @return an expression for fetching the values of the property identified by the given type.
* @since 1.5
*/
- public static Expression<? super Feature, ?> expressionOf(final PropertyType property) {
+ public static Expression<? super AbstractFeature, ?> expressionOf(final AbstractIdentifiedType property) {
// Test final class first because it is fast.
if (property instanceof ExpressionOperation<?>) {
- final Function<? super Feature, ?> expression = ((ExpressionOperation<?>) property).expression;
+ final Function<? super AbstractFeature, ?> expression = ((ExpressionOperation<?>) property).expression;
if (expression instanceof Expression<?,?>) {
- return (Expression<? super Feature, ?>) expression;
+ return (Expression<? super AbstractFeature, ?>) expression;
}
}
String name;
final Class<?> type;
- if (property instanceof AttributeType<?>) {
- type = ((AttributeType<?>) property).getValueClass();
+ if (property instanceof DefaultAttributeType<?>) {
+ type = ((DefaultAttributeType<?>) property).getValueClass();
name = null;
} else {
type = Object.class;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureType.java
new file mode 100644
index 0000000..d559a69
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FeatureType.java
@@ -0,0 +1,38 @@
+/*
+ * 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.feature;
+
+import java.util.Collection;
+import org.opengis.util.GenericName;
+
+
+/**
+ * Place-holder for an interface not available in GeoAPI 3.0.
+ * This place-holder will be removed after we upgrade to a later GeoAPI version.
+ *
+ * <p><strong>Do not put this type in public API</strong>. We need to prevent users from using
+ * this type in order to reduce compatibility breaks when we will upgrade the GeoAPI version.</p>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+interface FeatureType {
+ GenericName getName();
+
+ Collection<AbstractIdentifiedType> getProperties(boolean includeSuperTypes);
+
+ boolean isAssignableFrom(DefaultFeatureType type);
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Features.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Features.java
index 41f4b15..b0fbcb7 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Features.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Features.java
@@ -31,18 +31,6 @@
import org.apache.sis.util.iso.DefaultNameFactory;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.ScopeCode;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyType;
-
/**
* Static methods working on features or attributes.
@@ -74,7 +62,7 @@
* @category verification
*/
@SuppressWarnings("unchecked")
- public static <V> AttributeType<V> cast(final AttributeType<?> type, final Class<V> valueClass)
+ public static <V> DefaultAttributeType<V> cast(final DefaultAttributeType<?> type, final Class<V> valueClass)
throws ClassCastException
{
if (type != null) {
@@ -89,7 +77,7 @@
type.getName(), valueClass, actual));
}
}
- return (AttributeType<V>) type;
+ return (DefaultAttributeType<V>) type;
}
/**
@@ -106,7 +94,7 @@
* @category verification
*/
@SuppressWarnings("unchecked")
- public static <V> Attribute<V> cast(final Attribute<?> attribute, final Class<V> valueClass)
+ public static <V> AbstractAttribute<V> cast(final AbstractAttribute<?> attribute, final Class<V> valueClass)
throws ClassCastException
{
if (attribute != null) {
@@ -121,18 +109,18 @@
attribute.getName(), valueClass, actual));
}
}
- return (Attribute<V>) attribute;
+ return (AbstractAttribute<V>) attribute;
}
/**
- * Returns the given type as an {@link AttributeType} by casting if possible, or by getting the result type
+ * Returns the given type as an {@code AttributeType} by casting if possible, or by getting the result type
* of an operation. More specifically this method returns the first of the following types which apply:
*
* <ul>
- * <li>If the given type is an instance of {@link AttributeType}, then it is returned as-is.</li>
- * <li>If the given type is an instance of {@link Operation} and the {@linkplain Operation#getResult()
- * result type} is an {@link AttributeType}, then that result type is returned.</li>
- * <li>If the given type is an instance of {@link Operation} and the {@linkplain Operation#getResult()
+ * <li>If the given type is an instance of {@code AttributeType}, then it is returned as-is.</li>
+ * <li>If the given type is an instance of {@code Operation} and the {@code Operation.getResult()
+ * result type} is an {@code AttributeType}, then that result type is returned.</li>
+ * <li>If the given type is an instance of {@code Operation} and the {@code Operation.getResult()
* result type} is another operation, then the above check is performed recursively.</li>
* </ul>
*
@@ -142,19 +130,19 @@
* @since 1.1
*/
@SuppressWarnings("unchecked")
- public static Optional<AttributeType<?>> toAttribute(IdentifiedType type) {
- return toIdentifiedType(type, (Class) AttributeType.class);
+ public static Optional<DefaultAttributeType<?>> toAttribute(AbstractIdentifiedType type) {
+ return toIdentifiedType(type, (Class) DefaultAttributeType.class);
}
/**
- * Returns the given type as a {@link FeatureAssociationRole} by casting if possible, or by getting the result type
+ * Returns the given type as a {@code FeatureAssociationRole} by casting if possible, or by getting the result type
* of an operation. More specifically this method returns the first of the following types which apply:
*
* <ul>
- * <li>If the given type is an instance of {@link FeatureAssociationRole}, then it is returned as-is.</li>
- * <li>If the given type is an instance of {@link Operation} and the {@linkplain Operation#getResult()
- * result type} is an {@link FeatureAssociationRole}, then that result type is returned.</li>
- * <li>If the given type is an instance of {@link Operation} and the {@linkplain Operation#getResult()
+ * <li>If the given type is an instance of {@code FeatureAssociationRole}, then it is returned as-is.</li>
+ * <li>If the given type is an instance of {@code Operation} and the {@code Operation.getResult()
+ * result type} is an {@code FeatureAssociationRole}, then that result type is returned.</li>
+ * <li>If the given type is an instance of {@code Operation} and the {@code Operation.getResult()
* result type} is another operation, then the above check is performed recursively.</li>
* </ul>
*
@@ -163,21 +151,21 @@
*
* @since 1.4
*/
- public static Optional<FeatureAssociationRole> toAssociation(IdentifiedType type) {
- return toIdentifiedType(type, FeatureAssociationRole.class);
+ public static Optional<DefaultAssociationRole> toAssociation(AbstractIdentifiedType type) {
+ return toIdentifiedType(type, DefaultAssociationRole.class);
}
/**
- * Implementation of {@link #toAttribute(IdentifiedType)} and {@link #toAssociation(IdentifiedType)}.
+ * Implementation of {@code toAttribute(IdentifiedType)} and {@code toAssociation(IdentifiedType)}.
*/
- private static <T> Optional<T> toIdentifiedType(IdentifiedType type, final Class<T> target) {
+ private static <T> Optional<T> toIdentifiedType(AbstractIdentifiedType type, final Class<T> target) {
if (!target.isInstance(type)) {
- if (!(type instanceof Operation)) {
+ if (!(type instanceof AbstractOperation)) {
return Optional.empty();
}
- type = ((Operation) type).getResult();
+ type = ((AbstractOperation) type).getResult();
if (!target.isInstance(type)) {
- if (!(type instanceof Operation)) {
+ if (!(type instanceof AbstractOperation)) {
return Optional.empty();
}
/*
@@ -185,9 +173,9 @@
* contain a cycle. However, given that the consequence of an infinite cycle here
* would be thread freeze, we check as a safety.
*/
- final var done = new IdentityHashMap<IdentifiedType,Boolean>(4);
- while (!target.isInstance(type = ((Operation) type).getResult())) {
- if (!(type instanceof Operation) || done.put(type, Boolean.TRUE) != null) {
+ final var done = new IdentityHashMap<AbstractIdentifiedType,Boolean>(4);
+ while (!target.isInstance(type = ((AbstractOperation) type).getResult())) {
+ if (!(type instanceof AbstractOperation) || done.put(type, Boolean.TRUE) != null) {
return Optional.empty();
}
}
@@ -205,62 +193,33 @@
* @param types types for which to find a common type, or {@code null}.
* @return a feature type which is assignable from all given types, or {@code null} if none.
*
- * @see FeatureType#isAssignableFrom(FeatureType)
+ * @see DefaultFeatureType#isAssignableFrom(DefaultFeatureType)
*
* @since 1.0
*/
- public static FeatureType findCommonParent(final Iterable<? extends FeatureType> types) {
+ public static DefaultFeatureType findCommonParent(final Iterable<? extends DefaultFeatureType> types) {
return (types != null) ? CommonParentFinder.select(types) : null;
}
- /**
- * Returns the type of values provided by the given property. For {@linkplain AttributeType attributes}
- * (which is the most common case), the value type is given by {@link AttributeType#getValueClass()}.
- * For {@linkplain FeatureAssociationRole feature associations}, the value type is {@link Feature}.
- * For {@linkplain Operation operations}, the value type is determined recursively from the
- * {@linkplain Operation#getResult() operation result}.
- * If the value type cannot be determined, then this method returns {@code null}.
+ /*
+ * Following method is omitted on master because it depends on GeoAPI interfaces not yet published:
*
- * @param type the property for which to get the type of values, or {@code null}.
- * @return the type of values provided by the given property, or {@code null} if unknown.
- *
- * @see AttributeType#getValueClass()
- *
- * @since 1.0
+ * public static Class<?> getValueClass(PropertyType type)
*/
- public static Class<?> getValueClass(PropertyType type) {
- while (type instanceof Operation) {
- final IdentifiedType result = ((Operation) type).getResult();
- if (result != type && result instanceof PropertyType) {
- type = (PropertyType) result;
- } else if (result instanceof FeatureType) {
- return Feature.class;
- } else {
- break;
- }
- }
- if (type instanceof AttributeType<?>) {
- return ((AttributeType<?>) type).getValueClass();
- } else if (type instanceof FeatureAssociationRole) {
- return Feature.class;
- } else {
- return null;
- }
- }
/**
* Returns the name of the type of values that the given property can take.
- * The type of value can be a {@link Class}, a {@link org.opengis.feature.FeatureType}
+ * The type of value can be a {@link Class}, a {@code FeatureType}
* or another {@code PropertyType} depending on given argument:
*
* <ul>
- * <li>If {@code property} is an {@link AttributeType}, then this method gets the
+ * <li>If {@code property} is an {@code AttributeType}, then this method gets the
* {@linkplain DefaultAttributeType#getValueClass() value class} and
* {@linkplain DefaultNameFactory#toTypeName(Class) maps that class to a name}.</li>
- * <li>If {@code property} is a {@link FeatureAssociationRole}, then this method gets
+ * <li>If {@code property} is a {@code FeatureAssociationRole}, then this method gets
* the name of the {@linkplain DefaultAssociationRole#getValueType() value type}.
* This methods can work even if the associated {@code FeatureType} is not yet resolved.</li>
- * <li>If {@code property} is an {@link Operation}, then this method returns the name of the
+ * <li>If {@code property} is an {@code Operation}, then this method returns the name of the
* {@linkplain AbstractOperation#getResult() result type}.</li>
* </ul>
*
@@ -269,14 +228,14 @@
*
* @since 0.8
*/
- public static GenericName getValueTypeName(final PropertyType property) {
- if (property instanceof FeatureAssociationRole) {
+ public static GenericName getValueTypeName(final AbstractIdentifiedType property) {
+ if (property instanceof DefaultAssociationRole) {
// Tested first because this is the main interest for this method.
- return DefaultAssociationRole.getValueTypeName((FeatureAssociationRole) property);
- } else if (property instanceof AttributeType<?>) {
- return Names.createTypeName(((AttributeType<?>) property).getValueClass());
- } else if (property instanceof Operation) {
- final IdentifiedType result = ((Operation) property).getResult();
+ return DefaultAssociationRole.getValueTypeName((DefaultAssociationRole) property);
+ } else if (property instanceof DefaultAttributeType<?>) {
+ return Names.createTypeName(((DefaultAttributeType<?>) property).getValueClass());
+ } else if (property instanceof AbstractOperation) {
+ final AbstractIdentifiedType result = ((AbstractOperation) property).getResult();
if (result != null) {
return result.getName();
}
@@ -287,7 +246,7 @@
/**
* If the given property is a link, returns the name of the referenced property.
* A link is an operation created by a call to {@link FeatureOperations#link(Map, PropertyType)},
- * in which case the value returned by this method is the name of the {@link PropertyType} argument
+ * in which case the value returned by this method is the name of the {@code PropertyType} argument
* which has been given to that {@code link(…)} method.
*
* @param property the property to test, or {@code null} if none.
@@ -297,7 +256,7 @@
*
* @since 1.1
*/
- public static Optional<String> getLinkTarget(final PropertyType property) {
+ public static Optional<String> getLinkTarget(final AbstractIdentifiedType property) {
if (property instanceof LinkOperation) {
return Optional.of(((LinkOperation) property).referentName);
}
@@ -306,18 +265,18 @@
/**
* If the given property is a link or a compound key, returns the name of the referenced properties.
- * This method is similar to {@link #getLinkTarget(PropertyType)}, except that it recognizes also
+ * This method is similar to {@link #getLinkTarget(AbstractIdentifiedType)}, except that it recognizes also
* the operations created by {@link FeatureOperations#compound FeatureOperations.compound(…)}.
*
* @param property the property to test, or {@code null} if none.
* @return the referenced property names if {@code property} is a link or a compound key,
* or an empty list otherwise.
*
- * @see FeatureOperations#compound(Map, String, String, String, PropertyType...)
+ * @see FeatureOperations#compound(Map, String, String, String, AbstractIdentifiedType...)
*
* @since 1.5
*/
- public static List<String> getLinkTargets(final PropertyType property) {
+ public static List<String> getLinkTargets(final AbstractIdentifiedType property) {
return getLinkTarget(property).map(List::of).orElseGet(() -> {
if (property instanceof StringJoinOperation) {
return ((StringJoinOperation) property).getAttributeNames();
@@ -340,24 +299,13 @@
* {@code InvalidPropertyValueException} is thrown. Otherwise this method returns doing nothing.
*
* @param feature the feature to validate, or {@code null}.
- * @throws InvalidPropertyValueException if the given feature is non-null and does not pass validation.
+ * @throws IllegalArgumentException if the given feature is non-null and does not pass validation.
*
* @since 0.7
*/
- public static void validate(final Feature feature) throws InvalidPropertyValueException {
+ public static void validate(final AbstractFeature feature) throws IllegalArgumentException {
if (feature != null) {
- /*
- * Delegate to AbstractFeature.quality() if possible because the user may have overridden the method.
- * Otherwise fallback on the same code as AbstractFeature.quality() default implementation.
- */
- final DataQuality quality;
- if (feature instanceof AbstractFeature) {
- quality = ((AbstractFeature) feature).quality();
- } else {
- final var validator = new Validator(ScopeCode.FEATURE);
- validator.validate(feature.getType(), feature);
- quality = validator.quality;
- }
+ final DataQuality quality = feature.quality();
/*
* Loop on quality elements and check conformance results.
* NOTE: other types of result are ignored for now, since those other
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Field.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Field.java
index a2560fc..4812b5a 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Field.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Field.java
@@ -21,12 +21,6 @@
import org.apache.sis.util.Deprecable;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.MultiValuedPropertyException;
-import org.opengis.feature.InvalidPropertyValueException;
-
/**
* Base class of property that can be stored in a {@link AbstractFeature} instance.
@@ -36,7 +30,7 @@
*
* @param <V> the type of property values.
*/
-abstract class Field<V> implements Property {
+abstract class Field<V> extends Property {
/**
* For subclass constructors.
*/
@@ -58,12 +52,12 @@
* Returns the field feature or attribute value, or {@code null} if none.
*
* @return the feature or attribute value (may be {@code null}).
- * @throws MultiValuedPropertyException if this field contains more than one value.
+ * @throws IllegalStateException if this field contains more than one value.
*
* @see AbstractFeature#getPropertyValue(String)
*/
@Override
- public abstract V getValue() throws MultiValuedPropertyException;
+ public abstract V getValue() throws IllegalStateException;
/**
* Returns all features or attribute values, or an empty collection if none.
@@ -92,15 +86,15 @@
* then delegates to {@link #setValue(Object)}.</p>
*
* @param values the new values.
- * @throws InvalidPropertyValueException if the given collection contains too many elements.
+ * @throws IllegalArgumentException if the given collection contains too many elements.
*/
- public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException {
+ public void setValues(final Collection<? extends V> values) throws IllegalArgumentException {
V value = null;
final Iterator<? extends V> it = values.iterator();
if (it.hasNext()) {
value = it.next();
if (it.hasNext()) {
- throw new InvalidPropertyValueException(Errors.format(Errors.Keys.TooManyOccurrences_2, 1, getName()));
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.TooManyOccurrences_2, 1, getName()));
}
}
setValue(value);
@@ -109,7 +103,7 @@
/**
* Returns whether the given property is deprecated.
*/
- static boolean isDeprecated(final PropertyType type) {
+ static boolean isDeprecated(final AbstractIdentifiedType type) {
return (type instanceof Deprecable) && ((Deprecable) type).isDeprecated();
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FieldType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FieldType.java
index b20be6a..e7c42b3 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FieldType.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/FieldType.java
@@ -21,9 +21,6 @@
import org.opengis.util.GenericName;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.PropertyType;
-
/**
* Base class of property types having a value and a multiplicity.
@@ -36,7 +33,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-abstract class FieldType extends AbstractIdentifiedType implements PropertyType {
+abstract class FieldType extends AbstractIdentifiedType {
/**
* For cross-version compatibility.
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java
index 7f603f4..64d4fbe 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java
@@ -30,14 +30,6 @@
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.util.privy.CollectionsExt;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.Operation;
-
/**
* Creates a single (Multi){@code Polyline} instance from a sequence of points or polylines stored in another property.
@@ -87,18 +79,18 @@
* @param library the library providing the implementations of geometry objects to read and write.
* @param components attribute, association or operation providing the geometries to group as a polyline.
*/
- static AbstractOperation create(final Map<String,?> identification, final GeometryLibrary library, PropertyType components) {
+ static AbstractOperation create(final Map<String,?> identification, final GeometryLibrary library, AbstractIdentifiedType components) {
if (components instanceof LinkOperation) {
components = ((LinkOperation) components).result;
}
final boolean isFeatureAssociation;
- if (components instanceof AttributeType<?>) {
- if (((AttributeType<?>) components).getMaximumOccurs() <= 1) {
+ if (components instanceof DefaultAttributeType<?>) {
+ if (((DefaultAttributeType<?>) components).getMaximumOccurs() <= 1) {
return new LinkOperation(identification, components);
}
isFeatureAssociation = false;
} else {
- isFeatureAssociation = (components instanceof FeatureAssociationRole);
+ isFeatureAssociation = (components instanceof DefaultAssociationRole);
if (!isFeatureAssociation) {
throw new IllegalArgumentException(Resources.format(Resources.Keys.IllegalPropertyType_2,
components.getName(), components.getClass()));
@@ -113,7 +105,7 @@
* number of occurrences of attribute values or feature instances is greater than 1.
*/
private GroupAsPolylineOperation(final Map<String,?> identification, final Geometries<?> geometries,
- final PropertyType components, final boolean isFeatureAssociation)
+ final AbstractIdentifiedType components, final boolean isFeatureAssociation)
{
super(identification);
this.geometries = geometries;
@@ -144,8 +136,8 @@
* @return the new operation, or {@code this} if unchanged.
*/
@Override
- public Operation updateDependencies(final Map<String, PropertyType> dependencies) {
- final PropertyType target = dependencies.get(propertyName);
+ public AbstractOperation updateDependencies(final Map<String, AbstractIdentifiedType> dependencies) {
+ final AbstractIdentifiedType target = dependencies.get(propertyName);
if (target != null) {
final AbstractOperation op = create(inherit(), geometries.library, target);
if (!equals(op)) {
@@ -159,7 +151,7 @@
* Returns the expected result type.
*/
@Override
- public final AttributeType<?> getResult() {
+ public final DefaultAttributeType<?> getResult() {
synchronized (TYPES) {
return TYPES.computeIfAbsent(geometries.library, (library) -> {
var name = Map.of(AbstractIdentifiedType.NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY);
@@ -174,7 +166,7 @@
*/
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
- public final Property apply(Feature feature, ParameterValueGroup parameters) {
+ public final Property apply(AbstractFeature feature, ParameterValueGroup parameters) {
return new Result<>(getResult(), feature);
}
@@ -182,7 +174,7 @@
/**
* The attribute resulting from execution of the {@link GroupAsPolylineOperation}.
* The value is computed when first requested, then cached for this {@code Result} instance only.
- * Note that the cache is not used when {@link #apply(Feature, ParameterValueGroup)} is invoked,
+ * Note that the cache is not used when {@code apply(Feature, ParameterValueGroup)} is invoked,
* causing a new value to be computed again. The intent is to behave as if the operation has been
* executed at {@code apply(…)} invocation time, even if we deferred the actual execution.
*
@@ -203,7 +195,7 @@
* Creates a new result for an execution on the given feature.
* The actual computation is deferred to the first call of {@link #getValue()}.
*/
- Result(final AttributeType<G> resultType, final Feature feature) {
+ Result(final DefaultAttributeType<G> resultType, final AbstractFeature feature) {
super(resultType, feature);
}
@@ -237,7 +229,7 @@
}
@Override public Object next() {
- return ((Feature) it.next()).getPropertyValue(AttributeConvention.GEOMETRY);
+ return ((AbstractFeature) it.next()).getPropertyValue(AttributeConvention.GEOMETRY);
}
};
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/InvalidFeatureException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/InvalidFeatureException.java
index 6aeff94..54c0e15 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/InvalidFeatureException.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/InvalidFeatureException.java
@@ -19,23 +19,15 @@
import org.opengis.util.InternationalString;
import org.apache.sis.util.LocalizedException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.InvalidPropertyValueException;
-
/**
* Thrown when a feature fails at least one conformance test.
*
- * <h2>API design note</h2>
- * This exception extends {@link InvalidPropertyValueException} because an Apache SIS feature
- * can be invalid only if a property is invalid.
- *
* @author Martin Desruisseaux (Geomatys)
*
- * @see Features#validate(Feature)
+ * @see Features#validate(AbstractFeature)
*/
-final class InvalidFeatureException extends InvalidPropertyValueException implements LocalizedException {
+final class InvalidFeatureException extends IllegalArgumentException implements LocalizedException {
/**
* For cross-version compatibility.
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java
index 63da5f3..7a092d8 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java
@@ -23,13 +23,6 @@
import org.opengis.parameter.ParameterDescriptorGroup;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-
/**
* A link operation, which is like a redirection or an alias.
@@ -51,8 +44,7 @@
/**
* The type of the result.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final PropertyType result;
+ final AbstractIdentifiedType result;
/**
* The name of the referenced attribute or feature association.
@@ -64,10 +56,8 @@
*
* @param identification the name of the link, together with optional information.
* @param referent the referenced attribute or feature association.
- *
- * @see FeatureOperations#link(Map, PropertyType)
*/
- LinkOperation(final Map<String,?> identification, PropertyType referent) {
+ LinkOperation(final Map<String,?> identification, AbstractIdentifiedType referent) {
super(identification);
if (referent instanceof LinkOperation) {
referent = ((LinkOperation) referent).result;
@@ -92,7 +82,7 @@
* Returns the expected result type.
*/
@Override
- public IdentifiedType getResult() {
+ public AbstractIdentifiedType getResult() {
return result;
}
@@ -111,8 +101,8 @@
* @return the new operation, or {@code this} if unchanged.
*/
@Override
- public Operation updateDependencies(final Map<String, PropertyType> dependencies) {
- final PropertyType target = dependencies.get(referentName);
+ public AbstractOperation updateDependencies(final Map<String, AbstractIdentifiedType> dependencies) {
+ final AbstractIdentifiedType target = dependencies.get(referentName);
if (target == null || target.equals(result)) {
return this;
}
@@ -127,7 +117,7 @@
* @return the linked property from the given feature.
*/
@Override
- public Property apply(final Feature feature, final ParameterValueGroup parameters) {
+ public Object apply(final AbstractFeature feature, final ParameterValueGroup parameters) {
return feature.getProperty(referentName);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAssociation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAssociation.java
index 1f9b497..ecca415 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAssociation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAssociation.java
@@ -21,12 +21,6 @@
import org.apache.sis.util.privy.CheckedArrayList;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.MultiValuedPropertyException;
-
/**
* An instance of an {@linkplain DefaultAssociationRole association role} containing an arbitrary number of values.
@@ -56,16 +50,16 @@
/**
* The association values.
*/
- private CheckedArrayList<Feature> values;
+ private CheckedArrayList<AbstractFeature> values;
/**
* Creates a new association of the given role.
*
* @param role Information about the association.
*/
- public MultiValuedAssociation(final FeatureAssociationRole role) {
+ public MultiValuedAssociation(final DefaultAssociationRole role) {
super(role);
- values = new CheckedArrayList<>(Feature.class);
+ values = new CheckedArrayList<>(AbstractFeature.class);
}
/**
@@ -74,12 +68,12 @@
* @param role Information about the association.
* @param values The initial values, or {@code null} for initializing to an empty list.
*/
- MultiValuedAssociation(final FeatureAssociationRole role, final Object values) {
+ MultiValuedAssociation(final DefaultAssociationRole role, final Object values) {
super(role);
if (values == null) {
- this.values = new CheckedArrayList<>(Feature.class);
+ this.values = new CheckedArrayList<>(AbstractFeature.class);
} else {
- this.values = CheckedArrayList.castOrCopy((CheckedArrayList<?>) values, Feature.class);
+ this.values = CheckedArrayList.castOrCopy((CheckedArrayList<?>) values, AbstractFeature.class);
}
}
@@ -87,14 +81,14 @@
* Returns the feature, or {@code null} if none.
*
* @return the feature (may be {@code null}).
- * @throws MultiValuedPropertyException if this association contains more than one value.
+ * @throws IllegalStateException if this association contains more than one value.
*/
@Override
- public Feature getValue() {
+ public AbstractFeature getValue() {
switch (values.size()) {
case 0: return null;
case 1: return values.get(0);
- default: throw new MultiValuedPropertyException(Resources.format(Resources.Keys.NotASingleton_1, getName()));
+ default: throw new IllegalStateException(Resources.format(Resources.Keys.NotASingleton_1, getName()));
}
}
@@ -107,7 +101,7 @@
*/
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
- public Collection<Feature> getValues() {
+ public Collection<AbstractFeature> getValues() {
return values;
}
@@ -117,7 +111,7 @@
* @param value the new value, or {@code null} for removing all values from this association.
*/
@Override
- public void setValue(final Feature value) {
+ public void setValue(final AbstractFeature value) {
values.clear();
if (value != null) {
ensureValid(role.getValueType(), value.getType());
@@ -131,12 +125,12 @@
* @param newValues the new values.
*/
@Override
- public void setValues(final Collection<? extends Feature> newValues) {
+ public void setValues(final Collection<? extends AbstractFeature> newValues) {
if (newValues != values) {
ArgumentChecks.ensureNonNull("values", newValues); // The parameter name in public API is "values".
- final FeatureType base = role.getValueType();
+ final DefaultFeatureType base = role.getValueType();
values.clear();
- for (final Feature value : newValues) {
+ for (final AbstractFeature value : newValues) {
ensureValid(base, value.getType());
values.add(value);
}
@@ -155,7 +149,7 @@
@SuppressWarnings("unchecked")
public MultiValuedAssociation clone() throws CloneNotSupportedException {
final MultiValuedAssociation clone = (MultiValuedAssociation) super.clone();
- clone.values = (CheckedArrayList<Feature>) clone.values.clone();
+ clone.values = (CheckedArrayList<AbstractFeature>) clone.values.clone();
return clone;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAttribute.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAttribute.java
index 482edf2..60161fb 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAttribute.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/MultiValuedAttribute.java
@@ -24,10 +24,6 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.MultiValuedPropertyException;
-
/**
* An instance of an {@linkplain DefaultAttributeType attribute type} containing an arbitrary number of values.
@@ -70,7 +66,7 @@
*
* @param type information about the attribute (base Java class, domain of values, <i>etc.</i>).
*/
- public MultiValuedAttribute(final AttributeType<V> type) {
+ public MultiValuedAttribute(final DefaultAttributeType<V> type) {
super(type);
values = new CheckedArrayList<>(type.getValueClass());
final V value = type.getDefaultValue();
@@ -87,7 +83,7 @@
* @param values the initial values, or {@code null} for initializing to an empty list.
*/
@SuppressWarnings("unchecked")
- MultiValuedAttribute(final AttributeType<V> type, final Object values) {
+ MultiValuedAttribute(final DefaultAttributeType<V> type, final Object values) {
super(type);
final Class<V> valueClass = type.getValueClass();
if (values == null) {
@@ -106,14 +102,14 @@
* Returns the attribute value, or {@code null} if none.
*
* @return the attribute value (may be {@code null}).
- * @throws MultiValuedPropertyException if this attribute contains more than one value.
+ * @throws IllegalStateException if this attribute contains more than one value.
*/
@Override
public V getValue() {
switch (values.size()) {
case 0: return null;
case 1: return values.get(0);
- default: throw new MultiValuedPropertyException(Resources.format(Resources.Keys.NotASingleton_1, getName()));
+ default: throw new IllegalStateException(Resources.format(Resources.Keys.NotASingleton_1, getName()));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/NamedFeatureType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/NamedFeatureType.java
index abc94cb..540e63e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/NamedFeatureType.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/NamedFeatureType.java
@@ -22,16 +22,6 @@
import org.opengis.util.GenericName;
import org.apache.sis.util.privy.Strings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Set;
-import org.opengis.util.InternationalString;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.feature.FeatureInstantiationException;
-import org.apache.sis.feature.internal.Resources;
-
/**
* A feature type identified only by its name. Instances of {@code NamedFeatureType} shall be used only as placeholder
@@ -77,51 +67,10 @@
}
/**
- * Undefined.
- */
- @Override
- public InternationalString getDefinition() {
- return null;
- }
-
- /**
- * Declares that this feature shall not be instantiated.
- */
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- /**
- * Conservatively assumes that the feature is not simple,
- * since we do not know what the actual feature will be.
- */
- @Override
- public boolean isSimple() {
- return false;
- }
-
- /**
- * Always throws {@link PropertyNotFoundException} since this feature type has no declared property yet.
- */
- @Override
- public PropertyType getProperty(final String name) throws PropertyNotFoundException {
- throw new PropertyNotFoundException(Resources.format(Resources.Keys.PropertyNotFound_2, getName(), name));
- }
-
- /**
* Returns an empty set since this feature has no declared property yet.
*/
@Override
- public Collection<? extends PropertyType> getProperties(final boolean includeSuperTypes) {
- return Collections.emptySet();
- }
-
- /**
- * Returns an empty set since this feature has no declared parent yet.
- */
- @Override
- public Set<? extends FeatureType> getSuperTypes() {
+ public Collection<AbstractIdentifiedType> getProperties(final boolean includeSuperTypes) {
return Collections.emptySet();
}
@@ -129,26 +78,8 @@
* This feature type is considered independent of all other feature types except itself.
*/
@Override
- public boolean isAssignableFrom(FeatureType type) {
- if (type == this) {
- return true;
- }
- if (type instanceof NamedFeatureType) {
- type = ((NamedFeatureType) type).resolved;
- }
- if (type == null) {
- return false;
- }
- final FeatureType resolved = this.resolved;
- return (resolved != null) && resolved.isAssignableFrom(type);
- }
-
- /**
- * Unsupported operation, since the feature has not yet been resolved.
- */
- @Override
- public Feature newInstance() throws FeatureInstantiationException {
- throw new FeatureInstantiationException(Resources.format(Resources.Keys.UnresolvedFeatureName_1, getName()));
+ public boolean isAssignableFrom(final DefaultFeatureType type) {
+ return false;
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/OperationResult.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/OperationResult.java
index 04e3ba7..159408c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/OperationResult.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/OperationResult.java
@@ -18,11 +18,6 @@
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-
/**
* Base class of attributes that are the result of a feature operation.
@@ -44,7 +39,7 @@
* The feature instance to use as a source for computing the result.
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
- protected final Feature feature;
+ protected final AbstractFeature feature;
/**
* Creates a new operation for a result of the given type.
@@ -52,7 +47,7 @@
* @param type information about the attribute (base Java class, domain of values, <i>etc.</i>).
* @param feature the feature instance to use as a source for computing the result.
*/
- protected OperationResult(final AttributeType<V> type, final Feature feature) {
+ protected OperationResult(final DefaultAttributeType<V> type, final AbstractFeature feature) {
super(type);
this.feature = feature;
}
@@ -64,6 +59,6 @@
*/
@Override
public void setValue(V value) {
- throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, Attribute.class));
+ throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, AbstractAttribute.class));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Property.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Property.java
new file mode 100644
index 0000000..931c1ca
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Property.java
@@ -0,0 +1,35 @@
+/*
+ * 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.feature;
+
+import org.opengis.util.GenericName;
+
+
+/**
+ * Place-holder for an interface not available in GeoAPI 3.0.
+ * This place-holder will be removed after we upgrade to a later GeoAPI version.
+ *
+ * <p><strong>Do not put this type in public API</strong>. We need to prevent users from using
+ * this type in order to reduce compatibility breaks when we will upgrade the GeoAPI version.</p>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+abstract class Property {
+ public abstract GenericName getName();
+
+ public abstract Object getValue();
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/PropertyView.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/PropertyView.java
index ce5e2fd..c80f925 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/PropertyView.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/PropertyView.java
@@ -26,15 +26,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.io.Serializable;
-import org.opengis.feature.Feature;
-import org.opengis.feature.Property;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.MultiValuedPropertyException;
+// Specific to the main branch:
+import org.opengis.util.GenericName;
/**
@@ -50,33 +43,11 @@
*
* @param <V> the type of property values.
*/
-abstract class PropertyView<V> extends Field<V> implements Property, Serializable {
+final class PropertyView {
/**
- * For cross-version compatibility.
+ * Do not allow instantiation of this class.
*/
- private static final long serialVersionUID = -5605415150581699255L;
-
- /**
- * The feature from which to read and where to write the attribute or association value.
- */
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- final Feature feature;
-
- /**
- * The string representation of the property name. This is the value to be given in calls to
- * {@link Feature#getPropertyValue(String)} and {@link Feature#setPropertyValue(String, Object)}.
- */
- final String name;
-
- /**
- * Creates a new property which will delegate its work to the given feature.
- *
- * @param feature the feature from which to read and where to write the property value.
- * @param name the string representation of the property name.
- */
- PropertyView(final Feature feature, final String name) {
- this.feature = feature;
- this.name = name;
+ private PropertyView() {
}
/**
@@ -86,32 +57,26 @@
* @param type the type of the property. Must be one of the properties listed in the
* {@code feature} (this is not verified by this constructor).
*/
- static Property create(final Feature feature, final PropertyType type) {
- if (type instanceof AttributeType<?>) {
- return AttributeView.create(feature, (AttributeType<?>) type);
- } else if (type instanceof FeatureAssociationRole) {
- return AssociationView.create(feature, (FeatureAssociationRole) type);
- } else if (type instanceof Operation) {
- return ((Operation) type).apply(feature, null);
+ static Property create(final AbstractFeature feature, final AbstractIdentifiedType type) {
+ if (type instanceof DefaultAttributeType<?>) {
+ return AttributeView.create(feature, (DefaultAttributeType<?>) type);
+ } else if (type instanceof DefaultAssociationRole) {
+ return AssociationView.create(feature, (DefaultAssociationRole) type);
+ } else if (type instanceof AbstractOperation) {
+ return (Property) ((AbstractOperation) type).apply(feature, null);
} else {
throw new IllegalArgumentException(Errors.format(Errors.Keys.UnknownType_1, Classes.getClass(type)));
}
}
/**
- * Returns the class of values.
- */
- abstract Class<V> getValueClass();
-
- /**
* Returns the singleton value. This default implementation assumes that the property is multi-valued
* (single-valued properties shall override this method), but we nevertheless provide a fallback for
* non-{@code Iterable} values as a safety against implementations that are not strictly compliant
- * to our {@link Feature#getPropertyValue(String)} method contract. Then this method verifies that
+ * to our {@code Feature.getPropertyValue(String)} method contract. Then this method verifies that
* the value is a collection containing zero or one element and returns that element or {@code null}.
*/
- @Override
- public V getValue() throws MultiValuedPropertyException {
+ static Object getValue(final AbstractFeature feature, final String name) {
Object value = feature.getPropertyValue(name);
if (value instanceof Iterable<?>) {
final Iterator<?> it = ((Iterable<?>) value).iterator();
@@ -120,19 +85,18 @@
}
value = it.next();
if (it.hasNext()) {
- throw new MultiValuedPropertyException(Resources.format(Resources.Keys.NotASingleton_1, name));
+ throw new IllegalStateException(Resources.format(Resources.Keys.NotASingleton_1, name));
}
}
- return getValueClass().cast(value);
+ return value;
}
/**
* Sets the values of the given attribute. This default implementation assumes that the property
* is multi-valued (single-valued properties shall override this method) and that the
- * {@link Feature#setPropertyValue(String, Object)} implementation will verify the argument type.
+ * {@code Feature.setPropertyValue(String, Object)} implementation will verify the argument type.
*/
- @Override
- public void setValue(final V value) {
+ static void setValue(final AbstractFeature feature, final String name, final Object value) {
feature.setPropertyValue(name, singletonOrEmpty(value));
}
@@ -152,13 +116,11 @@
* contains elements of the expected type, but this verification is not always possible.
* Consequently this method may, sometimes, be actually unsafe.
*/
- @Override
@SuppressWarnings("unchecked") // Actually not 100% safe, but we have done our best.
- public Collection<V> getValues() {
+ static <V> Collection<V> getValues(final AbstractFeature feature, final String name, final Class<V> expected) {
final Object values = feature.getPropertyValue(name);
if (values instanceof Collection<?>) {
if (values instanceof CheckedContainer<?>) {
- final Class<?> expected = getValueClass();
final Class<?> actual = ((CheckedContainer<?>) values).getElementType();
if (expected != actual) { // Really exact match, not Class.isAssignableFrom(Class).
throw new ClassCastException(Errors.format(Errors.Keys.UnexpectedTypeForReference_3, name, expected, actual));
@@ -166,49 +128,31 @@
}
return (Collection<V>) values;
} else {
- return singletonOrEmpty(getValueClass().cast(values));
+ return singletonOrEmpty(expected.cast(values));
}
}
/**
* Sets the values of the given attribute. This method assumes that the
- * {@link Feature#setPropertyValue(String, Object)} implementation will
+ * {@code Feature.setPropertyValue(String, Object)} implementation will
* verify the argument type.
*/
- @Override
- public final void setValues(final Collection<? extends V> values) {
+ static void setValues(final AbstractFeature feature, final String name, final Collection<?> values) {
feature.setPropertyValue(name, values);
}
/**
* Returns a hash code value for this property.
*/
- @Override
- public final int hashCode() {
+ static int hashCode(final AbstractFeature feature, final String name) {
return Objects.hashCode(name) ^ System.identityHashCode(feature);
}
/**
- * Compares this attribute with the given object for equality.
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj != null && obj.getClass() == getClass()) {
- final PropertyView<?> that = (PropertyView<?>) obj;
- return feature == that.feature && Objects.equals(name, that.name);
- }
- return false;
- }
-
- /**
* Returns a string representation of this property for debugging purposes.
*/
- @Override
- public final String toString() {
- return FieldType.toString(false, getClass().getSimpleName(), getName(),
- Classes.getShortName(getValueClass()), getValues().iterator()).toString();
+ static String toString(final Class<?> classe, final Class<?> valueClass, final GenericName name, final Collection<?> values) {
+ return FieldType.toString(false, classe.getSimpleName(), name,
+ Classes.getShortName(valueClass), values.iterator()).toString();
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAssociation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAssociation.java
index e97f95c..f384449 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAssociation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAssociation.java
@@ -18,11 +18,6 @@
import java.util.Objects;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.InvalidPropertyValueException;
-
/**
* An instance of an {@linkplain DefaultAssociationRole association role} containing at most one value.
@@ -50,15 +45,14 @@
/**
* The associated feature.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private Feature value;
+ private AbstractFeature value;
/**
* Creates a new association of the given role.
*
* @param role information about the association.
*/
- public SingletonAssociation(final FeatureAssociationRole role) {
+ public SingletonAssociation(final DefaultAssociationRole role) {
super(role);
assert isSingleton(role.getMaximumOccurs());
}
@@ -69,7 +63,7 @@
* @param role information about the association.
* @param value the initial value (may be {@code null}).
*/
- SingletonAssociation(final FeatureAssociationRole role, final Feature value) {
+ SingletonAssociation(final DefaultAssociationRole role, final AbstractFeature value) {
super(role);
assert isSingleton(role.getMaximumOccurs());
this.value = value;
@@ -84,7 +78,7 @@
* @return the associated feature (may be {@code null}).
*/
@Override
- public Feature getValue() {
+ public AbstractFeature getValue() {
return value;
}
@@ -92,10 +86,10 @@
* Sets the associated feature.
*
* @param value the new value, or {@code null}.
- * @throws InvalidPropertyValueException if the given feature is not valid for this association.
+ * @throws IllegalArgumentException if the given feature is not valid for this association.
*/
@Override
- public void setValue(final Feature value) throws InvalidPropertyValueException {
+ public void setValue(final AbstractFeature value) throws IllegalArgumentException {
if (value != null) {
ensureValid(role.getValueType(), value.getType());
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAttribute.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAttribute.java
index 8175cd6..2ef54b2 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAttribute.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/SingletonAttribute.java
@@ -19,9 +19,6 @@
import java.util.Objects;
import org.apache.sis.util.privy.CloneAccess;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* An instance of an {@linkplain DefaultAttributeType attribute type} containing at most one value.
@@ -63,7 +60,7 @@
*
* @param type information about the attribute (base Java class, domain of values, <i>etc.</i>).
*/
- public SingletonAttribute(final AttributeType<V> type) {
+ public SingletonAttribute(final DefaultAttributeType<V> type) {
super(type);
assert isSingleton(type.getMaximumOccurs());
value = type.getDefaultValue();
@@ -76,7 +73,7 @@
* @param type information about the attribute (base Java class, domain of values, <i>etc.</i>).
* @param value the initial value (may be {@code null}).
*/
- SingletonAttribute(final AttributeType<V> type, final Object value) {
+ SingletonAttribute(final DefaultAttributeType<V> type, final Object value) {
super(type);
assert isSingleton(type.getMaximumOccurs());
this.value = type.getValueClass().cast(value);
diff --git 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
index 76a110b..e74ed55 100644
--- 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
@@ -28,12 +28,6 @@
import org.apache.sis.util.privy.CloneAccess;
import org.apache.sis.util.privy.Cloner;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Property;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* A feature in which only a small fraction of properties are expected to be provided. This implementation uses
@@ -120,15 +114,14 @@
* @param name the property name.
* @return the index for the property of the given name,
* or a negative value if the property is a parameterless operation.
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*/
- private Integer getIndex(final String name) throws PropertyNotFoundException {
- ArgumentChecks.ensureNonNull("name", name); // Parameter name in public API.
+ private Integer getIndex(final String name) throws IllegalArgumentException {
final Integer index = indices.get(name);
if (index != null) {
return index;
}
- throw new PropertyNotFoundException(propertyNotFound(type, getName(), name));
+ throw new IllegalArgumentException(propertyNotFound(type, getName(), name));
}
/**
@@ -173,10 +166,10 @@
*
* @param name the property name.
* @return the property of the given name.
- * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
+ * @throws IllegalArgumentException if the given argument is not a property name of this feature.
*/
@Override
- public Property getProperty(final String name) throws PropertyNotFoundException {
+ public Object getProperty(final String name) throws IllegalArgumentException {
// Null value check done by the invoked method.
requireMapOfProperties();
return getPropertyInstance(name);
@@ -186,11 +179,11 @@
* Implementation of {@link #getProperty(String)} invoked when we know that the {@link #properties}
* map contains {@code Property} instances (as opposed to their value).
*/
- private Property getPropertyInstance(final String name) throws PropertyNotFoundException {
+ private Property getPropertyInstance(final String name) throws IllegalArgumentException {
assert valuesKind == PROPERTIES : valuesKind;
final Integer index = getIndex(name);
if (index < 0) {
- return getOperationResult(name);
+ return (Property) getOperationResult(name);
}
Property property = (Property) properties.get(index);
if (property == null) {
@@ -208,9 +201,9 @@
* known to this feature, or if the property cannot be set for another reason.
*/
@Override
- public void setProperty(final Property property) throws IllegalArgumentException {
- final String name = property.getName().toString();
- verifyPropertyType(name, property);
+ public void setProperty(final Object property) throws IllegalArgumentException {
+ final String name = ((Property) property).getName().toString();
+ verifyPropertyType(name, (Property) property);
requireMapOfProperties();
/*
* Following index should never be OPERATION_INDEX (a negative value) because the call
@@ -240,10 +233,10 @@
if (element != null) {
if (valuesKind == VALUES) {
return element; // Most common case.
- } else if (element instanceof Attribute<?>) {
- return getAttributeValue((Attribute<?>) element);
- } else if (element instanceof FeatureAssociation) {
- return getAssociationValue((FeatureAssociation) element);
+ } else if (element instanceof AbstractAttribute<?>) {
+ return getAttributeValue((AbstractAttribute<?>) element);
+ } else if (element instanceof AbstractAssociation) {
+ return getAssociationValue((AbstractAssociation) element);
} else if (valuesKind == PROPERTIES) {
throw new IllegalArgumentException(unsupportedPropertyType(((Property) element).getName()));
} else {
@@ -315,7 +308,7 @@
*/
@Override
public Optional<?> getCharacteristicValue(final String property, final String characteristic)
- throws PropertyNotFoundException
+ throws IllegalArgumentException
{
if (valuesKind != VALUES) {
return super.getCharacteristicValue(property, characteristic);
@@ -391,10 +384,10 @@
for (final Map.Entry<Integer,Object> entry : properties.entrySet()) {
final Object p = entry.getValue();
final Object value;
- if (p instanceof Attribute<?>) {
- value = getAttributeValue((Attribute<?>) p);
- } else if (p instanceof FeatureAssociation) {
- value = getAssociationValue((FeatureAssociation) p);
+ if (p instanceof AbstractAttribute<?>) {
+ value = getAttributeValue((AbstractAttribute<?>) p);
+ } else if (p instanceof AbstractAssociation) {
+ value = getAssociationValue((AbstractAssociation) p);
} else {
value = null;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java
index c6dd910..02d2310 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java
@@ -39,18 +39,6 @@
import org.apache.sis.feature.internal.Resources;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.Operation;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* An operation concatenating the string representations of the values of multiple properties.
@@ -124,7 +112,7 @@
@Override public Class<Object> getTargetClass() {return Object.class;}
@Override public Object apply(final Object f) {
return (f != null) ? format(converter.inverse(),
- ((Feature) f).getPropertyValue(AttributeConvention.IDENTIFIER)) : null;
+ ((AbstractFeature) f).getPropertyValue(AttributeConvention.IDENTIFIER)) : null;
}
}
@@ -160,8 +148,7 @@
/**
* The type of the result returned by the string concatenation operation.
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final AttributeType<String> resultType;
+ private final DefaultAttributeType<String> resultType;
/**
* The characters to use at the beginning of the concatenated string, or an empty string if none.
@@ -192,11 +179,11 @@
* @throws UnconvertibleObjectException if at least one attributes is not convertible from a string.
* @throws IllegalArgumentException if the operation failed for another reason.
*
- * @see FeatureOperations#compound(Map, String, String, String, PropertyType...)
+ * @see FeatureOperations#compound(Map, String, String, String, AbstractIdentifiedType...)
*/
@SuppressWarnings({"rawtypes", "unchecked"}) // Generic array creation.
StringJoinOperation(final Map<String,?> identification, final String delimiter,
- final String prefix, final String suffix, final PropertyType[] singleAttributes,
+ final String prefix, final String suffix, final AbstractIdentifiedType[] singleAttributes,
final StringJoinOperation inheritFrom)
{
super(identification);
@@ -215,7 +202,7 @@
* which may in turn produce an AttributeType. We do not accept more complex
* combinations (e.g. operation producing an association).
*/
- IdentifiedType propertyType = singleAttributes[i];
+ AbstractIdentifiedType propertyType = singleAttributes[i];
if (inheritFrom == null) {
ArgumentChecks.ensureNonNullElement("singleAttributes", i, propertyType);
} else if (propertyType == null) {
@@ -225,25 +212,25 @@
}
final GenericName name = propertyType.getName();
int maximumOccurs = 0; // May be a bitwise combination; need only to know if > 1.
- PropertyNotFoundException cause = null; // In case of failure to find "sis:identifier" property.
- final boolean isAssociation = (propertyType instanceof FeatureAssociationRole);
+ IllegalArgumentException cause = null; // In case of failure to find "sis:identifier" property.
+ final boolean isAssociation = (propertyType instanceof DefaultAssociationRole);
if (isAssociation) {
- final var role = (FeatureAssociationRole) propertyType;
- final FeatureType ft = role.getValueType();
+ final var role = (DefaultAssociationRole) propertyType;
+ final DefaultFeatureType ft = role.getValueType();
maximumOccurs = role.getMaximumOccurs();
try {
propertyType = ft.getProperty(AttributeConvention.IDENTIFIER);
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
cause = e;
}
}
- if (propertyType instanceof Operation) {
- propertyType = ((Operation) propertyType).getResult();
+ if (propertyType instanceof AbstractOperation) {
+ propertyType = ((AbstractOperation) propertyType).getResult();
}
- if (propertyType instanceof AttributeType) {
- maximumOccurs |= ((AttributeType<?>) propertyType).getMaximumOccurs();
+ if (propertyType instanceof DefaultAttributeType) {
+ maximumOccurs |= ((DefaultAttributeType<?>) propertyType).getMaximumOccurs();
} else {
- final Class<?>[] inf = Classes.getLeafInterfaces(Classes.getClass(propertyType), PropertyType.class);
+ final Class<?>[] inf = Classes.getLeafInterfaces(Classes.getClass(propertyType), AbstractIdentifiedType.class);
throw new IllegalArgumentException(Resources.forProperties(identification)
.getString(Resources.Keys.IllegalPropertyType_2, name, (inf.length != 0) ? inf[0] : null), cause);
}
@@ -256,7 +243,7 @@
* We need only their names and how to convert from String to their values.
*/
attributeNames[i] = name.toString();
- final Class<?> valueClass = ((AttributeType<?>) propertyType).getValueClass();
+ final Class<?> valueClass = ((DefaultAttributeType<?>) propertyType).getValueClass();
ObjectConverter<? super String, ?> converter;
try {
converter = ObjectConverters.find(String.class, valueClass);
@@ -298,7 +285,7 @@
* @return an {@code AttributeType<String>}.
*/
@Override
- public IdentifiedType getResult() {
+ public AbstractIdentifiedType getResult() {
return resultType;
}
@@ -332,9 +319,9 @@
* @return the new operation, or {@code this} if unchanged.
*/
@Override
- public Operation updateDependencies(final Map<String, PropertyType> dependencies) {
+ public AbstractOperation updateDependencies(final Map<String, AbstractIdentifiedType> dependencies) {
boolean hasNonNull = false;
- final var singleAttributes = new PropertyType[attributeNames.length];
+ final var singleAttributes = new AbstractIdentifiedType[attributeNames.length];
for (int i=0; i < singleAttributes.length; i++) {
hasNonNull |= (singleAttributes[i] = dependencies.get(attributeNames[i])) != null;
}
@@ -367,7 +354,7 @@
* @return the concatenation of feature property values.
*/
@Override
- public Property apply(Feature feature, ParameterValueGroup parameters) {
+ public Property apply(AbstractFeature feature, ParameterValueGroup parameters) {
return new Result(Objects.requireNonNull(feature));
}
@@ -387,7 +374,7 @@
/**
* Creates a new attribute for the given feature.
*/
- Result(final Feature feature) {
+ Result(final AbstractFeature feature) {
super(resultType, feature);
}
@@ -446,14 +433,14 @@
* parsed, then this method does not store any property value ("all or nothing" behavior).
*
* @param value the concatenated string.
- * @throws InvalidPropertyValueException if one of the attribute values cannot be parsed to the expected type.
+ * @throws IllegalArgumentException if one of the attribute values cannot be parsed to the expected type.
*/
@Override
- public void setValue(final String value) throws InvalidPropertyValueException {
+ public void setValue(final String value) throws IllegalArgumentException {
final int endAt = value.length() - suffix.length();
final boolean prefixMatches = value.startsWith(prefix);
if (!prefixMatches || !value.endsWith(suffix)) {
- throw new InvalidPropertyValueException(Errors.format(Errors.Keys.UnexpectedCharactersAtBound_4,
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.UnexpectedCharactersAtBound_4,
getName(),
prefixMatches ? 1 : 0, // For "{1,choice,0#begin|1#end}" in message format.
prefixMatches ? suffix : prefix,
@@ -520,7 +507,7 @@
try {
values[count] = converter.apply(element);
} catch (UnconvertibleObjectException e) {
- throw new InvalidPropertyValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.CanNotAssign_2, attributeNames[count], element), e);
}
}
@@ -534,14 +521,14 @@
* below do not fail).
*/
if (values.length != count) {
- throw new InvalidPropertyValueException(Resources.format(
+ throw new IllegalArgumentException(Resources.format(
Resources.Keys.UnexpectedNumberOfComponents_4, getName(), value, values.length, count));
}
for (int i=0; i < values.length; i++) {
- Feature f = feature;
+ AbstractFeature f = feature;
String name = attributeNames[i];
if (converters[i] instanceof ForFeature) {
- f = (Feature) f.getPropertyValue(name);
+ f = (AbstractFeature) f.getPropertyValue(name);
name = AttributeConvention.IDENTIFIER;
}
f.setPropertyValue(name, values[i]);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Validator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Validator.java
index 6413f86..d492bb2 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Validator.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/Validator.java
@@ -34,16 +34,6 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.metadata.iso.quality.DefaultScope;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociation;
-import org.opengis.feature.FeatureAssociationRole;
-
/**
* Provides validation methods to be shared by different implementations.
@@ -62,6 +52,7 @@
* @param scope {@code FEATURE} if the object to validate is a feature, or
* {@code ATTRIBUTE} for an attribute, or {@code null} otherwise.
*/
+ @SuppressWarnings("deprecation")
Validator(final ScopeCode scope) {
quality = new DefaultDataQuality();
if (scope != null) {
@@ -88,7 +79,7 @@
*/
@SuppressWarnings("deprecation")
private AbstractElement addViolationReport(AbstractElement report,
- final PropertyType type, final InternationalString explanation)
+ final AbstractIdentifiedType type, final InternationalString explanation)
{
if (report == null) {
final GenericName name = type.getName();
@@ -119,19 +110,19 @@
* @param type the type of the {@code feature} argument, provided explicitly for protecting from user overriding.
* @param feature the feature to validate.
*/
- void validate(final FeatureType type, final Feature feature) {
- for (final PropertyType pt : type.getProperties(true)) {
- final Property property = feature.getProperty(pt.getName().toString());
+ void validate(final FeatureType type, final AbstractFeature feature) {
+ for (final AbstractIdentifiedType pt : type.getProperties(true)) {
+ final Object property = feature.getProperty(pt.getName().toString());
final DataQuality pq;
if (property instanceof AbstractAttribute<?>) {
pq = ((AbstractAttribute<?>) property).quality();
} else if (property instanceof AbstractAssociation) {
pq = ((AbstractAssociation) property).quality();
- } else if (property instanceof Attribute<?>) {
- validate(((Attribute<?>) property).getType(), ((Attribute<?>) property).getValues());
+ } else if (property instanceof AbstractAttribute<?>) {
+ validate(((AbstractAttribute<?>) property).getType(), ((AbstractAttribute<?>) property).getValues());
continue;
- } else if (property instanceof FeatureAssociation) {
- validate(((FeatureAssociation) property).getRole(), ((FeatureAssociation) property).getValues());
+ } else if (property instanceof AbstractAssociation) {
+ validate(((AbstractAssociation) property).getRole(), ((AbstractAssociation) property).getValues());
continue;
} else {
continue;
@@ -146,21 +137,21 @@
* Verifies if the given value is valid for the given attribute type.
* This method delegates to one of the {@code validate(…)} methods depending of the value type.
*/
- void validateAny(final PropertyType type, final Object value) {
- if (type instanceof AttributeType<?>) {
- validate((AttributeType<?>) type, asList(value,
- ((AttributeType<?>) type).getMaximumOccurs()));
+ void validateAny(final AbstractIdentifiedType type, final Object value) {
+ if (type instanceof DefaultAttributeType<?>) {
+ validate((DefaultAttributeType<?>) type, asList(value,
+ ((DefaultAttributeType<?>) type).getMaximumOccurs()));
}
- if (type instanceof FeatureAssociationRole) {
- validate((FeatureAssociationRole) type, asList(value,
- ((FeatureAssociationRole) type).getMaximumOccurs()));
+ if (type instanceof DefaultAssociationRole) {
+ validate((DefaultAssociationRole) type, asList(value,
+ ((DefaultAssociationRole) type).getMaximumOccurs()));
}
}
/**
* Verifies if the given values are valid for the given attribute type.
*/
- void validate(final AttributeType<?> type, final Collection<?> values) {
+ void validate(final DefaultAttributeType<?> type, final Collection<?> values) {
AbstractElement report = null;
for (final Object value : values) {
/*
@@ -183,10 +174,10 @@
/**
* Verifies if the given value is valid for the given association role.
*/
- void validate(final FeatureAssociationRole role, final Collection<?> values) {
+ void validate(final DefaultAssociationRole role, final Collection<?> values) {
AbstractElement report = null;
for (final Object value : values) {
- final FeatureType type = ((Feature) value).getType();
+ final DefaultFeatureType type = ((AbstractFeature) value).getType();
final FeatureType valueType = role.getValueType();
if (!valueType.isAssignableFrom(type)) {
report = addViolationReport(report, role, Errors.formatInternational(
@@ -204,7 +195,7 @@
*
* @param report where to add the result, or {@code null} if not yet created.
*/
- private void verifyCardinality(final AbstractElement report, final PropertyType type,
+ private void verifyCardinality(final AbstractElement report, final AbstractIdentifiedType type,
final int minimumOccurs, final int maximumOccurs, final int count)
{
if (count < minimumOccurs) {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AssociationRoleBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AssociationRoleBuilder.java
index 35171c1..aa13441 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AssociationRoleBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AssociationRoleBuilder.java
@@ -20,23 +20,22 @@
import org.apache.sis.feature.Features;
import org.apache.sis.feature.DefaultAssociationRole;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
* Describes one association from the {@code FeatureType} to be built by an {@code FeatureTypeBuilder} to another
* {@code FeatureType}. A different instance of {@code AssociationRoleBuilder} exists for each feature association
- * to describe. Those instances are created preferably by {@link FeatureTypeBuilder#addAssociation(FeatureType)},
- * or in case of cyclic reference by {@link FeatureTypeBuilder#addAssociation(GenericName)}.
+ * to describe. Those instances are created preferably by {@code FeatureTypeBuilder.addAssociation(FeatureType)},
+ * or in case of cyclic reference by {@code FeatureTypeBuilder.addAssociation(GenericName)}.
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @version 0.8
*
* @see org.apache.sis.feature.DefaultAssociationRole
- * @see FeatureTypeBuilder#addAssociation(FeatureType)
+ * @see FeatureTypeBuilder#addAssociation(DefaultFeatureType)
* @see FeatureTypeBuilder#addAssociation(GenericName)
*
* @since 0.8
@@ -45,7 +44,7 @@
/**
* The target feature type, or {@code null} if unknown.
*/
- private final FeatureType type;
+ private final DefaultFeatureType type;
/**
* Name of the target feature type (never null).
@@ -56,7 +55,7 @@
* The association created by this builder, or {@code null} if not yet created.
* This field must be cleared every time that a setter method is invoked on this builder.
*/
- private transient FeatureAssociationRole property;
+ private transient DefaultAssociationRole property;
/**
* Creates a new {@code AssociationRole} builder for values of the given type.
@@ -64,7 +63,7 @@
*
* @param owner the builder of the {@code FeatureType} for which to add this property.
*/
- AssociationRoleBuilder(final FeatureTypeBuilder owner, final FeatureType type, final GenericName typeName) {
+ AssociationRoleBuilder(final FeatureTypeBuilder owner, final DefaultFeatureType type, final GenericName typeName) {
super(owner);
this.type = type;
this.typeName = typeName;
@@ -75,12 +74,12 @@
*
* @param owner the builder of the {@code FeatureType} for which to add this property.
*/
- AssociationRoleBuilder(final FeatureTypeBuilder owner, final FeatureAssociationRole template) {
+ AssociationRoleBuilder(final FeatureTypeBuilder owner, final DefaultAssociationRole template) {
super(owner);
property = template;
minimumOccurs = template.getMinimumOccurs();
maximumOccurs = template.getMaximumOccurs();
- if (template instanceof DefaultAssociationRole && !((DefaultAssociationRole) template).isResolved()) {
+ if (!template.isResolved()) {
type = null;
typeName = Features.getValueTypeName(template);
} else {
@@ -248,10 +247,13 @@
* If a role has already been built and this builder state has not changed since the role creation,
* then the previously created {@code FeatureAssociationRole} instance is returned.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@code org.opengis.feature.FeatureAssociationRole} interface. This change is pending GeoAPI revision.</div>
+ *
* @return the association role.
*/
@Override
- public FeatureAssociationRole build() {
+ public DefaultAssociationRole build() {
if (property == null) {
if (type != null) {
property = new DefaultAssociationRole(identification(), type, minimumOccurs, maximumOccurs);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AttributeTypeBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AttributeTypeBuilder.java
index 9c1eeaa..3e52764 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AttributeTypeBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/AttributeTypeBuilder.java
@@ -40,9 +40,6 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* Describes one {@code AttributeType} which will be part of the feature type to be built by
@@ -104,7 +101,7 @@
* The attribute type created by this builder, or {@code null} if not yet created.
* This field must be cleared every time that a setter method is invoked on this builder.
*/
- private transient AttributeType<V> property;
+ private transient DefaultAttributeType<V> property;
/**
* Creates a new builder initialized to the values of the given builder.
@@ -139,16 +136,16 @@
*
* @param owner the builder of the {@code FeatureType} for which to add the attribute.
*/
- AttributeTypeBuilder(final FeatureTypeBuilder owner, final AttributeType<V> template) {
+ AttributeTypeBuilder(final FeatureTypeBuilder owner, final DefaultAttributeType<V> template) {
super(owner);
property = template;
minimumOccurs = template.getMinimumOccurs();
maximumOccurs = template.getMaximumOccurs();
valueClass = template.getValueClass();
defaultValue = template.getDefaultValue();
- final Map<String, AttributeType<?>> tc = template.characteristics();
+ final Map<String, DefaultAttributeType<?>> tc = template.characteristics();
characteristics = new ArrayList<>(tc.size());
- for (final AttributeType<?> c : tc.values()) {
+ for (final DefaultAttributeType<?> c : tc.values()) {
characteristics.add(new CharacteristicTypeBuilder<>(this, c));
}
initialize(template);
@@ -520,13 +517,17 @@
* Adds another attribute type that describes this attribute type, using an existing one as a template.
* See <q>Attribute characterization</q> in {@link DefaultAttributeType} Javadoc for more information.
*
+ * <div class="warning"><b>Warning:</b>
+ * The {@code template} argument type will be changed to {@code AttributeType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param <C> the compile-time type of values in the {@code template} argument.
* @param template an existing attribute type to use as a template.
* @return a builder for a characteristic of this attribute, initialized with the values of the given template.
*
* @see #characteristics()
*/
- public <C> CharacteristicTypeBuilder<C> addCharacteristic(final AttributeType<C> template) {
+ public <C> CharacteristicTypeBuilder<C> addCharacteristic(final DefaultAttributeType<C> template) {
ensureNonNull("template", template);
final CharacteristicTypeBuilder<C> characteristic = new CharacteristicTypeBuilder<>(this, template);
characteristics.add(characteristic);
@@ -544,7 +545,7 @@
*
* @see #getCharacteristic(String)
* @see #addCharacteristic(Class)
- * @see #addCharacteristic(AttributeType)
+ * @see #addCharacteristic(DefaultAttributeType)
* @see #setValidValues(Object...)
* @see #setCRS(CoordinateReferenceSystem)
*/
@@ -746,12 +747,15 @@
* i.e. the {@linkplain #getValueClass() value class} is lost at compile-time.
* By comparison, this {@code build()} method has a more accurate return type.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@code org.opengis.feature.AttributeType} interface. This change is pending GeoAPI revision.</div>
+ *
* @return the attribute type.
*/
@Override
- public AttributeType<V> build() {
+ public DefaultAttributeType<V> build() {
if (property == null) {
- final AttributeType<?>[] chrts = new AttributeType<?>[characteristics.size()];
+ final DefaultAttributeType<?>[] chrts = new DefaultAttributeType<?>[characteristics.size()];
for (int i=0; i<chrts.length; i++) {
chrts[i] = characteristics.get(i).build();
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
index 5c9a32e..c4ac670 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
@@ -23,9 +23,6 @@
import org.apache.sis.util.ObjectConverters;
import org.apache.sis.util.UnconvertibleObjectException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* Describes one characteristic of the {@code AttributeType} will will be built by a {@code FeatureTypeBuilder}.
@@ -69,7 +66,7 @@
* The characteristic created by this builder, or {@code null} if not yet created.
* This field must be cleared every time that a setter method is invoked on this builder.
*/
- private transient AttributeType<V> characteristic;
+ private transient DefaultAttributeType<V> characteristic;
/**
* Creates a new builder initialized to the values of the given builder but a different type.
@@ -104,7 +101,7 @@
*
* @param owner the builder of the {@code AttributeType} for which to add this property.
*/
- CharacteristicTypeBuilder(final AttributeTypeBuilder<?> owner, final AttributeType<V> template) {
+ CharacteristicTypeBuilder(final AttributeTypeBuilder<?> owner, final DefaultAttributeType<V> template) {
super(owner.getLocale());
this.owner = owner;
characteristic = template;
@@ -320,10 +317,13 @@
* If a type has already been built and this builder state has not changed since the type creation,
* then the previously created {@code AttributeType} instance is returned.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@code org.opengis.feature.AttributeType} interface. This change is pending GeoAPI revision.</div>
+ *
* @return the characteristic type.
*/
@Override
- public AttributeType<V> build() {
+ public DefaultAttributeType<V> build() {
if (characteristic == null) {
characteristic = new DefaultAttributeType<>(identification(), valueClass, 0, 1, defaultValue);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/FeatureTypeBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/FeatureTypeBuilder.java
index 8a22418..9e687eb 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/FeatureTypeBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/FeatureTypeBuilder.java
@@ -42,17 +42,15 @@
import org.apache.sis.util.iso.DefaultNameFactory;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.Operation;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAssociationRole;
+import org.apache.sis.feature.DefaultAttributeType;
/**
- * Helper class for the creation of {@link FeatureType} instances.
+ * Helper class for the creation of {@code FeatureType} instances.
* This builder can create the arguments to be given to the
* {@linkplain DefaultFeatureType#DefaultFeatureType feature type constructor}
* from simpler parameters given to this builder.
@@ -66,7 +64,7 @@
* and whether the feature type is {@linkplain #setAbstract abstract}.</li>
* <li>Convenience methods for setting the {@linkplain #setNameSpace name space} and the
* {@linkplain #setDefaultMultiplicity default multiplicity} of properties to be added to the feature type.</li>
- * <li>Methods for {@linkplain #addAttribute(Class) adding an attribute}, {@linkplain #addAssociation(FeatureType)
+ * <li>Methods for {@linkplain #addAttribute(Class) adding an attribute}, {@linkplain #addAssociation(DefaultFeatureType)
* an association} or {@linkplain #addProperty an operation}.</li>
* <li>Method for listing the previously added {@linkplain #properties() properties}.</li>
* <li>A {@link #build()} method for creating the {@code FeatureType} instance from all previous information.</li>
@@ -121,7 +119,7 @@
/**
* The parent of the feature to create. By default, new features have no parent.
*/
- private final List<FeatureType> superTypes;
+ private final List<DefaultFeatureType> superTypes;
/**
* Whether the feature type is abstract. The default value is {@code false}.
@@ -190,7 +188,7 @@
* The object created by this builder, or {@code null} if not yet created.
* This field must be cleared every time that a setter method is invoked on this builder.
*/
- private transient FeatureType feature;
+ private transient DefaultFeatureType feature;
/**
* Creates a new builder instance using the default name factory.
@@ -206,12 +204,14 @@
* to values inferred from the given template. The properties list will contain properties
* declared explicitly in the given template, not including properties inherited from super types.
*
- * @param template an existing feature type to use as a template, or {@code null} if none.
+ * <div class="warning"><b>Warning:</b>
+ * The {@code template} argument type will be changed to {@code FeatureType} if and when such interface
+ * will be defined in GeoAPI.</div>
*
- * @see #setAll(FeatureType)
+ * @param template an existing feature type to use as a template, or {@code null} if none.
*/
@SuppressWarnings("this-escape") // The invoked method does not store `this` and is not overrideable.
- public FeatureTypeBuilder(final FeatureType template) {
+ public FeatureTypeBuilder(final DefaultFeatureType template) {
this(null, null, null);
if (template != null) {
initialize(template);
@@ -267,14 +267,16 @@
/**
* Sets all properties of this builder to the values of the given feature type.
* This builder is {@linkplain #clear() cleared} before the properties of the given type are copied.
- * The copy is performed as documented in the {@linkplain #FeatureTypeBuilder(FeatureType) constructor}.
+ * The copy is performed as documented in the {@linkplain #FeatureTypeBuilder(DefaultFeatureType) constructor}.
+ *
+ * <div class="warning"><b>Warning:</b>
+ * The {@code template} argument type will be changed to {@code FeatureType} if and when such interface
+ * will be defined in GeoAPI.</div>
*
* @param template an existing feature type to use as a template, or {@code null} if none.
* @return {@code this} for allowing method calls chaining.
- *
- * @see #FeatureTypeBuilder(FeatureType)
*/
- public FeatureTypeBuilder setAll(final FeatureType template) {
+ public FeatureTypeBuilder setAll(final DefaultFeatureType template) {
clear();
if (template != null) {
initialize(template);
@@ -285,10 +287,8 @@
/**
* Initializes this builder to the value of the given type.
* The caller is responsible to invoke {@link #clear()} (if needed) before this method.
- *
- * @see #setAll(FeatureType)
*/
- private void initialize(final FeatureType template) {
+ private void initialize(final DefaultFeatureType template) {
super.initialize(template);
feature = template;
isAbstract = template.isAbstract();
@@ -299,12 +299,12 @@
* is not one of the operations automatically generated by this builder.
*/
final var propertyRoles = new HashMap<String,Set<AttributeRole>>();
- for (final PropertyType property : template.getProperties(false)) {
+ for (final AbstractIdentifiedType property : template.getProperties(false)) {
PropertyTypeBuilder builder;
- if (property instanceof AttributeType<?>) {
- builder = new AttributeTypeBuilder<>(this, (AttributeType<?>) property);
- } else if (property instanceof FeatureAssociationRole) {
- builder = new AssociationRoleBuilder(this, (FeatureAssociationRole) property);
+ if (property instanceof DefaultAttributeType<?>) {
+ builder = new AttributeTypeBuilder<>(this, (DefaultAttributeType<?>) property);
+ } else if (property instanceof DefaultAssociationRole) {
+ builder = new AssociationRoleBuilder(this, (DefaultAssociationRole) property);
} else {
builder = null; // Do not create OperationWrapper now - see below.
}
@@ -402,25 +402,33 @@
/**
* Returns the direct parents of the feature type to create.
*
+ * <div class="warning"><b>Warning:</b>
+ * The return type will be changed to {@code FeatureType[]} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @return the parents of the feature type to create, or an empty array if none.
*
* @see DefaultFeatureType#getSuperTypes()
*/
- public FeatureType[] getSuperTypes() {
- return superTypes.toArray(FeatureType[]::new);
+ public DefaultFeatureType[] getSuperTypes() {
+ return superTypes.toArray(DefaultFeatureType[]::new);
}
/**
* Sets the parent types (or super-type) from which to inherit properties.
* If this method is not invoked, then the default value is no parent.
*
+ * <div class="warning"><b>Warning:</b>
+ * The {@code parents} argument type will be changed to {@code FeatureType...} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param parents the parent types from which to inherit properties, or an empty array if none.
* Null elements are ignored.
* @return {@code this} for allowing method calls chaining.
*/
- public FeatureTypeBuilder setSuperTypes(final FeatureType... parents) {
+ public FeatureTypeBuilder setSuperTypes(final DefaultFeatureType... parents) {
ensureNonNull("parents", parents);
- final List<FeatureType> asList = Arrays.asList(parents);
+ final List<DefaultFeatureType> asList = Arrays.asList(parents);
if (!superTypes.equals(asList)) {
superTypes.clear();
superTypes.addAll(asList);
@@ -593,7 +601,6 @@
* @return {@code this} for allowing method calls chaining.
*
* @see AttributeRole#IDENTIFIER_COMPONENT
- * @see FeatureOperations#compound(Map, String, String, String, PropertyType...)
*/
public FeatureTypeBuilder setIdentifierDelimiters(final String delimiter, final String prefix, final String suffix) {
ensureNonEmpty("delimiter", delimiter);
@@ -619,10 +626,10 @@
*
* @see #getProperty(String)
* @see #addAttribute(Class)
- * @see #addAttribute(AttributeType)
- * @see #addAssociation(FeatureType)
+ * @see #addAttribute(DefaultAttributeType)
+ * @see #addAssociation(DefaultFeatureType)
* @see #addAssociation(GenericName)
- * @see #addAssociation(FeatureAssociationRole)
+ * @see #addAssociation(DefaultAssociationRole)
*/
public List<PropertyTypeBuilder> properties() {
return new RemoveOnlyList<>(properties);
@@ -650,8 +657,6 @@
* @param name name of the property to search.
* @return property of the given name, or {@code null} if none.
* @throws IllegalArgumentException if the given name is ambiguous.
- *
- * @see #addProperty(PropertyType)
*/
public PropertyTypeBuilder getProperty(final String name) {
return forName(properties, name, true);
@@ -668,7 +673,7 @@
* }
*
* The value class cannot be {@code Feature.class} since features shall be handled
- * as {@linkplain #addAssociation(FeatureType) associations} instead of attributes.
+ * as {@linkplain #addAssociation(DefaultFeatureType) associations} instead of attributes.
*
* @param <V> the compile-time value of {@code valueClass} argument.
* @param valueClass the class of attribute values (cannot be {@code Feature.class}).
@@ -678,7 +683,7 @@
*/
public <V> AttributeTypeBuilder<V> addAttribute(final Class<V> valueClass) {
ensureNonNull("valueClass", valueClass);
- if (Feature.class.isAssignableFrom(valueClass)) {
+ if (AbstractFeature.class.isAssignableFrom(valueClass)) {
// We disallow Feature.class because that type shall be handled as association instead of attribute.
throw new IllegalArgumentException(errors().getString(Errors.Keys.IllegalArgumentValue_2, "valueClass", valueClass));
}
@@ -693,13 +698,17 @@
* If the new attribute duplicates an existing one (for example if the same template is used many times),
* caller should use the returned builder for modifying some attributes.
*
+ * <div class="warning"><b>Warning:</b>
+ * The {@code template} argument type will be changed to {@code AttributeType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param <V> the compile-time type of values in the {@code template} argument.
* @param template an existing attribute type to use as a template.
* @return a builder for an {@code AttributeType}, initialized with the values of the given template.
*
* @see #properties()
*/
- public <V> AttributeTypeBuilder<V> addAttribute(final AttributeType<V> template) {
+ public <V> AttributeTypeBuilder<V> addAttribute(final DefaultAttributeType<V> template) {
ensureNonNull("template", template);
final var property = new AttributeTypeBuilder<V>(this, template);
properties.add(property);
@@ -757,12 +766,16 @@
* The default association name is the name of the given type, but callers should invoke one
* of the {@code AssociationRoleBuilder.setName(…)} methods on the returned instance with a better name.
*
+ * <div class="warning"><b>Warning:</b>
+ * The {@code type} argument type will be changed to {@code FeatureType} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param type the type of feature values.
* @return a builder for a {@code FeatureAssociationRole}.
*
* @see #properties()
*/
- public AssociationRoleBuilder addAssociation(final FeatureType type) {
+ public AssociationRoleBuilder addAssociation(final DefaultFeatureType type) {
ensureNonNull("type", type);
final var property = new AssociationRoleBuilder(this, type, type.getName());
properties.add(property);
@@ -772,7 +785,7 @@
/**
* Creates a new {@code FeatureAssociationRole} builder for features of a type of the given name.
- * This method can be invoked as an alternative to {@link #addAssociation(FeatureType)} when the
+ * This method can be invoked as an alternative to {@code addAssociation(FeatureType)} when the
* {@code FeatureType} instance is not yet available because of cyclic dependency.
*
* @param type the name of the type of feature values.
@@ -794,12 +807,16 @@
* same template is used many times), caller should use the returned builder for modifying some
* associations.
*
+ * <div class="warning"><b>Warning:</b>
+ * The {@code template} argument type will be changed to {@code FeatureAssociationRole} if and when such interface
+ * will be defined in GeoAPI.</div>
+ *
* @param template an existing feature association to use as a template.
* @return a builder for an {@code FeatureAssociationRole}, initialized with the values of the given template.
*
* @see #properties()
*/
- public AssociationRoleBuilder addAssociation(final FeatureAssociationRole template) {
+ public AssociationRoleBuilder addAssociation(final DefaultAssociationRole template) {
ensureNonNull("template", template);
final var property = new AssociationRoleBuilder(this, template);
properties.add(property);
@@ -812,9 +829,9 @@
* The given property shall be an instance of one of the following types:
*
* <ul>
- * <li>{@link AttributeType}, in which case this method delegate to {@link #addAttribute(AttributeType)}.</li>
- * <li>{@link FeatureAssociationRole}, in which case this method delegate to {@link #addAssociation(FeatureAssociationRole)}.</li>
- * <li>{@link Operation}, in which case the given operation object will be added verbatim in the {@code FeatureType};
+ * <li>{@code AttributeType}, in which case this method delegate to {@code addAttribute(AttributeType)}.</li>
+ * <li>{@code FeatureAssociationRole}, in which case this method delegate to {@code addAssociation(FeatureAssociationRole)}.</li>
+ * <li>{@code Operation}, in which case the given operation object will be added verbatim in the {@code FeatureType};
* this builder does not create new operations.</li>
* </ul>
*
@@ -822,6 +839,9 @@
* If the same template is used many times, then the caller should use the returned builder
* for modifying some properties.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the argument type may be changed to the
+ * {@code org.opengis.feature.PropertyType} interface. This change is pending GeoAPI revision.</div>
+ *
* @param template the property to add to the feature type.
* @return a builder initialized to the given template.
* In the {@code Operation} case, the builder is a read-only accessor on the operation properties.
@@ -829,12 +849,12 @@
* @see #properties()
* @see #getProperty(String)
*/
- public PropertyTypeBuilder addProperty(final PropertyType template) {
+ public PropertyTypeBuilder addProperty(final AbstractIdentifiedType template) {
ensureNonNull("template", template);
- if (template instanceof AttributeType<?>) {
- return addAttribute((AttributeType<?>) template);
- } else if (template instanceof FeatureAssociationRole) {
- return addAssociation((FeatureAssociationRole) template);
+ if (template instanceof DefaultAttributeType<?>) {
+ return addAttribute((DefaultAttributeType<?>) template);
+ } else if (template instanceof DefaultAssociationRole) {
+ return addAssociation((DefaultAssociationRole) template);
} else {
final var property = new OperationWrapper(this, template);
properties.add(property);
@@ -884,6 +904,9 @@
* One of the {@code setName(…)} methods must have been invoked before this {@code build()} method (mandatory).
* All other methods are optional, but some calls to a {@code add} method are usually needed.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@code org.opengis.feature.FeatureType} interface. This change is pending GeoAPI revision.</div>
+ *
* <p>If a feature type has already been built and this builder state has not changed since the
* feature type creation, then the previously created {@code FeatureType} instance is returned.</p>
*
@@ -893,7 +916,7 @@
* @see #clear()
*/
@Override
- public FeatureType build() throws IllegalStateException {
+ public DefaultFeatureType build() throws IllegalStateException {
if (feature == null) {
/*
* Creates an initial array of property types with up to 3 slots reserved for sis:identifier, sis:geometry
@@ -904,13 +927,13 @@
int numSynthetic; // Number of synthetic properties that may be generated.
int envelopeIndex = -1;
int geometryIndex = -1;
- final PropertyType[] identifierTypes;
+ final AbstractIdentifiedType[] identifierTypes;
if (identifierCount == 0) {
numSynthetic = 0;
identifierTypes = null;
} else {
numSynthetic = 1;
- identifierTypes = new PropertyType[identifierCount];
+ identifierTypes = new AbstractIdentifiedType[identifierCount];
}
if (defaultGeometry != null) {
envelopeIndex = numSynthetic++;
@@ -918,12 +941,12 @@
geometryIndex = numSynthetic++;
}
}
- final var propertyTypes = new PropertyType[numSynthetic + numSpecified];
+ final var propertyTypes = new AbstractIdentifiedType[numSynthetic + numSpecified];
int propertyCursor = numSynthetic;
int identifierCursor = 0;
for (int i=0; i<numSpecified; i++) {
final PropertyTypeBuilder builder = properties.get(i);
- final PropertyType instance = builder.buildForFeature();
+ final AbstractIdentifiedType instance = builder.buildForFeature();
propertyTypes[propertyCursor] = instance;
/*
* Collect the attributes to use as identifier components while we loop over all properties.
@@ -985,7 +1008,7 @@
}
}
feature = new DefaultFeatureType(identification(), isAbstract(),
- superTypes.toArray(FeatureType[]::new),
+ superTypes.toArray(DefaultFeatureType[]::new),
ArraysExt.resize(propertyTypes, propertyCursor));
}
return feature;
@@ -1033,7 +1056,7 @@
buffer.insert(buffer.indexOf("[") + 1, "abstract ");
}
String separator = " : ";
- for (final FeatureType parent : superTypes) {
+ for (final DefaultFeatureType parent : superTypes) {
buffer.append(separator).append('“').append(parent.getName()).append('”');
separator = ", ";
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/OperationWrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/OperationWrapper.java
index 7a6a656..8f533bf 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/OperationWrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/OperationWrapper.java
@@ -22,8 +22,8 @@
import org.apache.sis.feature.AbstractOperation;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.PropertyType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractIdentifiedType;
/**
@@ -37,12 +37,12 @@
/**
* The wrapped operation.
*/
- private final PropertyType operation;
+ private final AbstractIdentifiedType operation;
/**
* Creates a new wrapper for the given operation.
*/
- OperationWrapper(final FeatureTypeBuilder owner, final PropertyType operation) {
+ OperationWrapper(final FeatureTypeBuilder owner, final AbstractIdentifiedType operation) {
super(owner);
this.operation = operation;
minimumOccurs = 1;
@@ -54,7 +54,7 @@
* Returns the wrapped operation.
*/
@Override
- public PropertyType build() {
+ public AbstractIdentifiedType build() {
return operation;
}
@@ -72,11 +72,11 @@
* @throws IllegalStateException if the builder contains inconsistent information.
*/
@Override
- final PropertyType buildForFeature() {
+ final AbstractIdentifiedType buildForFeature() {
final FeatureTypeBuilder owner = owner();
if (operation instanceof AbstractOperation) {
final var op = (AbstractOperation) operation;
- final var dependencies = new HashMap<String, PropertyType>();
+ final var dependencies = new HashMap<String, AbstractIdentifiedType>();
for (final String name : op.getDependencies()) {
final PropertyTypeBuilder target;
try {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/PropertyTypeBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/PropertyTypeBuilder.java
index 214fd41..84753e8 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/PropertyTypeBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/PropertyTypeBuilder.java
@@ -20,11 +20,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.FeatureAssociationRole;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractIdentifiedType;
/**
@@ -34,10 +31,10 @@
*
* <ul>
* <li>{@link FeatureTypeBuilder#addAttribute(Class)}</li>
- * <li>{@link FeatureTypeBuilder#addAttribute(AttributeType)} for using an existing attribute as a template</li>
- * <li>{@link FeatureTypeBuilder#addAssociation(FeatureType)}</li>
+ * <li>{@link FeatureTypeBuilder#addAttribute(DefaultAttributeType)} for using an existing attribute as a template</li>
+ * <li>{@link FeatureTypeBuilder#addAssociation(DefaultFeatureType)}</li>
* <li>{@link FeatureTypeBuilder#addAssociation(GenericName)}</li>
- * <li>{@link FeatureTypeBuilder#addAssociation(FeatureAssociationRole)} for using an existing association as a template</li>
+ * <li>{@link FeatureTypeBuilder#addAssociation(DefaultAssociationRole)} for using an existing association as a template</li>
* </ul>
*
* @author Johann Sorel (Geomatys)
@@ -290,11 +287,14 @@
* then the previously created {@code PropertyType} instance is returned
* (see {@link AttributeTypeBuilder#build()} for more information).
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed
+ * to {@code org.opengis.feature.PropertyType}. This change is pending GeoAPI revision.</div>
+ *
* @return the property type.
* @throws IllegalStateException if the builder contains inconsistent information.
*/
@Override
- public abstract PropertyType build() throws IllegalStateException;
+ public abstract AbstractIdentifiedType build() throws IllegalStateException;
/**
* Builds the final property type to use in {@code FeatureType}.
@@ -305,7 +305,7 @@
* @return the property type.
* @throws IllegalStateException if the builder contains inconsistent information.
*/
- PropertyType buildForFeature() throws IllegalStateException {
+ AbstractIdentifiedType buildForFeature() throws IllegalStateException {
return build();
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/TypeBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/TypeBuilder.java
index 85ae7dd..695d05c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/TypeBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/builder/TypeBuilder.java
@@ -32,10 +32,6 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.PropertyNotFoundException;
-
/**
* Information common to all kind of types (feature, association, characteristics).
@@ -118,7 +114,7 @@
* Initializes this builder to the value of the given type.
* The caller is responsible to invoke {@link #reset()} (if needed) before this method.
*/
- final void initialize(final IdentifiedType template) {
+ final void initialize(final AbstractIdentifiedType template) {
putIfNonNull(AbstractIdentifiedType.NAME_KEY, template.getName());
putIfNonNull(AbstractIdentifiedType.DEFINITION_KEY, template.getDefinition());
putIfNonNull(AbstractIdentifiedType.DESIGNATION_KEY, template.getDesignation().orElse(null));
@@ -456,7 +452,7 @@
}
}
if (ambiguity != null && nonAmbiguous) {
- throw new PropertyNotFoundException(errors().getString(
+ throw new IllegalArgumentException(errors().getString(
Errors.Keys.AmbiguousName_3, best.getName(), ambiguity.getName(), name));
}
return best;
@@ -568,8 +564,11 @@
* If a type has already been built and this builder state has not changed since the type creation,
* then the previously created {@code IdentifiedType} instance is returned.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@code org.opengis.feature.IdentifiedType} interface. This change is pending GeoAPI revision.</div>
+ *
* @return the feature or property type.
* @throws IllegalStateException if the builder contains inconsistent information.
*/
- public abstract IdentifiedType build() throws IllegalStateException;
+ public abstract AbstractIdentifiedType build() throws IllegalStateException;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java
index c927308..b103b0a 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java
@@ -27,16 +27,10 @@
import org.apache.sis.feature.AbstractFeature;
import org.apache.sis.geometry.wrapper.Geometries;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyNotFoundException;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -105,9 +99,9 @@
* <p>The {@linkplain org.apache.sis.feature.DefaultAttributeType#getValueClass() value class} can be
* the {@link com.esri.core.geometry.Geometry} class from ESRI's API, or the {@code Geometry} class from
* <cite>Java Topology Suite</cite> (JTS) library, or any other class defined in future SIS versions.
- * See {@link #isGeometryAttribute(IdentifiedType)} for testing whether the value is a supported type.</p>
+ * See {@code isGeometryAttribute(IdentifiedType)} for testing whether the value is a supported type.</p>
*
- * @see #isGeometryAttribute(IdentifiedType)
+ * @see #isGeometryAttribute(AbstractIdentifiedType)
*/
public static final ScopedName GEOMETRY_PROPERTY = Names.createScopedName(SCOPE, null, "geometry");
@@ -139,7 +133,7 @@
* <p>The {@linkplain org.apache.sis.feature.DefaultAttributeType#getValueClass() value class} should be
* {@link org.opengis.referencing.crs.CoordinateReferenceSystem}.</p>
*
- * @see #getCRSCharacteristic(Feature, String)
+ * @see #getCRSCharacteristic(AbstractFeature, String)
*/
public static final ScopedName CRS_CHARACTERISTIC = Names.createScopedName(SCOPE, null, "crs");
@@ -169,7 +163,7 @@
* <p>The {@linkplain org.apache.sis.feature.DefaultAttributeType#getValueClass() value class} should be
* {@link Integer}.</p>
*
- * @see #getMaximalLengthCharacteristic(Feature, String)
+ * @see #getMaximalLengthCharacteristic(AbstractFeature, String)
*/
public static final ScopedName MAXIMAL_LENGTH_CHARACTERISTIC = Names.createScopedName(SCOPE, null, "maximalLength");
@@ -184,19 +178,19 @@
/**
* String representation of the {@link #IDENTIFIER_PROPERTY} name.
- * This can be used in calls to {@link Feature#getPropertyValue(String)}.
+ * This can be used in calls to {@link AbstractFeature#getPropertyValue(String)}.
*/
public static final String IDENTIFIER = "sis:identifier";
/**
* String representation of the {@link #GEOMETRY_PROPERTY} name.
- * This can be used in calls to {@link Feature#getPropertyValue(String)}.
+ * This can be used in calls to {@link AbstractFeature#getPropertyValue(String)}.
*/
public static final String GEOMETRY = "sis:geometry";
/**
* String representation of the {@link #ENVELOPE_PROPERTY} name.
- * This can be used in calls to {@link Feature#getPropertyValue(String)}.
+ * This can be used in calls to {@link AbstractFeature#getPropertyValue(String)}.
*/
public static final String ENVELOPE = "sis:envelope";
@@ -256,17 +250,17 @@
* @param feature the feature type to test, or {@code null}.
* @return whether the given feature type is non-null and has a {@value #IDENTIFIER} property.
*/
- public static boolean hasIdentifier(final FeatureType feature) {
+ public static boolean hasIdentifier(final DefaultFeatureType feature) {
if (feature != null) try {
return feature.getProperty(IDENTIFIER) != null;
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
// Ignore
}
return false;
}
/**
- * Returns {@code true} if the given type is an {@link AttributeType} or an {@link Operation} computing
+ * Returns {@code true} if the given type is an {@code AttributeType} or an {@code Operation} computing
* an attribute, and the attribute value is one of the geometry types recognized by SIS.
* The types currently recognized by SIS are:
*
@@ -282,8 +276,8 @@
*
* @see #GEOMETRY_PROPERTY
*/
- public static boolean isGeometryAttribute(final IdentifiedType type) {
- final Optional<AttributeType<?>> at = Features.toAttribute(type);
+ public static boolean isGeometryAttribute(final AbstractIdentifiedType type) {
+ final Optional<DefaultAttributeType<?>> at = Features.toAttribute(type);
return at.isPresent() && Geometries.isKnownType(at.get().getValueClass());
}
@@ -295,7 +289,7 @@
* @param type the operation or attribute type for which to get the CRS, or {@code null}.
* @return {@code true} if a characteristic for Coordinate Reference System has been found.
*/
- public static boolean characterizedByCRS(final IdentifiedType type) {
+ public static boolean characterizedByCRS(final AbstractIdentifiedType type) {
return hasCharacteristic(type, CRS, CoordinateReferenceSystem.class);
}
@@ -312,7 +306,7 @@
*
* @see org.apache.sis.feature.builder.AttributeTypeBuilder#setCRS(CoordinateReferenceSystem)
*/
- public static CoordinateReferenceSystem getCRSCharacteristic(final Feature feature, final String property) {
+ public static CoordinateReferenceSystem getCRSCharacteristic(final AbstractFeature feature, final String property) {
return (CoordinateReferenceSystem) getCharacteristic(feature, property, CRS);
}
@@ -322,7 +316,7 @@
* If the given property is a link, then this method follows the link in the given feature type (if non-null).
*
* <p>This method should be used only when the actual property instance is unknown.
- * Otherwise, {@link #getCRSCharacteristic(Feature, String)} should be used because
+ * Otherwise, {@link #getCRSCharacteristic(AbstractFeature, String)} should be used because
* the <abbr>CRS</abbr> may vary for each property instance.</p>
*
* @param feature the feature type in which to follow links, or {@code null} if none.
@@ -331,7 +325,7 @@
* @throws ClassCastException if {@link #CRS_CHARACTERISTIC} has been found but is associated
* to an object which is not a {@link CoordinateReferenceSystem} instance.
*/
- public static CoordinateReferenceSystem getCRSCharacteristic(final FeatureType feature, final PropertyType attribute) {
+ public static CoordinateReferenceSystem getCRSCharacteristic(final DefaultFeatureType feature, final AbstractIdentifiedType attribute) {
return (CoordinateReferenceSystem) getCharacteristic(feature, attribute, CRS);
}
@@ -343,7 +337,7 @@
* @param type the operation or attribute type for which to get the maximal length, or {@code null}.
* @return {@code true} if a characteristic for maximal length has been found.
*/
- public static boolean characterizedByMaximalLength(final IdentifiedType type) {
+ public static boolean characterizedByMaximalLength(final AbstractIdentifiedType type) {
return hasCharacteristic(type, MAXIMAL_LENGTH, Integer.class);
}
@@ -360,7 +354,7 @@
*
* @see org.apache.sis.feature.builder.AttributeTypeBuilder#setMaximalLength(Integer)
*/
- public static Integer getMaximalLengthCharacteristic(final Feature feature, final String property) {
+ public static Integer getMaximalLengthCharacteristic(final AbstractFeature feature, final String property) {
return (Integer) getCharacteristic(feature, property, MAXIMAL_LENGTH);
}
@@ -370,7 +364,7 @@
* If the given property is a link, then this method follows the link in the given feature type (if non-null).
*
* <p>This method should be used only when the actual property instance is unknown.
- * Otherwise, {@link #getMaximalLengthCharacteristic(Feature, String)} should be used
+ * Otherwise, {@link #getMaximalLengthCharacteristic(AbstractFeature, String)} should be used
* because the maximal length may vary for each property instance.</p>
*
* @param feature the feature type in which to follow links, or {@code null} if none.
@@ -379,7 +373,7 @@
* @throws ClassCastException if {@link #MAXIMAL_LENGTH_CHARACTERISTIC} has been found but is associated
* to an object which is not a {@link CoordinateReferenceSystem} instance.
*/
- public static Integer getMaximalLengthCharacteristic(final FeatureType feature, final PropertyType attribute) {
+ public static Integer getMaximalLengthCharacteristic(final DefaultFeatureType feature, final AbstractIdentifiedType attribute) {
return (Integer) getCharacteristic(feature, attribute, MAXIMAL_LENGTH);
}
@@ -392,10 +386,10 @@
* @param valueClass the expected characteristic values.
* @return {@code true} if a characteristic of the given name exists and has values assignable to the given class.
*/
- private static boolean hasCharacteristic(IdentifiedType type, final String name, final Class<?> valueClass) {
- final Optional<AttributeType<?>> at = Features.toAttribute(type);
+ private static boolean hasCharacteristic(AbstractIdentifiedType type, final String name, final Class<?> valueClass) {
+ final Optional<DefaultAttributeType<?>> at = Features.toAttribute(type);
if (at.isPresent()) {
- final AttributeType<?> ct = at.get().characteristics().get(name);
+ final DefaultAttributeType<?> ct = at.get().characteristics().get(name);
if (ct != null) {
return valueClass.isAssignableFrom(ct.getValueClass());
}
@@ -414,25 +408,8 @@
* @return the value or default value of the specified characteristic in the specified property, or {@code null} if none.
* @throws PropertyNotFoundException if the {@code property} argument is not the name of a property of the given feature.
*/
- private static Object getCharacteristic(final Feature feature, final String property, final String characteristic) {
- if (feature instanceof AbstractFeature) {
- return ((AbstractFeature) feature).getCharacteristicValue(property, characteristic).orElse(null);
- }
- final Property attribute = feature.getProperty(property);
- if (attribute instanceof Attribute<?>) {
- final Attribute<?> at = ((Attribute<?>) attribute).characteristics().get(characteristic);
- if (at != null) {
- final Object value = at.getValue();
- if (value != null) {
- return value;
- }
- }
- final AttributeType<?> type = ((Attribute<?>) attribute).getType().characteristics().get(characteristic);
- if (type != null) {
- return type.getDefaultValue();
- }
- }
- return null;
+ private static Object getCharacteristic(final AbstractFeature feature, final String property, final String characteristic) {
+ return feature.getCharacteristicValue(property, characteristic).orElse(null);
}
/**
@@ -445,13 +422,13 @@
* @param characteristic name of the characteristic from which to get the default value.
* @return the default value of the named characteristic in the given property, or {@code null} if none.
*/
- private static Object getCharacteristic(final FeatureType feature, PropertyType property, final String characteristic) {
+ private static Object getCharacteristic(final DefaultFeatureType feature, AbstractIdentifiedType property, final String characteristic) {
final Optional<String> referent = Features.getLinkTarget(property);
if (referent.isPresent() && feature != null) {
property = feature.getProperty(referent.get());
}
- if (property instanceof AttributeType<?>) {
- final AttributeType<?> type = ((AttributeType<?>) property).characteristics().get(characteristic);
+ if (property instanceof DefaultAttributeType<?>) {
+ final DefaultAttributeType<?> type = ((DefaultAttributeType<?>) property).characteristics().get(characteristic);
if (type != null) {
return type.getDefaultValue();
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureExpression.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureExpression.java
index 03dbf49..cdf5e57 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureExpression.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureExpression.java
@@ -23,15 +23,10 @@
import org.apache.sis.filter.DefaultFilterFactory;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.filter.InvalidFilterValueException;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -44,7 +39,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <V> the type of values computed by the expression.
*/
public interface FeatureExpression<R,V> extends Expression<R,V> {
@@ -76,23 +71,23 @@
/**
* Provides the expected type of values produced by this expression when a feature of a given type is evaluated.
* Except for the special case of links (described below), the resulting type shall describe a "static" property,
- * <i>i.e.</i> the type should be an {@link AttributeType} or a {@link org.opengis.feature.FeatureAssociationRole}
- * but not an {@link org.opengis.feature.Operation}. The value of the static property will be set to the result of
+ * <i>i.e.</i> the type should be an {@code AttributeType} or a {@code FeatureAssociationRole}
+ * but not an {@code Operation}. The value of the static property will be set to the result of
* evaluating the expression when instances of the {@code FeatureType} will be created.
- * This evaluation will be performed by {@link FeatureProjection#apply(Feature)}.
+ * This evaluation will be performed by {@link FeatureProjection#apply(AbstractFeature)}.
*
* <h4>Implementation guideline</h4>
* Implementations should declare the property by invoking some of the following methods:
*
* <ul>
* <li>{@link FeatureProjectionBuilder#source()} for the source of the {@link PropertyType} in next point.</li>
- * <li>{@link FeatureProjectionBuilder#addSourceProperty(PropertyType, boolean)}</li>
+ * <li>{@link FeatureProjectionBuilder#addSourceProperty(AbstractIdentifiedType, boolean)}</li>
* <li>{@link FeatureProjectionBuilder#addComputedProperty(PropertyTypeBuilder, boolean)}</li>
* </ul>
*
* Inherited methods such as {@link FeatureProjectionBuilder#addAttribute(Class)} can also be invoked,
* but callers will be responsible for providing the value of the properties added by those methods.
- * These values will not be provided by {@link FeatureProjection#apply(Feature)}.
+ * These values will not be provided by {@link FeatureProjection#apply(AbstractFeature)}.
*
* <h4>Operations</h4>
* If the property is a link to another property, such as {@code "sis:identifier"} or {@code "sis:geometry"},
@@ -101,8 +96,8 @@
*
* @param addTo where to add the type of the property evaluated by this expression.
* @return handler of the added property, or {@code null} if the property cannot be added.
- * @throws InvalidFilterValueException if this expression is invalid for the requested operation.
- * @throws PropertyNotFoundException if the property was not found in {@code addTo.source()}.
+ * @throws IllegalArgumentException if this expression is invalid for the requested operation.
+ * @throws IllegalArgumentException if the property was not found in {@code addTo.source()}.
* @throws UnconvertibleObjectException if the property default value cannot be converted to the expected type.
*/
FeatureProjectionBuilder.Item expectedType(FeatureProjectionBuilder addTo);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjection.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjection.java
index b263c1e..9796665 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjection.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjection.java
@@ -29,11 +29,11 @@
import org.apache.sis.filter.privy.ListingPropertyVisitor;
import org.apache.sis.io.TableAppender;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -44,20 +44,20 @@
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class FeatureProjection implements UnaryOperator<Feature> {
+public final class FeatureProjection implements UnaryOperator<AbstractFeature> {
/**
* The type of features with the properties explicitly requested by the user.
* The property names may differ from the properties of the {@link FeatureProjectionBuilder#source() source}
* features if aliases were specified by calls to {@link FeatureProjectionBuilder.Item#setName(GenericName)}.
*/
- public final FeatureType typeRequested;
+ public final DefaultFeatureType typeRequested;
/**
* The requested type augmented with dependencies required for the execution of operations such as links.
* If there is no need for additional properties, then this value is the same as {@link #typeRequested}.
* The property names are the same as {@link #typeRequested} (i.e., may be aliases).
*/
- public final FeatureType typeWithDependencies;
+ public final DefaultFeatureType typeWithDependencies;
/**
* Names of the properties to be stored in the feature instances created by this {@code FeatureProjection}.
@@ -71,24 +71,24 @@
* This array has the same length as {@link #propertiesToCopy} and each expression is associated to the
* property at the same index.
*/
- private final Expression<? super Feature, ?>[] expressions;
+ private final Expression<? super AbstractFeature, ?>[] expressions;
/**
- * Whether the {@link #apply(Feature)} method shall create instances of {@link #typeWithDependencies}.
- * If {@code false}, then the instances given to the {@link #apply(Feature)} method will be assumed
+ * Whether the {@link #apply(AbstractFeature)} method shall create instances of {@link #typeWithDependencies}.
+ * If {@code false}, then the instances given to the {@link #apply(AbstractFeature)} method will be assumed
* to be already instances of {@link #typeWithDependencies} and will be modified in-place.
*/
private final boolean createInstance;
/**
* Creates a new projection with the given properties specified by a builder.
- * The {@link #apply(Feature)} method will copy the properties of the given
+ * The {@link #apply(AbstractFeature)} method will copy the properties of the given
* features into new instances of {@link #typeWithDependencies}.
*
* @param typeRequested the type of projected features.
* @param projection descriptions of the properties to keep in the projected features.
*/
- FeatureProjection(final FeatureType typeRequested, final FeatureType typeWithDependencies,
+ FeatureProjection(final DefaultFeatureType typeRequested, final DefaultFeatureType typeWithDependencies,
final List<FeatureProjectionBuilder.Item> projection)
{
this.createInstance = true;
@@ -98,7 +98,7 @@
// Expressions to apply on the source feature for fetching the property values of the projected feature.
@SuppressWarnings({"LocalVariableHidesMemberVariable", "unchecked", "rawtypes"})
- final Expression<? super Feature,?>[] expressions = new Expression[projection.size()];
+ final Expression<? super AbstractFeature,?>[] expressions = new Expression[projection.size()];
// Names of the properties to be stored in the attributes of the target features.
@SuppressWarnings("LocalVariableHidesMemberVariable")
@@ -121,7 +121,7 @@
*
* <h4>behavioral change</h4>
* Projections created by this constructor assumes that the feature instances given to the
- * {@link #apply(Feature)} method are already instances of {@link #typeWithDependencies}
+ * {@link #apply(AbstractFeature)} method are already instances of {@link #typeWithDependencies}
* and can be modified (if needed) in place. This constructor is designed for cases where
* the caller does itself a part of the {@code FeatureProjection} work.
*
@@ -181,7 +181,7 @@
* @return path in the source features, or empty if the property is not a {@link ValueReference}.
*/
public Optional<String> xpath(final int index) {
- final Expression<? super Feature, ?> expression = expressions[index];
+ final Expression<? super AbstractFeature, ?> expression = expressions[index];
if (expression instanceof ValueReference<?,?>) {
return Optional.of(((ValueReference<?,?>) expression).getXPath());
}
@@ -222,7 +222,7 @@
* @return the "projected" (<abbr>SQL</abbr> database sense) feature instance.
*/
@Override
- public Feature apply(final Feature source) {
+ public AbstractFeature apply(final AbstractFeature source) {
var feature = createInstance ? typeWithDependencies.newInstance() : source;
for (int i=0; i < expressions.length; i++) {
feature.setPropertyValue(propertiesToCopy[i], expressions[i].apply(source));
@@ -306,7 +306,7 @@
* @param featureType the type from which to get the list of properties.
* @param type the "stored", "operation" or "dependency" value to assign to {@link #type}.
*/
- private static void addAll(final Map<String,Row> rowByName, final FeatureType featureType, final String type) {
+ private static void addAll(final Map<String,Row> rowByName, final DefaultFeatureType featureType, final String type) {
for (final var property : featureType.getProperties(true)) {
Row row = rowByName.computeIfAbsent(property.getName().toString(), Row::new);
row.type = type;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjectionBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjectionBuilder.java
index 51ab93d..621337d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjectionBuilder.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureProjectionBuilder.java
@@ -42,15 +42,13 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Vocabulary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -61,7 +59,7 @@
* this class keeps trace of the dependencies required for recreating the link.
*
* <p>Properties that are copied from the source feature type are declared by calls to
- * {@link #addSourceProperty(PropertyType, boolean)} and related methods defined in this class.
+ * {@link #addSourceProperty(AbstractIdentifiedType, boolean)} and related methods defined in this class.
* The methods inherited from the parent class can also be invoked,
* but they will receive no special treatment.</p>
*
@@ -74,14 +72,14 @@
*
* @see #source()
*/
- private FeatureType source;
+ private DefaultFeatureType source;
/**
* Whether the source is a dependency of the feature type given to the constructor.
* This flag become {@code true} when following a XPath of the form {@code "a/b/c"}.
* In such case, {@link #source} may be temporarily set to the tip {@code "c"} type.
*
- * @see #using(FeatureType, FeatureExpression)
+ * @see #using(DefaultFeatureType, FeatureExpression)
*/
private boolean sourceIsDependency;
@@ -150,7 +148,7 @@
* @param source the type from which to take the properties to keep in the projected feature.
* @param locale the locale to use for formatting error messages, or {@code null} for the default locale.
*/
- public FeatureProjectionBuilder(final FeatureType source, final Locale locale) {
+ public FeatureProjectionBuilder(final DefaultFeatureType source, final Locale locale) {
super(null, null, locale);
this.source = Objects.requireNonNull(source);
requested = new ArrayList<>();
@@ -165,7 +163,7 @@
*
* @return the current source of properties (never {@code null}).
*/
- public FeatureType source() {
+ public DefaultFeatureType source() {
return source;
}
@@ -181,8 +179,8 @@
*
* @see FeatureExpression#expectedType(FeatureProjectionBuilder)
*/
- public Item using(final FeatureType childType, final FeatureExpression<?,?> expression) {
- final FeatureType previous = source;
+ public Item using(final DefaultFeatureType childType, final FeatureExpression<?,?> expression) {
+ final DefaultFeatureType previous = source;
final boolean status = sourceIsDependency;
try {
sourceIsDependency = true;
@@ -205,8 +203,8 @@
* @param deferred where to add operation's dependencies, or {@code null} for not collecting dependencies.
* @return builder for the projected property, or {@code null} if it cannot be resolved.
*/
- private PropertyTypeBuilder addPropertyResult(PropertyType property, final Collection<String> deferred) {
- if (property instanceof Operation) {
+ private PropertyTypeBuilder addPropertyResult(AbstractIdentifiedType property, final Collection<String> deferred) {
+ if (property instanceof AbstractOperation) {
final GenericName name = property.getName();
do {
if (deferred != null) {
@@ -220,15 +218,15 @@
*/
}
}
- final IdentifiedType result = ((Operation) property).getResult();
- if (result != property && result instanceof PropertyType) {
- property = (PropertyType) result;
- } else if (result instanceof FeatureType) {
- return addAssociation((FeatureType) result).setName(name);
+ final AbstractIdentifiedType result = ((AbstractOperation) property).getResult();
+ if (result != property && result instanceof AbstractIdentifiedType) {
+ property = result;
+ } else if (result instanceof DefaultFeatureType) {
+ return addAssociation((DefaultFeatureType) result).setName(name);
} else {
return null;
}
- } while (property instanceof Operation);
+ } while (property instanceof AbstractOperation);
return addProperty(property).setName(name);
}
return addProperty(property);
@@ -243,7 +241,7 @@
* @param named whether the {@code property} name can be used as a default name.
* @return handler for the given item, or {@code null} if the given property cannot be resolved.
*/
- public Item addSourceProperty(final PropertyType property, final boolean named) {
+ public Item addSourceProperty(final AbstractIdentifiedType property, final boolean named) {
if (property == null) {
return null;
}
@@ -353,7 +351,7 @@
*
* @see #attributeValueGetter()
*/
- private Expression<? super Feature, ?> attributeValueGetter;
+ private Expression<? super AbstractFeature, ?> attributeValueGetter;
/**
* Creates a new handle for the property created by the given builder.
@@ -442,15 +440,15 @@
// We do not yet have a special case for this one.
} else {
final var property = builder.build();
- if (property instanceof Operation) {
+ if (property instanceof AbstractOperation) {
/*
* Less common case where the caller wants to change the type of an operation.
* We cannot change the type of an operation (unless we replace the operation
* by a stored attribute). Therefore, we only check type compatibility.
*/
- final var result = ((Operation) property).getResult();
- if (result instanceof AttributeType<?>) {
- final Class<?> c = ((AttributeType<?>) result).getValueClass();
+ final var result = ((AbstractOperation) property).getResult();
+ if (result instanceof DefaultAttributeType<?>) {
+ final Class<?> c = ((DefaultAttributeType<?>) result).getValueClass();
final Class<?> r = type.apply(c);
if (r != null) {
/*
@@ -480,7 +478,7 @@
*
* @param expression the expression to be evaluated by the operation.
*/
- public void setValueGetter(final Expression<? super Feature, ?> expression, final boolean stored) {
+ public void setValueGetter(final Expression<? super AbstractFeature, ?> expression, final boolean stored) {
if (builder instanceof AttributeTypeBuilder<?>) {
if (stored) {
attributeValueGetter = expression;
@@ -493,11 +491,11 @@
* the property in the source feature type, because it allows an optimization
* in `ExpressionOperation.create(…)` (a replacement by a `LinkOperation`).
*/
- AttributeType<?> storedType = null;
+ DefaultAttributeType<?> storedType = null;
if (expression instanceof ValueReference<?,?>) {
var candidate = source.getProperty(((ValueReference<?,?>) expression).getXPath());
- if (candidate instanceof AttributeType<?>) {
- storedType = (AttributeType<?>) candidate;
+ if (candidate instanceof DefaultAttributeType<?>) {
+ storedType = (DefaultAttributeType<?>) candidate;
}
}
if (storedType == null) {
@@ -518,7 +516,7 @@
* The expression may be {@code null} if the value is computed on-the-fly (i.e. the property is
* an operation), or if the expression has not been specified.
*/
- final Expression<? super Feature, ?> attributeValueGetter() {
+ final Expression<? super AbstractFeature, ?> attributeValueGetter() {
return attributeValueGetter;
}
@@ -547,7 +545,7 @@
*
* @see #isIdentity()
*/
- private boolean equivalent(final PropertyType property) {
+ private boolean equivalent(final AbstractIdentifiedType property) {
return builder.getName().equals(property.getName());
}
@@ -635,11 +633,11 @@
* @param deferred where to add missing transitive dependencies (source properties).
* @throws UnsupportedOperationException if there is an attempt to rename a property which is used by an operation.
*/
- private void resolveDependencies(final List<PropertyType> deferred) {
+ private void resolveDependencies(final List<AbstractIdentifiedType> deferred) {
final var it = dependencies.entrySet().iterator();
while (it.hasNext()) {
final Map.Entry<String, List<Item>> entry = it.next();
- final PropertyType property = source.getProperty(entry.getKey());
+ final AbstractIdentifiedType property = source.getProperty(entry.getKey());
final GenericName sourceName = property.getName();
Item item = reservedNames.get(sourceName);
if (item != null) {
@@ -667,7 +665,7 @@
return false;
}
final Iterator<Item> it = requested.iterator();
- for (PropertyType property : source.getProperties(true)) {
+ for (AbstractIdentifiedType property : source.getProperties(true)) {
if (!(it.hasNext() && it.next().equivalent(property))) {
return false;
}
@@ -680,7 +678,7 @@
* {@linkplain #source() source} directly if this projection performs no operation.
*/
@Override
- public FeatureType build() {
+ public DefaultFeatureType build() {
return isIdentity() ? source : super.build();
}
@@ -708,18 +706,18 @@
*/
final List<PropertyTypeBuilder> properties = properties();
final int count = properties.size();
- final var deferred = new ArrayList<PropertyType>();
+ final var deferred = new ArrayList<AbstractIdentifiedType>();
resolveDependencies(deferred);
/*
* If there is no dependencies, the requested type and the type with dependencies are the same.
* Otherwise, we need to resolve transitive dependencies before to build each type.
*/
- final FeatureType typeRequested, typeWithDependencies;
+ final DefaultFeatureType typeRequested, typeWithDependencies;
if (deferred.isEmpty()) {
typeRequested = typeWithDependencies = build();
} else {
do {
- for (PropertyType property : deferred) {
+ for (AbstractIdentifiedType property : deferred) {
final Item item = addSourceProperty(property, true);
if (item != null) {
item.validateName();
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureView.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureView.java
index a0dac0a..f8c5a97 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureView.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureView.java
@@ -18,10 +18,8 @@
import org.apache.sis.feature.AbstractFeature;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Property;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -50,7 +48,7 @@
* The instance with all properties.
*/
@SuppressWarnings("serial") // Apache SIS implementations are serializable.
- private final Feature source;
+ private final AbstractFeature source;
/**
* Creates a new feature instance which is a subset of the given {@code source} feature.
@@ -59,7 +57,7 @@
* @param subset the feature type that describes the feature subset.
* @param source the complete feature instance to view as a subset.
*/
- FeatureView(final FeatureType subset, final Feature source) {
+ FeatureView(final DefaultFeatureType subset, final AbstractFeature source) {
super(subset);
this.source = source;
}
@@ -72,7 +70,7 @@
* @return the property of the given name (never {@code null}).
*/
@Override
- public Property getProperty(final String name) {
+ public Object getProperty(final String name) {
return source.getProperty(name);
}
@@ -83,7 +81,7 @@
* @param property the property to set.
*/
@Override
- public void setProperty(final Property property) {
+ public void setProperty(final Object property) {
source.setProperty(property);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/MovingFeatures.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/MovingFeatures.java
index c468b4d..5a78faf 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/MovingFeatures.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/MovingFeatures.java
@@ -25,9 +25,8 @@
import org.apache.sis.referencing.crs.DefaultTemporalCRS;
import org.apache.sis.util.privy.UnmodifiableArrayList;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractAttribute;
/**
@@ -43,14 +42,14 @@
* Definition of characteristics containing a list of instants, without duplicates.
* Should be in chronological order, but this is not verified.
*/
- public static final AttributeType<Instant> TIME_AS_INSTANTS;
+ public static final DefaultAttributeType<Instant> TIME_AS_INSTANTS;
/**
* An alternative to {@link #TIME_AS_INSTANTS} used when times cannot be mapped to calendar dates.
* This characteristic uses the same name as {@code TIME_AS_INSTANTS}. Consequently, at most one
* of {@code TIME_AS_INSTANTS} and {@code TIME_AS_NUMBERS} can be used on the same property.
*/
- private static final AttributeType<Number> TIME_AS_NUMBERS;
+ private static final DefaultAttributeType<Number> TIME_AS_NUMBERS;
static {
final var scope = Names.createLocalName("OGC", null, "MF");
final var properties = Map.of(DefaultAttributeType.NAME_KEY, Names.createScopedName(scope, null, "datetimes"));
@@ -66,7 +65,7 @@
* @param hasCRS whether a temporal CRS is available.
* @return the "datetimes" characteristic.
*/
- public static AttributeType<?> characteristic(final boolean hasCRS) {
+ public static DefaultAttributeType<?> characteristic(final boolean hasCRS) {
return hasCRS ? TIME_AS_INSTANTS : TIME_AS_NUMBERS;
}
@@ -92,8 +91,8 @@
* @param dest the attribute on which to set time characteristic.
* @param millis times in milliseconds since the epoch.
*/
- public final void setInstants(final Attribute<?> dest, final long[] millis) {
- final Attribute<Instant> c = TIME_AS_INSTANTS.newInstance();
+ public final void setInstants(final AbstractAttribute<?> dest, final long[] millis) {
+ final AbstractAttribute<Instant> c = TIME_AS_INSTANTS.newInstance();
c.setValues(cache.computeIfAbsent(InstantList.vectorize(millis), InstantList::new));
dest.characteristics().values().add(c);
}
@@ -110,18 +109,18 @@
* @param values times in arbitrary units since an arbitrary epoch.
* @param converter the CRS to use for converting values to {@link Instant} instances, or {@code null}.
*/
- public static void setTimes(final Attribute<?> dest, final Vector values, final DefaultTemporalCRS converter) {
- final Attribute<?> ct;
+ public static void setTimes(final AbstractAttribute<?> dest, final Vector values, final DefaultTemporalCRS converter) {
+ final AbstractAttribute<?> ct;
if (converter != null) {
final Instant[] instants = new Instant[values.size()];
for (int i=0; i<instants.length; i++) {
instants[i] = converter.toInstant(values.doubleValue(i));
}
- final Attribute<Instant> c = TIME_AS_INSTANTS.newInstance();
+ final AbstractAttribute<Instant> c = TIME_AS_INSTANTS.newInstance();
c.setValues(UnmodifiableArrayList.wrap(instants));
ct = c;
} else {
- final Attribute<Number> c = TIME_AS_NUMBERS.newInstance();
+ final AbstractAttribute<Number> c = TIME_AS_NUMBERS.newInstance();
c.setValues(values);
ct = c;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ArithmeticFunction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ArithmeticFunction.java
index eabd8cd..1ad4f4f 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ArithmeticFunction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ArithmeticFunction.java
@@ -26,9 +26,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.math.Fraction;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -38,7 +37,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
abstract class ArithmeticFunction<R> extends BinaryFunction<R,Number,Number>
implements FeatureExpression<R,Number>, Optimization.OnExpression<R,Number>
@@ -64,14 +63,14 @@
* @param name name of the attribute to create.
* @return an attribute of the given name for numbers.
*/
- static AttributeType<Number> createNumericType(final String name) {
+ static DefaultAttributeType<Number> createNumericType(final String name) {
return createType(Number.class, name);
}
/**
* Returns the type of results computed by this arithmetic function.
*/
- protected abstract AttributeType<Number> expectedType();
+ protected abstract DefaultAttributeType<Number> expectedType();
/**
* Returns the type of values computed by this expression.
@@ -137,8 +136,8 @@
private static final long serialVersionUID = 5445433312445869201L;
/** Description of results of the {@code "Add"} expression. */
- private static final AttributeType<Number> TYPE = createNumericType(FunctionNames.Add);
- @Override protected AttributeType<Number> expectedType() {return TYPE;}
+ private static final DefaultAttributeType<Number> TYPE = createNumericType(FunctionNames.Add);
+ @Override protected DefaultAttributeType<Number> expectedType() {return TYPE;}
/** Creates a new expression for the {@code "Add"} operation. */
Add(final Expression<R, ? extends Number> expression1,
@@ -177,8 +176,8 @@
private static final long serialVersionUID = 3048878022726271508L;
/** Description of results of the {@code "Subtract"} expression. */
- private static final AttributeType<Number> TYPE = createNumericType(FunctionNames.Subtract);
- @Override protected AttributeType<Number> expectedType() {return TYPE;}
+ private static final DefaultAttributeType<Number> TYPE = createNumericType(FunctionNames.Subtract);
+ @Override protected DefaultAttributeType<Number> expectedType() {return TYPE;}
/** Creates a new expression for the {@code "Subtract"} operation. */
Subtract(final Expression<R, ? extends Number> expression1,
@@ -217,8 +216,8 @@
private static final long serialVersionUID = -1300022614832645625L;
/** Description of results of the {@code "Multiply"} expression. */
- private static final AttributeType<Number> TYPE = createNumericType(FunctionNames.Multiply);
- @Override protected AttributeType<Number> expectedType() {return TYPE;}
+ private static final DefaultAttributeType<Number> TYPE = createNumericType(FunctionNames.Multiply);
+ @Override protected DefaultAttributeType<Number> expectedType() {return TYPE;}
/** Creates a new expression for the {@code "Multiply"} operation. */
Multiply(final Expression<R, ? extends Number> expression1,
@@ -257,8 +256,8 @@
private static final long serialVersionUID = -7709291845568648891L;
/** Description of results of the {@code "Divide"} expression. */
- private static final AttributeType<Number> TYPE = createNumericType(FunctionNames.Divide);
- @Override protected AttributeType<Number> expectedType() {return TYPE;}
+ private static final DefaultAttributeType<Number> TYPE = createNumericType(FunctionNames.Divide);
+ @Override protected DefaultAttributeType<Number> expectedType() {return TYPE;}
/** Creates a new expression for the {@code "Divide"} operation. */
Divide(final Expression<R, ? extends Number> expression1,
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/AssociationValue.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/AssociationValue.java
index 1ab716a..43b9a49 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/AssociationValue.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/AssociationValue.java
@@ -25,14 +25,14 @@
import org.apache.sis.feature.privy.FeatureProjectionBuilder;
import org.apache.sis.math.FunctionProperty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.opengis.util.ScopedName;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAssociationRole;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.Name;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -46,8 +46,8 @@
*
* @see PropertyValue
*/
-final class AssociationValue<V> extends LeafExpression<Feature, V>
- implements ValueReference<Feature, V>, Optimization.OnExpression<Feature, V>
+final class AssociationValue<V> extends LeafExpression<AbstractFeature, V>
+ implements ValueReference<AbstractFeature, V>, Optimization.OnExpression<AbstractFeature, V>
{
/**
* For cross-version compatibility.
@@ -56,7 +56,7 @@
/**
* Path to the property from which to retrieve the value.
- * Each element in the array is an argument to give in a call to {@link Feature#getProperty(String)}.
+ * Each element in the array is an argument to give in a call to {@code Feature.getProperty(String)}.
* This array should be considered read-only because it may be shared.
*/
private final String[] path;
@@ -90,12 +90,17 @@
this.accessor = accessor;
}
+ @Override
+ public final ScopedName getFunctionName() {
+ return Name.VALUE_REFERENCE;
+ }
+
/**
* Returns the class of resources expected by this expression.
*/
@Override
- public final Class<Feature> getResourceClass() {
- return Feature.class;
+ public final Class<AbstractFeature> getResourceClass() {
+ return AbstractFeature.class;
}
/**
@@ -134,12 +139,12 @@
* @return value for the property identified by the XPath (may be {@code null}).
*/
@Override
- public V apply(Feature instance) {
+ public V apply(AbstractFeature instance) {
walk: if (instance != null) {
for (final String p : path) {
final Object value = instance.getPropertyValue(p);
- if (!(value instanceof Feature)) break walk;
- instance = (Feature) value;
+ if (!(value instanceof AbstractFeature)) break walk;
+ instance = (AbstractFeature) value;
}
return accessor.apply(instance);
}
@@ -151,20 +156,20 @@
* to the target properties. This is needed for better SQL WHERE clause in database queries.
*/
@Override
- public Expression<Feature, V> optimize(final Optimization optimization) {
- final FeatureType specifiedType = optimization.getFeatureType();
+ public Expression<AbstractFeature, V> optimize(final Optimization optimization) {
+ final DefaultFeatureType specifiedType = optimization.getFeatureType();
walk: if (specifiedType != null) try {
- FeatureType type = specifiedType;
+ DefaultFeatureType type = specifiedType;
String[] direct = path; // To be cloned before any modification.
for (int i=0; i<path.length; i++) {
- PropertyType property = type.getProperty(path[i]);
+ AbstractIdentifiedType property = type.getProperty(path[i]);
Optional<String> link = Features.getLinkTarget(property);
if (link.isPresent()) {
if (direct == path) direct = direct.clone();
property = type.getProperty(direct[i] = link.get());
}
- if (!(property instanceof FeatureAssociationRole)) break walk;
- type = ((FeatureAssociationRole) property).getValueType();
+ if (!(property instanceof DefaultAssociationRole)) break walk;
+ type = ((DefaultAssociationRole) property).getValueType();
}
/*
* At this point all links have been resolved, up to the final property to evaluate.
@@ -181,7 +186,7 @@
if (converted != accessor || direct != path) {
return new AssociationValue<>(direct, converted);
}
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
warning(e, true);
}
return this;
@@ -192,7 +197,7 @@
*/
@Override
@SuppressWarnings("unchecked")
- public final <N> Expression<Feature,N> toValueType(final Class<N> target) {
+ public final <N> Expression<AbstractFeature,N> toValueType(final Class<N> target) {
final PropertyValue<N> converted = accessor.toValueType(target);
if (converted == accessor) {
return (AssociationValue<N>) this;
@@ -206,26 +211,26 @@
*
* @param addTo where to add the type of properties evaluated by this expression.
* @return builder of the added property, or {@code null} if this method cannot add a property.
- * @throws PropertyNotFoundException if the property was not found in {@code addTo.source()}.
+ * @throws IllegalArgumentException if the property was not found in {@code addTo.source()}.
*/
@Override
public FeatureProjectionBuilder.Item expectedType(final FeatureProjectionBuilder addTo) {
- FeatureType valueType = addTo.source();
+ DefaultFeatureType valueType = addTo.source();
for (final String p : path) {
- final PropertyType type;
+ final AbstractIdentifiedType type;
try {
type = valueType.getProperty(p);
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
if (accessor.isVirtual) {
// The association does not exist but may be defined on a yet unknown child type.
return accessor.defaultType(addTo);
}
throw e;
}
- if (!(type instanceof FeatureAssociationRole)) {
+ if (!(type instanceof DefaultAssociationRole)) {
return null;
}
- valueType = ((FeatureAssociationRole) type).getValueType();
+ valueType = ((DefaultAssociationRole) type).getValueType();
}
return addTo.using(valueType, accessor);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryFunction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryFunction.java
index ddafb45..ab7a43c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryFunction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryFunction.java
@@ -26,10 +26,6 @@
import org.apache.sis.math.DecimalFunctions;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-
/**
* Base class for expressions, comparators or filters performing operations on two expressions.
@@ -40,7 +36,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <V1> the type of value computed by the first expression.
* @param <V2> the type of value computed by the second expression.
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
index 92502c3..892b6d6 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
@@ -27,16 +27,10 @@
import org.apache.sis.filter.internal.Node;
import org.apache.sis.util.Exceptions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.SpatialOperator;
-import org.opengis.filter.BinarySpatialOperator;
-import org.opengis.filter.InvalidFilterValueException;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyNotFoundException;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -48,9 +42,9 @@
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*
- * @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.
*/
-abstract class BinaryGeometryFilter<R> extends Node implements SpatialOperator<R>, Optimization.OnFilter<R> {
+abstract class BinaryGeometryFilter<R> extends Node implements Optimization.OnFilter<R> {
/**
* For cross-version compatibility.
*/
@@ -58,16 +52,12 @@
/**
* The first of the two expressions to be used by this function.
- *
- * @see BinarySpatialOperator#getOperand1()
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
protected final Expression<R, GeometryWrapper> expression1;
/**
* The second of the two expressions to be used by this function.
- *
- * @see BinarySpatialOperator#getOperand2()
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
protected final Expression<R, GeometryWrapper> expression2;
@@ -129,7 +119,7 @@
}
}
} catch (Exception e) {
- throw new InvalidFilterValueException(Exceptions.unwrap(e));
+ throw new IllegalArgumentException(Exceptions.unwrap(e));
}
this.expression1 = expression1;
this.expression2 = expression2;
@@ -146,7 +136,7 @@
/**
* Returns the original expression specified by the user.
*
- * @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.
* @param expression the expression to unwrap.
* @return the unwrapped expression.
*/
@@ -217,7 +207,7 @@
* then try to fetch the CRS of the property values. If we can transform the literal to that
* CRS, do it now in order to avoid doing this transformation for all feature instances.
*/
- final FeatureType featureType = optimization.getFeatureType();
+ final DefaultFeatureType featureType = optimization.getFeatureType();
if (featureType != null && other instanceof ValueReference<?,?>) try {
final CoordinateReferenceSystem targetCRS = AttributeConvention.getCRSCharacteristic(
featureType, featureType.getProperty(((ValueReference<?,?>) other).getXPath()));
@@ -225,12 +215,12 @@
final GeometryWrapper geometry = wrapper.apply(null);
final GeometryWrapper transformed = geometry.transform(targetCRS);
if (geometry != transformed) {
- literal = Optimization.literal(transformed);
+ literal = (Literal<R,?>) Optimization.literal(transformed);
if (literal == effective1) effective1 = literal;
else effective2 = literal;
}
}
- } catch (PropertyNotFoundException | TransformException e) {
+ } catch (IllegalArgumentException | TransformException e) {
warning(e, true);
}
/*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
index 3e03ba7..02c3a97 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
@@ -25,10 +25,8 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.util.Exceptions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.BinarySpatialOperator;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
@@ -40,9 +38,9 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
-final class BinarySpatialFilter<R> extends BinaryGeometryFilter<R> implements BinarySpatialOperator<R> {
+final class BinarySpatialFilter<R> extends BinaryGeometryFilter<R> {
/**
* For cross-version compatibility.
*/
@@ -110,7 +108,6 @@
/**
* Returns the first expression to be evaluated.
*/
- @Override
public Expression<R,?> getOperand1() {
return original(expression1);
}
@@ -118,7 +115,6 @@
/**
* Returns the second expression to be evaluated.
*/
- @Override
public Expression<R,?> getOperand2() {
return original(expression2);
}
@@ -134,7 +130,7 @@
/**
* Given an object, determines if the test(s) represented by this filter are passed.
*
- * @param object the object (often a {@link Feature} instance) to evaluate.
+ * @param object the object (often a {@code Feature} instance) to evaluate.
* @return {@code true} if the test(s) are passed for the provided object.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Capabilities.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Capabilities.java
deleted file mode 100644
index 1150353..0000000
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Capabilities.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.filter;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
-import java.util.Optional;
-import org.opengis.util.LocalName;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.capability.Conformance;
-import org.opengis.filter.capability.IdCapabilities;
-import org.opengis.filter.capability.AvailableFunction;
-import org.opengis.filter.capability.FilterCapabilities;
-import org.opengis.filter.capability.ScalarCapabilities;
-import org.opengis.filter.capability.SpatialCapabilities;
-import org.opengis.filter.capability.TemporalCapabilities;
-import org.apache.sis.util.collection.CodeListSet;
-import org.apache.sis.feature.privy.AttributeConvention;
-
-
-/**
- * Metadata about the specific elements that Apache SIS implementation supports.
- *
- * @todo Missing {@link SpatialCapabilities} and {@link TemporalCapabilities}.
- *
- * @author Johann Sorel (Geomatys)
- * @author Martin Desruisseaux (Geomatys)
- */
-final class Capabilities implements FilterCapabilities, Conformance, IdCapabilities, ScalarCapabilities {
- /**
- * The filter factory which is providing the functions.
- *
- * @see #getFunctions()
- */
- private final DefaultFilterFactory<?,?,?> factory;
-
- /**
- * Creates a new capability document.
- *
- * @param factory the filter factory which is providing functions.
- */
- Capabilities(final DefaultFilterFactory<?,?,?> factory) {
- this.factory = factory;
- }
-
- /**
- * Declaration of which conformance classes a particular implementation supports.
- */
- @Override
- public Conformance getConformance() {
- return this;
- }
-
- /**
- * Returns whether the implementation supports the <i>Resource Identification</i> conformance level.
- */
- @Override
- public boolean implementsResourceld() {
- return true;
- }
-
- /**
- * Provides capabilities used to convey supported identifier operators.
- */
- @Override
- public Optional<IdCapabilities> getIdCapabilities() {
- return Optional.of(this);
- }
-
- /**
- * Declares the names of the properties used for resource identifiers.
- */
- @Override
- public Collection<LocalName> getResourceIdentifiers() {
- return Set.of(AttributeConvention.IDENTIFIER_PROPERTY.tip());
- }
-
- /**
- * Returns whether the implementation supports the <i>Standard Filter</i> conformance level.
- * A value of {@code true} means that all the logical operators ({@code And}, {@code Or}, {@code Not})
- * are supported, together with all the standard {@link ComparisonOperatorName}. Those operators shall
- * be listed in the {@linkplain FilterCapabilities#getScalarCapabilities() scalar capabilities}.
- */
- @Override
- public boolean implementsStandardFilter() {
- return true;
- }
-
- /**
- * Indicates that SIS supports <i>And</i>, <i>Or</i> and <i>Not</i> operators.
- */
- @Override
- public boolean hasLogicalOperators() {
- return true;
- }
-
- /**
- * Advertises which logical, comparison and arithmetic operators the service supports.
- */
- @Override
- public Optional<ScalarCapabilities> getScalarCapabilities() {
- return Optional.of(this);
- }
-
- /**
- * Advertises that SIS supports all comparison operators.
- */
- @Override
- public Set<ComparisonOperatorName> getComparisonOperators() {
- return new CodeListSet<>(ComparisonOperatorName.class, true);
- }
-
- /**
- * Indicates that Apache SIS supports the <i>Spatial Filter</i> conformance level.
- *
- * @todo Need to implement {@linkplain FilterCapabilities#getSpatialCapabilities() temporal capabilities}.
- */
- @Override
- public boolean implementsSpatialFilter() {
- return true;
- }
-
- /**
- * Indicates that Apache SIS supports the <i>Temporal Filter</i> conformance level.
- *
- * @todo Need to implement {@linkplain FilterCapabilities#getTemporalCapabilities() temporal capabilities}.
- */
- @Override
- public boolean implementsTemporalFilter() {
- return true;
- }
-
- /**
- * Indicates that Apache SIS supports the <i>Sorting</i> conformance level.
- */
- @Override
- public boolean implementsSorting() {
- return true;
- }
-
- /**
- * Enumerates the functions that may be used in filter expressions.
- *
- * @return the function that may be used in filter expressions.
- */
- @Override
- public Map<String,AvailableFunction> getFunctions() {
- return factory.new Functions();
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
index 04b5b9d..d1a0203 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
@@ -38,13 +38,11 @@
import org.apache.sis.math.Fraction;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.MatchAction;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.BetweenComparisonOperator;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.MatchAction;
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
+import org.apache.sis.pending.geoapi.filter.BinaryComparisonOperator;
+import org.apache.sis.pending.geoapi.filter.BetweenComparisonOperator;
/**
@@ -71,7 +69,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
abstract class ComparisonFilter<R> extends BinaryFunction<R,Object,Object>
implements BinaryComparisonOperator<R>, Optimization.OnFilter<R>
@@ -813,6 +811,10 @@
this.upper = new LessThanOrEqualTo<>(expression, upper, true, MatchAction.ANY);
}
+ @Override public ComparisonOperatorName getOperatorType() {
+ return ComparisonOperatorName.PROPERTY_IS_BETWEEN;
+ }
+
/**
* Creates a new filter of the same type but different parameters.
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ConvertFunction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ConvertFunction.java
index c614215..354bac4 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ConvertFunction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ConvertFunction.java
@@ -28,16 +28,13 @@
import org.apache.sis.math.FunctionProperty;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-
/**
* Expression whose results are converted to a different type.
*
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <S> the type of value computed by the wrapped exception. This is the type to convert.
* @param <V> the type of value computed by this expression. This is the type after conversion.
*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
index 004d098..1c39a4b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
@@ -34,27 +34,30 @@
import org.apache.sis.util.iso.AbstractFactory;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Iterator;
-import java.time.Instant;
-import org.opengis.filter.*;
-import org.opengis.feature.Feature;
-import org.opengis.filter.capability.AvailableFunction;
-import org.opengis.filter.capability.FilterCapabilities;
-import org.apache.sis.util.privy.Strings;
-import org.apache.sis.util.privy.AbstractMap;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.MatchAction;
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
* A factory of default {@link Filter} and {@link Expression} implementations.
* This base class operates on resources of arbitrary type {@code <R>}.
- * Concrete subclass operates on resources of specific type such as {@link org.opengis.feature.Feature}.
+ * Concrete subclass operates on resources of specific type such as {@link AbstractFeature}.
+ *
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * In a future version, all {@link Filter} and {@link Expression} parameters may be replaced by parameters
+ * of the same names but from the {@code org.opengis.filter} package instead of {@code org.apache.sis.filter}.
+ * This change is pending next GeoAPI release.
+ * In addition, return types may become more specialized types.
+ * </div>
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
*
- * @param <R> the type of resources (e.g. {@link org.opengis.feature.Feature}) to use as inputs.
+ * @param <R> the type of resources (e.g. {@link AbstractFeature}) to use as inputs.
* @param <G> base class of geometry objects. The implementation-neutral type is GeoAPI {@link Geometry},
* but this factory allows the use of other implementations such as JTS
* {@link org.locationtech.jts.geom.Geometry} or ESRI {@link com.esri.core.geometry.Geometry}.
@@ -62,7 +65,7 @@
*
* @since 1.1
*/
-public abstract class DefaultFilterFactory<R,G,T> extends AbstractFactory implements FilterFactory<R,G,T> {
+public abstract class DefaultFilterFactory<R,G,T> extends AbstractFactory {
/**
* The geometry library used by this factory.
*/
@@ -129,13 +132,13 @@
}
/**
- * Returns a factory operating on {@link Feature} instances.
+ * Returns a factory operating on {@link AbstractFeature} instances.
* The {@linkplain GeometryLibrary geometry library} will be the system default.
* The temporal objects can be {@link java.util.Date} or implementations of {@link java.time.temporal.Temporal}.
*
- * @return factory operating on {@link Feature} instances.
+ * @return factory operating on {@link AbstractFeature} instances.
*/
- public static FilterFactory<Feature, Object, Object> forFeatures() {
+ public static DefaultFilterFactory<AbstractFeature, Object, Object> forFeatures() {
return Features.DEFAULT;
}
@@ -155,45 +158,33 @@
* @since 1.5
*/
@SuppressWarnings("unchecked")
- public static <R> Optional<FilterFactory<R, Object, Object>> forResources(final Class<R> type) {
- if (type.equals(Feature.class)) {
- return Optional.of((FilterFactory<R, Object, Object>) forFeatures());
+ public static <R> Optional<DefaultFilterFactory<R, Object, Object>> forResources(final Class<R> type) {
+ if (type.equals(AbstractFeature.class)) {
+ return Optional.of((DefaultFilterFactory<R, Object, Object>) forFeatures());
} else {
return Optional.empty();
}
}
/**
- * Describes the abilities of this factory. The description includes restrictions on
- * the available spatial operations, scalar operations, lists of supported functions,
- * and description of which geometry literals are understood.
- *
- * @return description of the abilities of this factory.
- */
- @Override
- public FilterCapabilities getCapabilities() {
- return new Capabilities(this); // Cheap to construct, no need to cache.
- }
-
- /**
- * A filter factory operating on {@link Feature} instances.
+ * A filter factory operating on {@link AbstractFeature} instances.
*
* @param <G> base class of geometry objects. The implementation-neutral type is GeoAPI {@link Geometry},
* but this factory allows the use of other implementations such as JTS
* {@link org.locationtech.jts.geom.Geometry} or ESRI {@link com.esri.core.geometry.Geometry}.
* @param <T> base class of temporal objects.
*/
- public static class Features<G,T> extends DefaultFilterFactory<Feature, G, T> {
+ public static class Features<G,T> extends DefaultFilterFactory<AbstractFeature, G, T> {
/**
* The instance using system default.
*
* @see #forFeatures()
*/
- static final FilterFactory<Feature,Object,Object> DEFAULT =
+ static final DefaultFilterFactory<AbstractFeature,Object,Object> DEFAULT =
new Features<>(Object.class, Object.class, WraparoundMethod.SPLIT);
/**
- * Creates a new factory operating on {@link Feature} instances.
+ * Creates a new factory operating on {@link AbstractFeature} instances.
* See the {@linkplain DefaultFilterFactory#DefaultFilterFactory(Class, Class, WraparoundMethod)}
* super-class constructor} for a list of valid class arguments.
*
@@ -209,34 +200,12 @@
/**
* Creates a new predicate to identify an identifiable resource within a filter expression.
- * The predicate uses no versioning and no time range.
*
* @param identifier identifier of the resource that shall be selected by the predicate.
* @return the predicate.
*/
@Override
- public ResourceId<Feature> resourceId(final String identifier) {
- return new IdentifierFilter(identifier);
- }
-
- /**
- * Creates a new predicate to identify an identifiable resource within a filter expression.
- * If {@code startTime} and {@code endTime} are non-null, the filter will select all versions
- * of a resource between the specified dates.
- *
- * @param identifier identifier of the resource that shall be selected by the predicate.
- * @param version version of the resource to select, or {@code null} for any version.
- * @param startTime start time of the resource to select, or {@code null} if none.
- * @param endTime end time of the resource to select, or {@code null} if none.
- * @return the predicate.
- *
- * @todo Current implementation ignores the version, start time and end time.
- * This limitation may be resolved in a future version.
- */
- @Override
- public ResourceId<Feature> resourceId(final String identifier, final Version version,
- final Instant startTime, final Instant endTime)
- {
+ public Filter<AbstractFeature> resourceId(final String identifier) {
return new IdentifierFilter(identifier);
}
@@ -267,7 +236,7 @@
* @return an expression evaluating the referenced property value.
*/
@Override
- public <V> ValueReference<Feature,V> property(final String xpath, final Class<V> type) {
+ public <V> Expression<AbstractFeature,V> property(final String xpath, final Class<V> type) {
ArgumentChecks.ensureNonEmpty("xpath", xpath);
ArgumentChecks.ensureNonNull ("type", type);
return PropertyValue.create(xpath, type);
@@ -275,6 +244,41 @@
}
/**
+ * Creates a predicate to identify an identifiable resource within a filter expression.
+ *
+ * @param rid identifier of the resource that shall be selected by the predicate.
+ * @return the predicate.
+ */
+ public abstract Filter<R> resourceId(String rid);
+
+ /**
+ * Creates an expression whose value is computed by retrieving the value indicated by a path in a resource.
+ * If all characters in the path are {@linkplain Character#isUnicodeIdentifierPart(int) Unicode identifier parts},
+ * then the XPath expression is simply a property name.
+ *
+ * @param xpath the path to the property whose value will be returned by the {@code apply(R)} method.
+ * @return an expression evaluating the referenced property value.
+ */
+ public Expression<R,?> property(String xpath) {
+ return property(xpath, Object.class);
+ }
+
+ /**
+ * Creates an expression retrieving the value as an instance of the specified class.
+ * The {@code xpath} argument follows the rule described in {@link #property(String)}.
+ *
+ * <p>The desired type of property values can be specified. For example if the property values should be numbers,
+ * then {@code type} can be <code>{@linkplain Number}.class</code>. If property values can be of any type with no
+ * conversion desired, then {@code type} should be {@code Object.class}.</p>
+ *
+ * @param <V> the type of the values to be fetched (compile-time value of {@code type}).
+ * @param xpath the path to the property whose value will be returned by the {@code apply(R)} method.
+ * @param type the type of the values to be fetched (run-time value of {@code <V>}).
+ * @return an expression evaluating the referenced property value.
+ */
+ public abstract <V> Expression<R,V> property(String xpath, Class<V> type);
+
+ /**
* Creates a constant, literal value that can be used in expressions.
* The given value should be data objects such as strings, numbers, dates or geometries.
*
@@ -282,8 +286,7 @@
* @param value the literal value. May be {@code null}.
* @return a literal for the given value.
*/
- @Override
- public <V> Literal<R,V> literal(final V value) {
+ public <V> Expression<R,V> literal(final V value) {
return new LeafExpression.Literal<>(value);
}
@@ -292,19 +295,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} = {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_EQUAL_TO
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> equal(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> equal(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.EqualTo<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.EqualTo<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -312,19 +308,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} ≠ {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_NOT_EQUAL_TO
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> notEqual(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> notEqual(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.NotEqualTo<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.NotEqualTo<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -332,19 +321,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} < {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_LESS_THAN
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> less(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> less(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.LessThan<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.LessThan<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -352,19 +334,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} > {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_GREATER_THAN
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> greater(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> greater(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.GreaterThan<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.GreaterThan<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -372,19 +347,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} ≤ {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_LESS_THAN_OR_EQUAL_TO
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> lessOrEqual(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> lessOrEqual(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.LessThanOrEqualTo<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.LessThanOrEqualTo<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -392,19 +360,12 @@
*
* @param expression1 the first of the two expressions to be used by this comparator.
* @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
* @return a filter evaluating {@code expression1} ≥ {@code expression2}.
- *
- * @see ComparisonOperatorName#PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO
- * @todo Revisit if we can be more specific on the second parameterized type in expressions.
*/
- @Override
- public BinaryComparisonOperator<R> greaterOrEqual(final Expression<R,?> expression1,
- final Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
+ public Filter<R> greaterOrEqual(final Expression<R,?> expression1,
+ final Expression<R,?> expression2)
{
- return new ComparisonFilter.GreaterThanOrEqualTo<>(expression1, expression2, isMatchingCase, matchAction);
+ return new ComparisonFilter.GreaterThanOrEqualTo<>(expression1, expression2, true, MatchAction.ANY);
}
/**
@@ -417,15 +378,27 @@
* @return a filter evaluating ({@code expression} ≥ {@code lowerBoundary})
* & ({@code expression} ≤ {@code upperBoundary}).
*/
- @Override
- public BetweenComparisonOperator<R> between(final Expression<R,?> expression,
- final Expression<R,?> lowerBoundary,
- final Expression<R,?> upperBoundary)
+ public Filter<R> between(final Expression<R,?> expression,
+ final Expression<R,?> lowerBoundary,
+ final Expression<R,?> upperBoundary)
{
return new ComparisonFilter.Between<>(expression, lowerBoundary, upperBoundary);
}
/**
+ * Character string comparison operator with pattern matching and default wildcards.
+ * The wildcard character is {@code '%'}, the single character is {@code '_'} and
+ * the escape character is {@code '\\'}. The comparison is case-sensitive.
+ *
+ * @param expression source of values to compare against the pattern.
+ * @param pattern pattern to match against expression values.
+ * @return a character string comparison operator with pattern matching.
+ */
+ public Filter<R> like(Expression<R,?> expression, String pattern) {
+ return like(expression, pattern, '%', '_', '\\', true);
+ }
+
+ /**
* Character string comparison operator with pattern matching and specified wildcards.
*
* @param expression source of values to compare against the pattern.
@@ -436,8 +409,7 @@
* @param isMatchingCase specifies how a filter expression processor should perform string comparisons.
* @return a character string comparison operator with pattern matching.
*/
- @Override
- public LikeOperator<R> like(final Expression<R,?> expression, final String pattern,
+ public Filter<R> like(final Expression<R,?> expression, final String pattern,
final char wildcard, final char singleChar, final char escape, final boolean isMatchingCase)
{
return new LikeFilter<>(expression, pattern, wildcard, singleChar, escape, isMatchingCase);
@@ -450,14 +422,13 @@
* @param expression source of values to compare against {@code null}.
* @return a filter that checks if an expression's value is {@code null}.
*/
- @Override
- public NullOperator<R> isNull(final Expression<R,?> expression) {
+ public Filter<R> isNull(final Expression<R,?> expression) {
return new UnaryFunction.IsNull<>(expression);
}
/**
* An operator that tests if an expression's value is nil.
- * The difference with {@link NullOperator} is that a value should exist
+ * The difference with {@code NullOperator} is that a value should exist
* but cannot be provided for the reason given by {@code nilReason}.
* Possible reasons are:
*
@@ -479,8 +450,7 @@
* @see org.apache.sis.xml.NilObject
* @see org.apache.sis.xml.NilReason
*/
- @Override
- public NilOperator<R> isNil(final Expression<R,?> expression, final String nilReason) {
+ public Filter<R> isNil(final Expression<R,?> expression, final String nilReason) {
return new UnaryFunction.IsNil<>(expression, nilReason);
}
@@ -490,11 +460,8 @@
* @param operand1 the first operand of the AND operation.
* @param operand2 the second operand of the AND operation.
* @return a filter evaluating {@code operand1 AND operand2}.
- *
- * @see LogicalOperatorName#AND
*/
- @Override
- public LogicalOperator<R> and(final Filter<R> operand1, final Filter<R> operand2) {
+ public Filter<R> and(final Filter<R> operand1, final Filter<R> operand2) {
ArgumentChecks.ensureNonNull("operand1", operand1);
ArgumentChecks.ensureNonNull("operand2", operand2);
return new LogicalFilter.And<>(operand1, operand2);
@@ -506,11 +473,8 @@
* @param operands a collection of at least 2 operands.
* @return a filter evaluating {@code operand1 AND operand2 AND operand3}…
* @throws IllegalArgumentException if the given collection contains less than 2 elements.
- *
- * @see LogicalOperatorName#AND
*/
- @Override
- public LogicalOperator<R> and(final Collection<? extends Filter<R>> operands) {
+ public Filter<R> and(final Collection<? extends Filter<R>> operands) {
return new LogicalFilter.And<>(operands);
}
@@ -520,11 +484,8 @@
* @param operand1 the first operand of the OR operation.
* @param operand2 the second operand of the OR operation.
* @return a filter evaluating {@code operand1 OR operand2}.
- *
- * @see LogicalOperatorName#OR
*/
- @Override
- public LogicalOperator<R> or(final Filter<R> operand1, final Filter<R> operand2) {
+ public Filter<R> or(final Filter<R> operand1, final Filter<R> operand2) {
ArgumentChecks.ensureNonNull("operand1", operand1);
ArgumentChecks.ensureNonNull("operand2", operand2);
return new LogicalFilter.Or<>(operand1, operand2);
@@ -536,11 +497,8 @@
* @param operands a collection of at least 2 operands.
* @return a filter evaluating {@code operand1 OR operand2 OR operand3}…
* @throws IllegalArgumentException if the given collection contains less than 2 elements.
- *
- * @see LogicalOperatorName#OR
*/
- @Override
- public LogicalOperator<R> or(final Collection<? extends Filter<R>> operands) {
+ public Filter<R> or(final Collection<? extends Filter<R>> operands) {
return new LogicalFilter.Or<>(operands);
}
@@ -549,11 +507,8 @@
*
* @param operand the operand of the NOT operation.
* @return a filter evaluating {@code NOT operand}.
- *
- * @see LogicalOperatorName#NOT
*/
- @Override
- public LogicalOperator<R> not(final Filter<R> operand) {
+ public Filter<R> not(final Filter<R> operand) {
return new LogicalFilter.Not<>(operand);
}
@@ -564,13 +519,8 @@
* @param geometry expression fetching the geometry to check for interaction with bounds.
* @param bounds the bounds to check geometry against.
* @return a filter checking for any interactions between the bounding boxes.
- *
- * @see SpatialOperatorName#BBOX
- *
- * @todo Maybe the expression parameterized type should extend {@link Geometry}.
*/
- @Override
- public BinarySpatialOperator<R> bbox(final Expression<R, ? extends G> geometry, final Envelope bounds) {
+ public Filter<R> bbox(final Expression<R, ? extends G> geometry, final Envelope bounds) {
return new BinarySpatialFilter<>(library, geometry, bounds, wraparound);
}
@@ -580,12 +530,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Equals" operation between the two geometries.
- *
- * @see SpatialOperatorName#EQUALS
*/
- @Override
- public BinarySpatialOperator<R> equals(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> equals(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.EQUALS, library, geometry1, geometry2);
}
@@ -596,12 +543,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Disjoint" operation between the two geometries.
- *
- * @see SpatialOperatorName#DISJOINT
*/
- @Override
- public BinarySpatialOperator<R> disjoint(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> disjoint(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.DISJOINT, library, geometry1, geometry2);
}
@@ -612,12 +556,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Intersects" operation between the two geometries.
- *
- * @see SpatialOperatorName#INTERSECTS
*/
- @Override
- public BinarySpatialOperator<R> intersects(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> intersects(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.INTERSECTS, library, geometry1, geometry2);
}
@@ -628,12 +569,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Touches" operation between the two geometries.
- *
- * @see SpatialOperatorName#TOUCHES
*/
- @Override
- public BinarySpatialOperator<R> touches(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> touches(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.TOUCHES, library, geometry1, geometry2);
}
@@ -644,12 +582,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Crosses" operation between the two geometries.
- *
- * @see SpatialOperatorName#CROSSES
*/
- @Override
- public BinarySpatialOperator<R> crosses(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> crosses(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.CROSSES, library, geometry1, geometry2);
}
@@ -661,12 +596,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Within" operation between the two geometries.
- *
- * @see SpatialOperatorName#WITHIN
*/
- @Override
- public BinarySpatialOperator<R> within(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> within(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.WITHIN, library, geometry1, geometry2);
}
@@ -677,12 +609,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Contains" operation between the two geometries.
- *
- * @see SpatialOperatorName#CONTAINS
*/
- @Override
- public BinarySpatialOperator<R> contains(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> contains(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.CONTAINS, library, geometry1, geometry2);
}
@@ -694,12 +623,9 @@
* @param geometry1 expression fetching the first geometry of the binary operator.
* @param geometry2 expression fetching the second geometry of the binary operator.
* @return a filter for the "Overlaps" operation between the two geometries.
- *
- * @see SpatialOperatorName#OVERLAPS
*/
- @Override
- public BinarySpatialOperator<R> overlaps(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
+ public Filter<R> overlaps(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2)
{
return new BinarySpatialFilter<>(SpatialOperatorName.OVERLAPS, library, geometry1, geometry2);
}
@@ -713,13 +639,10 @@
* @param distance minimal distance for evaluating the expression as {@code true}.
* @return operator that evaluates to {@code true} when all of a feature's geometry
* is more distant than the given distance from the second geometry.
- *
- * @see DistanceOperatorName#BEYOND
*/
- @Override
- public DistanceOperator<R> beyond(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2,
- final Quantity<Length> distance)
+ public Filter<R> beyond(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2,
+ final Quantity<Length> distance)
{
return new DistanceFilter<>(DistanceOperatorName.BEYOND, library, geometry1, geometry2, distance);
}
@@ -733,13 +656,10 @@
* @param distance maximal distance for evaluating the expression as {@code true}.
* @return operator that evaluates to {@code true} when any part of the feature's geometry
* lies within the given distance of the second geometry.
- *
- * @see DistanceOperatorName#WITHIN
*/
- @Override
- public DistanceOperator<R> within(final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2,
- final Quantity<Length> distance)
+ public Filter<R> within(final Expression<R, ? extends G> geometry1,
+ final Expression<R, ? extends G> geometry2,
+ final Quantity<Length> distance)
{
return new DistanceFilter<>(DistanceOperatorName.WITHIN, library, geometry1, geometry2, distance);
}
@@ -750,12 +670,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "After" operator between the two temporal values.
- *
- * @see TemporalOperatorName#AFTER
*/
- @Override
- public TemporalOperator<R> after(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> after(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.After::new, time1, time2);
}
@@ -766,12 +683,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "Before" operator between the two temporal values.
- *
- * @see TemporalOperatorName#BEFORE
*/
- @Override
- public TemporalOperator<R> before(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> before(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Before::new, time1, time2);
}
@@ -782,12 +696,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "Begins" operator between the two temporal values.
- *
- * @see TemporalOperatorName#BEGINS
*/
- @Override
- public TemporalOperator<R> begins(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> begins(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Begins::new, time1, time2);
}
@@ -798,12 +709,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "BegunBy" operator between the two temporal values.
- *
- * @see TemporalOperatorName#BEGUN_BY
*/
- @Override
- public TemporalOperator<R> begunBy(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> begunBy(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.BegunBy::new, time1, time2);
}
@@ -814,12 +722,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "TContains" operator between the two temporal values.
- *
- * @see TemporalOperatorName#CONTAINS
*/
- @Override
- public TemporalOperator<R> tcontains(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> tcontains(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Contains::new, time1, time2);
}
@@ -830,12 +735,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "During" operator between the two temporal values.
- *
- * @see TemporalOperatorName#DURING
*/
- @Override
- public TemporalOperator<R> during(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> during(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.During::new, time1, time2);
}
@@ -846,12 +748,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "TEquals" operator between the two temporal values.
- *
- * @see TemporalOperatorName#EQUALS
*/
- @Override
- public TemporalOperator<R> tequals(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> tequals(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Equals::new, time1, time2);
}
@@ -862,12 +761,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "TOverlaps" operator between the two temporal values.
- *
- * @see TemporalOperatorName#OVERLAPS
*/
- @Override
- public TemporalOperator<R> toverlaps(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> toverlaps(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Overlaps::new, time1, time2);
}
@@ -878,12 +774,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "Meets" operator between the two temporal values.
- *
- * @see TemporalOperatorName#MEETS
*/
- @Override
- public TemporalOperator<R> meets(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> meets(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Meets::new, time1, time2);
}
@@ -894,12 +787,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "Ends" operator between the two temporal values.
- *
- * @see TemporalOperatorName#ENDS
*/
- @Override
- public TemporalOperator<R> ends(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> ends(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.Ends::new, time1, time2);
}
@@ -910,12 +800,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "OverlappedBy" operator between the two temporal values.
- *
- * @see TemporalOperatorName#OVERLAPPED_BY
*/
- @Override
- public TemporalOperator<R> overlappedBy(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> overlappedBy(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.OverlappedBy::new, time1, time2);
}
@@ -926,12 +813,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "MetBy" operator between the two temporal values.
- *
- * @see TemporalOperatorName#MET_BY
*/
- @Override
- public TemporalOperator<R> metBy(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> metBy(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.MetBy::new, time1, time2);
}
@@ -942,12 +826,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "EndedBy" operator between the two temporal values.
- *
- * @see TemporalOperatorName#ENDED_BY
*/
- @Override
- public TemporalOperator<R> endedBy(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> endedBy(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.EndedBy::new, time1, time2);
}
@@ -959,12 +840,9 @@
* @param time1 expression fetching the first temporal value.
* @param time2 expression fetching the second temporal value.
* @return a filter for the "AnyInteracts" operator between the two temporal values.
- *
- * @see TemporalOperatorName#ANY_INTERACTS
*/
- @Override
- public TemporalOperator<R> anyInteracts(final Expression<R, ? extends T> time1,
- final Expression<R, ? extends T> time2)
+ public Filter<R> anyInteracts(final Expression<R, ? extends T> time1,
+ final Expression<R, ? extends T> time2)
{
return TemporalFilter.create(temporal, TemporalOperation.AnyInteracts::new, time1, time2);
}
@@ -975,10 +853,7 @@
* @param operand1 expression fetching the first number.
* @param operand2 expression fetching the second number.
* @return an expression for the "Add" function between the two numerical values.
- *
- * @todo Should we really restrict the type to {@link Number}?
*/
- @Override
public Expression<R,Number> add(final Expression<R, ? extends Number> operand1,
final Expression<R, ? extends Number> operand2)
{
@@ -991,10 +866,7 @@
* @param operand1 expression fetching the first number.
* @param operand2 expression fetching the second number.
* @return an expression for the "Subtract" function between the two numerical values.
- *
- * @todo Should we really restrict the type to {@link Number}?
*/
- @Override
public Expression<R,Number> subtract(final Expression<R, ? extends Number> operand1,
final Expression<R, ? extends Number> operand2)
{
@@ -1007,10 +879,7 @@
* @param operand1 expression fetching the first number.
* @param operand2 expression fetching the second number.
* @return an expression for the "Multiply" function between the two numerical values.
- *
- * @todo Should we really restrict the type to {@link Number}?
*/
- @Override
public Expression<R,Number> multiply(final Expression<R, ? extends Number> operand1,
final Expression<R, ? extends Number> operand2)
{
@@ -1023,10 +892,7 @@
* @param operand1 expression fetching the first number.
* @param operand2 expression fetching the second number.
* @return an expression for the "Divide" function between the two numerical values.
- *
- * @todo Should we really restrict the type to {@link Number}?
*/
- @Override
public Expression<R,Number> divide(final Expression<R, ? extends Number> operand1,
final Expression<R, ? extends Number> operand2)
{
@@ -1034,6 +900,35 @@
}
/**
+ * Creates an implementation-specific function with a single parameter.
+ *
+ * @param name name of the function to call.
+ * @param parameter expression providing values for the function argument.
+ * @return an expression which will call the specified function.
+ * @throws IllegalArgumentException if the given name is not recognized,
+ * or if the argument is illegal for the specified function.
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public Expression<R,?> function(String name, Expression<? super R, ?> parameter) {
+ return function(name, new Expression[] {parameter});
+ }
+
+ /**
+ * Creates an implementation-specific function with two parameters.
+ *
+ * @param name name of the function to call.
+ * @param param1 expression providing values for the first function argument.
+ * @param param2 expression providing values for the second function argument.
+ * @return an expression which will call the specified function.
+ * @throws IllegalArgumentException if the given name is not recognized,
+ * or if the arguments are illegal for the specified function.
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public Expression<R,?> function(String name, Expression<? super R, ?> param1, Expression<? super R, ?> param2) {
+ return function(name, new Expression[] {param1, param2});
+ }
+
+ /**
* Returns the provider for the function of the given name.
* If the given name is {@code null}, then this method only
* ensures that {@link #availableFunctions} is initialized.
@@ -1068,7 +963,6 @@
/**
* Creates an implementation-specific function.
- * The names of available functions is given by {@link #getCapabilities()}.
*
* @param name name of the function to call.
* @param parameters expressions providing values for the function arguments.
@@ -1076,7 +970,6 @@
* @throws IllegalArgumentException if the given name is not recognized,
* or if the arguments are illegal for the specified function.
*/
- @Override
public Expression<R,?> function(final String name, Expression<R,?>[] parameters) {
ArgumentChecks.ensureNonNull("name", name);
ArgumentChecks.ensureNonNull("parameters", parameters);
@@ -1090,107 +983,4 @@
}
return register.create(name, parameters);
}
-
- /**
- * Map of all functions supported by this factory, together with their providers.
- * This is a view over {@link #availableFunctions} which delegates descriptions
- * to {@link FunctionRegister#describe(String)}. No values is stored in this map.
- *
- * @see Capabilities#getFunctions()
- */
- final class Functions extends AbstractMap<String, AvailableFunction> {
- /**
- * Creates a new map.
- */
- Functions() {
- }
-
- /**
- * {@return the number of functions}.
- */
- @Override
- public int size() {
- synchronized (availableFunctions) {
- register(null); // Ensure that `availableFunctions` is initialized.
- return availableFunctions.size();
- }
- }
-
- /**
- * Returns the description of the function of the given name.
- * This method delegates to {@link FunctionRegister#describe(String)}.
- *
- * @param key name of the function to describe.
- * @return description of the requested function, or {@code null} if none.
- */
- @Override
- public AvailableFunction get(final Object key) {
- if (key instanceof String) {
- final String name = (String) key;
- final FunctionRegister register = register(name);
- if (register != null) {
- return register.describe(name);
- }
- }
- return null;
- }
-
- /**
- * {@return an iterator over the entries in this map}.
- */
- @Override
- protected EntryIterator<String, AvailableFunction> entryIterator() {
- final Iterator<Entry<String, FunctionRegister>> it;
- synchronized (availableFunctions) {
- register(null); // Ensure that `availableFunctions` is initialized.
- it = availableFunctions.entrySet().iterator();
- }
- /*
- * Following is theoretically not thread-safe, but it is okay in our case
- * because the `availableFunctions` map is not changed after construction.
- */
- return new EntryIterator<>() {
- private Entry<String, FunctionRegister> entry;
-
- @Override protected boolean next() {
- return (entry = it.hasNext() ? it.next() : null) != null;
- }
-
- @Override protected String getKey() {
- return entry.getKey();
- }
-
- @Override protected AvailableFunction getValue() {
- return entry.getValue().describe(getKey());
- }
- };
- }
- }
-
- /**
- * Indicates a property by which contents should be sorted, along with intended order.
- * The given expression should evaluate to {@link Comparable} objects,
- * but {@link Iterable} objects are accepted as well.
- *
- * @param property the property to sort by.
- * @param order the sorting order, ascending or descending.
- * @return definition of sort order of a property.
- */
- @Override
- public SortProperty<R> sort(final ValueReference<R,?> property, final SortOrder order) {
- return new DefaultSortProperty<>(property, order);
- }
-
- /**
- * Returns a string representation of this factory for debugging purposes.
- * The string returned by this method may change in any future version.
- *
- * @return a string representation for debugging purposes.
- *
- * @since 1.5
- */
- @Override
- public String toString() {
- return Strings.toString(getClass(), "spatial", library.library, "temporal", temporal.getSimpleName());
- }
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultSortProperty.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultSortProperty.java
index 6c67e14..9b4d59c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultSortProperty.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultSortProperty.java
@@ -23,10 +23,10 @@
import org.apache.sis.util.collection.Containers;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SortOrder;
-import org.opengis.filter.SortProperty;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SortOrder;
+import org.apache.sis.pending.geoapi.filter.SortProperty;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
index 3fd8a10..aae97ab 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
@@ -27,11 +27,9 @@
import org.apache.sis.geometry.wrapper.SpatialOperationContext;
import org.apache.sis.util.Exceptions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.DistanceOperator;
-import org.opengis.filter.DistanceOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
@@ -45,9 +43,9 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
-final class DistanceFilter<R> extends BinaryGeometryFilter<R> implements DistanceOperator<R> {
+final class DistanceFilter<R> extends BinaryGeometryFilter<R> {
/**
* For cross-version compatibility.
*/
@@ -125,7 +123,6 @@
/**
* Returns the buffer distance around the geometry that will be used when comparing features geometries.
*/
- @Override
public Quantity<Length> getDistance() {
return distance;
}
@@ -135,7 +132,6 @@
*
* @throws IllegalStateException if the geometry is not a literal.
*/
- @Override
public Geometry getGeometry() {
final Literal<R, ? extends GeometryWrapper> literal;
if (expression2 instanceof Literal<?,?>) {
@@ -151,7 +147,7 @@
/**
* Given an object, determines if the test(s) represented by this filter are passed.
*
- * @param object the object (often a {@link Feature} instance) to evaluate.
+ * @param object the object (often a {@code Feature} instance) to evaluate.
* @return {@code true} if the test(s) are passed for the provided object.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Expression.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Expression.java
new file mode 100644
index 0000000..82f2c09
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Expression.java
@@ -0,0 +1,81 @@
+/*
+ * 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.filter;
+
+import java.util.List;
+import java.util.function.Function;
+import org.opengis.util.ScopedName;
+
+
+/**
+ * A literal or a named procedure that performs a distinct computation.
+ *
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * This is a placeholder for a GeoAPI 3.1 interface not yet released.
+ * In a future version, all usages of this interface may be replaced
+ * by an interface of the same name but in the {@code org.opengis.filter} package
+ * instead of {@code org.apache.sis.filter}.
+ * </div>
+ *
+ * @param <R> the type of resources (e.g. {@code Feature}) used as inputs.
+ * @param <V> the type of values computed by the expression.
+ */
+public interface Expression<R,V> extends Function<R,V> {
+ /**
+ * Returns the name of the function to be called.
+ *
+ * @return name of the function to be called.
+ */
+ ScopedName getFunctionName();
+
+ /**
+ * Returns the class of resources expected by this expression.
+ *
+ * @return type of resources accepted by this expression.
+ */
+ Class<? super R> getResourceClass();
+
+ /**
+ * Returns the list sub-expressions that will be evaluated to provide the parameters to the function.
+ *
+ * @return the sub-expressions to be evaluated, or an empty list if none.
+ */
+ List<Expression<R,?>> getParameters();
+
+ /**
+ * Evaluates the expression value based on the content of the given object.
+ *
+ * @param input the object to be evaluated by the expression.
+ * Can be {@code null} if this expression allows null values.
+ * @return value computed by the expression.
+ * @throws NullPointerException if {@code input} is null and this expression requires non-null values.
+ * @throws IllegalArgumentException if the expression can not be applied on the given object.
+ */
+ @Override
+ V apply(R input);
+
+ /**
+ * Returns an expression doing the same evaluation than this method, but returning results
+ * as values of the specified type.
+ *
+ * @param <N> compile-time value of {@code type}.
+ * @param type desired type of expression results.
+ * @return expression doing the same operation this this expression but with results of the specified type.
+ * @throws ClassCastException if the specified type is not a target type supported by implementation.
+ */
+ <N> Expression<R,N> toValueType(Class<N> type);
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Filter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Filter.java
new file mode 100644
index 0000000..abada86
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Filter.java
@@ -0,0 +1,94 @@
+/*
+ * 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.filter;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+
+/**
+ * Identification of a subset of resources from a collection of resources
+ * whose property values satisfy a set of logically connected predicates.
+ *
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * This is a placeholder for a GeoAPI 3.1 interface not yet released.
+ * In a future version, all usages of this interface may be replaced
+ * by an interface of the same name but in the {@code org.opengis.filter} package
+ * instead of {@code org.apache.sis.filter}.
+ * </div>
+ *
+ * @param <R> the type of resources (e.g. {@link org.apache.sis.feature.AbstractFeature}) to filter.
+ *
+ * @since 1.1
+ */
+public interface Filter<R> extends Predicate<R> {
+ /**
+ * A filter that always evaluates to {@code true}.
+ *
+ * @param <R> the type of resources to filter.
+ * @return the "no filtering" filter.
+ */
+ @SuppressWarnings("unchecked")
+ static <R> Filter<R> include() {
+ return FilterLiteral.INCLUDE;
+ }
+
+ /**
+ * A filter that always evaluates to {@code false}.
+ *
+ * @param <R> the type of resources to filter.
+ * @return the "exclude all" filter.
+ */
+ @SuppressWarnings("unchecked")
+ static <R> Filter<R> exclude() {
+ return FilterLiteral.EXCLUDE;
+ }
+
+ /**
+ * Returns the nature of the operator.
+ *
+ * @return the nature of this operator.
+ */
+ Enum<?> getOperatorType();
+
+ /**
+ * Returns the class of resources expected by this filter.
+ *
+ * @return type of resources accepted by this filter.
+ *
+ * @since 1.4
+ */
+ Class<? super R> getResourceClass();
+
+ /**
+ * Returns the expressions used as arguments for this filter.
+ *
+ * @return the expressions used as inputs, or an empty list if none.
+ */
+ List<Expression<R,?>> getExpressions();
+
+ /**
+ * Given an object, determines if the test(s) represented by this filter are passed.
+ *
+ * @param object the object (often a {@code Feature} instance) to evaluate.
+ * @return {@code true} if the test(s) are passed for the provided object.
+ * @throws NullPointerException if {@code object} is null.
+ * @throws IllegalArgumentException if the filter can not be applied on the given object.
+ */
+ @Override
+ boolean test(R object);
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterLiteral.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterLiteral.java
new file mode 100644
index 0000000..d39cef5
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterLiteral.java
@@ -0,0 +1,70 @@
+/*
+ * 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.filter;
+
+import java.util.List;
+import java.util.Collections;
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+final class FilterLiteral implements Filter<Object>, Serializable {
+ @SuppressWarnings("rawtypes")
+ public static final Filter INCLUDE = new FilterLiteral(true);
+
+ @SuppressWarnings("rawtypes")
+ public static final Filter EXCLUDE = new FilterLiteral(false);
+
+ private final boolean value;
+
+ private FilterLiteral(final boolean value) {
+ this.value = value;
+ }
+
+ @Override
+ public Enum<?> getOperatorType() {
+ return value ? FilterName.INCLUDE : FilterName.EXCLUDE;
+ }
+
+ @Override
+ public Class<Object> getResourceClass() {
+ return Object.class;
+ }
+
+ @Override
+ public List<Expression<? super Object, ?>> getExpressions() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean test(Object object) {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return "Filter." + (value ? "INCLUDE" : "EXCLUDE");
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return value ? INCLUDE : EXCLUDE;
+ }
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterName.java
similarity index 77%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterName.java
index 8fb81f9..7f23319 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FilterName.java
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
+package org.apache.sis.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public interface Ellipse {
-
+enum FilterName {
+ RESOURCE_ID, INCLUDE, EXCLUDE;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
index 1789b46..810ede2 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
@@ -18,10 +18,6 @@
import java.util.Collection;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.capability.AvailableFunction;
-
/**
* A factory of {@code org.opengis.filter} functions identified by their names.
@@ -36,8 +32,6 @@
* @author Johann Sorel (Geomatys)
* @version 1.5
* @since 1.5
- *
- * @see org.opengis.filter.FilterFactory#function(String, Expression...)
*/
public interface FunctionRegister {
/**
@@ -57,18 +51,9 @@
Collection<String> getNames();
/**
- * Describes the parameters of a function.
- *
- * @param name name of the function to describe (not null).
- * @return description of the function parameters.
- * @throws IllegalArgumentException if function name is unknown..
- */
- AvailableFunction describe(String name) throws IllegalArgumentException;
-
- /**
* Creates a new function of the given name with given parameters.
*
- * @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.
* @param name name of the function to create (not null).
* @param parameters function parameters.
* @return function for the given name and parameters.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/IdentifierFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/IdentifierFilter.java
index 54bf782..4d3919e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/IdentifierFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/IdentifierFilter.java
@@ -22,11 +22,8 @@
import org.apache.sis.filter.internal.Node;
import org.apache.sis.feature.privy.AttributeConvention;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ResourceId;
-import org.opengis.filter.Filter;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -36,7 +33,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-final class IdentifierFilter extends Node implements ResourceId<Feature>, Optimization.OnFilter<Feature> {
+final class IdentifierFilter extends Node implements Optimization.OnFilter<AbstractFeature> {
/**
* For cross-version compatibility.
*/
@@ -55,12 +52,17 @@
this.identifier = identifier;
}
+ @Override
+ public Enum<?> getOperatorType() {
+ return FilterName.RESOURCE_ID;
+ }
+
/**
* Nothing to optimize here. The {@code Optimization.OnFilter} interface
* is implemented for inheriting the AND, OR and NOT methods overriding.
*/
@Override
- public Filter<Feature> optimize(Optimization optimization) {
+ public Filter<AbstractFeature> optimize(Optimization optimization) {
return this;
}
@@ -68,14 +70,13 @@
* Returns the class of resources expected by this expression.
*/
@Override
- public Class<Feature> getResourceClass() {
- return Feature.class;
+ public Class<AbstractFeature> getResourceClass() {
+ return AbstractFeature.class;
}
/**
* Returns the identifiers of feature instances to accept.
*/
- @Override
public String getIdentifier() {
return identifier;
}
@@ -84,7 +85,7 @@
* Returns the parameters of this filter.
*/
@Override
- public List<Expression<Feature,?>> getExpressions() {
+ public List<Expression<AbstractFeature,?>> getExpressions() {
return List.of(new LeafExpression.Literal<>(identifier));
}
@@ -98,11 +99,11 @@
}
/**
- * Returns {@code true} if the given object is a {@link Feature} instance and its identifier
+ * Returns {@code true} if the given object is a {@link AbstractFeature} instance and its identifier
* is one of the identifier specified at {@code IdentifierFilter} construction time.
*/
@Override
- public boolean test(final Feature object) {
+ public boolean test(final AbstractFeature object) {
if (object == null) {
return false;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/InvalidXPathException.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/InvalidXPathException.java
index 39c1a5d..aae8e46 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/InvalidXPathException.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/InvalidXPathException.java
@@ -16,9 +16,6 @@
*/
package org.apache.sis.filter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.InvalidFilterValueException;
-
/**
* Exception thrown when the XPath in an expression is invalid or unsupported.
@@ -38,7 +35,7 @@
*
* @since 1.5
*/
-public class InvalidXPathException extends InvalidFilterValueException {
+public class InvalidXPathException extends IllegalArgumentException {
/**
* Serial number for inter-operability with different versions.
*/
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LeafExpression.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LeafExpression.java
index a869d79..0c9958f 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LeafExpression.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LeafExpression.java
@@ -31,9 +31,8 @@
import org.apache.sis.filter.internal.Node;
import org.apache.sis.math.FunctionProperty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -43,7 +42,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <V> the type of value computed by the expression.
*/
abstract class LeafExpression<R,V> extends Node implements FeatureExpression<R,V> {
@@ -87,7 +86,7 @@
* @param <R> the type of resources used as inputs.
* @param <V> the type of value computed by the expression.
*/
- static class Literal<R,V> extends LeafExpression<R,V> implements org.opengis.filter.Literal<R,V> {
+ static class Literal<R,V> extends LeafExpression<R,V> implements org.apache.sis.pending.geoapi.filter.Literal<R,V> {
/** The properties of this function, which returns constants. */
private static final Set<FunctionProperty> CONSTANT =
Set.of(FunctionProperty.ORDER_PRESERVING, FunctionProperty.ORDER_REVERSING);
@@ -104,6 +103,10 @@
this.value = value; // Null is accepted.
}
+ @Override public Class<? super R> getResourceClass() {
+ return Object.class;
+ }
+
/** For {@link #toString()}, {@link #hashCode()} and {@link #equals(Object)} implementations. */
@Override protected Collection<?> getChildren() {
// Not `List.of(…)` because value may be null.
@@ -150,7 +153,7 @@
/**
* Provides the type of values returned by {@link #apply(Object)}.
- * The returned item wraps an {@link AttributeType} named "Literal".
+ * The returned item wraps an {@code AttributeType} named "Literal".
* The attribute type is determined by the class of the {@linkplain #value}.
*
* @param addTo where to add the type of properties evaluated by the given expression.
@@ -159,7 +162,7 @@
@Override
public FeatureProjectionBuilder.Item expectedType(final FeatureProjectionBuilder addTo) {
final Class<?> valueType = getValueClass();
- AttributeType<?> propertyType;
+ DefaultAttributeType<?> propertyType;
synchronized (TYPES) {
propertyType = TYPES.get(valueType);
if (propertyType == null) {
@@ -174,17 +177,17 @@
}
/**
- * A cache of {@link AttributeType} instances for literal classes. Used for avoiding to create
+ * A cache of {@link DefaultAttributeType} instances for literal classes. Used for avoiding to create
* duplicated instances when the literal is a common type like {@link String} or {@link Integer}.
*/
@SuppressWarnings("unchecked")
- private static final WeakValueHashMap<Class<?>, AttributeType<?>> TYPES = new WeakValueHashMap<>((Class) Class.class);
+ private static final WeakValueHashMap<Class<?>, DefaultAttributeType<?>> TYPES = new WeakValueHashMap<>((Class) Class.class);
/**
* Invoked when a new attribute type need to be created for the given standard type.
* The given standard type should be a GeoAPI interface, not the implementation class.
*/
- private static <R> AttributeType<R> newType(final Class<R> standardType) {
+ private static <R> DefaultAttributeType<R> newType(final Class<R> standardType) {
return createType(standardType, Names.createLocalName(null, null, "Literal"));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LikeFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LikeFilter.java
index 25a6870..f4e0df0 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LikeFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LikeFilter.java
@@ -22,10 +22,8 @@
import java.util.regex.Pattern;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.LikeOperator;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
/**
@@ -34,9 +32,9 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
-final class LikeFilter<R> extends Node implements LikeOperator<R>, Optimization.OnFilter<R> {
+final class LikeFilter<R> extends Node implements Optimization.OnFilter<R> {
/**
* For cross-version compatibility.
*/
@@ -150,6 +148,11 @@
this.regex = original.regex;
}
+ @Override
+ public ComparisonOperatorName getOperatorType() {
+ return ComparisonOperatorName.PROPERTY_IS_LIKE;
+ }
+
/**
* Creates a new filter of the same type but different parameters.
*/
@@ -187,7 +190,6 @@
* Returns the pattern character for matching any sequence of characters.
* For the SQL "{@code LIKE}" operator, this property is the {@code %} character.
*/
- @Override
public char getWildCard() {
return wildcard;
}
@@ -196,7 +198,6 @@
* Returns the pattern character for matching exactly one character.
* For the SQL "{@code LIKE}" operator, this property is the {@code _} character.
*/
- @Override
public char getSingleChar() {
return singleChar;
}
@@ -205,7 +206,6 @@
* Returns the pattern character for indicating that the next character should be matched literally.
* For the SQL "{@code LIKE}" operator, this property is the {@code '} character.
*/
- @Override
public char getEscapeChar() {
return escape;
}
@@ -213,7 +213,6 @@
/**
* Specifies how a filter expression processor should perform string comparisons.
*/
- @Override
public boolean isMatchingCase() {
return isMatchingCase;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LogicalFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LogicalFilter.java
index 42ef29a..6127180 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LogicalFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/LogicalFilter.java
@@ -25,10 +25,9 @@
import org.apache.sis.util.privy.CollectionsExt;
import org.apache.sis.util.privy.UnmodifiableArrayList;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
+import org.apache.sis.pending.geoapi.filter.LogicalOperatorName;
/**
@@ -38,7 +37,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Optimization.OnFilter<R> {
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Optimization.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Optimization.java
index 29b26bd..dca145e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Optimization.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/Optimization.java
@@ -29,13 +29,11 @@
import org.apache.sis.filter.internal.Node;
import org.apache.sis.util.privy.CollectionsExt;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
+import org.apache.sis.pending.geoapi.filter.LogicalOperatorName;
/**
@@ -90,7 +88,7 @@
/**
* The type of feature instances to be filtered, or {@code null} if unknown.
*/
- private FeatureType featureType;
+ private DefaultFeatureType featureType;
/**
* Filters and expressions already optimized. Also used for avoiding never-ending loops.
@@ -113,12 +111,12 @@
/**
* Returns the type of feature instances to be filtered, or {@code null} if unknown.
- * This is the last value specified by a call to {@link #setFeatureType(FeatureType)}.
+ * This is the last value specified by a call to {@link #setFeatureType(DefaultFeatureType)}.
* The default value is {@code null}.
*
* @return the type of feature instances to be filtered, or {@code null} if unknown.
*/
- public FeatureType getFeatureType() {
+ public DefaultFeatureType getFeatureType() {
return featureType;
}
@@ -130,7 +128,7 @@
*
* @param type the type of feature instances to be filtered, or {@code null} if unknown.
*/
- public void setFeatureType(final FeatureType type) {
+ public void setFeatureType(final DefaultFeatureType type) {
featureType = type;
}
@@ -448,7 +446,7 @@
if (filter == null) {
return List.of();
}
- final CodeList<?> type = filter.getOperatorType();
+ final Enum<?> type = filter.getOperatorType();
if (type == LogicalOperatorName.AND) {
return ((LogicalOperator<R>) filter).getOperands();
}
@@ -538,7 +536,7 @@
*
* @see DefaultFilterFactory#literal(Object)
*/
- public static <R,V> Literal<R,V> literal(final V value) {
+ public static <R,V> Expression<R,V> literal(final V value) {
return new LeafExpression.Literal<>(value);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/PropertyValue.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/PropertyValue.java
index 29e203d..e32e0d0 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/PropertyValue.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/PropertyValue.java
@@ -27,13 +27,14 @@
import org.apache.sis.filter.privy.XPath;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.opengis.util.ScopedName;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.Name;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -48,8 +49,8 @@
*
* @see AssociationValue
*/
-abstract class PropertyValue<V> extends LeafExpression<Feature,V>
- implements ValueReference<Feature,V>, Optimization.OnExpression<Feature,V>
+abstract class PropertyValue<V> extends LeafExpression<AbstractFeature,V>
+ implements ValueReference<AbstractFeature,V>, Optimization.OnExpression<AbstractFeature,V>
{
/**
* For cross-version compatibility.
@@ -82,6 +83,11 @@
this.isVirtual = isVirtual;
}
+ @Override
+ public final ScopedName getFunctionName() {
+ return Name.VALUE_REFERENCE;
+ }
+
/**
* Creates a new expression retrieving values from a property of the given path.
* Simple path expressions of the form "a/b/c" can be used.
@@ -93,7 +99,7 @@
* @throws IllegalArgumentException if the given XPath is not supported.
*/
@SuppressWarnings("unchecked")
- static <V> ValueReference<Feature,V> create(final String xpath, final Class<V> type) {
+ static <V> ValueReference<AbstractFeature,V> create(final String xpath, final Class<V> type) {
final var parsed = new XPath(xpath);
List<String> path = parsed.path;
boolean isVirtual = false;
@@ -125,8 +131,8 @@
* Returns the class of resources expected by this expression.
*/
@Override
- public final Class<Feature> getResourceClass() {
- return Feature.class;
+ public final Class<AbstractFeature> getResourceClass() {
+ return AbstractFeature.class;
}
/**
@@ -158,7 +164,7 @@
}
/**
- * Returns the type of values fetched from {@link Feature} instance.
+ * Returns the type of values fetched from {@link AbstractFeature} instance.
* This is the type before conversion to the {@linkplain #getValueClass() target type}.
* The type is always {@link Object} on newly created expression because the type of feature property
* values is unknown, but may become a specialized type after {@link Optimization} has been applied.
@@ -229,7 +235,7 @@
* If no value is found for the given feature, then this method returns {@code null}.
*/
@Override
- public Object apply(final Feature instance) {
+ public Object apply(final AbstractFeature instance) {
return (instance != null) ? instance.getValueOrFallback(name, null) : null;
}
@@ -241,11 +247,11 @@
*/
@Override
public PropertyValue<Object> optimize(final Optimization optimization) {
- final FeatureType type = optimization.getFeatureType();
+ final DefaultFeatureType type = optimization.getFeatureType();
if (type != null) try {
return Features.getLinkTarget(type.getProperty(name))
.map((rename) -> new AsObject(rename, isVirtual)).orElse(this);
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
warning(e, true);
}
return this;
@@ -292,11 +298,14 @@
* If no value is found for the given feature, then this method returns {@code null}.
*/
@Override
- public V apply(final Feature instance) {
+ public V apply(final AbstractFeature instance) {
if (instance != null) try {
return ObjectConverters.convert(instance.getValueOrFallback(name, null), type);
} catch (UnconvertibleObjectException e) {
warning(e, false);
+ } catch (IllegalArgumentException e) {
+ warning(e, true);
+ // Null will be returned below.
}
return null;
}
@@ -308,7 +317,7 @@
*/
@Override
public final PropertyValue<V> optimize(final Optimization optimization) {
- final FeatureType featureType = optimization.getFeatureType();
+ final DefaultFeatureType featureType = optimization.getFeatureType();
if (featureType != null) try {
/*
* Resolve link (e.g. "sis:identifier" as a reference to the real identifier property).
@@ -316,12 +325,12 @@
* If there is no renaming to apply (which is the usual case), then `rename` is null.
*/
String rename = name;
- PropertyType property = featureType.getProperty(rename);
+ AbstractIdentifiedType property = featureType.getProperty(rename);
Optional<String> target = Features.getLinkTarget(property);
if (target.isPresent()) try {
rename = target.get();
property = featureType.getProperty(rename);
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
warning(e, true);
rename = name;
}
@@ -332,8 +341,8 @@
*/
Class<?> source = getSourceClass();
final Class<?> original = source;
- if (property instanceof AttributeType<?>) {
- source = ((AttributeType<?>) property).getValueClass();
+ if (property instanceof DefaultAttributeType<?>) {
+ source = ((DefaultAttributeType<?>) property).getValueClass();
}
if (!(rename.equals(name) && source.equals(original))) {
if (source == Object.class) {
@@ -342,7 +351,7 @@
return new CastedAndConverted<>(source, type, rename, isVirtual);
}
}
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
warning(e, true);
}
return this;
@@ -376,14 +385,14 @@
*
* @param addTo where to add the type of properties evaluated by this expression.
* @return builder of the added property, or {@code null} if this method cannot add a property.
- * @throws PropertyNotFoundException if the property was not found in {@code addTo.source()}.
+ * @throws IllegalArgumentException if this method cannot determine the property type for the given feature type.
*/
@Override
public FeatureProjectionBuilder.Item expectedType(final FeatureProjectionBuilder addTo) {
- PropertyType type;
+ AbstractIdentifiedType type;
try {
type = addTo.source().getProperty(name);
- } catch (PropertyNotFoundException e) {
+ } catch (IllegalArgumentException e) {
if (isVirtual) {
// The property does not exist but may be defined in a yet unknown child type.
return defaultType(addTo);
@@ -423,7 +432,7 @@
}
/**
- * Returns the type of values fetched from {@link Feature} instance.
+ * Returns the type of values fetched from {@link AbstractFeature} instance.
*/
@Override
protected Class<S> getSourceClass() {
@@ -435,11 +444,13 @@
* If no value is found for the given feature, then this method returns {@code null}.
*/
@Override
- public V apply(final Feature instance) {
+ public V apply(final AbstractFeature instance) {
if (instance != null) try {
return converter.apply(source.cast(instance.getValueOrFallback(name, null)));
} catch (ClassCastException | UnconvertibleObjectException e) {
warning(e, false);
+ } catch (IllegalArgumentException e) {
+ warning(e, true);
}
return null;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
index a8c05ad..af083af 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
@@ -22,13 +22,9 @@
import org.apache.sis.temporal.TimeMethods;
import org.apache.sis.feature.privy.FeatureExpression;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.TemporalOperator;
-import org.opengis.filter.TemporalOperatorName;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -39,11 +35,11 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <T> the base type of temporal objects, or {@code Object.class} for any type.
*/
class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
- implements TemporalOperator<R>, Optimization.OnFilter<R>
+ implements Filter<R>, Optimization.OnFilter<R>
{
/**
* For cross-version compatibility.
@@ -180,7 +176,7 @@
* Determines if the test(s) represented by this filter passes with the given operands.
* Values of {@link #expression1} and {@link #expression2} shall be two single values.
*
- * @throws InvalidFilterValueException if two temporal objects cannot be compared.
+ * @throws IllegalArgumentException if two temporal objects cannot be compared.
*/
@Override
public boolean test(final R candidate) {
@@ -200,7 +196,7 @@
return operation.evaluate(left, right);
}
} catch (DateTimeException e) {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.CannotCompareInstanceOf_2, left.getClass(), right.getClass()), e);
}
}
@@ -239,7 +235,7 @@
if (right != null) try {
return operation.evaluate(left, right);
} catch (DateTimeException e) {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.CannotCompareInstanceOf_2, left.getClass(), right.getClass()), e);
}
}
@@ -279,7 +275,7 @@
if (right != null) try {
return operation.evaluate(left, right);
} catch (DateTimeException e) {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.CannotCompareInstanceOf_2, left.getClass(), right.getClass()), e);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalOperation.java
index 5eef593..c95e471 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalOperation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalOperation.java
@@ -27,11 +27,11 @@
import static org.apache.sis.temporal.TimeMethods.AFTER;
import static org.apache.sis.temporal.TimeMethods.EQUAL;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.IndeterminateValue;
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
+import org.apache.sis.pending.geoapi.temporal.Instant;
+import org.apache.sis.pending.geoapi.temporal.IndeterminateValue;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/UnaryFunction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/UnaryFunction.java
index ee78c0e..eefd5a1 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/UnaryFunction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/UnaryFunction.java
@@ -23,11 +23,8 @@
import org.apache.sis.xml.NilReason;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.NilOperator;
-import org.opengis.filter.NullOperator;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
/**
@@ -37,7 +34,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <V> the type of value computed by the expression.
*/
class UnaryFunction<R,V> extends Node {
@@ -107,8 +104,8 @@
* @param <R> the type of resources used as inputs.
*/
static final class IsNull<R> extends UnaryFunction<R,Object>
- implements NullOperator<R>, Optimization.OnFilter<R>
- {
+ implements Filter<R>, Optimization.OnFilter<R>
+ {
/** For cross-version compatibility. */
private static final long serialVersionUID = 2960285515924533419L;
@@ -117,6 +114,10 @@
super(expression);
}
+ @Override public ComparisonOperatorName getOperatorType() {
+ return ComparisonOperatorName.PROPERTY_IS_NULL;
+ }
+
/** Creates a new filter of the same type but different parameters. */
@Override public Filter<R> recreate(final Expression<R,?>[] effective) {
return new IsNull<>(effective[0]);
@@ -142,7 +143,7 @@
* @param <R> the type of resources used as inputs.
*/
static final class IsNil<R> extends UnaryFunction<R,Object>
- implements NilOperator<R>, Optimization.OnFilter<R>
+ implements Filter<R>, Optimization.OnFilter<R>
{
/** For cross-version compatibility. */
private static final long serialVersionUID = -7540765433296725888L;
@@ -156,13 +157,17 @@
this.nilReason = nilReason;
}
+ @Override public ComparisonOperatorName getOperatorType() {
+ return ComparisonOperatorName.PROPERTY_IS_NIL;
+ }
+
/** Creates a new filter of the same type but different parameters. */
@Override public Filter<R> recreate(final Expression<R,?>[] effective) {
return new IsNil<>(effective[0], nilReason);
}
/** Returns the reason why the value is nil. */
- @Override public Optional<String> getNilReason() {
+ public Optional<String> getNilReason() {
return Optional.ofNullable(nilReason);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryConverter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryConverter.java
index 5e77717..6e28225 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryConverter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryConverter.java
@@ -32,10 +32,9 @@
import org.apache.sis.feature.internal.Resources;
import org.apache.sis.filter.Optimization;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.filter.Expression;
/**
@@ -45,7 +44,7 @@
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*
- * @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.
* @param <G> the geometry implementation type.
*
* @see org.apache.sis.filter.ConvertFunction
@@ -103,7 +102,7 @@
if (library.equals(candidate.library)) {
return (GeometryConverter<R,G>) expression;
}
- throw new InvalidFilterValueException(Resources.format(
+ throw new IllegalArgumentException(Resources.format(
Resources.Keys.MixedGeometryImplementation_2,
library.library, candidate.library.library));
}
@@ -173,7 +172,7 @@
*
* @param input the geometry to evaluate with this expression.
* @return the geometry wrapper, or {@code null} if the evaluated value is null.
- * @throws InvalidFilterValueException if the expression result is not an instance of a supported type.
+ * @throws IllegalArgumentException if the expression result is not an instance of a supported type.
*/
@Override
public GeometryWrapper apply(final R input) {
@@ -190,7 +189,7 @@
return library.castOrWrap(value);
}
} catch (ClassCastException | MismatchedDimensionException e) {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalClass_2, library.rootClass, Classes.getClass(value)), e);
}
return library.toGeometry2D(envelope, WraparoundMethod.NONE);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryFromFeature.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryFromFeature.java
index 178a668..c221faf 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryFromFeature.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/GeometryFromFeature.java
@@ -22,11 +22,10 @@
import org.apache.sis.feature.privy.AttributeConvention;
import org.apache.sis.filter.privy.XPath;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -38,7 +37,7 @@
*
* @param <G> the geometry implementation type.
*/
-final class GeometryFromFeature<G> extends GeometryConverter<Feature, G> {
+final class GeometryFromFeature<G> extends GeometryConverter<AbstractFeature, G> {
/**
* For cross-version compatibility.
*/
@@ -56,7 +55,7 @@
* @param library the geometry library to use.
* @param expression the expression providing geometric objects of the given library.
*/
- private GeometryFromFeature(Geometries<G> library, Expression<Feature,?> expression, String propertyName) {
+ private GeometryFromFeature(Geometries<G> library, Expression<AbstractFeature,?> expression, String propertyName) {
super(library, expression);
this.propertyName = propertyName;
}
@@ -69,7 +68,7 @@
* @return the geometry converter, or {@code null} if the given expression cannot be used.
*/
static <G> GeometryFromFeature<G> tryCreate(final Geometries<G> library, final Expression<?,?> expression) {
- if (Feature.class.isAssignableFrom(expression.getResourceClass()) && expression instanceof ValueReference<?,?>) {
+ if (AbstractFeature.class.isAssignableFrom(expression.getResourceClass()) && expression instanceof ValueReference<?,?>) {
final var xpath = new XPath(((ValueReference<?,?>) expression).getXPath());
if (xpath.path == null) {
/*
@@ -78,7 +77,7 @@
* ignore the fact that <R> may be a subtype of `Feature`.
*/
@SuppressWarnings("unchecked")
- final var ve = (Expression<Feature,?>) expression;
+ final var ve = (Expression<AbstractFeature,?>) expression;
return new GeometryFromFeature<>(library, ve, xpath.tip);
}
}
@@ -95,7 +94,7 @@
* @throws InvalidFilterValueException if the expression result is not an instance of a supported type.
*/
@Override
- public GeometryWrapper apply(final Feature input) {
+ public GeometryWrapper apply(final AbstractFeature input) {
final GeometryWrapper wrapper = super.apply(input);
if (wrapper.getCoordinateReferenceSystem() == null) {
final CoordinateReferenceSystem crs = AttributeConvention.getCRSCharacteristic(input, propertyName);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/Node.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/Node.java
index 5be96dd..45fd2b8 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/Node.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/Node.java
@@ -44,11 +44,9 @@
import org.apache.sis.util.logging.Logging;
import org.apache.sis.system.Loggers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
/**
@@ -93,10 +91,10 @@
*
* @see Expression#getFunctionName()
*/
- protected static <T> AttributeType<T> createType(final Class<T> type, final Object name) {
+ protected static <T> DefaultAttributeType<T> createType(final Class<T> type, final Object name) {
// We do not use `Map.of(…)` for better exception message in case of null name.
return new DefaultAttributeType<>(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name),
- type, 1, 1, null, (AttributeType<?>[]) null);
+ type, 1, 1, null, (DefaultAttributeType<?>[]) null);
}
/**
@@ -171,12 +169,12 @@
* Returns an expression whose results is a geometry wrapper.
* Note that the {@code apply(R)} method of the returned expression may throw {@link BackingStoreException}.
*
- * @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.
* @param <G> the geometry implementation type.
* @param library the geometry library to use.
* @param expression the expression providing geometry instances of the given library.
* @return an expression whose results is a geometry wrapper.
- * @throws InvalidFilterValueException if the given expression is already a wrapper
+ * @throws IllegalArgumentException if the given expression is already a wrapper
* but for another geometry implementation.
*/
protected static <R,G> Expression<R, GeometryWrapper> toGeometryWrapper(
@@ -189,7 +187,7 @@
* If the given exception was wrapped by {@link #toGeometryWrapper(Geometries, Expression)},
* returns the original expression. Otherwise, returns the given expression as-is.
*
- * @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.
* @param expression the expression to unwrap.
* @return the unwrapped expression.
*/
@@ -213,7 +211,7 @@
if (expression instanceof GeometryConverter<?,?>) {
return ((GeometryConverter<?,?>) expression).library;
}
- throw new InvalidFilterValueException(Resources.format(Resources.Keys.NotAGeometryAtFirstExpression));
+ throw new IllegalArgumentException(Resources.format(Resources.Keys.NotAGeometryAtFirstExpression));
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/package-info.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/package-info.java
index d944af3..1100972 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/package-info.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/package-info.java
@@ -34,7 +34,7 @@
* <li>For other operations, the common CRS is chosen by
* {@linkplain org.apache.sis.referencing.CRS#suggestCommonTarget referencing utility method}.
* If that method cannot provide a common space,
- * then an {@link org.opengis.filter.InvalidFilterValueException} is thrown.</li>
+ * then an {@link java.lang.IllegalArgumentException} is thrown.</li>
* </ul>
* </li>
* </ul>
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/CopyVisitor.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/CopyVisitor.java
deleted file mode 100644
index e274fcd..0000000
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/CopyVisitor.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * 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.filter.privy;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Objects;
-import javax.measure.Quantity;
-import javax.measure.quantity.Length;
-import org.opengis.util.CodeList;
-import org.opengis.geometry.Envelope;
-import org.opengis.filter.*;
-import org.apache.sis.util.privy.CollectionsExt;
-import org.apache.sis.util.resources.Errors;
-import org.apache.sis.feature.internal.Resources;
-
-
-/**
- * Visitor used to copy expressions and filters with potentially a change of parameterized types.
- * This class can be used when filters need to be recreated using a different {@link FilterFactory},
- * for example because the type of resources changed. For example different filter implementations
- * may be needed if the filters need to operate on {@link org.apache.sis.coverage.grid.GridCoverage}
- * resources instead of {@link org.opengis.feature.Feature} instances.
- *
- * @author Johann Sorel (Geomatys)
- * @author Martin Desruisseaux (Geomatys)
- *
- * @param <SR> the type of resources expected by the filters to copy (source resource).
- * @param <TR> the type of resources expected by the copied filters (target resource).
- * @param <G> base class of geometry objects.
- * @param <T> base class of temporal objects.
- */
-public class CopyVisitor<SR,TR,G,T> extends Visitor<SR, List<Object>> {
- /**
- * The factory to use for creating the new filters and expressions.
- * Note that some methods in this factory may return {@code null}.
- * See <cite>Partially implemented factory</cite> in {@link EditVisitor} Javadoc.
- */
- protected final FilterFactory<TR,G,T> factory;
-
- /**
- * Whether to force creation of new filters or expressions even when the operands did not changed.
- * If {@code false}, new filters and expressions are created only when at least one operand changed.
- * This flag should be {@code true} if the {@code <SR>} and {@code <TR>} types are not the same,
- * or if the user knows that the {@linkplain #factory} may create a different kind of object even
- * when the operands are the same.
- */
- private final boolean forceNew;
-
- /**
- * Whether to force the use of newly created filters or expressions even when they are equal to the original ones.
- * If {@code false}, then the previously existing filters or expressions will be reused when the newly created
- * instances are equal according to {@link Object#equals(Object)}. Note this sharing requires that the filter
- * or expression to reuse expects a base resource type {@code <R>} which is common to both {@code <? super SR>}
- * and {@code <? super TR>}. We have no way to verify that.
- *
- * <p>This flag should be {@code true} if the filters or expressions are mutable.
- * Otherwise it may be {@code false} as a way to share existing instances.</p>
- */
- private final boolean forceUse;
-
- /**
- * The factory method to invoke for creating a binary comparison operator.
- * This is used for invoking one of the {@link FilterFactory} methods for
- * a given {@link ComparisonOperatorName}. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, FilterFactory::equal);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- *
- * @see CopyVisitor#setCopyHandler(ComparisonOperatorName, BinaryComparisonFactory)
- */
- @FunctionalInterface
- protected interface BinaryComparisonFactory<R> {
- /**
- * Creates a new binary comparison operator from the given operands.
- *
- * @param factory the factory to use for creating the filter
- * @param expression1 the first of the two expressions to be used by this comparator.
- * @param expression2 the second of the two expressions to be used by this comparator.
- * @param isMatchingCase specifies whether comparisons are case sensitive.
- * @param matchAction specifies how the comparisons shall be evaluated for a collection of values.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- */
- BinaryComparisonOperator<R> create(
- FilterFactory<R,?,?> factory,
- Expression<R,?> expression1,
- Expression<R,?> expression2,
- boolean isMatchingCase, MatchAction matchAction);
- }
-
- /**
- * The factory method to invoke for creating a temporal operator.
- * This is used for invoking one of the {@link FilterFactory} methods
- * for a given {@link TemporalOperatorName}. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(TemporalOperatorName.AFTER, FilterFactory::after);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- * @param <T> base class of temporal objects specified by the enclosing class.
- *
- * @see CopyVisitor#setCopyHandler(TemporalOperatorName, TemporalComparisonFactory)
- */
- @FunctionalInterface
- protected interface TemporalFactory<R,T> {
- /**
- * Creates a new temporal operator from the given operands.
- *
- * @param factory the factory to use for creating the filter.
- * @param time1 expression fetching the first temporal value.
- * @param time2 expression fetching the second temporal value.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- */
- TemporalOperator<R> create(
- FilterFactory<R,?,T> factory,
- Expression<R, ? extends T> time1,
- Expression<R, ? extends T> time2);
- }
-
- /**
- * The factory method to invoke for creating a spatial operator.
- * This is used for invoking one of the {@link FilterFactory} methods
- * for a given {@link SpatialOperatorName}. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(SpatialOperatorName.EQUALS, FilterFactory::equals);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- * @param <G> base class of geometry objects specified by the enclosing class.
- *
- * @see CopyVisitor#setCopyHandler(SpatialOperatorName, SpatialFactory)
- */
- @FunctionalInterface
- protected interface SpatialFactory<R,G> {
- /**
- * Creates a new spatial operator from the given operands.
- *
- * @param factory the factory to use for creating the filter.
- * @param geometry1 expression fetching the first geometry of the binary operator.
- * @param geometry2 expression fetching the second geometry of the binary operator.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- */
- BinarySpatialOperator<R> create(
- FilterFactory<R,G,?> factory,
- Expression<R, ? extends G> geometry1,
- Expression<R, ? extends G> geometry2);
-
- /**
- * Bridge for the "bbox" operation, because it uses a different method signature.
- * Usage example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(SpatialOperatorName.BBOX, SpatialFactory::bbox);
- * }
- *
- * @param <R> the {@link CopyVisitor} type of resources.
- * @param <G> base class of geometry objects specified by {@code CopyVisitor}.
- * @param factory the factory to use for creating the filter.
- * @param geometry1 expression fetching the geometry to check for interaction with bounds.
- * @param geometry2 the bounds to check geometry against.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- *
- * @see SpatialOperatorName#BBOX
- */
- static <R,G> BinarySpatialOperator<R> bbox(
- final FilterFactory<R,G,?> factory,
- final Expression<R, ? extends G> geometry1,
- final Expression<R, ? extends G> geometry2)
- {
- if (geometry2 instanceof Literal<?,?>) {
- final Object bounds = ((Literal<?,?>) geometry2).getValue();
- if (bounds instanceof Envelope) {
- return factory.bbox(geometry1, (Envelope) bounds);
- }
- }
- return null;
- }
- }
-
- /**
- * The factory method to invoke for creating a distance operator.
- * This is used for invoking one of the {@link FilterFactory} methods
- * for a given {@link DistanceOperatorName}. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(DistanceOperatorName.BEYOND, FilterFactory::beyond);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- * @param <G> base class of geometry objects specified by the enclosing class.
- *
- * @see CopyVisitor#setCopyHandler(DistanceOperatorName, DistanceFactory)
- */
- @FunctionalInterface
- protected interface DistanceFactory<R,G> {
- /**
- * Creates a new spatial operator from the given operands.
- *
- * @param factory the factory to use for creating the filter.
- * @param geometry1 expression fetching the first geometry of the binary operator.
- * @param geometry2 expression fetching the second geometry of the binary operator.
- * @param distance distance for evaluating the expression as {@code true}.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- */
- DistanceOperator<R> create(
- FilterFactory<R,G,?> factory,
- Expression<R, ? extends G> geometry1,
- Expression<R, ? extends G> geometry2,
- Quantity<Length> distance);
- }
-
- /**
- * The factory method to invoke for creating a logical operator.
- * This is used for invoking one of the {@link FilterFactory}
- * methods for a given {@link LogicalOperatorName}. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(LogicalOperatorName.AND, FilterFactory::and);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- *
- * @see CopyVisitor#setCopyHandler(LogicalOperatorName, LogicalFactory)
- */
- @FunctionalInterface
- protected interface LogicalFactory<R> {
- /**
- * Creates a new binary comparison operator from the given operands.
- *
- * @param factory the factory to use for creating the filter.
- * @param operands a collection of operands.
- * @return the new filter, or {@code null} if this method cannot create a filter from the given arguments.
- */
- LogicalOperator<R> create(
- FilterFactory<R,?,?> factory,
- Collection<? extends Filter<R>> operands);
-
- /**
- * Bridge for the "not" operation, because it uses a different method signature.
- * This method signature shall be identical to {@code create(…)} method signature.
- * Usage example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler(LogicalOperatorName.NOT, LogicalFactory::not);
- * }
- *
- * @param <R> the {@link CopyVisitor} type of resources.
- * @param factory the factory to use for creating the filter.
- * @param operands the operand of the NOT operation.
- * @return a filter evaluating {@code NOT operand}.
- */
- static <R> LogicalOperator<R> not(
- final FilterFactory<R,?,?> factory,
- final Collection<? extends Filter<R>> operands)
- {
- Filter<R> op = CollectionsExt.singletonOrNull(operands);
- return (op != null) ? factory.not(op) : null;
- }
- }
-
- /**
- * The factory method to invoke for creating a binary function.
- * This is used for invoking one of the {@link FilterFactory}
- * methods for a given arithmetic function name. Example:
- *
- * {@snippet lang="java" :
- * copyVisitor.setCopyHandler("Multiply", FilterFactory::multiply);
- * }
- *
- * @param <R> the same type of resources specified by the enclosing {@link CopyVisitor} class.
- *
- * @see CopyVisitor#setCopyHandler(String, BinaryFunctionFactory)
- */
- @FunctionalInterface
- protected interface BinaryFunctionFactory<R> {
- /**
- * Creates a new binary function from the given operands.
- *
- * @param factory the factory to use for creating the filter.
- * @param operand1 the first of the two expressions to be used by this function.
- * @param operand2 the second of the two expressions to be used by this function.
- * @return the new expression, or {@code null} if this method cannot create an expression from the given arguments.
- */
- Expression<R,Number> create(
- FilterFactory<R,?,?> factory,
- Expression<R, ? extends Number> operand1,
- Expression<R, ? extends Number> operand2);
- }
-
- /**
- * Creates a new copy visitor with the given factory.
- *
- * @param factory the factory to use for creating the new filters and expressions.
- * @param force whether to force new filters or expressions even when existing instances could be reused.
- */
- public CopyVisitor(final FilterFactory<TR,G,T> factory, final boolean force) {
- this(factory, true, force);
- }
-
- /**
- * Creates a new copy visitor with the given factory.
- * The {@code forceNew} argument can be {@code false}
- * only if {@code <SR>} and {@code <TR>} are the same type.
- *
- * @param newFactory the factory to use for creating the new filters and expressions.
- * @param forceNew whether to force creation of new filters or expressions even when the operands did not changed.
- * @param forceUse whether to force the use of newly created filters or expressions even when they are equal to the original ones.
- */
- @SuppressWarnings("this-escape")
- CopyVisitor(final FilterFactory<TR,G,T> newFactory, final boolean forceNew, final boolean forceUse) {
- this.factory = Objects.requireNonNull(newFactory);
- this.forceNew = forceNew;
- this.forceUse = forceUse;
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, FilterFactory::equal);
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_NOT_EQUAL_TO, FilterFactory::notEqual);
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_LESS_THAN, FilterFactory::less);
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN, FilterFactory::greater);
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO, FilterFactory::lessOrEqual);
- setCopyHandler(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO, FilterFactory::greaterOrEqual);
- setCopyHandler( TemporalOperatorName.AFTER, FilterFactory::after);
- setCopyHandler( TemporalOperatorName.BEFORE, FilterFactory::before);
- setCopyHandler( TemporalOperatorName.BEGINS, FilterFactory::begins);
- setCopyHandler( TemporalOperatorName.BEGUN_BY, FilterFactory::begunBy);
- setCopyHandler( TemporalOperatorName.CONTAINS, FilterFactory::tcontains);
- setCopyHandler( TemporalOperatorName.DURING, FilterFactory::during);
- setCopyHandler( TemporalOperatorName.EQUALS, FilterFactory::tequals);
- setCopyHandler( TemporalOperatorName.OVERLAPS, FilterFactory::toverlaps);
- setCopyHandler( TemporalOperatorName.MEETS, FilterFactory::meets);
- setCopyHandler( TemporalOperatorName.ENDS, FilterFactory::ends);
- setCopyHandler( TemporalOperatorName.OVERLAPPED_BY, FilterFactory::overlappedBy);
- setCopyHandler( TemporalOperatorName.MET_BY, FilterFactory::metBy);
- setCopyHandler( TemporalOperatorName.ENDED_BY, FilterFactory::endedBy);
- setCopyHandler( TemporalOperatorName.ANY_INTERACTS, FilterFactory::anyInteracts);
- setCopyHandler( SpatialOperatorName.BBOX, SpatialFactory::bbox);
- setCopyHandler( SpatialOperatorName.EQUALS, FilterFactory::equals);
- setCopyHandler( SpatialOperatorName.DISJOINT, FilterFactory::disjoint);
- setCopyHandler( SpatialOperatorName.INTERSECTS, FilterFactory::intersects);
- setCopyHandler( SpatialOperatorName.TOUCHES, FilterFactory::touches);
- setCopyHandler( SpatialOperatorName.CROSSES, FilterFactory::crosses);
- setCopyHandler( SpatialOperatorName.WITHIN, FilterFactory::within);
- setCopyHandler( SpatialOperatorName.CONTAINS, FilterFactory::contains);
- setCopyHandler( SpatialOperatorName.OVERLAPS, FilterFactory::overlaps);
- setCopyHandler( DistanceOperatorName.WITHIN, FilterFactory::within);
- setCopyHandler( DistanceOperatorName.BEYOND, FilterFactory::beyond);
- setCopyHandler( LogicalOperatorName.AND, FilterFactory::and);
- setCopyHandler( LogicalOperatorName.OR, FilterFactory::or);
- setCopyHandler( LogicalOperatorName.NOT, LogicalFactory::not);
- setCopyHandler( FunctionNames.Add, FilterFactory::add);
- setCopyHandler( FunctionNames.Subtract, FilterFactory::subtract);
- setCopyHandler( FunctionNames.Multiply, FilterFactory::multiply);
- setCopyHandler( FunctionNames.Divide, FilterFactory::divide);
- /*
- * Following are factory methods with different signatures, but where each signature appears only once.
- * It is not worth to create e.g. a `TrinaryComparisonFactory` functional interface for only one method.
- */
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_BETWEEN), (filter, accumulator) -> {
- BetweenComparisonOperator<TR> target = null;
- BetweenComparisonOperator<SR> source = (BetweenComparisonOperator<SR>) filter;
- var exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 2) {
- target = factory.between(exps.get(0), exps.get(1), exps.get(2));
- }
- accept(accumulator, source, target);
- });
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_LIKE), (filter, accumulator) -> {
- LikeOperator<TR> target = null;
- LikeOperator<SR> source = (LikeOperator<SR>) filter;
- var exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 2) {
- final Expression<?,?> p2 = exps.get(1);
- if (p2 instanceof Literal<?,?>) {
- final Object literal = ((Literal<?,?>) p2).getValue();
- if (literal instanceof String) {
- target = factory.like(exps.get(0), (String) literal, source.getWildCard(),
- source.getSingleChar(), source.getEscapeChar(), source.isMatchingCase());
- }
- }
- }
- accept(accumulator, source, target);
- });
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NIL), (filter, accumulator) -> {
- NilOperator<TR> target = null;
- NilOperator<SR> source = (NilOperator<SR>) filter;
- var exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 1) {
- target = factory.isNil(exps.get(0), source.getNilReason().orElse(null));
- }
- accept(accumulator, source, target);
- });
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NULL), (filter, accumulator) -> {
- NullOperator<TR> target = null;
- NullOperator<SR> source = (NullOperator<SR>) filter;
- var exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 1) {
- target = factory.isNull(exps.get(0));
- }
- accept(accumulator, source, target);
- });
- setExpressionHandler(FunctionNames.Literal, (expression, accumulator) -> {
- Literal<SR,?> source = (Literal<SR,?>) expression;
- Literal<TR,?> target = factory.literal(source.getValue());
- accept(accumulator, source, target);
- });
- setExpressionHandler(FunctionNames.ValueReference, (expression, accumulator) -> {
- ValueReference<SR,?> source = (ValueReference<SR,?>) expression;
- ValueReference<TR,?> target = factory.property(source.getXPath());
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given type of binary comparison operator.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, FilterFactory::equal);
- * }
- *
- * @param type identification of the filter type.
- * @param action the action to execute when the identified filter is found.
- */
- protected final void setCopyHandler(final ComparisonOperatorName type, final BinaryComparisonFactory<TR> action) {
- setFilterHandler(type, (filter, accumulator) -> {
- BinaryComparisonOperator<TR> target = null;
- BinaryComparisonOperator<SR> source = (BinaryComparisonOperator<SR>) filter;
- var exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 2) {
- target = action.create(factory, exps.get(0), exps.get(1), source.isMatchingCase(), source.getMatchAction());
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given type of temporal operator.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler(TemporalOperatorName.AFTER, FilterFactory::after);
- * }
- *
- * @param type identification of the filter type.
- * @param action the action to execute when the identified filter is found.
- */
- protected final void setCopyHandler(final TemporalOperatorName type, final TemporalFactory<TR,T> action) {
- setFilterHandler(type, (filter, accumulator) -> {
- TemporalOperator<TR> target = null;
- TemporalOperator<SR> source = (TemporalOperator<SR>) filter;
- List<Expression<TR,T>> exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 2) {
- target = action.create(factory, exps.get(0), exps.get(1));
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given type of spatial operator.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler(SpatialOperatorName.EQUALS, FilterFactory::equals);
- * }
- *
- * @param type identification of the filter type.
- * @param action the action to execute when the identified filter is found.
- */
- protected final void setCopyHandler(final SpatialOperatorName type, final SpatialFactory<TR,G> action) {
- setFilterHandler(type, (filter, accumulator) -> {
- BinarySpatialOperator<TR> target = null;
- BinarySpatialOperator<SR> source = (BinarySpatialOperator<SR>) filter;
- List<Expression<TR,G>> exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 2) {
- target = action.create(factory, exps.get(0), exps.get(1));
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given type of distance operator.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler(DistanceOperatorName.BEYOND, FilterFactory::beyond);
- * }
- *
- * @param type identification of the filter type.
- * @param action the action to execute when the identified filter is found.
- */
- protected final void setCopyHandler(final DistanceOperatorName type, final DistanceFactory<TR,G> action) {
- setFilterHandler(type, (filter, accumulator) -> {
- DistanceOperator<TR> target = null;
- DistanceOperator<SR> source = (DistanceOperator<SR>) filter;
- List<Expression<TR,G>> exps = copyExpressions(source.getExpressions());
- if (exps != null && exps.size() == 3) {
- target = action.create(factory, exps.get(0), exps.get(1), source.getDistance());
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given type of logical operator.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler(LogicalOperatorName.AND, FilterFactory::and);
- * }
- *
- * @param type identification of the filter type.
- * @param action the action to execute when the identified filter is found.
- */
- protected final void setCopyHandler(final LogicalOperatorName type, final LogicalFactory<TR> action) {
- setFilterHandler(type, (filter, accumulator) -> {
- LogicalOperator<TR> target = null;
- LogicalOperator<SR> source = (LogicalOperator<SR>) filter;
- final var exps = copyFilters(source.getOperands());
- if (exps != null) {
- target = action.create(factory, exps);
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Sets the action to execute for the given function.
- * Example:
- *
- * {@snippet lang="java" :
- * setCopyHandler("Multiply", FilterFactory::multiply);
- * }
- *
- * @param name identification of the function.
- * @param action the action to execute when the identified function is found.
- */
- protected final void setCopyHandler(final String name, final BinaryFunctionFactory<TR> action) {
- setExpressionHandler(name, (source, accumulator) -> {
- Expression<TR,?> target = null;
- List<Expression<TR,Number>> exps = copyExpressions(source.getParameters());
- if (exps != null) {
- target = action.create(factory, exps.get(0), exps.get(1));
- }
- accept(accumulator, source, target);
- });
- }
-
- /**
- * Adds the target filter or expression in the list of copied elements.
- *
- * @param accumulator the list of copied elements where to add the {@code target} element.
- * @param source the original filter or expression which has been copied.
- * @param target the copied filter or expression, or {@code null} if the copy could not be done.
- * @throws IllegalArgumentException if {@code source} copy was mandated and couldn't be done.
- */
- private void accept(final List<Object> accumulator, final Object source, Object target) {
- if (target == null) {
- if (forceNew) {
- throw new IllegalArgumentException(Errors.format(Errors.Keys.CanNotCopy_1, source));
- }
- target = source;
- } else if (!forceUse && target.equals(source)) {
- target = source;
- }
- accumulator.add(target);
- }
-
- /**
- * Copies all expressions that are in the given list.
- * The returned list has the same length as the given list.
- * If all copied expressions are equal to the original expressions and {@link #forceNew} is {@code false},
- * then this method returns {@code null} for telling that filter or expression does not need to be created.
- *
- * <h4>Note on parameterized types</h4>
- * This method cannot guarantee that the elements in the returned list have really the parameterized types
- * declared in this method signature. They <em>should be</em> if the {@link FilterFactory}, {@link Filter}
- * and {@link Expression} methods invoked by the caller fulfill the API contract. For example the operands
- * of an arithmetic function should have {@link Number} value. But we have no way to verify that.
- *
- * @param <V> expected type of values returned by the expressions. This type <em>is not verified</em>,
- * so this method is not really type-safe. This parameterized type is nevertheless used for more
- * convenient casts by the callers, but should not be used outside private methods.
- * @param source the list of expressions to copy.
- * @return the copies expressions, or {@code null} if no copy is needed.
- */
- @SuppressWarnings({"unchecked","rawtypes"})
- private <V> List<Expression<TR,V>> copyExpressions(final List<Expression<SR,?>> source) {
- final List<Object> results = new ArrayList<>(source.size());
- for (final Expression<SR,?> e : source) {
- visit(e, results);
- }
- // Cast to <TR> is safe because of factory method signatures.
- return !forceNew && results.equals(source) ? null : (List) results;
- }
-
- /**
- * Copies all filters that are in the given list.
- * The returned list has the same length as the given list.
- * If all copied filters are equal to the original filters and {@link #forceNew} is {@code false},
- * then this method returns {@code null} for telling that filter does not need to be created.
- *
- * @param source the list of filters to copy.
- * @return the copies filters, or {@code null} if no copy is needed.
- */
- @SuppressWarnings({"unchecked","rawtypes"})
- private List<Filter<TR>> copyFilters(final List<Filter<SR>> source) {
- final var results = new ArrayList<Object>(source.size());
- for (final Filter<SR> e : source) {
- visit(e, results);
- }
- // Cast to <TR> is safe because of factory method signatures.
- return !forceNew && results.equals(source) ? null : (List) results;
- }
-
- /**
- * Copies the given filter using the factory specified at construction time.
- *
- * @param source the filter to copy.
- * @return the copied filter.
- * @throws IllegalArgumentException if the filter cannot be copied.
- */
- @SuppressWarnings("unchecked")
- public Filter<TR> copy(final Filter<SR> source) {
- final var accumulator = new ArrayList<Object>(1);
- visit(source, accumulator);
- switch (accumulator.size()) {
- case 0: return null;
- case 1: return (Filter<TR>) accumulator.get(0);
- default: throw new AssertionError(accumulator); // Should never happen.
- }
- }
-
- /**
- * Copies the given expression using the factory specified at construction time.
- *
- * @param <V> the type of values computed by the expression.
- * @param source the expression to copy.
- * @return the copied expression.
- * @throws IllegalArgumentException if the expression cannot be copied.
- */
- @SuppressWarnings("unchecked")
- public <V> Expression<TR,V> copy(final Expression<SR,V> source) {
- final var accumulator = new ArrayList<Object>(1);
- visit(source, accumulator);
- switch (accumulator.size()) {
- case 0: return null;
- case 1: return (Expression<TR,V>) accumulator.get(0);
- default: throw new AssertionError(accumulator); // Should never happen.
- }
- }
-
- /**
- * Invoked when no copy operation is registered for the given filter.
- * The default implementation throws an {@link IllegalArgumentException}.
- *
- * @param type the filter type which has not been found.
- * @param filter the filter to copy.
- * @param accumulator where to add filters.
- * @throws IllegalArgumentException if a copy of the given filter was required by cannot be performed.
- */
- @Override
- protected void typeNotFound(final CodeList<?> type, final Filter<SR> filter, final List<Object> accumulator) {
- if (forceNew) {
- throw new IllegalArgumentException(Resources.format(Resources.Keys.CanNotVisit_2, 0, type));
- }
- accumulator.add(filter);
- }
-
- /**
- * Invoked when no copy operation is registered for the given expression.
- * The default implementation creates a new function of the same name using the generic API.
- *
- * @param name the expression type which has not been found.
- * @param expression the expression.
- * @param accumulator where to add expressions.
- * @throws IllegalArgumentException if an expression cannot be copied.
- */
- @Override
- @SuppressWarnings("unchecked")
- protected void typeNotFound(final String name, Expression<SR,?> expression, final List<Object> accumulator) {
- var exps = copyExpressions(expression.getParameters());
- if (exps != null) {
- expression = factory.function(name, exps.toArray(Expression[]::new));
- }
- accumulator.add(expression);
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/EditVisitor.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/EditVisitor.java
deleted file mode 100644
index 517cf55..0000000
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/EditVisitor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.filter.privy;
-
-import org.opengis.filter.Literal;
-import org.opengis.filter.FilterFactory;
-
-
-/**
- * Visitor used to copy expressions and filters with same parameterized types.
- * This class can be used when some filters need to be recreated with the same types
- * but potentially different values. For example a change of {@link Literal} value
- * requires to recreate all parents in the filter graph.
- *
- * <h2>Partially implemented factory</h2>
- * {@code EditVisitor} relaxes the usual factory API contract by allowing unsupported factory
- * methods to return {@code null} instead of throwing an {@link UnsupportedOperationException}.
- * A null value is interpreted as an instruction to continue to use the old filter or expression,
- * without replacing it by a new instance created by the {@linkplain #factory}.
- * By contrast, an {@link UnsupportedOperationException} causes the copy operation to fail.
- *
- * @author Johann Sorel (Geomatys)
- * @author Martin Desruisseaux (Geomatys)
- *
- * @param <R> the type of resources expected by the filters and expressions.
- * @param <G> base class of geometry objects.
- * @param <T> base class of temporal objects.
- */
-public class EditVisitor<R,G,T> extends CopyVisitor<R,R,G,T> {
- /**
- * Creates a new edit visitor with given factory.
- * If the {@code force} argument is {@code false}, then the factory is used for
- * creating new filters and expressions only when at least one operand changed.
- *
- * @param factory the factory to use for creating the new filters and expressions.
- * @param force whether to force new filters or expressions even when existing instances could be reused.
- */
- public EditVisitor(final FilterFactory<R,G,T> factory, final boolean force) {
- super(factory, force, force);
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/FunctionNames.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/FunctionNames.java
index 06be9b3..ad709c9 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/FunctionNames.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/FunctionNames.java
@@ -27,22 +27,22 @@
* @author Martin Desruisseaux (Geomatys)
*/
public final class FunctionNames extends Static {
- /** Value of {@link org.opengis.filter.NullOperator#getOperatorType()}. */
+ /** Value of {@code NullOperator.getOperatorType()}. */
public static final String PROPERTY_IS_NULL = "PROPERTY_IS_NULL";
- /** Value of {@link org.opengis.filter.NilOperator#getOperatorType()}. */
+ /** Value of {@code NilOperator.getOperatorType()}. */
public static final String PROPERTY_IS_NIL = "PROPERTY_IS_NIL";
- /** Value of {@link org.opengis.filter.LikeOperator#getOperatorType()}. */
+ /** Value of {@code LikeOperator.getOperatorType()}. */
public static final String PROPERTY_IS_LIKE = "PROPERTY_IS_LIKE";
/** Value of {@link org.opengis.filter.BetweenComparisonOperator#getOperatorType()}. */
public static final String PROPERTY_IS_BETWEEN = "PROPERTY_IS_BETWEEN";
- /** Value of {@link org.opengis.filter.Literal#getFunctionName()}. */
+ /** Value of {@code Literal.getFunctionName()}. */
public static final String Literal = "Literal";
- /** Value of {@link org.opengis.filter.ValueReference#getFunctionName()}. */
+ /** Value of {@code ValueReference.getFunctionName()}. */
public static final String ValueReference = "ValueReference";
/** The "Add" (+) arithmetic expression. */
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/ListingPropertyVisitor.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/ListingPropertyVisitor.java
index 4b9e664..719d2f7 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/ListingPropertyVisitor.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/ListingPropertyVisitor.java
@@ -19,15 +19,13 @@
import java.util.HashSet;
import java.util.Set;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.filter.BetweenComparisonOperator;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.LikeOperator;
-import org.opengis.filter.LogicalOperator;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.BetweenComparisonOperator;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
/**
@@ -60,8 +58,7 @@
visit(filter.getUpperBoundary(), names);
});
setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_LIKE), (f, names) -> {
- final var filter = (LikeOperator<Object>) f;
- visit(filter.getExpressions().get(0), names);
+ visit(f.getExpressions().get(0), names);
});
setExpressionHandler(FunctionNames.ValueReference, (e, names) -> {
final var expression = (ValueReference<Object,?>) e;
@@ -77,7 +74,7 @@
* @param xpaths where to add the XPaths.
*/
@Override
- protected void typeNotFound(final CodeList<?> type, final Filter<Object> filter, final Set<String> xpaths) {
+ protected void typeNotFound(final Enum<?> type, final Filter<Object> filter, final Set<String> xpaths) {
for (final var f : filter.getExpressions()) {
visit(f, xpaths);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/SortByComparator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/SortByComparator.java
index 624e60d..9c1d3a5 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/SortByComparator.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/SortByComparator.java
@@ -25,10 +25,10 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.privy.UnmodifiableArrayList;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SortBy;
-import org.opengis.filter.SortProperty;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SortBy;
+import org.apache.sis.pending.geoapi.filter.SortProperty;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/Visitor.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/Visitor.java
index b314efe..517433d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/Visitor.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/Visitor.java
@@ -23,15 +23,14 @@
import java.util.function.BiConsumer;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
-import org.opengis.filter.TemporalOperatorName;
-import org.opengis.filter.ComparisonOperatorName;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.LogicalOperatorName;
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -50,7 +49,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <A> type of the accumulator object where actions will write their results.
*/
public abstract class Visitor<R,A> {
@@ -58,9 +57,9 @@
* All filters known to this visitor.
* May contain an entry associated to the {@code null} key.
*
- * @see #setFilterHandler(CodeList, BiConsumer)
+ * @see #setFilterHandler(Enum, BiConsumer)
*/
- private final Map<CodeList<?>, BiConsumer<Filter<R>,A>> filters;
+ private final Map<Enum<?>, BiConsumer<Filter<R>,A>> filters;
/**
* All expressions known to this visitor.
@@ -114,7 +113,7 @@
* @param type identification of the filter type (can be {@code null}).
* @return the action to execute when the identified filter is found, or {@code null} if none.
*/
- protected final BiConsumer<Filter<R>,A> getFilterHandler(final CodeList<?> type) {
+ protected final BiConsumer<Filter<R>,A> getFilterHandler(final Enum<?> type) {
return filters.get(type);
}
@@ -138,7 +137,7 @@
* @param type identification of the filter type (can be {@code null}).
* @param action the action to execute when the identified filter is found.
*/
- protected final void setFilterHandler(final CodeList<?> type, final BiConsumer<Filter<R>,A> action) {
+ protected final void setFilterHandler(final Enum<?> type, final BiConsumer<Filter<R>,A> action) {
filters.put(type, action);
}
@@ -149,8 +148,8 @@
* @param lastType identification of the last filter type (inclusive).
* @param action the action to execute when an identified filter is found.
*/
- private void setFamilyHandlers(final CodeList<?> lastType, final BiConsumer<Filter<R>,A> action) {
- for (final CodeList<?> type : lastType.family()) {
+ private void setFamilyHandlers(final Enum<?> lastType, final BiConsumer<Filter<R>,A> action) {
+ for (final Enum<?> type : lastType.getClass().getEnumConstants()) {
filters.put(type, action);
if (type == lastType) break;
}
@@ -195,8 +194,8 @@
* @param action the action to execute when one of the enumerated filters is found.
*/
protected final void setNullAndNilHandlers(final BiConsumer<Filter<R>,A> action) {
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NULL), action);
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NIL), action);
+ setFilterHandler(ComparisonOperatorName.PROPERTY_IS_NULL, action);
+ setFilterHandler(ComparisonOperatorName.PROPERTY_IS_NIL, action);
}
/**
@@ -247,7 +246,7 @@
*
* @param types types of filters to remove.
*/
- protected final void removeFilterHandlers(final Collection<? extends CodeList<?>> types) {
+ protected final void removeFilterHandlers(final Collection<? extends Enum<?>> types) {
filters.keySet().removeAll(types);
}
@@ -259,7 +258,7 @@
* This method sometimes needs to be invoked with instances of {@code Filter<? super R>},
* because this is the type of predicate expected by {@link java.util.function} and {@link java.util.stream}.
* But the parameterized type expected by this method matches the parameterized type of handlers registered by
- * {@link #setFilterHandler(CodeList, BiConsumer)} and similar methods, which use the exact {@code <R>} type.
+ * {@link #setFilterHandler(Enum, BiConsumer)} and similar methods, which use the exact {@code <R>} type.
* This restriction exists because when doing otherwise, parameterized types become hard to express in Java
* (we get a cascade of {@code super} keywords, something like {@code <? super ? super R>}).
* However, doing the {@code (Filter<R>) filter} cast is actually safe if the handlers do not invoke any
@@ -274,7 +273,7 @@
* @throws UnsupportedOperationException if there is no action registered for the given filter.
*/
public void visit(final Filter<R> filter, final A accumulator) {
- final CodeList<?> type = (filter != null) ? filter.getOperatorType() : null;
+ final Enum<?> type = (filter != null) ? filter.getOperatorType() : null;
final BiConsumer<Filter<R>, A> f = filters.get(type);
if (f != null) {
f.accept(filter, accumulator);
@@ -310,7 +309,7 @@
* @param accumulator where to write the result of all actions.
* @throws UnsupportedOperationException if there is no default action.
*/
- protected void typeNotFound(final CodeList<?> type, final Filter<R> filter, final A accumulator) {
+ protected void typeNotFound(final Enum<?> type, final Filter<R> filter, final A accumulator) {
throw new UnsupportedOperationException(Resources.format(Resources.Keys.CanNotVisit_2, 0, type));
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/WarningEvent.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/WarningEvent.java
index edba134..a8e8394 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/WarningEvent.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/privy/WarningEvent.java
@@ -21,10 +21,9 @@
import org.opengis.util.ScopedName;
import org.apache.sis.filter.internal.Node;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
/**
@@ -69,7 +68,7 @@
*
* @return the operator type if the source is a filter.
*/
- public Optional<CodeList<?>> getOperatorType() {
+ public Optional<Enum<?>> getOperatorType() {
if (source instanceof Filter<?>) {
return Optional.of(((Filter<?>) source).getOperatorType());
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionDescription.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionDescription.java
deleted file mode 100644
index 263646d..0000000
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionDescription.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * 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.filter.sqlmm;
-
-import java.util.List;
-import java.io.Serializable;
-import java.lang.reflect.Type;
-import org.opengis.util.TypeName;
-import org.opengis.util.LocalName;
-import org.opengis.parameter.ParameterValue;
-import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.filter.capability.AvailableFunction;
-import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.Utilities;
-import org.apache.sis.util.iso.Names;
-import org.apache.sis.geometry.wrapper.Geometries;
-import org.apache.sis.geometry.wrapper.GeometryType;
-import org.apache.sis.metadata.simple.SimpleIdentifiedObject;
-import org.apache.sis.parameter.DefaultParameterValue;
-import org.apache.sis.referencing.NamedIdentifier;
-
-
-/**
- * Description of a SQLMM function with its parameters.
- *
- * @todo Argument descriptions are incomplete. They have no good names,
- * and the types are missing (they are {@code null}) except for geometry types.
- *
- * @author Martin Desruisseaux (Geomatys)
- *
- * @see SQLMM#description(Geometries)
- */
-final class FunctionDescription implements AvailableFunction, Serializable {
- /**
- * For cross-version compatibility.
- */
- private static final long serialVersionUID = -264656649425360058L;
-
- /**
- * The name space for function descriptions.
- */
- private static final String NAMESPACE = "SQLMM";
-
- /**
- * The function name in SQLMM namespace.
- *
- * @see #getName()
- */
- @SuppressWarnings("serial") // The implementation used here is serializable.
- private final LocalName name;
-
- /**
- * The name and type of each argument expected by this function.
- * This list is unmodifiable.
- *
- * @see #getArguments()
- */
- @SuppressWarnings("serial") // The implementation used here is serializable.
- private final List<ParameterDescriptor<?>> arguments;
-
- /**
- * The type of return value.
- *
- * @see #getReturnType()
- */
- @SuppressWarnings("serial") // The implementation used here is serializable.
- private final TypeName result;
-
- /**
- * Creates a new description for the given SQLMM function.
- *
- * @param function the SQLMM function for which to create a description.
- * @param library the geometry library implementation in use.
- */
- FunctionDescription(final SQLMM function, final Geometries<?> library) {
- name = Names.createLocalName(NAMESPACE, null, function.name());
- final var args = new Argument<?>[function.maxParamCount];
- for (int i=0; i<args.length; i++) {
- final GeometryType gt;
- switch (i) {
- case 0: gt = function.geometryType1; break;
- case 1: gt = function.geometryType2; break;
- default: gt = null; break;
- }
- final TypeName type = (gt != null) ? gt.getTypeName(library) : null;
- args[i] = new Argument<>("arg" + (i+1), type, Argument.getValueClass(type), true);
- }
- arguments = List.of(args);
- result = function.getGeometryType().map((t) -> t.getTypeName(library))
- .orElseGet(() -> Names.createTypeName(function.getReturnType(library)));
- }
-
- /**
- * Returns the function name in SQLMM namespace. This is the {@linkplain SQLMM#name() name}
- * of the enumeration value, but wrapped in a {@link LocalName} with the "SQLMM" namespace.
- *
- * @return the function name.
- */
- @Override
- public LocalName getName() {
- return name;
- }
-
- /**
- * Returns the name and type of each argument expected by this function.
- *
- * @return arguments that the function accepts.
- */
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField")
- public List<ParameterDescriptor<?>> getArguments() {
- return arguments;
- }
-
- /**
- * {@return the type of return value}.
- */
- @Override
- public TypeName getReturnType() {
- return result;
- }
-
- /**
- * Description of an argument of a SQLMM function.
- *
- * @todo Argument names are not informative.
- * @todo Argument types are unknown if not geometric.
- *
- * @param <T> the type of the argument value.
- */
- private static final class Argument<T> extends SimpleIdentifiedObject implements ParameterDescriptor<T> {
- /**
- * For cross-version compatibility.
- */
- private static final long serialVersionUID = 1607271450895713628L;
-
- /**
- * Java type of the argument value, or {@code Object.class} if unknown.
- */
- private final Class<T> valueClass;
-
- /**
- * The value type in OGC namespace, or {@code null} if unknown.
- */
- @SuppressWarnings("serial") // Most Apache SIS implementations are serializable.
- private final TypeName type;
-
- /**
- * Whether this argument is mandatory.
- */
- private final boolean mandatory;
-
- /**
- * Creates a new argument description.
- *
- * @param name name of the argument being created.
- * @param type the {@code valueClass} name in OGC namespace, or {@code null} if unknown.
- * @param valueClass Java type of the argument value, or {@code Object.class} if unknown.
- * @param mandatory whether this argument is mandatory.
- */
- Argument(final String name, final TypeName type, final Class<T> valueClass, final boolean mandatory) {
- this.name = new NamedIdentifier(null, NAMESPACE, name, null, null);
- this.type = type;
- this.valueClass = valueClass;
- this.mandatory = mandatory;
- }
-
- /**
- * {@return the name of the type of the argument}.
- */
- @Override
- public TypeName getValueType() {
- return type;
- }
-
- /**
- * Returns the Java type for the specified type name, or {@code Object.class} if none.
- * This method is for computing the value returned by {@link #getValueClass()}.
- * It cannot be inlined because of parameterized type.
- *
- * @param type type for which to get the Java class.
- * @return the Java class for the specified type name.
- */
- static Class<?> getValueClass(final TypeName type) {
- if (type != null) {
- final Type t = type.toJavaType().orElse(null);
- if (t instanceof Class<?>) {
- return (Class<?>) t;
- }
- }
- return Object.class;
- }
-
- /**
- * Returns the Java type of the argument value, or {@code Object.class} if none.
- * This is the Java equivalent of {@link #getValueType()}.
- *
- * @return the Java type of the argument value.
- */
- @Override
- public Class<T> getValueClass() {
- return valueClass;
- }
-
- /**
- * Creates a new instance of parameter value initialized with the default value.
- *
- * @return a new parameter value initialized to the default value.
- */
- @Override
- public ParameterValue<T> createValue() {
- return new DefaultParameterValue<>(this);
- }
-
- /**
- * Returns the maximum number of times that values for this argument can be provided.
- * This is 0 for optional argument and 1 for mandatory argument.
- *
- * @return the minimum occurrence.
- */
- @Override
- public int getMinimumOccurs() {
- return mandatory ? 1 : 0;
- }
-
- /**
- * Returns the maximum number of times that values for this argument can be provided.
- *
- * @return the maximum occurrence.
- */
- @Override
- public int getMaximumOccurs() {
- return 1;
- }
-
- /**
- * Tests whether the given object is equal to this argument description.
- *
- * @param obj the object to test for equality.
- * @param mode the strictness level of the comparison.
- * @return whether the given object describes the same argument as this.
- */
- @Override
- public boolean equals(final Object obj, final ComparisonMode mode) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof Argument) {
- final var other = (Argument) obj;
- return Utilities.deepEquals(name, other.name, mode)
- && Utilities.deepEquals(type, other.type, mode);
- }
- return false;
- }
-
- /**
- * {@return a hash-code value for this argument description}.
- */
- @Override
- public int hashCode() {
- return name.hashCode() + type.hashCode();
- }
-
- /**
- * {@return a string representation of this argument}.
- * Current version includes the name and the type.
- * Should be used only for debugging purposes.
- */
- @Override
- public String toString() {
- final var sb = new StringBuilder(20);
- addType(sb.append(name.getCode()), type);
- return sb.toString();
- }
- }
-
- /**
- * Appends the given type name if non-null.
- *
- * @param sb where to append the type name.
- * @param type the type name to add, or {@code null} if none.
- */
- private static void addType(final StringBuilder sb, final TypeName type) {
- if (type != null) {
- sb.append(" : ").append(type);
- }
- }
-
- /**
- * Tests whether the given object is equal to this function description.
- *
- * @param obj the object to test for equality.
- * @return whether the given object describes the same function as this.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof FunctionDescription) {
- final var other = (FunctionDescription) obj;
- return name.equals(other.name)
- && result.equals(other.result)
- && arguments.equals(other.arguments);
- }
- return false;
- }
-
- /**
- * {@return a hash-code value for this function description}.
- */
- @Override
- public int hashCode() {
- return name.hashCode() + arguments.hashCode() + result.hashCode();
- }
-
- /**
- * {@return a string representation of this function with its argument}.
- * Should be used only for debugging purposes.
- */
- @Override
- public String toString() {
- final var sb = new StringBuilder(40).append(name).append('(');
- boolean isMore = false;
- for (final ParameterDescriptor<?> arg : getArguments()) {
- if (isMore) sb.append(", ");
- addType(sb.append(arg.getName().getCode()), arg.getValueType());
- isMore = true;
- }
- addType(sb.append(')'), getReturnType());
- return sb.toString();
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionWithSRID.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionWithSRID.java
index fc3b821..5e34c7b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionWithSRID.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/FunctionWithSRID.java
@@ -28,10 +28,9 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.Literal;
/**
@@ -42,7 +41,7 @@
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*
- * @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.
*/
abstract class FunctionWithSRID<R> extends SpatialFunction<R> {
/**
@@ -112,7 +111,7 @@
if (literalCRS) try {
setTargetCRS(value);
} catch (FactoryException e) {
- throw new InvalidFilterValueException(e);
+ throw new IllegalArgumentException(e);
}
}
} else {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryConstructor.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryConstructor.java
index 299fe55..8792bcc 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryConstructor.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryConstructor.java
@@ -24,9 +24,8 @@
import org.apache.sis.util.Classes;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -37,7 +36,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <G> the implementation type of geometry objects.
*/
class GeometryConstructor<R,G> extends FunctionWithSRID<R> {
@@ -124,7 +123,7 @@
final Object geomImpl = library.getGeometry(result);
final Class<?> expected = operation.getReturnType(library);
if (!expected.isInstance(geomImpl)) {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentClass_3, "geom", expected, Classes.getClass(geomImpl)));
}
if (srid != null) {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryParser.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryParser.java
index c9fe682..ebc7fb9 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryParser.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/GeometryParser.java
@@ -23,9 +23,8 @@
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -36,7 +35,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <G> the implementation type of geometry objects.
*/
abstract class GeometryParser<R,G> extends GeometryConstructor<R,G> {
@@ -99,7 +98,7 @@
case ST_BdPolyFromText:
case ST_BdMPolyFromWKB:
case ST_BdMPolyFromText: break;
- default: warning(new InvalidFilterValueException(Errors.format(
+ default: warning(new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentClass_3, inputName(),
getValueClass(),
Classes.getClass(library.getGeometry(result)))), true);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/OneGeometry.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/OneGeometry.java
index 2ca9c78..e823758 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/OneGeometry.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/OneGeometry.java
@@ -20,8 +20,8 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.geometry.wrapper.GeometryWrapper;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -32,7 +32,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
class OneGeometry<R> extends SpatialFunction<R> {
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/Registry.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/Registry.java
index 632b473..c2c749e 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/Registry.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/Registry.java
@@ -22,9 +22,8 @@
import org.apache.sis.filter.FunctionRegister;
import org.apache.sis.pending.jdk.JDK16;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.capability.AvailableFunction;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -66,18 +65,6 @@
}
/**
- * Describes the parameters of a function.
- *
- * @param name name of the function to describe.
- * @return description of the function parameters.
- * @throws IllegalArgumentException if function name is unknown..
- */
- @Override
- public AvailableFunction describe(final String name) {
- return SQLMM.valueOf(name).description(library);
- }
-
- /**
* Create a new function of the given name with given parameters.
* It is caller's responsibility to ensure that the given array is non-null,
* has been cloned and does not contain null elements.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SQLMM.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SQLMM.java
index 748d06f..2283eb0 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SQLMM.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SQLMM.java
@@ -23,11 +23,8 @@
import org.apache.sis.geometry.wrapper.GeometryType;
import static org.apache.sis.geometry.wrapper.GeometryType.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.EnumMap;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.capability.AvailableFunction;
-import org.apache.sis.setup.GeometryLibrary;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
@@ -787,14 +784,6 @@
private final Object returnType;
/**
- * Description of this SQLMM function, created when first needed.
- * The associated Java type depends on the geometry library.
- *
- * @see #description(Geometries)
- */
- private transient EnumMap<GeometryLibrary,AvailableFunction> descriptions;
-
- /**
* Creates a new enumeration value for an operation expecting exactly one geometry object
* and no other argument.
*/
@@ -835,20 +824,6 @@
}
/**
- * Returns a description of this SQLMM function.
- * The Java types associated to arguments and return value depend on which geometry library is used.
- *
- * @param library the geometry library implementation to use.
- * @return description of this SQLMM function.
- */
- public final synchronized AvailableFunction description(final Geometries<?> library) {
- if (descriptions == null) {
- descriptions = new EnumMap<>(GeometryLibrary.class);
- }
- return descriptions.computeIfAbsent(library.library, (key) -> new FunctionDescription(this, library));
- }
-
- /**
* Returns the number of parameters that are geometry objects. Those parameters shall be first.
* This value shall be between {@link #minParamCount} and {@link #maxParamCount}.
*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromBinary.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromBinary.java
index f8e6b47..b9bc122 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromBinary.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromBinary.java
@@ -20,8 +20,8 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.geometry.wrapper.GeometryWrapper;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -30,7 +30,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <G> the implementation type of geometry objects.
*/
final class ST_FromBinary<R,G> extends GeometryParser<R,G> {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromText.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromText.java
index ffb4df3..f409618 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromText.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_FromText.java
@@ -19,8 +19,8 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.geometry.wrapper.GeometryWrapper;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -29,7 +29,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
* @param <G> the implementation type of geometry objects.
*/
final class ST_FromText<R,G> extends GeometryParser<R,G> {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Point.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Point.java
index 9aec4e3..efe88a1 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Point.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Point.java
@@ -25,9 +25,8 @@
import org.apache.sis.util.privy.UnmodifiableArrayList;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -45,7 +44,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
final class ST_Point<R> extends FunctionWithSRID<R> {
/**
@@ -116,13 +115,13 @@
/**
* Returns the numerical value evaluated by the expression at the given index.
* If the value is {@code null}, then {@link Double#NaN} is returned.
- * If the value is not a number, then an {@link InvalidFilterValueException} is thrown.
+ * If the value is not a number, then an {@link IllegalArgumentException} is thrown.
*
* @param input the object to be evaluated by the expression. Can be {@code null}.
* @param index the parameter index.
* @param name parameter name to report in exception message if the value is not a number.
* @return the numerical value, or {@link Double#NaN} if the value was null.
- * @throws InvalidFilterValueException if the value is not a number.
+ * @throws IllegalArgumentException if the value is not a number.
*/
private double value(final R input, final int index, final String name) {
final Object value = parameters[index].apply(input);
@@ -131,7 +130,7 @@
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentClass_3, name, Number.class, value.getClass()));
}
}
@@ -143,7 +142,7 @@
*
* @param value the WKB or WKT value to parse. Can be {@code null}.
* @return the parsed point, or {@code null} if the given value is null.
- * @throws InvalidFilterValueException if the value is not a string or byte array.
+ * @throws IllegalArgumentException if the value is not a string or byte array.
* @throws Exception if parsing failed for another reason.
*/
private GeometryWrapper parse(final Object value) throws Exception {
@@ -157,7 +156,7 @@
} else if (value instanceof String) {
point = library.parseWKT((String) value);
} else {
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentClass_3, "wkt|wkb", String.class, value.getClass()));
}
final Object geometry = library.getGeometry(point);
@@ -165,7 +164,7 @@
return point;
} else {
final String type = (value instanceof String) ? "wkt" : "wkb";
- throw new InvalidFilterValueException(Errors.format(
+ throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentClass_3, type, library.pointClass, point.getClass()));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Transform.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Transform.java
index 0a3b7c8..08352f4 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Transform.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/ST_Transform.java
@@ -24,10 +24,9 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.Literal;
/**
@@ -77,7 +76,7 @@
* Creates a new function with the given parameters. It is caller's responsibility to ensure
* that the given array is non-null and does not contain null elements.
*
- * @throws InvalidFilterValueException if CRS cannot be constructed from the second expression.
+ * @throws IllegalArgumentException if CRS cannot be constructed from the second expression.
*/
ST_Transform(final Expression<R,?>[] parameters, final Geometries<?> library) {
super(SQLMM.ST_Transform, parameters, PRESENT);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SpatialFunction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SpatialFunction.java
index b938087..714288c 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SpatialFunction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/SpatialFunction.java
@@ -30,9 +30,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.Names;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -41,7 +40,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
abstract class SpatialFunction<R> extends Node implements FeatureExpression<R,Object>, Optimization.OnExpression<R,Object> {
/**
@@ -180,7 +179,7 @@
*
* @param addTo where to add the type of properties evaluated by this expression.
* @return builder of type resulting from expression evaluation (never null).
- * @throws InvalidFilterValueException if the source feature type does not contain the expected properties,
+ * @throws IllegalArgumentException if the source feature type does not contain the expected properties,
* or if this method cannot determine the result type of the expression.
* It may be because that expression is backed by an unsupported implementation.
*/
@@ -198,7 +197,7 @@
return item;
}
}
- throw new InvalidFilterValueException(Resources.format(Resources.Keys.NotAGeometryAtFirstExpression));
+ throw new IllegalArgumentException(Resources.format(Resources.Keys.NotAGeometryAtFirstExpression));
}
return addTo.addComputedProperty(addTo.addAttribute(getValueClass()).setName(getFunctionName()), false);
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/TwoGeometries.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/TwoGeometries.java
index dcdf386..baa77fa 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/TwoGeometries.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/sqlmm/TwoGeometries.java
@@ -24,12 +24,11 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.geometry.wrapper.GeometryWrapper;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -38,7 +37,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*
- * @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.
*/
class TwoGeometries<R> extends SpatialFunction<R> {
/**
@@ -78,7 +77,7 @@
*/
@Override
public Expression<R,?> optimize(final Optimization optimization) {
- final FeatureType featureType = optimization.getFeatureType();
+ final DefaultFeatureType featureType = optimization.getFeatureType();
if (featureType != null) {
final Expression<R,?> p1 = unwrap(geometry1);
if (p1 instanceof ValueReference<?,?> && unwrap(geometry2) instanceof Literal<?,?>) try {
@@ -96,7 +95,7 @@
}
}
}
- } catch (PropertyNotFoundException | TransformException e) {
+ } catch (IllegalArgumentException | TransformException e) {
warning(e, true);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/Geometries.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/Geometries.java
index ff220d6..1532dab 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/Geometries.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/Geometries.java
@@ -44,8 +44,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.geometry.MismatchedDimensionException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -244,7 +244,7 @@
* @return a wrapper for the geometry implementation of the given feature, or empty value.
* @throws BackingStoreException if the operation failed because of a checked exception.
*/
- public static Optional<GeometryWrapper> wrap(final Feature feature, final String property) {
+ public static Optional<GeometryWrapper> wrap(final AbstractFeature feature, final String property) {
if (feature == null) {
return Optional.empty();
}
@@ -266,7 +266,7 @@
* @return a wrapper for the geometry implementation of the given feature, or empty value.
* @throws BackingStoreException if the operation failed because of a checked exception.
*/
- public static Optional<GeometryWrapper> wrap(final Feature feature) {
+ public static Optional<GeometryWrapper> wrap(final AbstractFeature feature) {
return wrap(feature, AttributeConvention.GEOMETRY);
}
@@ -276,7 +276,7 @@
* If the given object is not recognized, then this method returns an empty value.
*
* <h4>Recommended alternative</h4>
- * Prefers {@link #wrap(Feature)} for wrapping the default geometry of a feature instance.
+ * Prefers {@link #wrap(AbstractFeature)} for wrapping the default geometry of a feature instance.
* This is preferred for allowing <abbr>SIS</abbr> to fetch the default <abbr>CRS</abbr>
* from the feature type when that information was not present in the geometry object.
*
@@ -381,8 +381,8 @@
final Object geometry;
final int n = point.getDimension();
switch (n) {
- case BIDIMENSIONAL: geometry = createPoint(point.getCoordinate(0), point.getCoordinate(1)); break;
- case TRIDIMENSIONAL: geometry = createPoint(point.getCoordinate(0), point.getCoordinate(1), point.getCoordinate(2)); break;
+ case BIDIMENSIONAL: geometry = createPoint(point.getOrdinate(0), point.getOrdinate(1)); break;
+ case TRIDIMENSIONAL: geometry = createPoint(point.getOrdinate(0), point.getOrdinate(1), point.getOrdinate(2)); break;
default: throw new MismatchedDimensionException(
Errors.format(Errors.Keys.MismatchedDimension_3, "point",
(n <= BIDIMENSIONAL) ? BIDIMENSIONAL : TRIDIMENSIONAL, n));
@@ -619,10 +619,10 @@
} else {
final DirectPosition lc = envelope.getLowerCorner();
final DirectPosition uc = envelope.getUpperCorner();
- xmin = lc.getCoordinate(xd);
- ymin = lc.getCoordinate(yd);
- xmax = uc.getCoordinate(xd);
- ymax = uc.getCoordinate(yd);
+ xmin = lc.getOrdinate(xd);
+ ymin = lc.getOrdinate(yd);
+ xmax = uc.getOrdinate(xd);
+ ymax = uc.getOrdinate(yd);
}
final double[] coordinates;
/*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
index 0ef0e31..127f829 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
@@ -28,8 +28,8 @@
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
-import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
import org.opengis.util.FactoryException;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.filter.sqlmm.SQLMM;
@@ -43,14 +43,9 @@
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Set;
-import org.opengis.geometry.Boundary;
-import org.opengis.geometry.TransfiniteSet;
-import org.opengis.geometry.complex.Complex;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
@@ -137,7 +132,6 @@
*
* @return the geometry <abbr>CRS</abbr>, or {@code null} if unknown.
*/
- @Override
public final CoordinateReferenceSystem getCoordinateReferenceSystem() {
return crs;
}
@@ -163,7 +157,6 @@
*
* @return the coordinate dimension.
*/
- @Override
public int getCoordinateDimension() {
return Geometries.BIDIMENSIONAL;
}
@@ -185,7 +178,6 @@
*
* @return the geometry envelope. Should never be {@code null}.
*/
- @Override
public abstract GeneralEnvelope getEnvelope();
/**
@@ -195,7 +187,6 @@
*
* @todo Consider a {@code getCentroid2D()} method avoiding the cost of fetching the CRS.
*/
- @Override
public abstract DirectPosition getCentroid();
/**
@@ -557,7 +548,6 @@
*
* @see #getCoordinateReferenceSystem()
*/
- @Override
public GeometryWrapper transform(final CoordinateReferenceSystem targetCRS) throws TransformException {
if (targetCRS == null || targetCRS == crs || crs == null) {
return this;
@@ -569,7 +559,7 @@
* We wrap that exception because `Geometry.transform(…)` does not declare `FactoryException`.
* We may revisit in a future version if `Geometry.transform(…)` method declaration is updated.
*/
- throw new TransformException(e);
+ throw new TransformException(e.toString(), e);
}
}
@@ -600,32 +590,6 @@
}
/**
- * Methods from the {@link Geometry} interface. The {@link Override} annotation is intentionally omitted
- * for reducing the risk of compilation failures during the upcoming revision of GeoAPI interfaces since
- * some of those methods will be removed.
- */
- @Deprecated @Override public final Geometry getMbRegion() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final DirectPosition getRepresentativePoint() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Boundary getBoundary() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Complex getClosure() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final boolean isSimple() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final boolean isCycle() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final double distance(Geometry geometry) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final int getDimension(DirectPosition point) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Set<Complex> getMaximalComplex() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Geometry getConvexHull() {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Geometry getBuffer(double distance) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final Geometry clone() throws CloneNotSupportedException {throw new CloneNotSupportedException();}
- @Deprecated @Override public final boolean contains(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final boolean contains(DirectPosition point) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final boolean intersects(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final boolean equals(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final TransfiniteSet union(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final TransfiniteSet intersection(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final TransfiniteSet difference(TransfiniteSet pointSet) {throw new UnsupportedOperationException();}
- @Deprecated @Override public final TransfiniteSet symmetricDifference(TransfiniteSet ps) {throw new UnsupportedOperationException();}
-
- /**
* Returns {@code true} if the given object is a wrapper of the same class
* and the wrapped geometry implementations are equal.
*
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
index 9a4ed9d..26fd634 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
@@ -49,9 +49,9 @@
// 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.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
@@ -306,7 +306,6 @@
* @throws TransformException if a coordinate conversion was required but failed.
* @throws IncommensurableException if a coordinate system does not use the expected units.
*/
- @SuppressWarnings("deprecation")
private static CoordinateReferenceSystem usingSystemUnit(final GeometryWrapper geometry,
final CoordinateReferenceSystem geometryCRS,
CoordinateReferenceSystem targetCRS,
@@ -375,7 +374,6 @@
* @throws TransformException if a coordinate conversion was required but failed.
* @throws IncommensurableException if a coordinate system does not use the expected units.
*/
- @SuppressWarnings("deprecation")
ProjectedCRS create(final GeographicCRS baseCRS, DirectPosition centroid, CoordinateReferenceSystem geometryCRS)
throws FactoryException, TransformException, IncommensurableException
{
@@ -403,7 +401,7 @@
double latitude = Double.NaN, longitude = Double.NaN;
for (int i=0; i<BIDIMENSIONAL; i++) {
final CoordinateSystemAxis axis = cs.getAxis(i);
- double coordinate = centroid.getCoordinate(i);
+ double coordinate = centroid.getOrdinate(i);
coordinate = axis.getUnit().getConverterToAny(Units.DEGREE).convert(coordinate);
final AxisDirection direction = axis.getDirection();
if (direction == AxisDirection.NORTH) latitude = coordinate;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/esri/Wrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/esri/Wrapper.java
index f956791..5a2f084 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/esri/Wrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/esri/Wrapper.java
@@ -43,8 +43,8 @@
import org.apache.sis.filter.sqlmm.SQLMM;
import org.apache.sis.util.Debug;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/PointWrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/PointWrapper.java
index da3ce14..e0c9b03 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/PointWrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/PointWrapper.java
@@ -31,8 +31,8 @@
import org.apache.sis.filter.sqlmm.SQLMM;
import org.apache.sis.util.Debug;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/Wrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/Wrapper.java
index f71187c..abda3bd 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/Wrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/j2d/Wrapper.java
@@ -38,8 +38,8 @@
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Debug;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
index 0ef1879..540081d 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
@@ -45,8 +45,8 @@
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
-import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
import org.apache.sis.referencing.privy.ReferencingUtilities;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.geometry.GeneralDirectPosition;
@@ -62,9 +62,9 @@
import org.apache.sis.filter.sqlmm.SQLMM;
import static org.apache.sis.geometry.wrapper.GeometryType.POINT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
@@ -757,7 +757,7 @@
* We wrap that exception because `Geometry.transform(…)` does not declare `FactoryException`.
* We may revisit in a future version if `Geometry.transform(…)` method declaration is updated.
*/
- throw new TransformException(e);
+ throw new TransformException(e.getMessage(), e);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedIterator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedIterator.java
index 7946d0c..7bca9db 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedIterator.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedIterator.java
@@ -29,9 +29,6 @@
import java.awt.image.WritableRaster;
import java.awt.image.WritableRenderedImage;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* A pixel iterator reading values directly from a {@link DataBuffer} instead of using {@link Raster} API.
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/Interpolation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/Interpolation.java
index 196c1c2..bb109ee 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/Interpolation.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/Interpolation.java
@@ -73,7 +73,7 @@
*
* Values in {@code source} buffer are always given with band index varying fastest, then column index,
* then row index. Columns are traversed from left to right and rows are traversed from top to bottom
- * ({@link org.opengis.coverage.grid.SequenceType#LINEAR} iteration order).
+ * ({@link org.apache.sis.image.SequenceType#LINEAR} iteration order).
*
* <p>The interpolation point is in the middle. For example if the {@linkplain #getSupportSize() support size}
* is 4×4 pixels, then the interpolation point is the dot below and the fractional coordinates are relative to
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PixelIterator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PixelIterator.java
index 76c8b23..8f606e1 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PixelIterator.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PixelIterator.java
@@ -49,9 +49,6 @@
import org.apache.sis.image.privy.ImageUtilities;
import static org.apache.sis.pending.jdk.JDK18.ceilDiv;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* An iterator over sample values in a raster or an image. This iterator makes easier to read and write efficiently
@@ -1094,7 +1091,7 @@
* <var>(number of bands)</var> × <var>(window width)</var> × <var>(window height)</var>.
* Values are always stored with band index varying fastest, then column index, then row index.
* Columns are traversed from left to right and rows are traversed from top to bottom
- * ({@link SequenceType#LINEAR} iteration order).
+ * (linear iteration order).
* That order is the same regardless the {@linkplain #getIterationOrder() iteration order} of this iterator.
*
* <div class="note"><b>Example:</b>
@@ -1115,7 +1112,7 @@
* <h4>Usage example</h4>
* following code creates an iterator over the full area of given image, then a window of 5×5 pixels.
* The window is moved over all the image area in iteration order. Inside the window, data are copied
- * in {@linkplain SequenceType#LINEAR linear order} regardless the iteration order.
+ * in linear order regardless the iteration order.
*
* {@snippet lang="java" :
* PixelIterator it = create(image, null, new Dimension(5, 5), null); // Windows size will be 5×5 pixels.
@@ -1192,8 +1189,8 @@
* capacity is <var>(number of bands)</var> × <var>(window width)</var> × <var>(window height)</var>.
* Values are always stored with band index varying fastest, then column index, then row index.
* Columns are traversed from left to right and rows are traversed from top to bottom
- * ({@link SequenceType#LINEAR} iteration order).
- * That order is the same regardless the {@linkplain PixelIterator#getIterationOrder() iteration order}
+ * (linear iteration order).
+ * That order is the same regardless the iteration order
* of enclosing iterator.
*
* <p>Every time that {@link #update()} is invoked, the buffer content is replaced by sample values
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SequenceType.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SequenceType.java
new file mode 100644
index 0000000..eca9e32
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SequenceType.java
@@ -0,0 +1,37 @@
+/*
+ * 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.image;
+
+
+/**
+ * Specifies the order in which attribute value records are assigned to grid points.
+ * Placeholder for {@code org.opengis.coverage.grid.SequenceType}.
+ *
+ * <div class="note"><b>Upcoming API change:</b>
+ * this class may move to GeoAPI in a future version. If that move happens,
+ * the {@code org.apache.sis.image} package name would become {@code org.opengis.coverage}.</div>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since 1.1
+ */
+public enum SequenceType {
+ /**
+ * Iterate consecutive grid points along complete grid lines.
+ */
+ LINEAR
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/WritablePixelIterator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/WritablePixelIterator.java
index 3c15235..1632d62 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/WritablePixelIterator.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/WritablePixelIterator.java
@@ -25,9 +25,6 @@
import java.awt.image.WritableRenderedImage;
import org.apache.sis.feature.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* A pixel iterator capable to write sample values. This iterator can edit pixel values in place,
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/processing/isoline/Isolines.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/processing/isoline/Isolines.java
index cc85ca3..9822b13 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/processing/isoline/Isolines.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/processing/isoline/Isolines.java
@@ -37,8 +37,8 @@
import static org.apache.sis.image.processing.isoline.Tracer.UPPER_RIGHT;
import static org.apache.sis.image.processing.isoline.Tracer.LOWER_RIGHT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
+// Specific to the main branch:
+import org.apache.sis.image.SequenceType;
/**
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BetweenComparisonOperator.java
similarity index 61%
copy from incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BetweenComparisonOperator.java
index 9a34ec3..e59a407 100644
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BetweenComparisonOperator.java
@@ -14,23 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.math;
+package org.apache.sis.pending.geoapi.filter;
+
+import org.apache.sis.filter.Expression;
+import org.apache.sis.filter.Filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public class TupleArrayNuiTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.UInt(SampleSystem.ofSize(dim), new int[length*dim]);
- }
-
+@SuppressWarnings("doclint:missing")
+public interface BetweenComparisonOperator<R> extends Filter<R> {
+ Expression<R,?> getExpression();
+ Expression<R,?> getLowerBoundary();
+ Expression<R,?> getUpperBoundary();
}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BinaryComparisonOperator.java
similarity index 61%
copy from incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BinaryComparisonOperator.java
index 9a34ec3..85df309 100644
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/BinaryComparisonOperator.java
@@ -14,23 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.math;
+package org.apache.sis.pending.geoapi.filter;
+
+import org.apache.sis.filter.Expression;
+import org.apache.sis.filter.Filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public class TupleArrayNuiTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.UInt(SampleSystem.ofSize(dim), new int[length*dim]);
- }
-
+@SuppressWarnings("doclint:missing")
+public interface BinaryComparisonOperator<R> extends Filter<R> {
+ Expression<R,?> getOperand1();
+ Expression<R,?> getOperand2();
+ boolean isMatchingCase();
+ MatchAction getMatchAction();
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ComparisonOperatorName.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ComparisonOperatorName.java
new file mode 100644
index 0000000..5936152
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ComparisonOperatorName.java
@@ -0,0 +1,36 @@
+/*
+ * 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.pending.geoapi.filter;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+public enum ComparisonOperatorName {
+ PROPERTY_IS_EQUAL_TO,
+ PROPERTY_IS_NOT_EQUAL_TO,
+ PROPERTY_IS_LESS_THAN,
+ PROPERTY_IS_GREATER_THAN,
+ PROPERTY_IS_LESS_THAN_OR_EQUAL_TO,
+ PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO,
+ PROPERTY_IS_BETWEEN,
+ PROPERTY_IS_LIKE,
+ PROPERTY_IS_NULL,
+ PROPERTY_IS_NIL;
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/DistanceOperatorName.java
similarity index 73%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/DistanceOperatorName.java
index 8fb81f9..843efbd 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/DistanceOperatorName.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
+package org.apache.sis.pending.geoapi.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public interface Ellipse {
-
+@SuppressWarnings("doclint:missing")
+public enum DistanceOperatorName {
+ BEYOND, WITHIN;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/FilterExpressions.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/FilterExpressions.java
new file mode 100644
index 0000000..4cbbb41
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/FilterExpressions.java
@@ -0,0 +1,111 @@
+/*
+ * 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.pending.geoapi.filter;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.AbstractList;
+import java.util.Locale;
+import org.opengis.util.ScopedName;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.util.iso.Names;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+final class FilterExpressions<R> extends AbstractList<Expression<R,?>> {
+ private final List<Filter<R>> filters;
+
+ FilterExpressions(final List<Filter<R>> filters) {
+ this.filters = Objects.requireNonNull(filters);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return filters.isEmpty();
+ }
+
+ @Override
+ public int size() {
+ return filters.size();
+ }
+
+ @Override
+ public Expression<R,?> get(final int index) {
+ return new Element<>(filters.get(index));
+ }
+
+ private static final class Element<R> implements Expression<R,Boolean> {
+ private final Filter<R> filter;
+
+ Element(final Filter<R> filter) {
+ this.filter = Objects.requireNonNull(filter);
+ }
+
+ @Override
+ public ScopedName getFunctionName() {
+ final Enum<?> type = filter.getOperatorType();
+ final String identifier = type.name().toLowerCase(Locale.US);
+ if (identifier != null) {
+ return Names.createScopedName(Name.STANDARD, null, identifier);
+ } else {
+ return Names.createScopedName(Name.EXTENSION, null, type.name());
+ }
+ }
+
+ @Override
+ public Class<? super R> getResourceClass() {
+ return filter.getResourceClass();
+ }
+
+ @Override
+ public List<Expression<R,?>> getParameters() {
+ return filter.getExpressions();
+ }
+
+ @Override
+ public Boolean apply(final R input) {
+ return filter.test(input);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <N> Expression<R,N> toValueType(final Class<N> type) {
+ if (type.isAssignableFrom(Boolean.class)) return (Expression<R,N>) this;
+ else throw new ClassCastException();
+ }
+
+ @Override
+ public int hashCode() {
+ return ~filter.hashCode();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return (obj instanceof Element) && filter.equals(((Element) obj).filter);
+ }
+
+ @Override
+ public String toString() {
+ return "Expression[" + filter.toString() + ']';
+ }
+ }
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Literal.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Literal.java
new file mode 100644
index 0000000..de447db
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Literal.java
@@ -0,0 +1,42 @@
+/*
+ * 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.pending.geoapi.filter;
+
+import java.util.List;
+import java.util.Collections;
+import org.opengis.util.ScopedName;
+import org.apache.sis.filter.Expression;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+public interface Literal<R,V> extends Expression<R,V> {
+ @Override
+ default ScopedName getFunctionName() {
+ return Name.LITERAL;
+ }
+
+ @Override
+ default List<Expression<R,?>> getParameters() {
+ return Collections.emptyList();
+ }
+
+ V getValue();
+}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperator.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperator.java
new file mode 100644
index 0000000..9ecd8f7
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperator.java
@@ -0,0 +1,39 @@
+/*
+ * 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.pending.geoapi.filter;
+
+import java.util.List;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+public interface LogicalOperator<R> extends Filter<R> {
+ @Override
+ LogicalOperatorName getOperatorType();
+
+ @Override
+ default List<Expression<R,?>> getExpressions() {
+ return new FilterExpressions<>(getOperands());
+ }
+
+ List<Filter<R>> getOperands();
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperatorName.java
similarity index 73%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperatorName.java
index 8fb81f9..8cda37d 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/LogicalOperatorName.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
+package org.apache.sis.pending.geoapi.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public interface Ellipse {
-
+@SuppressWarnings("doclint:missing")
+public enum LogicalOperatorName {
+ AND, OR, NOT;
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/MatchAction.java
similarity index 74%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/MatchAction.java
index 8fb81f9..bb48f8e 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/MatchAction.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
+package org.apache.sis.pending.geoapi.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public interface Ellipse {
-
+@SuppressWarnings("doclint:missing")
+public enum MatchAction {
+ ANY, ALL, ONE;
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Name.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Name.java
new file mode 100644
index 0000000..a2d6c7c
--- /dev/null
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/Name.java
@@ -0,0 +1,41 @@
+/*
+ * 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.pending.geoapi.filter;
+
+import org.opengis.util.LocalName;
+import org.opengis.util.ScopedName;
+import org.apache.sis.filter.privy.FunctionNames;
+import org.apache.sis.util.iso.Names;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+public final class Name {
+ static final LocalName STANDARD = Names.createLocalName(null, null, "fes");
+
+ static final LocalName EXTENSION = Names.createLocalName(null, null, "extension");
+
+ public static final ScopedName LITERAL = Names.createScopedName(STANDARD, null, FunctionNames.Literal);
+
+ public static final ScopedName VALUE_REFERENCE = Names.createScopedName(STANDARD, null, FunctionNames.ValueReference);
+
+ private Name() {
+ }
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortBy.java
similarity index 67%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortBy.java
index 05e9c3c..acda9ca 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortBy.java
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.splines;
+package org.apache.sis.pending.geoapi.filter;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
+import java.util.List;
+import java.util.Comparator;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-@UML(identifier="Bezier", specification=ISO_19107) // section 7.13.7
-public interface Bezier extends PolynomialSpline, BSplineCurve{
-
+@SuppressWarnings("doclint:missing")
+public interface SortBy<R> extends Comparator<R> {
+ List<SortProperty<R>> getSortProperties();
}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortOrder.java
similarity index 64%
rename from incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
rename to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortOrder.java
index 9a34ec3..6ed09b0 100644
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNuiTest.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortOrder.java
@@ -14,23 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.math;
+package org.apache.sis.pending.geoapi.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public class TupleArrayNuiTest extends AbstractTupleArrayTest {
+@SuppressWarnings("doclint:missing")
+public enum SortOrder {
+ ASCENDING("ASC"), DESCENDING("DESC");
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
+ private final String sql;
+
+ private SortOrder(final String sql) {
+ this.sql = sql;
}
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.UInt(SampleSystem.ofSize(dim), new int[length*dim]);
+ public String toSQL() {
+ return sql;
}
-
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Empty.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortProperty.java
similarity index 67%
rename from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Empty.java
rename to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortProperty.java
index 99f92b0..6927421 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Empty.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SortProperty.java
@@ -14,21 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries;
+package org.apache.sis.pending.geoapi.filter;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
+import java.util.Comparator;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-@UML(identifier="Empty", specification=ISO_19107) // section 6.4.10
-public interface Empty extends Geometry{
+@SuppressWarnings("doclint:missing")
+public interface SortProperty<R> extends Comparator<R> {
+ ValueReference<R,?> getValueReference();
- @Override
- default boolean isEmpty() {
- return true;
- }
+ SortOrder getSortOrder();
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SpatialOperatorName.java
similarity index 69%
rename from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
rename to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SpatialOperatorName.java
index 05e9c3c..a9fbf5c 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/SpatialOperatorName.java
@@ -14,17 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
+package org.apache.sis.pending.geoapi.filter;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-@UML(identifier="Bezier", specification=ISO_19107) // section 7.13.7
-public interface Bezier extends PolynomialSpline, BSplineCurve{
-
+@SuppressWarnings("doclint:missing")
+public enum SpatialOperatorName {
+ BBOX, EQUALS, DISJOINT, INTERSECTS, TOUCHES, CROSSES, WITHIN, CONTAINS, OVERLAPS;
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ValueReference.java
similarity index 68%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ValueReference.java
index 05e9c3c..868ac52 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/ValueReference.java
@@ -14,17 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.splines;
+package org.apache.sis.pending.geoapi.filter;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
+import org.apache.sis.filter.Expression;
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-@UML(identifier="Bezier", specification=ISO_19107) // section 7.13.7
-public interface Bezier extends PolynomialSpline, BSplineCurve{
-
+@SuppressWarnings("doclint:missing")
+public interface ValueReference<R,V> extends Expression<R,V> {
+ String getXPath();
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/package-info.java
similarity index 79%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/package-info.java
index 8fb81f9..4b7b314 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/pending/geoapi/filter/package-info.java
@@ -14,13 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
-
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
*/
-public interface Ellipse {
-
-}
+package org.apache.sis.pending.geoapi.filter;
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionAppenderTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionAppenderTest.java
index 9c24413..ca5f3c2 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionAppenderTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionAppenderTest.java
@@ -34,8 +34,8 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
index 4376261..e2c41ac 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
@@ -34,8 +34,8 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -126,7 +126,7 @@
* @param target expected reduced coordinates.
*/
private static void testPosition(final DimensionalityReduction reduction, double[] source, double[] target) {
- assertArrayEquals(target, reduction.apply(new DirectPositionView.Double(source)).getCoordinates());
+ assertArrayEquals(target, reduction.apply(new DirectPositionView.Double(source)).getCoordinate());
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridCoverage2DTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridCoverage2DTest.java
index 4721081..d4c0e15 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridCoverage2DTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridCoverage2DTest.java
@@ -43,10 +43,9 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.feature.Assertions.assertPixelsEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.PointOutsideCoverageException;
-import static org.opengis.test.Assertions.assertSampleValuesEqual;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.PointOutsideCoverageException;
/**
@@ -292,7 +291,7 @@
assertEquals(2, result.getMinY());
assertEquals(GRID_SIZE, result.getWidth());
assertEquals(GRID_SIZE, result.getHeight());
- assertSampleValuesEqual(coverage.render(null), result, STRICT, null);
+ assertPixelsEqual(coverage.render(null), null, result, null);
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java
index 0ed8c3b..de7cea0 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java
@@ -48,9 +48,9 @@
import org.apache.sis.referencing.operation.HardCodedConversions;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertBetween;
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -738,7 +738,7 @@
.build();
// Build expected grid point focused after slicing. We expect it to be upper corner.
- expectedGridPoint = DoubleStream.of(grid3d.getUpperCorner().getCoordinates())
+ expectedGridPoint = DoubleStream.of(grid3d.getUpperCorner().getCoordinate())
.mapToLong(value -> (long) value)
.map(exclusiveValue -> exclusiveValue - 1) // Exclusive to inclusive.
.toArray();
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridExtentTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridExtentTest.java
index 9507670..411107f 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridExtentTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridExtentTest.java
@@ -45,10 +45,10 @@
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.PointOutsideCoverageException;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import org.apache.sis.coverage.PointOutsideCoverageException;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridGeometryTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridGeometryTest.java
index b423c0b..038c725 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridGeometryTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridGeometryTest.java
@@ -42,8 +42,8 @@
import org.apache.sis.referencing.operation.HardCodedConversions;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/PixelTranslationTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/PixelTranslationTest.java
index 28c184f..3235bc1 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/PixelTranslationTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/PixelTranslationTest.java
@@ -28,8 +28,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/ResampledGridCoverageTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/ResampledGridCoverageTest.java
index f0530b7..a9c715c 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/ResampledGridCoverageTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/ResampledGridCoverageTest.java
@@ -60,9 +60,8 @@
import static org.apache.sis.feature.Assertions.assertValuesEqual;
import static org.apache.sis.feature.Assertions.assertPixelsEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertSampleValuesEqual;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -405,7 +404,7 @@
new AxisDirection[] {AxisDirection.FUTURE, AxisDirection.EAST, AxisDirection.NORTH, AxisDirection.UP},
"Expected (t,λ,φ,H) axes.");
- assertSampleValuesEqual(source.render(null), result.render(null), STRICT, null);
+ assertPixelsEqual(source.render(null), null, result.render(null), null);
}
/**
@@ -545,7 +544,7 @@
* Target image should be 6×6 pixels, like source image.
*/
final GridCoverage result = resample(source, targetGeom);
- assertSampleValuesEqual(source.render(null), result.render(null), STRICT, null);
+ assertPixelsEqual(source.render(null), null, result.render(null), null);
}
/**
@@ -561,7 +560,7 @@
final GridGeometry target4D = createGridGeometryND(HardCodedCRS.WGS84_4D, 0, 1, 2, 3, false);
final GridCoverage result = resample(source3D, target4D);
assertEquals(target4D, result.getGridGeometry());
- assertSampleValuesEqual(source3D.render(null), result.render(null), STRICT, null);
+ assertPixelsEqual(source3D.render(null), null, result.render(null), null);
}
/**
@@ -575,7 +574,7 @@
final GridCoverage source4D = createCoverageND(true);
final GridCoverage result = resample(source4D, target3D);
assertEquals(target3D, result.getGridGeometry());
- assertSampleValuesEqual(source4D.render(null), result.render(null), STRICT, null);
+ assertPixelsEqual(source4D.render(null), null, result.render(null), null);
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/AbstractFeatureTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/AbstractFeatureTest.java
index 637b6a1..c1caf4d 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/AbstractFeatureTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/AbstractFeatureTest.java
@@ -23,12 +23,6 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-
/**
* Tests some default method implementations provided in {@link AbstractFeature}.
@@ -67,8 +61,8 @@
*/
CustomFeature(final DefaultFeatureType type) {
super(type);
- for (final PropertyType property : type.getProperties(true)) {
- if (property instanceof AttributeType<?> attribute) {
+ for (final AbstractIdentifiedType property : type.getProperties(true)) {
+ if (property instanceof DefaultAttributeType<?> attribute) {
Object value = attribute.getDefaultValue();
if (isMultiValued(property)) {
value = new ArrayList<>(PropertyView.singletonOrEmpty(value));
@@ -83,8 +77,8 @@
/**
* Returns {@code true} if the given property can contains more than one value.
*/
- private static boolean isMultiValued(final PropertyType pt) {
- return (pt instanceof AttributeType<?>) && (((AttributeType<?>) pt).getMaximumOccurs() > 1);
+ private static boolean isMultiValued(final AbstractIdentifiedType pt) {
+ return (pt instanceof DefaultAttributeType<?>) && (((DefaultAttributeType<?>) pt).getMaximumOccurs() > 1);
}
/**
@@ -122,7 +116,7 @@
}
if (value != null) {
final Class<?> base;
- if (property instanceof AttributeType<?> attribute) {
+ if (property instanceof DefaultAttributeType<?> attribute) {
base = attribute.getValueClass();
} else {
base = FeatureType.class;
@@ -158,10 +152,7 @@
*/
@Override
boolean assertSameProperty(final String name, final Property expected, final boolean modified) {
- final var actual = feature.getProperty(name);
- if ((expected instanceof PropertyView) == (actual instanceof PropertyView)) {
- assertEquals(expected, actual, name);
- }
+ final var actual = (Property) feature.getProperty(name);
assertSame(expected.getName(), actual.getName(), "name");
if (!modified) {
assertSame(expected.getValue(), actual.getValue(), "value");
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
index 20545ef..12a634a 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
@@ -26,8 +26,9 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
+// Specific to the main branch:
+import java.awt.geom.PathIterator;
+import org.apache.sis.image.SequenceType;
/**
@@ -169,4 +170,38 @@
+ "— matrix indices (" + i + ", " + j + ") band " + band
+ ": expected " + expected + " but found " + actual;
}
+
+ /**
+ * Asserts that the path is equal to given reference.
+ *
+ * @param expected expected geometry outline.
+ * @param actual actual geometry outline.
+ * @param tolerance tolerance threshold for floating point value comparisons.
+ */
+ @SuppressWarnings("fallthrough")
+ public static void assertPathEquals(final PathIterator expected, final PathIterator actual, final double tolerance) {
+ assertEquals(expected.getWindingRule(), actual.getWindingRule(), "windingRule");
+ final double[] buffer = new double[6];
+ final double[] values = new double[6];
+ while (!expected.isDone()) {
+ assertFalse(actual.isDone(), "isDone");
+ final int type = expected.currentSegment(buffer);
+ assertEquals(type, actual.currentSegment(values), "currentSegment");
+ switch (type) {
+ case PathIterator.SEG_CUBICTO: assertEquals(buffer[4], values[4], tolerance, "x₃");
+ assertEquals(buffer[5], values[5], tolerance, "y₃");
+ case PathIterator.SEG_QUADTO: assertEquals(buffer[2], values[2], tolerance, "x₂");
+ assertEquals(buffer[3], values[3], tolerance, "y₂");
+ case PathIterator.SEG_LINETO: assertEquals(buffer[0], values[0], tolerance, "x₁");
+ assertEquals(buffer[1], values[1], tolerance, "y₁"); break;
+ case PathIterator.SEG_MOVETO: assertEquals(buffer[0], values[0], tolerance, "x₀");
+ assertEquals(buffer[1], values[1], tolerance, "y₀");
+ case PathIterator.SEG_CLOSE: break;
+ default: fail("Unexpected type: " + type);
+ }
+ expected.next();
+ actual.next();
+ }
+ assertTrue(actual.isDone(), "isDone");
+ }
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicMapTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicMapTest.java
index 2ff66c6..b663148 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicMapTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicMapTest.java
@@ -27,9 +27,6 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-
/**
* Tests {@link CharacteristicMap} indirectly, through {@link AbstractAttribute} construction.
@@ -64,7 +61,7 @@
}
/**
- * Tests adding explicitly a characteristic with {@link CharacteristicMap#put(String, Attribute)}.
+ * Tests adding explicitly a characteristic with {@code CharacteristicMap.put(String, AbstractAttribute)}.
*/
@Test
public void testPut() {
@@ -140,7 +137,7 @@
}
/**
- * Tests adding a characteristic indirectly with {@link CharacteristicMap#addValue(Attribute)}.
+ * Tests adding a characteristic indirectly with {@code CharacteristicMap.addValue(AbstractAttribute)}.
*/
@Test
public void testAddValue() {
@@ -196,7 +193,7 @@
*/
@Test
public void testAddKey() {
- final Attribute<?> units, accuracy;
+ final AbstractAttribute<?> units, accuracy;
final AbstractAttribute<?> temperature = temperature();
final var characteristics = temperature.characteristics();
final Collection<String> keys = characteristics.keySet();
@@ -251,8 +248,8 @@
* @param accuracy the second expected value in iteration order.
* @param characteristics the map to verify.
*/
- private static void assertEntriesEqual(final Attribute<?> units, final Attribute<?> accuracy,
- final Map<String,Attribute<?>> characteristics)
+ private static void assertEntriesEqual(final AbstractAttribute<?> units, final AbstractAttribute<?> accuracy,
+ final Map<String,AbstractAttribute<?>> characteristics)
{
assertArrayEquals(new String[] {"accuracy", "units"}, characteristics.keySet().toArray());
assertArrayEquals(new Object[] { accuracy , units }, characteristics.values().toArray());
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicTypeMapTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicTypeMapTest.java
index 9fb94bd..7e8300f 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicTypeMapTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CharacteristicTypeMapTest.java
@@ -27,9 +27,6 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* Tests {@link CharacteristicTypeMap} indirectly, through {@link DefaultAttributeType} construction.
@@ -77,7 +74,7 @@
*/
@Test
public void testMapMethods() {
- final AttributeType<?> units, accuracy;
+ final DefaultAttributeType<?> units, accuracy;
final DefaultAttributeType<Float> temperature = temperature();
final var characteristics = temperature.characteristics();
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CustomAttribute.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CustomAttribute.java
index 9cbb0d6..2ebf0f1 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CustomAttribute.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/CustomAttribute.java
@@ -24,9 +24,6 @@
import org.apache.sis.util.SimpleInternationalString;
import org.apache.sis.referencing.NamedIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* For testing {@link AbstractAttribute} customization.
@@ -49,7 +46,7 @@
/**
* Creates a new attribute.
*/
- public CustomAttribute(final AttributeType<V> type) {
+ public CustomAttribute(final DefaultAttributeType<V> type) {
super(type);
value = type.getDefaultValue();
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultAssociationRoleTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultAssociationRoleTest.java
index bc2323d..28e1ee3 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultAssociationRoleTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultAssociationRoleTest.java
@@ -29,10 +29,6 @@
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.FeatureType;
-
/**
* Tests {@link DefaultAssociationRole}.
@@ -88,10 +84,10 @@
* @return the feature type to use for testing purpose.
*/
private static DefaultFeatureType createType(final Object name,
- final FeatureType parent, final FeatureAssociationRole... property)
+ final DefaultFeatureType parent, final DefaultAssociationRole... property)
{
return new DefaultFeatureType(Map.of(NAME_KEY, name),
- false, new FeatureType[] {parent}, property);
+ false, new DefaultFeatureType[] {parent}, property);
}
/**
@@ -104,7 +100,7 @@
}
/**
- * Tests {@link DefaultAssociationRole#getTitleProperty(FeatureAssociationRole)}.
+ * Tests {@code DefaultAssociationRole.getTitleProperty(FeatureAssociationRole)}.
*/
@Test
public void testGetTitleProperty() {
@@ -127,7 +123,7 @@
@Test
public void testBidirectionalAssociation() {
final DefaultFeatureType twinTown = twinTownCity(true);
- final var association = assertInstanceOf(FeatureAssociationRole.class, twinTown.getProperty("twin town"));
+ final var association = (DefaultAssociationRole) twinTown.getProperty("twin town");
assertSame(twinTown, association.getValueType());
/*
* Creates a FeatureType copy containing the same properties. Used for verifying
@@ -142,7 +138,7 @@
}
/**
- * Tests {@link DefaultFeatureType#isAssignableFrom(FeatureType)} and {@link DefaultFeatureType#equals(Object)}
+ * Tests {@code DefaultFeatureType.isAssignableFrom(FeatureType)} and {@code DefaultFeatureType.equals(Object)}
* on a feature type having a bidirectional association to another feature. This test will fall in an infinite
* loop if the implementation does not have proper guard against infinite recursion.
*/
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultFeatureTypeTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultFeatureTypeTest.java
index a27dc36..1d79073 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultFeatureTypeTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/DefaultFeatureTypeTest.java
@@ -30,10 +30,6 @@
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-
/**
* Tests {@link DefaultFeatureType}.
@@ -203,7 +199,7 @@
final String... expected)
{
int index = 0;
- for (final PropertyType property : feature.getProperties(includeSuperTypes)) {
+ for (final AbstractIdentifiedType property : feature.getProperties(includeSuperTypes)) {
assertTrue(index < expected.length, "Found more properties than expected.");
final String name = expected[index++];
assertNotNull(property, name);
@@ -432,7 +428,7 @@
assertPropertiesEquals(metroCapital, false, "country");
assertPropertiesEquals(metroCapital, true, "city", "population", "region", "isGlobal", "parliament", "country");
assertEquals(CharSequence.class,
- assertInstanceOf(AttributeType.class, metroCapital.getProperty("region")).getValueClass());
+ assertInstanceOf(DefaultAttributeType.class, metroCapital.getProperty("region")).getValueClass());
// Check based only on name.
assertTrue (DefaultFeatureType.maybeAssignableFrom(capital, metroCapital));
@@ -473,7 +469,7 @@
assertPropertiesEquals(worldMetropolis, false, "region", "temperature");
assertPropertiesEquals(worldMetropolis, true, "city", "population", "region", "isGlobal", "universities", "temperature");
assertEquals(InternationalString.class,
- assertInstanceOf(AttributeType.class, worldMetropolis.getProperty("region")).getValueClass());
+ assertInstanceOf(DefaultAttributeType.class, worldMetropolis.getProperty("region")).getValueClass());
// Check based only on name.
assertTrue (DefaultFeatureType.maybeAssignableFrom(metropolis, worldMetropolis));
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/EnvelopeOperationTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/EnvelopeOperationTest.java
index 8e17de1..ed6ecb5 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/EnvelopeOperationTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/EnvelopeOperationTest.java
@@ -37,11 +37,6 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-
/**
* Tests {@link EnvelopeOperation}.
@@ -62,12 +57,12 @@
* @see #initialize()
* @see #initialize(CoordinateReferenceSystem, boolean, CoordinateReferenceSystem, boolean)
*/
- private FeatureType type;
+ private DefaultFeatureType type;
/**
* The feature created by a test method. Saved for allowing additional checks or operations.
*/
- private Feature feature;
+ private AbstractFeature feature;
/**
* Creates a new test case.
@@ -163,7 +158,7 @@
if (asCharacteristic) {
@SuppressWarnings("unchecked")
- final var property = (Attribute<GeometryWrapper>) feature.getProperty(propertyName);
+ final var property = (AbstractAttribute<GeometryWrapper>) feature.getProperty(propertyName);
final var crsCharacteristic = Features.cast(
property.getType().characteristics().get(AttributeConvention.CRS),
CoordinateReferenceSystem.class).newInstance();
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureOperationsTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureOperationsTest.java
index c4029ca..d5a9b86 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureOperationsTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureOperationsTest.java
@@ -34,9 +34,6 @@
import static org.apache.sis.test.Assertions.assertSetEquals;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.PropertyType;
-
/**
* Tests a feature combining various {@link FeatureOperations} applied of either sparse or dense features.
@@ -76,7 +73,7 @@
final var normalizedCRS = new DefaultAttributeType<>(
name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84);
- final PropertyType[] attributes = {
+ final AbstractIdentifiedType[] attributes = {
new DefaultAttributeType<>(name("name"), String.class, 1, 1, null),
new DefaultAttributeType<>(name("classes"), Polygon.class, 1, 1, null, standardCRS),
new DefaultAttributeType<>(name("climbing wall"), Point.class, 1, 1, null, standardCRS),
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
index e7cdce1..c080642 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
@@ -35,11 +35,6 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Property;
-
/**
* Tests common to {@link DenseFeatureTest} and {@link SparseFeatureTest}.
@@ -77,7 +72,7 @@
/**
* Asserts that {@link AbstractFeature#getProperty(String)} returns the given instance.
- * This assertion is verified after a call to {@link AbstractFeature#setProperty(Property)}
+ * This assertion is verified after a call to {@code AbstractFeature.setProperty(Property)}
* and should be true for all Apache SIS concrete implementations. But it is not guaranteed
* to be true for non-SIS implementations, for example built on top of {@code AbstractFeature}
* without overriding {@code setProperty(Property)}.
@@ -106,7 +101,7 @@
* - Attribute value shall be the same as the one we got at the beginning of this method.
* - Attribute values (as a collection) is either empty or contains the same value.
*/
- final var property = assertInstanceOf(Attribute.class, feature.getProperty(name));
+ final var property = assertInstanceOf(AbstractAttribute.class, feature.getProperty(name));
assertSame(feature.getType().getProperty(name), property.getType(), name);
assertSame(value, property.getValue(), name);
final Collection<?> values = property.getValues();
@@ -163,9 +158,9 @@
feature.setPropertyValue("REF_INSEE", "92007");
feature.setPropertyValue("CODE_POSTAL", "92220");
- assertEquals("92220", feature.getProperty("CODE_POSTAL").getValue());
- assertEquals("92007", feature.getProperty("REF_INSEE") .getValue());
- assertEquals("Bagneux", feature.getProperty("COMMUNE") .getValue());
+ assertEquals("92220", ((AbstractAttribute) feature.getProperty("CODE_POSTAL")).getValue());
+ assertEquals("92007", ((AbstractAttribute) feature.getProperty("REF_INSEE")) .getValue());
+ assertEquals("Bagneux", ((AbstractAttribute) feature.getProperty("COMMUNE")) .getValue());
assertEquals("92220", feature.getPropertyValue("CODE_POSTAL"));
assertEquals("92007", feature.getPropertyValue("REF_INSEE"));
@@ -287,14 +282,14 @@
}
/**
- * Tests the possibility to plugin custom attributes via {@link AbstractFeature#setProperty(Property)}.
+ * Tests the possibility to plugin custom attributes via {@code AbstractFeature.setProperty(Property)}.
*/
@Test
public void testCustomAttribute() {
feature = createFeature(DefaultFeatureTypeTest.city());
- final var wrong = SingletonAttributeTest.parliament();
- final var city = assertInstanceOf(AttributeType.class, feature.getType().getProperty("city"));
- final var cast = new CustomAttribute<>(Features.cast(city, String.class));
+ final var wrong = SingletonAttributeTest.parliament();
+ final var city = assertInstanceOf(DefaultAttributeType.class, feature.getType().getProperty("city"));
+ final var cast = new CustomAttribute<>(Features.cast(city, String.class));
feature.setProperty(cast);
setAttributeValue("city", "Utopia", "Atlantide");
@@ -419,13 +414,13 @@
* Force the conversion of a property value into a full Property object on one and only one of
* the Features to be compared. The implementation shall be able to wrap or unwrap the values.
*/
- assertEquals("Tokyo", clone.getProperty("city").getValue());
+ assertEquals("Tokyo", ((AbstractAttribute) clone.getProperty("city")).getValue());
assertEquals(feature.hashCode(), clone.hashCode());
assertEquals(feature, clone);
/*
* For the other Feature instance to contain full Property object and test again.
*/
- assertEquals("Tokyo", feature.getProperty("city").getValue());
+ assertEquals("Tokyo", ((AbstractAttribute) feature.getProperty("city")).getValue());
assertEquals(feature.hashCode(), clone.hashCode());
assertEquals(feature, clone);
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeaturesTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeaturesTest.java
index 7398ae8..6b044c4 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeaturesTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeaturesTest.java
@@ -22,9 +22,6 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.InvalidPropertyValueException;
-
/**
* Tests {@link Features}.
@@ -40,7 +37,7 @@
}
/**
- * Tests {@link Features#cast(AttributeType, Class)}.
+ * Tests {@code Features.cast(AttributeType, Class)}.
*/
@Test
public void testCastAttributeType() {
@@ -73,7 +70,7 @@
* Feature is invalid because of missing property “population”.
* Validation should raise an exception.
*/
- var e = assertThrows(InvalidPropertyValueException.class, () -> Features.validate(feature));
+ var e = assertThrows(IllegalArgumentException.class, () -> Features.validate(feature));
String message = e.getMessage();
assertTrue(message.contains("city") || message.contains("population"), message);
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/GroupAsPolylineOperationTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/GroupAsPolylineOperationTest.java
index 1d92c7d..aced83f 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/GroupAsPolylineOperationTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/GroupAsPolylineOperationTest.java
@@ -28,9 +28,6 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-
/**
* Tests {@link GroupAsPolylineOperation}.
@@ -62,7 +59,7 @@
GeometryLibrary.ESRI, feature.getType().getProperty("points"));
final var result = group.apply(feature, null);
- final var value = assertInstanceOf(Attribute.class, result).getValue();
+ final var value = assertInstanceOf(AbstractAttribute.class, result).getValue();
final var poly = assertInstanceOf(Polyline.class, value);
assertEquals(-6, poly.getPoint(0).getX());
assertEquals( 7, poly.getPoint(1).getY());
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/NoOperation.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/NoOperation.java
index b34a465..bb62097 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/NoOperation.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/NoOperation.java
@@ -20,11 +20,6 @@
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Property;
-
/**
* An operation that does nothing.
@@ -42,7 +37,7 @@
/**
* The type of the result, or {@code null} if none.
*/
- private final IdentifiedType result;
+ private final AbstractIdentifiedType result;
/**
* Constructs an operation from the given properties. The identification map is given unchanged to
@@ -53,7 +48,7 @@
* @param result the type of the result, or {@code null} if none.
*/
NoOperation(final Map<String,?> identification,
- final ParameterDescriptorGroup parameters, final IdentifiedType result)
+ final ParameterDescriptorGroup parameters, final AbstractIdentifiedType result)
{
super(identification);
this.parameters = parameters;
@@ -76,7 +71,7 @@
* @return the type of the result, or {@code null} if none.
*/
@Override
- public IdentifiedType getResult() {
+ public AbstractIdentifiedType getResult() {
return result;
}
@@ -86,7 +81,7 @@
* @return {@code null}
*/
@Override
- public Property apply(Feature feature, ParameterValueGroup parameters) {
+ public Object apply(AbstractFeature feature, ParameterValueGroup parameters) {
return null;
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/StringJoinOperationTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/StringJoinOperationTest.java
index 8225648..55640af 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/StringJoinOperationTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/StringJoinOperationTest.java
@@ -25,9 +25,6 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.InvalidPropertyValueException;
-
/**
* Tests {@link StringJoinOperation}.
@@ -139,24 +136,24 @@
@Test
public void testIllegalArgument() {
final var feature = new DenseFeature(person());
- InvalidPropertyValueException e;
+ IllegalArgumentException e;
- e = assertThrows(InvalidPropertyValueException.class,
+ e = assertThrows(IllegalArgumentException.class,
() -> feature.setPropertyValue("concat", "((:marc/21:>>"),
"Should fail because of mismatched prefix.");
assertMessageContains(e, "<<:", "((");
- e = assertThrows(InvalidPropertyValueException.class,
+ e = assertThrows(IllegalArgumentException.class,
() -> feature.setPropertyValue("concat", "<<:marc/21:))"),
"Should fail because of mismatched suffix.");
assertMessageContains(e, ":>>", "))");
- e = assertThrows(InvalidPropertyValueException.class,
+ e = assertThrows(IllegalArgumentException.class,
() -> feature.setPropertyValue("concat", "<<:marc/21/julie:>>"),
"Should fail because of too many components.");
assertMessageContains(e, "<<:marc/21/julie:>>");
- e = assertThrows(InvalidPropertyValueException.class,
+ e = assertThrows(IllegalArgumentException.class,
() -> feature.setPropertyValue("concat", "<<:marc/julie:>>"),
"Should fail because of unparsable number.");
assertMessageContains(e, "julie", "age");
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java
index f7c3a91..8e1ab97 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java
@@ -31,9 +31,9 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractAttribute;
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -241,11 +241,11 @@
assertEquals(Integer.class, boxBuilder.getValueClass(), "Attribute value type should have been boxed");
final var featureType = ftb.build();
- final var propertyType = assertInstanceOf(AttributeType.class, featureType.getProperty("boxed"));
+ final var propertyType = assertInstanceOf(DefaultAttributeType.class, featureType.getProperty("boxed"));
assertEquals(Integer.class, propertyType.getValueClass(), "Attribute value type should have been boxed");
final var feature = featureType.newInstance();
- final var property = assertInstanceOf(Attribute.class, feature.getProperty("boxed"));
+ final var property = assertInstanceOf(AbstractAttribute.class, feature.getProperty("boxed"));
assertEquals(Integer.class, property.getType().getValueClass(), "Attribute value type should have been boxed");
int value = 3;
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java
index 42cd331..caa2ac5 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java
@@ -33,11 +33,10 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -55,13 +54,13 @@
}
/**
- * Verifies that {@link FeatureTypeBuilder#setSuperTypes(FeatureType...)} ignores null parents.
+ * Verifies that {@code FeatureTypeBuilder.setSuperTypes(FeatureType...)} ignores null parents.
* This method tests only the builder state without creating feature type.
*/
@Test
public void testNullParents() {
var builder = new FeatureTypeBuilder(null);
- assertSame(builder, builder.setSuperTypes(new FeatureType[6]));
+ assertSame(builder, builder.setSuperTypes(new DefaultFeatureType[6]));
assertEquals(0, builder.getSuperTypes().length);
}
@@ -405,9 +404,9 @@
/**
* Verifies that the given property is an attribute with the given name and value class.
*/
- private static void assertPropertyEquals(final String name, final Class<?> valueClass, IdentifiedType property) {
+ private static void assertPropertyEquals(final String name, final Class<?> valueClass, AbstractIdentifiedType property) {
assertEquals(name, property.getName().toString());
- if (property instanceof Operation op) {
+ if (property instanceof AbstractOperation op) {
property = op.getResult();
}
assertEquals(valueClass, attributeType(property).getValueClass());
@@ -416,8 +415,8 @@
/**
* Casts a property to an attribute.
*/
- private static AttributeType<?> attributeType(final IdentifiedType property) {
- return assertInstanceOf(AttributeType.class, property);
+ private static DefaultAttributeType<?> attributeType(final AbstractIdentifiedType property) {
+ return assertInstanceOf(DefaultAttributeType.class, property);
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/test/FeatureComparator.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/test/FeatureComparator.java
index 8466701..2c30b0b 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/test/FeatureComparator.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/test/FeatureComparator.java
@@ -33,15 +33,13 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.apache.sis.util.Deprecable;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.DefaultAssociationRole;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.AbstractOperation;
/**
@@ -54,22 +52,22 @@
/**
* The expected feature, or {@code null} if comparing only feature type.
*/
- private final Feature expectedInstance;
+ private final AbstractFeature expectedInstance;
/**
* The expected feature type.
*/
- private final FeatureType expectedType;
+ private final DefaultFeatureType expectedType;
/**
* The actual feature, or {@code null} if comparing only feature type.
*/
- private final Feature actualInstance;
+ private final AbstractFeature actualInstance;
/**
* The actual feature type.
*/
- private final FeatureType actualType;
+ private final DefaultFeatureType actualType;
/**
* The fully-qualified name of properties to ignore in comparisons.
@@ -100,7 +98,7 @@
* to feature types and property types. The default value is {@code false}.
*
* @see #compare()
- * @see IdentifiedType#getDefinition()
+ * @see AbstractIdentifiedType#getDefinition()
*/
public boolean ignoreDefinition;
@@ -109,7 +107,7 @@
* to feature types and property types. The default value is {@code false}.
*
* @see #compare()
- * @see IdentifiedType#getDesignation()
+ * @see AbstractIdentifiedType#getDesignation()
*/
public boolean ignoreDesignation;
@@ -118,7 +116,7 @@
* to feature types and property types. The default value is {@code false}.
*
* @see #compare()
- * @see IdentifiedType#getDescription()
+ * @see AbstractIdentifiedType#getDescription()
*/
public boolean ignoreDescription;
@@ -133,7 +131,7 @@
* @param expected the expected feature instance.
* @param actual the actual feature instance.
*/
- public FeatureComparator(final Feature expected, final Feature actual) {
+ public FeatureComparator(final AbstractFeature expected, final AbstractFeature actual) {
expectedInstance = expected;
expectedType = expected.getType();
actualInstance = actual;
@@ -146,7 +144,7 @@
* @param expected the expected feature type.
* @param actual the actual feature type.
*/
- public FeatureComparator(final FeatureType expected, final FeatureType actual) {
+ public FeatureComparator(final DefaultFeatureType expected, final DefaultFeatureType actual) {
expectedInstance = null;
expectedType = Objects.requireNonNull(expected);
actualInstance = null;
@@ -176,16 +174,16 @@
* @param actual the actual type.
* @throws AssertionError if the actual type is not equal to the expected type.
*/
- private void compareType(final IdentifiedType expected, final IdentifiedType actual) {
+ private void compareType(final AbstractIdentifiedType expected, final AbstractIdentifiedType actual) {
boolean recognized = false;
- if (expected instanceof FeatureType type) {
- var c = assertInstanceOf(FeatureType.class, actual, this::path);
+ if (expected instanceof DefaultFeatureType type) {
+ var c = assertInstanceOf(DefaultFeatureType.class, actual, this::path);
compareFeatureType(type, c);
recognized = true;
}
- if (expected instanceof PropertyType type) {
- var c = assertInstanceOf(PropertyType.class, actual, this::path);
- comparePropertyType(type, c);
+ /* Condition in "geoapi-3.1" branch removed in this branch. */ {
+ var c = assertInstanceOf(AbstractIdentifiedType.class, actual, this::path);
+ comparePropertyType(expected, c);
recognized = true;
}
if (!recognized) {
@@ -200,7 +198,7 @@
* @param actual the actual type.
* @throws AssertionError if the actual type is not equal to the expected type.
*/
- private void compareFeatureType(final FeatureType expected, final FeatureType actual) {
+ private void compareFeatureType(final DefaultFeatureType expected, final DefaultFeatureType actual) {
compareIdentifiedType(expected, actual);
assertEquals(expected.isAbstract(), actual.isAbstract(), () -> path() + "Abstract state differ.");
@@ -209,12 +207,12 @@
* Compare all properties that are not ignored.
* Properties are removed from the `actualProperties` list as we found them.
*/
- final List<PropertyType> actualProperties = new ArrayList<>(actual.getProperties(false));
+ final List<AbstractIdentifiedType> actualProperties = new ArrayList<>(actual.getProperties(false));
actualProperties.removeIf(this::isIgnored);
- for (final PropertyType pte : expected.getProperties(false)) {
+ for (final AbstractIdentifiedType pte : expected.getProperties(false)) {
if (!isIgnored(pte)) {
final String tip = push(pte.getName().toString());
- PropertyType pta = findAndRemove(actualProperties, pte.getName());
+ AbstractIdentifiedType pta = findAndRemove(actualProperties, pte.getName());
comparePropertyType(pte, pta);
pull(tip);
}
@@ -226,7 +224,7 @@
final StringBuilder b = new StringBuilder(path())
.append("Actual type contains a property not declared in expected type:")
.append(System.lineSeparator());
- for (final PropertyType pta : actualProperties) {
+ for (final AbstractIdentifiedType pta : actualProperties) {
b.append(" ").append(pta.getName()).append(System.lineSeparator());
}
fail(b.toString());
@@ -241,9 +239,9 @@
* @param actual the actual instance.
* @throws AssertionError if the actual instance is not equal to the expected instance.
*/
- private void compareFeature(final Feature expected, final Feature actual) {
+ private void compareFeature(final AbstractFeature expected, final AbstractFeature actual) {
compareFeatureType(expected.getType(), actual.getType());
- for (final PropertyType p : expected.getType().getProperties(true)) {
+ for (final AbstractIdentifiedType p : expected.getType().getProperties(true)) {
if (isIgnored(p)) {
continue;
}
@@ -256,8 +254,8 @@
while (expectedIter.hasNext()) {
final Object expectedElement = expectedIter.next();
final Object actualElement = actualIter.next();
- if (expectedElement instanceof Feature instance) {
- compareFeature(instance, (Feature) actualElement);
+ if (expectedElement instanceof AbstractFeature instance) {
+ compareFeature(instance, (AbstractFeature) actualElement);
} else {
assertEquals(expectedElement, actualElement);
}
@@ -273,17 +271,17 @@
* @param actual the actual property.
* @throws AssertionError if the actual property is not equal to the expected property.
*/
- private void comparePropertyType(final PropertyType expected, final PropertyType actual) {
- if (expected instanceof AttributeType<?> type) {
- var c = assertInstanceOf(AttributeType.class, actual, this::path);
+ private void comparePropertyType(final AbstractIdentifiedType expected, final AbstractIdentifiedType actual) {
+ if (expected instanceof DefaultAttributeType<?> type) {
+ var c = assertInstanceOf(DefaultAttributeType.class, actual, this::path);
compareAttribute(type, c);
}
- if (expected instanceof FeatureAssociationRole role) {
- var c = assertInstanceOf(FeatureAssociationRole.class, actual, this::path);
+ if (expected instanceof DefaultAssociationRole role) {
+ var c = assertInstanceOf(DefaultAssociationRole.class, actual, this::path);
compareFeatureAssociationRole(role, c);
}
- if (expected instanceof Operation op) {
- var c = assertInstanceOf(Operation.class, actual, this::path);
+ if (expected instanceof AbstractOperation op) {
+ var c = assertInstanceOf(AbstractOperation.class, actual, this::path);
compareOperation(op, c);
}
}
@@ -295,21 +293,21 @@
* @param actual the actual property.
* @throws AssertionError if the actual property is not equal to the expected property.
*/
- private void compareAttribute(final AttributeType<?> expected, final AttributeType<?> actual) {
+ private void compareAttribute(final DefaultAttributeType<?> expected, final DefaultAttributeType<?> actual) {
compareIdentifiedType(expected, actual);
assertEquals(expected.getValueClass(), expected.getValueClass(), () -> path() + "Value classe differ.");
assertEquals(expected.getDefaultValue(), expected.getDefaultValue(), () -> path() + "Default value differ.");
- final Map<String, AttributeType<?>> expectedChrs = expected.characteristics();
- final Map<String, AttributeType<?>> actualChrs = actual.characteristics();
+ final Map<String, DefaultAttributeType<?>> expectedChrs = expected.characteristics();
+ final Map<String, DefaultAttributeType<?>> actualChrs = actual.characteristics();
final List<String> actualChrNames = new ArrayList<>(actualChrs.keySet());
actualChrNames.removeIf((p) -> ignoredCharacteristics.contains(p));
- for (final Map.Entry<String, AttributeType<?>> entry : expectedChrs.entrySet()) {
+ for (final Map.Entry<String, DefaultAttributeType<?>> entry : expectedChrs.entrySet()) {
final String p = entry.getKey();
if (!ignoredCharacteristics.contains(p)) {
- final AttributeType<?> expectedChr = entry.getValue();
- final AttributeType<?> actualChr = actualChrs.get(p);
+ final DefaultAttributeType<?> expectedChr = entry.getValue();
+ final DefaultAttributeType<?> actualChr = actualChrs.get(p);
final String tip = push("characteristic(" + p + ')');
assertNotNull(actualChr, this::path);
assertTrue(actualChrNames.remove(p));
@@ -338,7 +336,7 @@
* @param actual the actual property.
* @throws AssertionError if the actual property is not equal to the expected property.
*/
- private void compareFeatureAssociationRole(final FeatureAssociationRole expected, final FeatureAssociationRole actual) {
+ private void compareFeatureAssociationRole(final DefaultAssociationRole expected, final DefaultAssociationRole actual) {
compareIdentifiedType(expected, actual);
assertEquals(expected.getMinimumOccurs(), actual.getMinimumOccurs(), () -> path() + "Minimum occurences differ.");
assertEquals(expected.getMaximumOccurs(), actual.getMaximumOccurs(), () -> path() + "Maximum occurences differ.");
@@ -354,7 +352,7 @@
* @param actual the actual property.
* @throws AssertionError if the actual property is not equal to the expected property.
*/
- private void compareOperation(final Operation expected, final Operation actual) {
+ private void compareOperation(final AbstractOperation expected, final AbstractOperation actual) {
compareIdentifiedType(expected, actual);
assertEquals(expected.getParameters(), actual.getParameters());
final String tip = push("operation-actual(" + expected.getResult().getName() + ')');
@@ -369,7 +367,7 @@
* @param actual the actual type.
* @throws AssertionError if the actual type is not equal to the expected type.
*/
- private void compareIdentifiedType(final IdentifiedType expected, final IdentifiedType actual) {
+ private void compareIdentifiedType(final AbstractIdentifiedType expected, final AbstractIdentifiedType actual) {
assertEquals(expected.getName(), actual.getName(), () -> path() + "Name differ.");
if (!ignoreDefinition) {
assertEquals(expected.getDefinition(), actual.getDefinition(), () -> path() + "Definition differ.");
@@ -380,8 +378,8 @@
if (!ignoreDescription) {
assertEquals(expected.getDescription(), actual.getDescription(), () -> path() + "Description differ.");
}
- if (expected instanceof Deprecable de && actual instanceof Deprecable da) {
- assertEquals(de.isDeprecated(), da.isDeprecated(), () -> path() + "Deprecated state differ.");
+ /* Condition in "geoapi-3.1" branch removed in this branch. */ {
+ assertEquals(expected.isDeprecated(), actual.isDeprecated(), () -> path() + "Deprecated state differ.");
}
}
@@ -413,7 +411,7 @@
/**
* Returns {@code true} if the given property should be ignored in feature comparisons.
*/
- private boolean isIgnored(final PropertyType property) {
+ private boolean isIgnored(final AbstractIdentifiedType property) {
return ignoredProperties.contains(property.getName().toString());
}
@@ -421,10 +419,10 @@
* Searches for a property of the given name in the given list and remove the property from that list.
* If the property is not found, then this method fails.
*/
- private PropertyType findAndRemove(final Collection<PropertyType> properties, final GenericName name) {
- final Iterator<PropertyType> it = properties.iterator();
+ private AbstractIdentifiedType findAndRemove(final Collection<AbstractIdentifiedType> properties, final GenericName name) {
+ final Iterator<AbstractIdentifiedType> it = properties.iterator();
while (it.hasNext()) {
- final PropertyType pt = it.next();
+ final AbstractIdentifiedType pt = it.next();
if (pt.getName().equals(name)) {
it.remove();
return pt;
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
index 71ad083..a7889ca 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
@@ -22,9 +22,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.FilterFactory;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -36,7 +35,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Creates a new test case.
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/BinarySpatialFilterTestCase.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/BinarySpatialFilterTestCase.java
index 38fbe42..51cb616 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/BinarySpatialFilterTestCase.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/BinarySpatialFilterTestCase.java
@@ -38,11 +38,10 @@
import org.apache.sis.referencing.operation.HardCodedConversions;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Literal;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.DistanceOperatorName;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.DistanceOperatorName;
/**
@@ -59,7 +58,7 @@
/**
* The factory to use for testing purpose.
*/
- private final FilterFactory<Feature, G, Object> factory;
+ private final DefaultFilterFactory<AbstractFeature, G, Object> factory;
/**
* The geometry library used by this factory.
@@ -88,7 +87,7 @@
/**
* Creates the polygon identified by the given enumeration value.
*/
- private Literal<Feature,G> literal(final Polygon p) {
+ private Literal<AbstractFeature,G> literal(final Polygon p) {
final double[] coordinates;
boolean polygon = true;
switch (p) {
@@ -101,7 +100,8 @@
case TOUCHES: coordinates = new double[] {4, 2, 7, 5, 9, 3}; polygon = false; break;
default: throw new AssertionError(p);
}
- return factory.literal(library.createPolyline(polygon, false, Dimensions.XY, DoubleBuffer.wrap(coordinates)));
+ return (Literal<AbstractFeature,G>)
+ factory.literal(library.createPolyline(polygon, false, Dimensions.XY, DoubleBuffer.wrap(coordinates)));
}
/**
@@ -127,7 +127,7 @@
public void testExpressionType() {
var geometry = literal(Polygon.RIGHT);
var filter = factory.bbox(geometry, new Envelope2D(null, 0, 0, 1, 1));
- var arg2 = assertInstanceOf(Literal.class, filter.getOperand2());
+ var arg2 = assertInstanceOf(Literal.class, filter.getExpressions().get(1));
assertInstanceOf(Envelope.class, arg2.getValue(), "Second argument value should be an envelope.");
assertSame(arg2, filter.getExpressions().get(1), "The two ways to acquire the second argument return different values.");
}
@@ -321,7 +321,7 @@
// Ensure no error is raised, even if a reprojection is involved.
envelope = new Envelope2D(HardCodedCRS.WGS84, -1.36308465, -5.98385631, 6.56E-5, 6.57E-5);
filter = factory.bbox(geometry, envelope);
- assertTrue(filter.test(null));
+ filter.test(null);
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/CapabilitiesTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/CapabilitiesTest.java
deleted file mode 100644
index e4b152b..0000000
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/CapabilitiesTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.filter;
-
-import java.util.Set;
-import org.opengis.util.LocalName;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.capability.IdCapabilities;
-import org.opengis.filter.capability.ScalarCapabilities;
-import org.opengis.filter.capability.AvailableFunction;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.TestCase;
-import org.apache.sis.test.TestUtilities;
-
-
-/**
- * Tests {@link Capabilities} implementations.
- *
- * @author Johann Sorel (Geomatys)
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class CapabilitiesTest extends TestCase {
- /**
- * Creates a new test case.
- */
- public CapabilitiesTest() {
- }
-
- /**
- * Tests {@link Capabilities#getResourceIdentifiers()}.
- */
- @Test
- public void testResourceIdentifiers() {
- final var capabilities = DefaultFilterFactory.forFeatures().getCapabilities();
- assertTrue(capabilities.getConformance().implementsResourceld());
- final IdCapabilities idc = capabilities.getIdCapabilities().get();
- final LocalName id = TestUtilities.getSingleton(idc.getResourceIdentifiers());
- assertEquals("identifier", id.toString());
- }
-
- /**
- * Tests {@link Capabilities#getComparisonOperators()}.
- */
- @Test
- public void testComparisonOperators() {
- final var capabilities = DefaultFilterFactory.forFeatures().getCapabilities();
- final ScalarCapabilities c = capabilities.getScalarCapabilities().get();
- final Set<ComparisonOperatorName> op = c.getComparisonOperators();
- assertTrue(op.contains(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO));
- assertTrue(op.contains(ComparisonOperatorName.PROPERTY_IS_LESS_THAN));
- assertTrue(op.contains(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN));
- }
-
- /**
- * Tests {@link Capabilities#getFunctions()}.
- */
- @Test
- public void testFunctions() {
- final var capabilities = DefaultFilterFactory.forFeatures().getCapabilities();
- AvailableFunction desc = capabilities.getFunctions().get("ST_Transform");
- assertEquals("SQLMM:ST_Transform", desc.getName().toFullyQualifiedName().toString());
- assertEquals("OGC:Geometry", desc.getReturnType().toFullyQualifiedName().toString());
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ComparisonFilterTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ComparisonFilterTest.java
index e82bc64..612c38e 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ComparisonFilterTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ComparisonFilterTest.java
@@ -22,15 +22,10 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Literal;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.ComparisonOperator;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.BetweenComparisonOperator;
-import org.apache.sis.filter.privy.FunctionNames;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
+import org.apache.sis.pending.geoapi.filter.BetweenComparisonOperator;
/**
@@ -43,12 +38,12 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Expressions used as constant for the tests.
*/
- private final Literal<Feature,Integer> c05, c10, c20;
+ private final Expression<AbstractFeature,Integer> c05, c10, c20;
/**
* Expected name of the filter to be evaluated. The {@code evaluate(…)} methods
@@ -59,7 +54,7 @@
/**
* The filter tested by last call to {@code evaluate(…)} methods.
*/
- private ComparisonOperator<Feature> filter;
+ private Filter<AbstractFeature> filter;
/**
* Creates a new test case.
@@ -75,7 +70,7 @@
* Evaluates the given filter. The {@link #expectedName} field must be set before this method is invoked.
* This method assumes that the first expression of all filters is {@link #c10}.
*/
- private boolean evaluate(final BinaryComparisonOperator<Feature> filter) {
+ private boolean evaluate(final Filter<AbstractFeature> filter) {
this.filter = filter;
assertInstanceOf(ComparisonFilter.class, filter);
assertEquals(expectedName, filter.getOperatorType());
@@ -86,7 +81,7 @@
/**
* Evaluates the given "Property is between" filter.
*/
- private boolean evaluate(final BetweenComparisonOperator<Feature> filter) {
+ private boolean evaluate(final BetweenComparisonOperator<AbstractFeature> filter) {
this.filter = filter;
assertInstanceOf(ComparisonFilter.Between.class, filter);
assertEquals(expectedName, filter.getOperatorType());
@@ -170,10 +165,10 @@
*/
@Test
public void testBetween() {
- expectedName = ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_BETWEEN);
- assertTrue (evaluate(factory.between(c10, c05, c20)));
- assertFalse(evaluate(factory.between(c20, c05, c10)));
- assertFalse(evaluate(factory.between(c05, c10, c20)));
+ expectedName = ComparisonOperatorName.PROPERTY_IS_BETWEEN;
+ assertTrue (evaluate((BetweenComparisonOperator<AbstractFeature>) factory.between(c10, c05, c20)));
+ assertFalse(evaluate((BetweenComparisonOperator<AbstractFeature>) factory.between(c20, c05, c10)));
+ assertFalse(evaluate((BetweenComparisonOperator<AbstractFeature>) factory.between(c05, c10, c20)));
assertSerializedEquals(filter);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/IdentifierFilterTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/IdentifierFilterTest.java
index 361e3cd..cea0ce8 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/IdentifierFilterTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/IdentifierFilterTest.java
@@ -25,11 +25,9 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -42,7 +40,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Creates a new test case.
@@ -71,17 +69,17 @@
public void testEvaluate() {
final var builder = new FeatureTypeBuilder();
builder.addAttribute(String.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- final Feature f1 = builder.setName("Test 1").build().newInstance();
+ final AbstractFeature f1 = builder.setName("Test 1").build().newInstance();
f1.setPropertyValue("att", "123");
builder.clear().addAttribute(Integer.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- final Feature f2 = builder.setName("Test 2").build().newInstance();
+ final AbstractFeature f2 = builder.setName("Test 2").build().newInstance();
f2.setPropertyValue("att", 123);
- final Feature f3 = builder.clear().setName("Test 3").build().newInstance();
+ final AbstractFeature f3 = builder.clear().setName("Test 3").build().newInstance();
- final Filter<Feature> id = factory.resourceId("123");
- assertEquals(Feature.class, id.getResourceClass());
+ final Filter<AbstractFeature> id = factory.resourceId("123");
+ assertEquals(AbstractFeature.class, id.getResourceClass());
assertTrue (id.test(f1));
assertTrue (id.test(f2));
assertFalse(id.test(f3));
@@ -94,17 +92,17 @@
public void testEvaluateCombined() {
final var builder = new FeatureTypeBuilder();
builder.addAttribute(String.class).setName("att").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- final FeatureType type = builder.setName("Test").build();
+ final DefaultFeatureType type = builder.setName("Test").build();
- final Feature f1 = type.newInstance(); f1.setPropertyValue("att", "123");
- final Feature f2 = type.newInstance(); f2.setPropertyValue("att", "abc");
- final Feature f3 = type.newInstance(); f3.setPropertyValue("att", "abc123");
+ final AbstractFeature f1 = type.newInstance(); f1.setPropertyValue("att", "123");
+ final AbstractFeature f2 = type.newInstance(); f2.setPropertyValue("att", "abc");
+ final AbstractFeature f3 = type.newInstance(); f3.setPropertyValue("att", "abc123");
- final Filter<Feature> id = factory.or(
+ final Filter<AbstractFeature> id = factory.or(
factory.resourceId("abc"),
factory.resourceId("123"));
- assertEquals(Feature.class, id.getResourceClass());
+ assertEquals(AbstractFeature.class, id.getResourceClass());
assertTrue (id.test(f1));
assertTrue (id.test(f2));
assertFalse(id.test(f3));
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LeafExpressionTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LeafExpressionTest.java
index cd285db..16619ed 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LeafExpressionTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LeafExpressionTest.java
@@ -24,9 +24,10 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.FilterFactory;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -38,7 +39,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Creates a new test case.
@@ -53,7 +54,7 @@
@Test
public void testReferenceSerialization() {
var filter = factory.property("some_property", String.class);
- assertEquals("some_property", filter.getXPath());
+ assertEquals("some_property", ((ValueReference<?,?>) filter).getXPath());
assertSerializedEquals(filter);
}
@@ -62,11 +63,11 @@
*/
@Test
public void testLiteralSerialization() {
- final var e1 = factory.literal(true);
- final var e2 = factory.literal("a text string");
- final var e3 = factory.literal('x');
- final var e4 = factory.literal(122);
- final var e5 = factory.literal(45.56);
+ final var e1 = (Literal<?,?>) factory.literal(true);
+ final var e2 = (Literal<?,?>) factory.literal("a text string");
+ final var e3 = (Literal<?,?>) factory.literal('x');
+ final var e4 = (Literal<?,?>) factory.literal(122);
+ final var e5 = (Literal<?,?>) factory.literal(45.56);
assertEquals(Boolean.TRUE, e1.getValue());
assertEquals("a text string", e2.getValue());
@@ -91,7 +92,7 @@
final var instance = builder.setName("Test").build().newInstance();
var reference = factory.property("some_property");
- assertEquals(Feature.class, reference.getResourceClass());
+ assertEquals(AbstractFeature.class, reference.getResourceClass());
assertNull(reference.apply(instance));
assertNull(reference.apply(null));
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LogicalFilterTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LogicalFilterTest.java
index 2dcdb65..7a1520c 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LogicalFilterTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/LogicalFilterTest.java
@@ -30,11 +30,10 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.LogicalOperator;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
/**
@@ -47,7 +46,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Creates a new test case.
@@ -82,7 +81,7 @@
public void testNot() {
final var literal = factory.literal("text");
final var operand = factory.isNull(literal);
- final var filter = factory.not(operand);
+ final var filter = (LogicalOperator<AbstractFeature>) factory.not(operand);
assertArrayEquals(new Filter<?>[] {operand}, filter.getOperands().toArray());
assertTrue(filter.test(null));
assertSerializedEquals(filter);
@@ -104,7 +103,7 @@
*/
@Test
public void testVolatile() {
- final var literal = new LeafExpression.Literal<Feature,Object>("test") {
+ final var literal = new LeafExpression.Literal<AbstractFeature,Object>("test") {
@Override public Set<FunctionProperty> properties() {
return Set.of(FunctionProperty.VOLATILE);
}
@@ -121,8 +120,8 @@
* @param anyArity the function creating a logical operator from an arbitrary number of operands.
* @param expected expected evaluation result.
*/
- private void create(final BiFunction<Filter<Feature>, Filter<Feature>, LogicalOperator<Feature>> binary,
- final Function<Collection<Filter<Feature>>, LogicalOperator<Feature>> anyArity,
+ private void create(final BiFunction<Filter<AbstractFeature>, Filter<AbstractFeature>, Filter<AbstractFeature>> binary,
+ final Function<Collection<Filter<AbstractFeature>>, Filter<AbstractFeature>> anyArity,
final boolean expected)
{
final var f1 = factory.isNull(factory.literal("text"));
@@ -147,7 +146,7 @@
/*
* Test construction, evaluation and serialization.
*/
- var filter = binary.apply(f1, f2);
+ var filter = (LogicalOperator<AbstractFeature>) binary.apply(f1, f2);
assertArrayEquals(new Filter<?>[] {f1, f2}, filter.getOperands().toArray());
assertEquals(expected, filter.test(null));
assertSerializedEquals(filter);
@@ -155,7 +154,7 @@
/*
* Same test, using the constructor accepting any number of operands.
*/
- filter = anyArity.apply(List.of(f1, f2, f1));
+ filter = (LogicalOperator<AbstractFeature>) anyArity.apply(List.of(f1, f2, f1));
assertArrayEquals(new Filter<?>[] {f1, f2, f1}, filter.getOperands().toArray());
assertEquals(expected, filter.test(null));
assertSerializedEquals(filter);
@@ -223,7 +222,7 @@
/**
* Verifies an optimization which is expected to evaluate immediately.
*/
- private static void optimize(final Filter<Feature> original, final Filter<Feature> expected) {
+ private static void optimize(final Filter<AbstractFeature> original, final Filter<AbstractFeature> expected) {
final Filter<?> optimized = new Optimization().apply(original);
assertNotSame(original, optimized, "Expected a new optimized filter.");
assertSame(optimized, new Optimization().apply(optimized), "Second optimization should have no effect.");
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
index f547361..e724f09 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
@@ -20,11 +20,10 @@
import java.io.Serializable;
import org.apache.sis.temporal.TemporalObjects;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
-import org.opengis.temporal.Period;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.temporal.Period;
/**
@@ -34,7 +33,7 @@
* @author Martin Desruisseaux (Geomatys)
*/
@SuppressWarnings("serial")
-final class PeriodLiteral implements Period, Literal<Feature,Period>, Serializable {
+final class PeriodLiteral implements Period, Literal<AbstractFeature,Period>, Serializable {
/**
* Period beginning and ending, in milliseconds since Java epoch.
*/
@@ -54,11 +53,13 @@
return this;
}
+ @Override public Period apply(AbstractFeature input) {return this;}
+
/**
* Returns the beginning of this period.
*/
@Override
- public org.opengis.temporal.Instant getBeginning() {
+ public org.apache.sis.pending.geoapi.temporal.Instant getBeginning() {
return TemporalObjects.createInstant(Instant.ofEpochMilli(begin));
}
@@ -66,7 +67,7 @@
* Returns the ending of this period.
*/
@Override
- public org.opengis.temporal.Instant getEnding() {
+ public org.apache.sis.pending.geoapi.temporal.Instant getEnding() {
return TemporalObjects.createInstant(Instant.ofEpochMilli(end));
}
@@ -74,10 +75,13 @@
* Not needed for the tests.
*/
@Override
- public <N> Expression<Feature,N> toValueType(Class<N> target) {
+ public <N> Expression<AbstractFeature,N> toValueType(Class<N> target) {
throw new UnsupportedOperationException();
}
+ /** Not needed for the tests. */
+ @Override public Class<AbstractFeature> getResourceClass() {return AbstractFeature.class;}
+
/**
* Hash code value. Used by the tests for checking the results of deserialization.
*/
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/TemporalFilterTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/TemporalFilterTest.java
index b349e62..7c043c6 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/TemporalFilterTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/TemporalFilterTest.java
@@ -26,12 +26,10 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
-import org.opengis.feature.Feature;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.TemporalOperator;
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.temporal.Period;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -44,13 +42,13 @@
/**
* The factory to use for creating the objects to test.
*/
- private FilterFactory<Feature, Object, ? super Period> factory;
+ private DefaultFilterFactory<AbstractFeature, Object, ? super Period> factory;
/**
* The filter to test. This field shall be assigned by each {@code testFoo()} method by invoking
* a {@link #factory} method with {@link #expression1} and {@link #expression2} in arguments.
*/
- private TemporalOperator<Feature> filter;
+ private Filter<AbstractFeature> filter;
/**
* The expression to test. They are the arguments to be given to {@link #factory} method.
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/CopyVisitorTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/CopyVisitorTest.java
deleted file mode 100644
index 61afa6c..0000000
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/CopyVisitorTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.filter.privy;
-
-import java.util.Map;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.FilterFactory;
-import org.apache.sis.filter.DefaultFilterFactory;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.TestCase;
-
-
-/**
- * Tests copies using {@link CopyVisitor}.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class CopyVisitorTest extends TestCase {
- /**
- * Creates a new test case.
- */
- public CopyVisitorTest() {
- }
-
- /**
- * Tests copy a value reference.
- */
- @Test
- public void copyValueReference() {
- final FilterFactory<Feature, ?, ?> source = DefaultFilterFactory.forFeatures();
- final FilterFactory<Map<String,?>, ?, ?> target = new FilterFactoryMock();
- final CopyVisitor <Feature, Map<String,?>, ?, ?> visitor = new CopyVisitor<>(target, true);
-
- final String xpath = "someProperty";
- final Expression<Feature, ?> exp = source.property(xpath);
- final Expression<Map<String,?>, ?> result = visitor.copy(exp);
-
- assertTrue(result instanceof ValueReferenceMock);
- assertEquals(xpath, ((ValueReferenceMock) result).getXPath());
- }
-
- /**
- * Tests copy of a function.
- */
- @Test
- public void copyFunction() {
- final FilterFactory<Feature, ?, ?> source = DefaultFilterFactory.forFeatures();
- final FilterFactory<Map<String,?>, ?, ?> target = new FilterFactoryMock();
- final CopyVisitor <Feature, Map<String,?>, ?, ?> visitor = new CopyVisitor<>(target, true);
-
- final Expression<Feature, ?> exp1 = source.property("someProperty");
- final Expression<Feature, ?> exp2 = source.property("crs");
- final Expression<Feature, ?> fct = source.function("ST_GeomFromText", exp1, exp2);
- final Expression<Map<String,?>, ?> result = visitor.copy(fct);
-
- assertTrue(result instanceof FunctionMock);
- var resultfct = ((FunctionMock) result).getParameters();
- assertEquals(2, resultfct.size());
- assertTrue(resultfct.get(0) instanceof ValueReferenceMock);
- assertTrue(resultfct.get(1) instanceof ValueReferenceMock);
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FilterFactoryMock.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FilterFactoryMock.java
deleted file mode 100644
index 39455f6..0000000
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FilterFactoryMock.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * 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.filter.privy;
-
-import java.time.Instant;
-import java.util.Map;
-import java.util.Arrays;
-import java.util.Collection;
-import javax.measure.Quantity;
-import javax.measure.quantity.Length;
-import org.opengis.geometry.Envelope;
-import org.opengis.metadata.citation.Citation;
-import org.opengis.filter.*;
-import org.opengis.filter.capability.FilterCapabilities;
-import org.apache.sis.metadata.simple.SimpleCitation;
-
-
-/**
- * Dummy implementation of filter factory.
- * The features handled by this implementation are property-value maps.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class FilterFactoryMock implements FilterFactory<Map<String,?>, Object, Object> {
- /**
- * Creates a new dummy factory.
- */
- FilterFactoryMock() {
- }
-
- /**
- * Returns the "vendor" responsible for creating this factory implementation.
- */
- @Override
- public Citation getVendor() {
- return new SimpleCitation("SIS-tests");
- }
-
- /**
- * Creates an expression retrieving the value as an instance of the specified class.
- */
- @Override
- public <V> ValueReference<Map<String,?>, V> property(String xpath, Class<V> type) {
- return new ValueReferenceMock<>(xpath, type);
- }
-
- /**
- * Creates a dummy function with an arbitrary number of parameters.
- */
- @Override
- public Expression<Map<String,?>, ?> function(String name, Expression<Map<String,?>, ?>[] parameters) {
- return new FunctionMock(name, Arrays.asList(parameters));
- }
-
- // ======== All operations below this point are unsupported ===================================================
-
- /**
- * Unsupported operation.
- */
- @Override
- public FilterCapabilities getCapabilities() {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public ResourceId<Map<String,?>> resourceId(String rid, Version version, Instant startTime, Instant endTime) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public <V> Literal<Map<String,?>, V> literal(V value) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> equal(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> notEqual(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> less(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> greater(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> lessOrEqual(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinaryComparisonOperator<Map<String,?>> greaterOrEqual(
- Expression<Map<String,?>, ?> expression1,
- Expression<Map<String,?>, ?> expression2,
- boolean isMatchingCase, MatchAction matchAction)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BetweenComparisonOperator<Map<String,?>> between(
- Expression<Map<String,?>, ?> expression,
- Expression<Map<String,?>, ?> lowerBoundary,
- Expression<Map<String,?>, ?> upperBoundary)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public LikeOperator<Map<String,?>> like(
- Expression<Map<String,?>, ?> expression,
- String pattern, char wildcard, char singleChar, char escape, boolean isMatchingCase)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public NullOperator<Map<String,?>> isNull(Expression<Map<String,?>, ?> expression) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public NilOperator<Map<String,?>> isNil(Expression<Map<String,?>, ?> expression, String nilReason) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public LogicalOperator<Map<String,?>> and(Collection<? extends Filter<Map<String,?>>> operands) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public LogicalOperator<Map<String,?>> or(Collection<? extends Filter<Map<String,?>>> operands) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public LogicalOperator<Map<String,?>> not(Filter<Map<String,?>> operand) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> bbox(
- Expression<Map<String,?>, ? extends Object> geometry,
- Envelope bounds)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> equals(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> disjoint(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> intersects(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> touches(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> crosses(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> within(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> contains(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public BinarySpatialOperator<Map<String,?>> overlaps(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public DistanceOperator<Map<String,?>> beyond(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2,
- Quantity<Length> distance)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public DistanceOperator<Map<String,?>> within(
- Expression<Map<String,?>, ? extends Object> geometry1,
- Expression<Map<String,?>, ? extends Object> geometry2,
- Quantity<Length> distance)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> after(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> before(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> begins(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> begunBy(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> tcontains(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> during(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> tequals(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> toverlaps(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> meets(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> ends(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> overlappedBy(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> metBy(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> endedBy(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public TemporalOperator<Map<String,?>> anyInteracts(
- Expression<Map<String,?>, ? extends Object> time1,
- Expression<Map<String,?>, ? extends Object> time2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public Expression<Map<String,?>, Number> add(
- Expression<Map<String,?>, ? extends Number> operand1,
- Expression<Map<String,?>, ? extends Number> operand2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public Expression<Map<String,?>, Number> subtract(
- Expression<Map<String,?>, ? extends Number> operand1,
- Expression<Map<String,?>, ? extends Number> operand2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public Expression<Map<String,?>, Number> multiply(
- Expression<Map<String,?>, ? extends Number> operand1,
- Expression<Map<String,?>, ? extends Number> operand2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public Expression<Map<String,?>, Number> divide(
- Expression<Map<String,?>, ? extends Number> operand1,
- Expression<Map<String,?>, ? extends Number> operand2)
- {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public SortProperty<Map<String,?>> sort(ValueReference<Map<String,?>, ?> property, SortOrder order) {
- throw new UnsupportedOperationException("Not supported.");
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionMock.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionMock.java
deleted file mode 100644
index 1ad445e..0000000
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionMock.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.filter.privy;
-
-import java.util.Map;
-import java.util.List;
-import org.opengis.util.ScopedName;
-import org.opengis.filter.Expression;
-import org.apache.sis.util.iso.Names;
-
-
-/**
- * Dummy implementation of filter function.
- * The features handled by this implementation are property-value maps.
- * This class stores a function name and parameters but cannot do any operation.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class FunctionMock implements Expression<Map<String,?>, Object> {
- /**
- * The local part of the function name.
- */
- private final String name;
-
- /**
- * The function parameters.
- */
- private final List<Expression<Map<String,?>, ?>> parameters;
-
- /**
- * Creates a new dummy function.
- *
- * @param name the local part of the function name.
- * @param parameters the function parameters.
- */
- FunctionMock(final String name, final List<Expression<Map<String,?>, ?>> parameters) {
- this.name = name;
- this.parameters = parameters;
- }
-
- /**
- * Returns the function name.
- */
- @Override
- public ScopedName getFunctionName() {
- return Names.createScopedName(null, null, name);
- }
-
- /**
- * Returns the type of resources accepted by this mock.
- */
- @Override
- public Class<Map> getResourceClass() {
- return Map.class;
- }
-
- /**
- * Returns the function parameters.
- */
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField")
- public List<Expression<Map<String,?>, ?>> getParameters() {
- return parameters;
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public Object apply(Map<String,?> feature) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- /**
- * Unsupported operation.
- */
- @Override
- public <N> Expression<Map<String,?>, N> toValueType(Class<N> target) {
- throw new UnsupportedOperationException("Not supported.");
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionNamesTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionNamesTest.java
index f3e8064..27072d9 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionNamesTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/FunctionNamesTest.java
@@ -24,18 +24,6 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.List;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.ComparisonOperator;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.BetweenComparisonOperator;
-import org.opengis.filter.NullOperator;
-import org.opengis.filter.NilOperator;
-import org.opengis.filter.LikeOperator;
-import org.opengis.filter.Expression;
-
/**
* Verifies the values declared in {@link FunctionNames}.
@@ -62,81 +50,6 @@
}
/**
- * Base class for dummy implementation of filter.
- */
- private static abstract class FilterBase implements ComparisonOperator<Object> {
- @Override public List<Expression<Object,?>> getExpressions() {return List.of();}
- @Override public Class<Object> getResourceClass() {return Object.class;}
- @Override public boolean test(Object resource) {return false;}
- }
-
- /**
- * Verifies the {@value FunctionNames#PROPERTY_IS_NULL} name.
- */
- @Test
- public void verifyPropertyIsNull() {
- final class Instanciable extends FilterBase implements NullOperator<Object> {}
- assertSame(new Instanciable().getOperatorType(), ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NULL));
- }
-
- /**
- * Verifies the {@value FunctionNames#PROPERTY_IS_NIL} name.
- */
- @Test
- public void verifyPropertyIsNil() {
- final class Instanciable extends FilterBase implements NilOperator<Object> {}
- assertSame(new Instanciable().getOperatorType(), ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_NIL));
- }
-
- /**
- * Verifies the {@value FunctionNames#PROPERTY_IS_LIKE} name.
- */
- @Test
- public void verifyPropertyIsLike() {
- final class Instanciable extends FilterBase implements LikeOperator<Object> {}
- assertSame(new Instanciable().getOperatorType(), ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_LIKE));
- }
-
- /**
- * Verifies the {@value FunctionNames#PROPERTY_IS_BETWEEN} name.
- */
- @Test
- public void verifyPropertyIsBetween() {
- final class Instanciable extends FilterBase implements BetweenComparisonOperator<Object> {}
- assertSame(new Instanciable().getOperatorType(), ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_BETWEEN));
- }
-
- /**
- * Verifies the {@value FunctionNames#Literal} name.
- */
- @Test
- public void verifyLiteral() {
- final var expression = new Literal<Object,Object>() {
- @Override public Object getValue() {return null;}
- @Override public <N> Expression<Object, N> toValueType(Class<N> target) {
- throw new UnsupportedOperationException();
- }
- };
- assertEquals(expression.getFunctionName().tip().toString(), FunctionNames.Literal);
- }
-
- /**
- * Verifies the {@value FunctionNames#ValueReference} name.
- */
- @Test
- public void verifyValueReference() {
- final var expression = new ValueReference<Object,Object>() {
- @Override public String getXPath() {return null;}
- @Override public Object apply(Object o) {return null;}
- @Override public Class<Object> getResourceClass() {return Object.class;}
- @Override public <N> Expression<Object,N> toValueType(Class<N> target) {
- throw new UnsupportedOperationException();
- }
- };
- assertEquals(expression.getFunctionName().tip().toString(), FunctionNames.ValueReference);
- }
-
- /**
* Verifies SQLMM names.
*/
@Test
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/ValueReferenceMock.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/ValueReferenceMock.java
deleted file mode 100644
index c9c3ce7..0000000
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/privy/ValueReferenceMock.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.filter.privy;
-
-import java.util.Map;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
-
-
-/**
- * Dummy implementation of property value reference.
- * The features handled by this implementation are property-value maps.
- *
- * @author Johann Sorel (Geomatys)
- *
- * @param <V> type of values returned by this expression.
- */
-final class ValueReferenceMock<V> implements ValueReference<Map<String,?>, V> {
- /**
- * Name of the property for which to get values.
- */
- private final String xpath;
-
- /**
- * Expected type of values.
- */
- private final Class<V> type;
-
- /**
- * Creates a new dummy reference.
- *
- * @param xpath name of the property for which to get values.
- * @param type type of values returned by this expression.
- */
- ValueReferenceMock(final String xpath, final Class<V> type) {
- this.xpath = xpath;
- this.type = type;
- }
-
- /**
- * Returns the type of resources accepted by this mock.
- */
- @Override
- public Class<Map> getResourceClass() {
- return Map.class;
- }
-
- /**
- * Returns the name of the property for which to get values.
- */
- @Override
- public String getXPath() {
- return xpath;
- }
-
- /**
- * Returns the value of the referenced property in the given feature.
- */
- @Override
- public V apply(final Map<String,?> feature) {
- return type.cast(feature.get(xpath));
- }
-
- /**
- * Returns a reference to the same value but cast to a different type.
- */
- @Override
- public <N> Expression<Map<String,?>, N> toValueType(final Class<N> target) {
- return new ValueReferenceMock<>(xpath, target);
- }
-}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/RegistryTestCase.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/RegistryTestCase.java
index 70fe0ae..0cb0a48 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/RegistryTestCase.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/RegistryTestCase.java
@@ -24,8 +24,8 @@
import org.opengis.referencing.crs.ProjectedCRS;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.filter.DefaultFilterFactory;
import org.apache.sis.filter.Optimization;
+import org.apache.sis.filter.DefaultFilterFactory;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.geometry.WraparoundMethod;
import org.apache.sis.filter.internal.Node;
@@ -41,12 +41,10 @@
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.test.TestCaseWithLogs;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.capability.AvailableFunction;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.Literal;
/**
@@ -67,7 +65,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature, G, Object> factory;
+ private final DefaultFilterFactory<AbstractFeature, G, Object> factory;
/**
* The geometry library used by this factory.
@@ -92,7 +90,7 @@
*
* @see #evaluate(String, Object...)
*/
- private Expression<Feature,?> function;
+ private Expression<AbstractFeature,?> function;
/**
* Tolerance threshold for assertions. Default value is 0.
@@ -115,26 +113,6 @@
}
/**
- * Tests {@link Registry#describe(String)}.
- */
- @Test
- public void testDescribe() {
- final var r = new Registry(library);
- AvailableFunction desc = r.describe("ST_Transform");
- assertEquals("SQLMM:ST_Transform", desc.getName().toFullyQualifiedName().toString());
- assertEquals("OGC:Geometry", desc.getReturnType().toFullyQualifiedName().toString());
- assertEquals(library.rootClass, desc.getReturnType().toJavaType().get());
-
- desc = r.describe("ST_PointFromText");
- assertEquals("ST_PointFromText", desc.getName().toString());
- assertEquals("OGC:Point", desc.getReturnType().toFullyQualifiedName().toString());
- assertEquals(library.pointClass, desc.getReturnType().toJavaType().get());
-
- // Tested methods should not log.
- loggings.assertNoUnexpectedLog();
- }
-
- /**
* Verifies that attempts to create a function of the given name fail if no argument is provided.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@@ -169,7 +147,7 @@
* @param type the type of value in the property.
* @return a feature with a property of the given type.
*/
- private Feature createFeatureWithGeometry(final Class<?> type) {
+ private AbstractFeature createFeatureWithGeometry(final Class<?> type) {
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.addAttribute(type).setName(P_NAME);
final var mockType = ftb.setName("Test").build();
@@ -188,7 +166,7 @@
*/
private Object evaluate(final String name, final Object... values) {
@SuppressWarnings({"unchecked","rawtypes"})
- final Literal<Feature,?>[] parameters = new Literal[values.length];
+ final Expression<AbstractFeature,?>[] parameters = new Literal[values.length];
for (int i=0; i<values.length; i++) {
parameters[i] = factory.literal(values[i]);
}
@@ -533,7 +511,7 @@
*/
final Object literal = optimized.getParameters().get(1).apply(null);
final DirectPosition point = library.castOrWrap(literal).getCentroid();
- assertArrayEquals(new double[] {30, 10}, point.getCoordinates());
+ assertArrayEquals(new double[] {30, 10}, point.getCoordinate());
// Tested methods should not log.
loggings.assertNoUnexpectedLog();
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/SQLMMTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/SQLMMTest.java
index 7bd32b6..b1d8d40 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/SQLMMTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/sqlmm/SQLMMTest.java
@@ -31,10 +31,9 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.FilterFactory;
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -48,7 +47,7 @@
/**
* The factory to use for creating the objects to test.
*/
- private final FilterFactory<Feature,Object,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,Object,?> factory;
/**
* Creates a new test case.
@@ -118,9 +117,9 @@
* @throws FactoryException if an error occurred while fetching the CRS from a JTS geometry.
*/
private void verifyPoint(final CoordinateReferenceSystem expectedCRS,
- final BiFunction<Expression<Feature, Double>,
- Expression<Feature, Double>,
- Expression<Feature, ?>[]> argumentBundler)
+ final BiFunction<Expression<AbstractFeature, Double>,
+ Expression<AbstractFeature, Double>,
+ Expression<AbstractFeature, ?>[]> argumentBundler)
throws FactoryException
{
final var x = factory.literal(1.0);
@@ -130,7 +129,7 @@
Point point = assertInstanceOf(Point.class, rawPoint);
CoordinateReferenceSystem pointCRS = JTS.getCoordinateReferenceSystem(point);
assertEquals(expectedCRS, pointCRS);
- assertEquals(point.getX(), x.getValue());
- assertEquals(point.getY(), y.getValue());
+ assertEquals(point.getX(), x.apply(null));
+ assertEquals(point.getY(), y.apply(null));
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/GeometryTypeTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/GeometryTypeTest.java
index b284260..ed27193 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/GeometryTypeTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/GeometryTypeTest.java
@@ -54,11 +54,9 @@
public void testTypeName() {
TypeName name = GeometryType.LINESTRING.getTypeName(org.apache.sis.geometry.wrapper.jts.Factory.INSTANCE);
assertEquals("OGC:LineString", name.toFullyQualifiedName().toString());
- assertEquals(org.locationtech.jts.geom.LineString.class, name.toJavaType().get());
name = GeometryType.LINESTRING.getTypeName(org.apache.sis.geometry.wrapper.esri.Factory.INSTANCE);
assertEquals("OGC:LineString", name.toFullyQualifiedName().toString());
- assertEquals(com.esri.core.geometry.Polyline.class, name.toJavaType().get());
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
index 4eb9c4e..568f008 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
@@ -23,8 +23,8 @@
import org.junit.jupiter.api.Test;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertPathEquals;
+// Specific to the main branch:
+import static org.apache.sis.feature.Assertions.assertPathEquals;
/**
@@ -67,7 +67,7 @@
final Path2D.Double r = new Path2D.Double(Path2D.WIND_NON_ZERO);
createReferenceShape(r, coordinates, closed);
- assertPathEquals(r.getPathIterator(null), p.getPathIterator(null), STRICT, STRICT, null);
+ assertPathEquals(r.getPathIterator(null), p.getPathIterator(null), STRICT);
}
/**
@@ -107,7 +107,7 @@
createReferenceShape(r, coordinates[i], false);
}
final MultiPolylines p = new MultiPolylines(polylines);
- assertPathEquals(r.getPathIterator(null), p.getPathIterator(null), STRICT, STRICT, null);
+ assertPathEquals(r.getPathIterator(null), p.getPathIterator(null), STRICT);
}
/**
@@ -130,6 +130,6 @@
createReferenceShape(r, new double[]{4,5, 6,3, 8,5, 3,8, 7,5, 9,3, -2,5}, true);
createReferenceShape(r, new double[]{3,5, 6,1, -2,7}, false);
createReferenceShape(r, new double[]{3,8, 10,4, 6,4}, true);
- assertPathEquals(r.getPathIterator(null), b.build().getPathIterator(null), STRICT, STRICT, null);
+ assertPathEquals(r.getPathIterator(null), b.build().getPathIterator(null), STRICT);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/jts/JTSTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/jts/JTSTest.java
index 2998c4e..8a8c7cb 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/jts/JTSTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/jts/JTSTest.java
@@ -36,8 +36,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -154,8 +154,8 @@
wrapper.setCoordinateReferenceSystem(crs);
final GeneralEnvelope envelope = wrapper.getEnvelope();
assertEquals(crs, envelope.getCoordinateReferenceSystem());
- assertArrayEquals(new double[] {5, 6}, envelope.getLowerCorner().getCoordinates());
- assertArrayEquals(new double[] {5, 6}, envelope.getUpperCorner().getCoordinates());
+ assertArrayEquals(new double[] {5, 6}, envelope.getLowerCorner().getCoordinate());
+ assertArrayEquals(new double[] {5, 6}, envelope.getUpperCorner().getCoordinate());
}
{ /*
@@ -170,8 +170,8 @@
wrapper.setCoordinateReferenceSystem(crs);
final GeneralEnvelope envelope = wrapper.getEnvelope();
assertEquals(crs, envelope.getCoordinateReferenceSystem());
- assertArrayEquals(new double[] {5, 6, Double.NaN}, envelope.getLowerCorner().getCoordinates());
- assertArrayEquals(new double[] {5, 6, Double.NaN}, envelope.getUpperCorner().getCoordinates());
+ assertArrayEquals(new double[] {5, 6, Double.NaN}, envelope.getLowerCorner().getCoordinate());
+ assertArrayEquals(new double[] {5, 6, Double.NaN}, envelope.getUpperCorner().getCoordinate());
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/BandedIteratorTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/BandedIteratorTest.java
index 21907b6..bf51189 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/BandedIteratorTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/BandedIteratorTest.java
@@ -25,9 +25,6 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* Tests {@link BandedIterator} on floating point values.
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/LinearIteratorTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/LinearIteratorTest.java
index 7f845cc..1afacb3 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/LinearIteratorTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/LinearIteratorTest.java
@@ -22,9 +22,6 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* Tests the linear read-write iterator on signed short integer values.
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/MaskedImageTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/MaskedImageTest.java
index f32abbc..1c0f58a 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/MaskedImageTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/MaskedImageTest.java
@@ -39,9 +39,6 @@
import static org.apache.sis.feature.Assertions.assertPixelsEqual;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertSampleValuesEqual;
-
/**
* Tests {@link MaskedImage}.
@@ -91,7 +88,7 @@
public void noErrorOnEmptyMasks() {
final BufferedImage source = monoTile();
final RenderedImage masked = new MaskedImage(source, new Polygon(), true, new Number[] {127});
- assertSampleValuesEqual(source, masked, STRICT, null);
+ assertPixelsEqual(source, null, masked, null);
assertSame(source.getRaster(), masked.getTile(0,0)); // Optimization applied by MaskedImage.
}
@@ -205,7 +202,7 @@
3, 3, 3, 3, 2, 2, 2, 2,
3, 3, 3, 3, 2, 2, 2, 2
});
- assertSampleValuesEqual(expected, masked, STRICT, null);
+ assertPixelsEqual(expected, null, masked, null);
}
/**
@@ -224,7 +221,7 @@
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4
});
- assertSampleValuesEqual(expected, masked, STRICT, null);
+ assertPixelsEqual(expected, null, masked, null);
}
/**
@@ -243,7 +240,7 @@
3, 3, 3, 3, 2, 2, 2, 2,
3, 3, 3, 3, 2, 2, 2, 2
});
- assertSampleValuesEqual(expected, masked, STRICT, null);
+ assertPixelsEqual(expected, null, masked, null);
}
/**
@@ -262,7 +259,7 @@
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4
});
- assertSampleValuesEqual(expected, masked, STRICT, null);
+ assertPixelsEqual(expected, null, masked, null);
}
/**
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/PixelIteratorTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/PixelIteratorTest.java
index b461006..2f7a6f8 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/PixelIteratorTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/image/PixelIteratorTest.java
@@ -42,9 +42,6 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
-
/**
* Base class of {@link PixelIterator} tests. This base class tests the default read-write iterator
diff --git a/endorsed/src/org.apache.sis.metadata/main/module-info.java b/endorsed/src/org.apache.sis.metadata/main/module-info.java
index d160fb9..48064df 100644
--- a/endorsed/src/org.apache.sis.metadata/main/module-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/module-info.java
@@ -76,6 +76,9 @@
/*
* Internal API open only to other Apache SIS modules.
*/
+ exports org.apache.sis.pending.geoapi.temporal to
+ org.apache.sis.feature;
+
exports org.apache.sis.temporal to
org.apache.sis.referencing,
org.apache.sis.feature,
@@ -175,6 +178,13 @@
org.apache.sis.storage.xml,
org.apache.sis.gui; // In the "optional" sub-project.
+ exports org.apache.sis.pending.geoapi.evolution to
+ org.apache.sis.referencing,
+ org.opengis.geoapi;
+
+ // For instantiation of new CodeList values by reflection.
+ opens org.apache.sis.pending.geoapi.evolution to org.opengis.geoapi;
+
/*
* Allow JAXB to use reflection for marshalling and
* unmarshalling Apache SIS objects in XML documents.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java
index 2948efd..216fd55 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java
@@ -45,6 +45,9 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
import static org.apache.sis.util.ArgumentChecks.ensureNonNullElement;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Enumeration of some metadata standards. A standard is defined by a set of Java interfaces
@@ -114,7 +117,7 @@
* after construction should be the same.</p>
*/
@Configuration
- static final boolean IMPLEMENTATION_CAN_ALTER_API = false;
+ static final boolean IMPLEMENTATION_CAN_ALTER_API = true;
/**
* Metadata instances defined in this class. Standards will be tested in the order they appear in this array.
@@ -148,7 +151,7 @@
/**
* An instance working on ISO 19123 standard as defined by GeoAPI interfaces
- * in the {@link org.opengis.coverage} package and sub-packages.
+ * in the {@code org.opengis.coverage} package and sub-packages.
*/
public static final MetadataStandard ISO_19123;
static {
@@ -767,10 +770,10 @@
* <p>In the particular case of Apache SIS implementation, all values in the information map
* additionally implement the following interfaces:</p>
* <ul>
- * <li>{@link Identifier} with the following properties:
+ * <li>{@link ReferenceIdentifier} with the following properties:
* <ul>
* <li>The {@linkplain Identifier#getAuthority() authority} is this metadata standard {@linkplain #getCitation() citation}.</li>
- * <li>The {@linkplain Identifier#getCodeSpace() codespace} is the standard name of the interface that contain the property.</li>
+ * <li>The {@linkplain ReferenceIdentifier#getCodeSpace() codespace} is the standard name of the interface that contain the property.</li>
* <li>The {@linkplain Identifier#getCode() code} is the standard name of the property.</li>
* </ul>
* </li>
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyComparator.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyComparator.java
index a253377..5f48dee 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyComparator.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyComparator.java
@@ -24,6 +24,9 @@
import org.opengis.annotation.UML;
import org.opengis.annotation.Obligation;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
+
/**
* The comparator for sorting the properties in a metadata object.
@@ -124,8 +127,14 @@
* the parent class, and we want the properties in the parent class to be sorted first.
* If duplicated properties are found, keep the first occurence (i.e. sort the property
* with the most specialized child that declared it).
+ *
+ * We make an exception for ResponsibleParty.role, which should be replaced by Party.role
+ * but this replacement is not yet effective in GeoAPI 3.0.
*/
- order.putIfAbsent(propOrder[i], order.size());
+ final String prop = propOrder[i];
+ if (!"role".equals(prop) || !ResponsibleParty.class.isAssignableFrom(implementation)) {
+ order.putIfAbsent(prop, order.size());
+ }
}
}
implementation = implementation.getSuperclass();
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
index a28bc00..f570d26 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
@@ -181,6 +181,30 @@
}
/**
+ * Unconditionally returns {@code null}.
+ *
+ * @deprecated This property was defined in the 2003 edition of ISO 19115,
+ * but has been removed in the 2014 edition.
+ */
+ @Override
+ @Deprecated
+ public String getShortName() {
+ return null;
+ }
+
+ /**
+ * Unconditionally returns {@code null}.
+ *
+ * @deprecated This property was defined in the 2003 edition of ISO 19115,
+ * but has been removed in the 2014 edition.
+ */
+ @Override
+ @Deprecated
+ public Integer getDomainCode() {
+ return null;
+ }
+
+ /**
* Returns the definition of this property, or {@code null} if none.
*/
@Override
@@ -302,6 +326,22 @@
}
/**
+ * Unconditionally returns {@code null}.
+ */
+ public InternationalString getRationale() {
+ return null;
+ }
+
+ /**
+ * Unconditionally returns an empty list.
+ */
+ @Override
+ @Deprecated
+ public Collection<InternationalString> getRationales() {
+ return Collections.emptyList();
+ }
+
+ /**
* Returns the name of the person or organization creating the element.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/Pruner.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/Pruner.java
index 11c2ec4..5b791fc 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/Pruner.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/Pruner.java
@@ -22,8 +22,8 @@
import org.apache.sis.util.privy.CollectionsExt;
import static org.apache.sis.metadata.ValueExistencePolicy.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -133,7 +133,7 @@
} else if (!prune && element instanceof Emptiable) {
isEmptyElement = ((Emptiable) element).isEmpty();
// If 'prune' is true, we will rather test for Emptiable after our pruning attempt.
- } else if (!(element instanceof ControlledVocabulary)) {
+ } else if (!(element instanceof Enum<?>) && !(element instanceof CodeList<?>)) {
final MetadataStandard standard = MetadataStandard.forClass(element.getClass());
if (standard != null) {
/*
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/StandardImplementation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/StandardImplementation.java
index 68acb87..a50699e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/StandardImplementation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/StandardImplementation.java
@@ -25,10 +25,6 @@
import org.apache.sis.util.logging.Logging;
import org.apache.sis.system.Modules;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.annotation.Classifier;
-import org.opengis.annotation.Stereotype;
-
/**
* Information about an Apache SIS metadata standard implementation.
@@ -53,6 +49,12 @@
private final String implementationPackage;
/**
+ * The prefixes that implementation classes may have.
+ * The most common prefixes should be first, because the prefixes will be tried in that order.
+ */
+ private static final String[] IMPL_PREFIXES = {"Default", "Abstract"};
+
+ /**
* The acronyms that implementation classes may have, or {@code null} if none. If non-null,
* then this array shall contain (<var>full text</var>, <var>acronym</var>) pairs. The full
* text shall appear to the end of the class name, otherwise it is not replaced. This is
@@ -94,17 +96,6 @@
}
/**
- * Returns {@code true} if the given type is conceptually abstract.
- * The given type is usually an interface, so here "abstract" cannot be in the Java sense.
- * If this method cannot find information about whether the given type is abstract,
- * then this method conservatively returns {@code false}.
- */
- private static boolean isAbstract(final Class<?> type) {
- final Classifier c = type.getAnnotation(Classifier.class);
- return (c != null) && c.value() == Stereotype.ABSTRACT;
- }
-
- /**
* Accepts Apache SIS implementation classes as "pseudo-interfaces" if they are annotated with {@link UML}.
* We use this feature for example in the transition from ISO 19115:2003 to ISO 19115:2014, when new API is
* defined in Apache SIS but not yet available in GeoAPI interfaces.
@@ -154,17 +145,21 @@
}
}
/*
- * Try to instantiate the implementation class.
+ * Try to insert a prefix in front of the class name, until a match is found.
*/
final int prefixPosition = buffer.lastIndexOf(".") + 1;
- buffer.insert(prefixPosition, isAbstract(type) ? "Abstract" : "Default");
- classname = buffer.toString();
- try {
- candidate = Class.forName(classname);
+ int length = 0;
+ for (final String p : IMPL_PREFIXES) {
+ classname = buffer.replace(prefixPosition, prefixPosition + length, p).toString();
+ try {
+ candidate = Class.forName(classname);
+ } catch (ClassNotFoundException e) {
+ Logging.recoverableException(LOGGER, MetadataStandard.class, "getImplementation", e);
+ length = p.length();
+ continue;
+ }
implementations.put(type, candidate);
return candidate.asSubclass(type);
- } catch (ClassNotFoundException e) {
- Logging.recoverableException(LOGGER, MetadataStandard.class, "getImplementation", e);
}
implementations.put(type, Void.TYPE); // Marker for "class not found".
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/CitationConstant.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/CitationConstant.java
index 55e43a3..cb488cc 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/CitationConstant.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/CitationConstant.java
@@ -38,10 +38,6 @@
import java.util.Date;
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.OnlineResource;
-import org.opengis.metadata.identification.BrowseGraphic;
-
/**
* Base class for the {@code public static final Citation} constants defined in some SIS classes.
@@ -221,8 +217,6 @@
@Override public Collection<PresentationForm> getPresentationForms() {return delegate().getPresentationForms();}
@Override public Series getSeries() {return delegate().getSeries();}
@Override public InternationalString getOtherCitationDetails() {return delegate().getOtherCitationDetails();}
- @Override public Collection<? extends OnlineResource> getOnlineResources() {return delegate().getOnlineResources();}
- @Override public Collection<? extends BrowseGraphic> getGraphics() {return delegate().getGraphics();}
@Override public String getISBN() {return delegate().getISBN();}
@Override public String getISSN() {return delegate().getISSN();}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/ServicesForUtility.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/ServicesForUtility.java
index 5b67ae9..e049709 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/ServicesForUtility.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/internal/ServicesForUtility.java
@@ -19,9 +19,9 @@
import java.text.Format;
import java.util.Locale;
import java.util.TimeZone;
-import java.util.function.Supplier;
import javax.sql.DataSource;
import java.sql.SQLException;
+import java.util.function.Supplier;
import org.opengis.metadata.citation.Citation;
import org.apache.sis.util.Classes;
import org.apache.sis.util.Exceptions;
@@ -35,8 +35,8 @@
import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.xml.bind.Context;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -69,10 +69,10 @@
* @param locale desired locale for the title.
* @return the title.
*
- * @see org.apache.sis.util.iso.Types#getCodeTitle(ControlledVocabulary)
+ * @see org.apache.sis.util.iso.Types#getCodeTitle(CodeList)
*/
@Override
- public String getCodeTitle(final ControlledVocabulary code, final Locale locale) {
+ public String getCodeTitle(final CodeList<?> code, final Locale locale) {
return Types.getCodeTitle(code).toString(locale);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists.properties b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists.properties
new file mode 100644
index 0000000..cb51675
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists.properties
@@ -0,0 +1,18 @@
+# Copy from GeoAPI 3.0 (BSD-like license)
+CI_DateTypeCode.creation=Creation
+CI_DateTypeCode.publication=Publication
+CI_DateTypeCode.revision=Revision
+CI_OnLineFunctionCode.download=Download
+CI_OnLineFunctionCode.information=Information
+CI_OnLineFunctionCode.offlineAccess=Offline access
+CI_OnLineFunctionCode.order=Order
+CI_OnLineFunctionCode.search=Search
+MD_ScopeCode.attribute=Attribute
+MD_ScopeCode.attributeType=Attribute type
+MD_ScopeCode.dataset=Dataset
+MD_ScopeCode.series=Series
+MD_ScopeCode.nonGeographicDataset=Non geographic dataset
+MD_ScopeCode.feature=Feature
+MD_ScopeCode.featureType=Feature type
+MD_ScopeCode.propertyType=Property type
+MD_ScopeCode.tile=Tile
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_en.properties b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_en.properties
new file mode 100644
index 0000000..d70945d
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_en.properties
@@ -0,0 +1 @@
+# Inherit all resources from CodeLists.properties
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_fr.properties b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_fr.properties
new file mode 100644
index 0000000..f8afb6f
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/CodeLists_fr.properties
@@ -0,0 +1,18 @@
+# Copy from GeoAPI 3.0 (BSD-like license)
+CI_DateTypeCode.creation=Création
+CI_DateTypeCode.publication=Publication
+CI_DateTypeCode.revision=Révision
+CI_OnLineFunctionCode.download=Téléchargement
+CI_OnLineFunctionCode.information=Information
+CI_OnLineFunctionCode.offlineAccess=Accès hors ligne
+CI_OnLineFunctionCode.order=Commande en ligne
+CI_OnLineFunctionCode.search=Moteur de recherche
+MD_ScopeCode.attribute=Attribut
+MD_ScopeCode.attributeType=Type d\u2019attribut
+MD_ScopeCode.dataset=Jeu de données
+MD_ScopeCode.series=Série
+MD_ScopeCode.nonGeographicDataset=Jeu de données non géographiques
+MD_ScopeCode.feature=Élément
+MD_ScopeCode.featureType=Type d\u2019élément
+MD_ScopeCode.propertyType=Type de propriété
+MD_ScopeCode.tile=Tuile
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
index 1ed8ffc..3038d78 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
@@ -40,9 +40,10 @@
import org.opengis.metadata.Obligation;
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.AbstractSet;
-import java.util.Iterator;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -551,8 +552,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "rationale")
+ @UML(identifier="rationale", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getRationale() {
return LegacyPropertyAdapter.getSingleton(rationales, InternationalString.class, null,
DefaultExtendedElementInformation.class, "getRationale");
@@ -578,29 +579,7 @@
@Deprecated(since="1.0")
@Dependencies("getRationale")
public Collection<InternationalString> getRationales() {
- return new AbstractSet<InternationalString>() {
- /** Returns 0 if empty, or 1 if a density has been specified. */
- @Override public int size() {
- return getRationale() != null ? 1 : 0;
- }
-
- /** Returns an iterator over 0 or 1 element. Current iterator implementation is unmodifiable. */
- @Override public Iterator<InternationalString> iterator() {
- return CollectionsExt.singletonOrEmpty(getRationale()).iterator();
- }
-
- /** Adds an element only if the set is empty. This method is invoked by JAXB at unmarshalling time. */
- @Override public boolean add(final InternationalString newValue) {
- if (isEmpty()) {
- setRationale(newValue);
- return true;
- } else {
- LegacyPropertyAdapter.warnIgnoredExtraneous(InternationalString.class,
- DefaultExtendedElementInformation.class, "setRationales");
- return false;
- }
- }
- };
+ return rationales = nonNullCollection(rationales, InternationalString.class);
}
/**
@@ -610,8 +589,7 @@
*/
@Deprecated(since="1.0")
public void setRationales(final Collection<? extends InternationalString> newValues) {
- setRationale(LegacyPropertyAdapter.getSingleton(newValues, InternationalString.class,
- null, DefaultExtendedElementInformation.class, "setRationales"));
+ rationales = writeCollection(newValues, rationales, InternationalString.class);
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultIdentifier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultIdentifier.java
index 53fdf82..bc7e45d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultIdentifier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultIdentifier.java
@@ -27,6 +27,12 @@
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.xml.Namespaces;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Value uniquely identifying an object within a namespace.
@@ -218,10 +224,17 @@
super(object);
if (object != null) {
code = object.getCode();
- codeSpace = object.getCodeSpace();
- version = object.getVersion();
- description = object.getDescription();
authority = object.getAuthority();
+ if (object instanceof DefaultIdentifier) {
+ final DefaultIdentifier c = (DefaultIdentifier) object;
+ codeSpace = c.getCodeSpace();
+ version = c.getVersion();
+ description = c.getDescription();
+ } else if (object instanceof ReferenceIdentifier) {
+ final ReferenceIdentifier c = (ReferenceIdentifier) object;
+ codeSpace = c.getCodeSpace();
+ version = c.getVersion();
+ }
}
}
@@ -313,8 +326,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "codeSpace")
+ @UML(identifier="codeSpace", obligation=OPTIONAL, specification=ISO_19115)
public String getCodeSpace() {
return codeSpace;
}
@@ -341,8 +354,8 @@
*
* @return the version identifier for the namespace, or {@code null} if none.
*/
- @Override
@XmlElement(name = "version")
+ @UML(identifier="version", obligation=OPTIONAL, specification=ISO_19115)
public String getVersion() {
return version;
}
@@ -367,8 +380,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "description")
+ @UML(identifier="description", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDescription() {
return description;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadata.java
index 2b5f841..558f412 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadata.java
@@ -88,8 +88,14 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
+// Specific to the main branch:
+import java.util.LinkedHashMap;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.xml.bind.metadata.code.MD_CharacterSetCode;
/**
@@ -225,7 +231,7 @@
* Scope to which the metadata applies.
*/
@SuppressWarnings("serial")
- private Collection<MetadataScope> metadataScopes;
+ private Collection<DefaultMetadataScope> metadataScopes;
/**
* Parties responsible for the metadata information.
@@ -359,8 +365,8 @@
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultMetadata(final ResponsibleParty contact,
- final Date dateStamp,
- final Identification identificationInfo)
+ final Date dateStamp,
+ final Identification identificationInfo)
{
this(contact, TemporalDate.toTemporal(dateStamp), identificationInfo);
}
@@ -397,16 +403,7 @@
public DefaultMetadata(final Metadata object) {
super(object);
if (object != null) {
- identifiers = singleton(object.getMetadataIdentifier(), Identifier.class);
- parentMetadata = object.getParentMetadata();
- locales = copyMap (object.getLocalesAndCharsets(), Locale.class);
- metadataScopes = copyCollection(object.getMetadataScopes(), MetadataScope.class);
contacts = copyCollection(object.getContacts(), ResponsibleParty.class);
- dateInfo = copyCollection(object.getDateInfo(), CitationDate.class);
- metadataStandards = copyCollection(object.getMetadataStandards(), Citation.class);
- metadataProfiles = copyCollection(object.getMetadataProfiles(), Citation.class);
- alternativeMetadataReferences = copyCollection(object.getAlternativeMetadataReferences(), Citation.class);
- metadataLinkages = copyCollection(object.getMetadataLinkages(), OnlineResource.class);
spatialRepresentationInfo = copyCollection(object.getSpatialRepresentationInfo(), SpatialRepresentation.class);
referenceSystemInfo = copyCollection(object.getReferenceSystemInfo(), ReferenceSystem.class);
metadataExtensionInfo = copyCollection(object.getMetadataExtensionInfo(), MetadataExtensionInformation.class);
@@ -419,7 +416,35 @@
applicationSchemaInfo = copyCollection(object.getApplicationSchemaInfo(), ApplicationSchemaInformation.class);
metadataMaintenance = object.getMetadataMaintenance();
acquisitionInformation = copyCollection(object.getAcquisitionInformation(), AcquisitionInformation.class);
- resourceLineages = copyCollection(object.getResourceLineages(), Lineage.class);
+ if (object instanceof DefaultMetadata) {
+ final DefaultMetadata c = (DefaultMetadata) object;
+ identifiers = singleton(c.getMetadataIdentifier(), Identifier.class);
+ parentMetadata = c.getParentMetadata();
+ locales = copyMap (c.getLocalesAndCharsets(), Locale.class);
+ metadataScopes = copyCollection(c.getMetadataScopes(), DefaultMetadataScope.class);
+ dateInfo = copyCollection(c.getDateInfo(), CitationDate.class);
+ metadataStandards = copyCollection(c.getMetadataStandards(), Citation.class);
+ metadataProfiles = copyCollection(c.getMetadataProfiles(), Citation.class);
+ alternativeMetadataReferences = copyCollection(c.getAlternativeMetadataReferences(), Citation.class);
+ metadataLinkages = copyCollection(c.getMetadataLinkages(), OnlineResource.class);
+ resourceLineages = copyCollection(c.getResourceLineages(), Lineage.class);
+ } else {
+ setFileIdentifier (object.getFileIdentifier());
+ setParentIdentifier (object.getParentIdentifier());
+ setLanguage (object.getLanguage());
+ setLocales (object.getLocales());
+ setCharacterSet (object.getCharacterSet());
+ setHierarchyLevels (object.getHierarchyLevels());
+ setHierarchyLevelNames (object.getHierarchyLevelNames());
+ setDateStamp (object.getDateStamp());
+ setMetadataStandardName (object.getMetadataStandardName());
+ setMetadataStandardVersion(object.getMetadataStandardVersion());
+ try {
+ setDataSetUri(object.getDataSetUri());
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
}
}
@@ -500,9 +525,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "metadataIdentifier")
@XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
+ @UML(identifier="metadataIdentifier", obligation=OPTIONAL, specification=ISO_19115)
public Identifier getMetadataIdentifier() {
return super.getIdentifier();
}
@@ -579,8 +604,8 @@
*
* @since 1.0
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="defaultLocale+otherLocale", obligation=CONDITIONAL, specification=ISO_19115)
public Map<Locale,Charset> getLocalesAndCharsets() {
return locales = nonNullMap(locales, Locale.class);
}
@@ -664,6 +689,27 @@
}
/**
+ * Sets information about an alternatively used localized character string for a linguistic extension.
+ *
+ * @param newValues the new locales.
+ *
+ * @deprecated Replaced by putting keys in {@link #getLocalesAndCharsets()}.
+ */
+ @Deprecated
+ public void setLocales(final Collection<? extends Locale> newValues) {
+ final Collection<Locale> legacy = getLocales();
+ if (legacy != null) {
+ legacy.addAll(newValues);
+ } else if (!newValues.isEmpty()) {
+ final Map<Locale,Charset> locales = new LinkedHashMap<>();
+ for (final Locale locale : newValues) {
+ locales.put(locale, null);
+ }
+ setLocalesAndCharsets(locales);
+ }
+ }
+
+ /**
* Converter from {@link PT_Locale} and {@link Locale}.
*/
private static final class ToLocale extends SurjectiveConverter<PT_Locale,Locale> {
@@ -711,7 +757,7 @@
@Dependencies("getLocalesAndCharsets")
// @XmlElement at the end of this class.
public CharacterSet getCharacterSet() {
- return CharacterSet.fromCharset(getCharacterSets());
+ return MD_CharacterSetCode.fromCharset(getCharacterSets());
}
/**
@@ -734,9 +780,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "parentMetadata")
@XmlJavaTypeAdapter(CI_Citation.Since2014.class)
+ @UML(identifier="parentMetadata", obligation=CONDITIONAL, specification=ISO_19115)
public Citation getParentMetadata() {
return parentMetadata;
}
@@ -804,25 +850,35 @@
/**
* Returns the scope or type of resource for which metadata is provided.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code MetadataScope} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return scope or type of resource for which metadata is provided.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<MetadataScope> getMetadataScopes() {
- return metadataScopes = nonNullCollection(metadataScopes, MetadataScope.class);
+ @UML(identifier="metadataScope", obligation=CONDITIONAL, specification=ISO_19115)
+ public Collection<DefaultMetadataScope> getMetadataScopes() {
+ return metadataScopes = nonNullCollection(metadataScopes, DefaultMetadataScope.class);
}
/**
* Sets the scope or type of resource for which metadata is provided.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code MetadataScope} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new scope or type of resource.
*
* @since 0.5
*/
- public void setMetadataScopes(final Collection<? extends MetadataScope> newValues) {
- metadataScopes = writeCollection(newValues, metadataScopes, MetadataScope.class);
+ public void setMetadataScopes(final Collection<? extends DefaultMetadataScope> newValues) {
+ metadataScopes = writeCollection(newValues, metadataScopes, DefaultMetadataScope.class);
}
/**
@@ -841,22 +897,19 @@
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
return new MetadataScopeAdapter<ScopeCode>(getMetadataScopes()) {
/** Stores a legacy value into the new kind of value. */
- @Override protected MetadataScope wrap(final ScopeCode value) {
+ @Override protected DefaultMetadataScope wrap(final ScopeCode value) {
return new DefaultMetadataScope(value, null);
}
/** Extracts the legacy value from the new kind of value. */
- @Override protected ScopeCode unwrap(final MetadataScope container) {
+ @Override protected ScopeCode unwrap(final DefaultMetadataScope container) {
return container.getResourceScope();
}
/** Updates the legacy value in an existing instance of the new kind of value. */
- @Override protected boolean update(final MetadataScope container, final ScopeCode value) {
- if (container instanceof DefaultMetadataScope) {
- ((DefaultMetadataScope) container).setResourceScope(value);
- return true;
- }
- return false;
+ @Override protected boolean update(final DefaultMetadataScope container, final ScopeCode value) {
+ container.setResourceScope(value);
+ return true;
}
}.validOrNull();
}
@@ -891,23 +944,20 @@
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
return new MetadataScopeAdapter<String>(getMetadataScopes()) {
/** Stores a legacy value into the new kind of value. */
- @Override protected MetadataScope wrap(final String value) {
+ @Override protected DefaultMetadataScope wrap(final String value) {
return new DefaultMetadataScope(null, value);
}
/** Extracts the legacy value from the new kind of value. */
- @Override protected String unwrap(final MetadataScope container) {
+ @Override protected String unwrap(final DefaultMetadataScope container) {
final InternationalString name = container.getName();
return (name != null) ? name.toString() : null;
}
/** Updates the legacy value in an existing instance of the new kind of value. */
- @Override protected boolean update(final MetadataScope container, final String value) {
- if (container instanceof DefaultMetadataScope) {
- ((DefaultMetadataScope) container).setName(value != null ? new SimpleInternationalString(value) : null);
- return true;
- }
- return false;
+ @Override protected boolean update(final DefaultMetadataScope container, final String value) {
+ container.setName(value != null ? new SimpleInternationalString(value) : null);
+ return true;
}
}.validOrNull();
}
@@ -960,8 +1010,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="dateInfo", obligation=MANDATORY, specification=ISO_19115)
public Collection<CitationDate> getDateInfo() {
return dateInfo = nonNullCollection(dateInfo, CitationDate.class);
}
@@ -1052,8 +1102,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="metadataStandard", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getMetadataStandards() {
return metadataStandards = nonNullCollection(metadataStandards, Citation.class);
}
@@ -1080,8 +1130,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="metadataProfile", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getMetadataProfiles() {
return metadataProfiles = nonNullCollection(metadataProfiles, Citation.class);
}
@@ -1105,8 +1155,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="alternativeMetadataReference", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getAlternativeMetadataReferences() {
return alternativeMetadataReferences = nonNullCollection(alternativeMetadataReferences, Citation.class);
}
@@ -1232,8 +1282,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="metadataLinkage", obligation=OPTIONAL, specification=ISO_19115)
public Collection<OnlineResource> getMetadataLinkages() {
return metadataLinkages = nonNullCollection(metadataLinkages, OnlineResource.class);
}
@@ -1267,8 +1317,8 @@
if (FilterByVersion.LEGACY_METADATA.accept() && (info = getIdentificationInfo()) != null) {
for (final Identification identification : info) {
final Citation citation = identification.getCitation();
- if (citation != null) {
- final Collection<? extends OnlineResource> onlineResources = citation.getOnlineResources();
+ if (citation instanceof DefaultCitation) {
+ final Collection<? extends OnlineResource> onlineResources = ((DefaultCitation) citation).getOnlineResources();
if (onlineResources != null) {
for (final OnlineResource link : onlineResources) {
final URI uri = link.getLinkage();
@@ -1598,8 +1648,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="resourceLineage", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Lineage> getResourceLineages() {
return resourceLineages = nonNullCollection(resourceLineages, Lineage.class);
}
@@ -1726,7 +1776,7 @@
}
@XmlElement(name = "metadataScope")
- private Collection<MetadataScope> getMetadataScope() {
+ private Collection<DefaultMetadataScope> getMetadataScope() {
return FilterByVersion.CURRENT_METADATA.accept() ? getMetadataScopes() : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadataScope.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadataScope.java
index c1fe82d..121d6a7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadataScope.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/DefaultMetadataScope.java
@@ -23,8 +23,11 @@
import org.opengis.metadata.maintenance.ScopeCode;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -34,6 +37,14 @@
* <div class="preformat">{@code MD_MetadataScope}
* {@code └─resourceScope……} Resource scope</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code MetadataScope} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -53,7 +64,8 @@
"name"
})
@XmlRootElement(name = "MD_MetadataScope")
-public class DefaultMetadataScope extends ISOMetadata implements MetadataScope {
+@UML(identifier="MD_MetadataScope", specification=ISO_19115)
+public class DefaultMetadataScope extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -93,10 +105,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(MetadataScope)
*/
- public DefaultMetadataScope(final MetadataScope object) {
+ public DefaultMetadataScope(final DefaultMetadataScope object) {
super(object);
if (object != null) {
resourceScope = object.getResourceScope();
@@ -105,37 +115,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultMetadataScope}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultMetadataScope} instance is created using the
- * {@linkplain #DefaultMetadataScope(MetadataScope) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultMetadataScope castOrCopy(final MetadataScope object) {
- if (object == null || object instanceof DefaultMetadataScope) {
- return (DefaultMetadataScope) object;
- }
- return new DefaultMetadataScope(object);
- }
-
- /**
* Returns the code for the scope.
*
* @return the code for the scope.
*/
- @Override
@XmlElement(name = "resourceScope", required = true)
+ @UML(identifier="resourceScope", obligation=MANDATORY, specification=ISO_19115)
public ScopeCode getResourceScope() {
return resourceScope;
}
@@ -155,8 +140,8 @@
*
* @return description of the scope, or {@code null} if none.
*/
- @Override
@XmlElement(name = "name")
+ @UML(identifier="name", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getName() {
return name;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/MetadataScopeAdapter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/MetadataScopeAdapter.java
index c0bf7c2..cfdb969 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/MetadataScopeAdapter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/MetadataScopeAdapter.java
@@ -23,9 +23,6 @@
import java.util.ConcurrentModificationException;
import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
-
/**
* A specialization of {@link LegacyPropertyAdapter} which will try to merge the
@@ -34,25 +31,25 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-abstract class MetadataScopeAdapter<L> extends LegacyPropertyAdapter<L,MetadataScope> {
+abstract class MetadataScopeAdapter<L> extends LegacyPropertyAdapter<L,DefaultMetadataScope> {
/**
* @param scopes Value of {@link DefaultMetadata#getMetadataScopes()}.
*/
- MetadataScopeAdapter(final Collection<MetadataScope> scopes) {
+ MetadataScopeAdapter(final Collection<DefaultMetadataScope> scopes) {
super(scopes);
}
/**
* Invoked (indirectly) by JAXB when adding a new scope code or scope name. This implementation searches
- * for an existing {@link MetadataScope} instance with a free slot for the new value before to create a
+ * for an existing {@code MetadataScope} instance with a free slot for the new value before to create a
* new {@link DefaultMetadataScope} instance.
*/
@Override
public boolean add(final L newValue) {
int n = 0;
- final Iterator<MetadataScope> it = elements.iterator();
+ final Iterator<DefaultMetadataScope> it = elements.iterator();
while (it.hasNext()) {
- MetadataScope scope = it.next();
+ DefaultMetadataScope scope = it.next();
if (unwrap(scope) != null) {
n++;
continue;
@@ -63,18 +60,16 @@
* But if the metadata is not modifiable, then we will need to clone it and replaces the element in
* the collection.
*/
- if (!(scope instanceof DefaultMetadataScope) ||
- ((DefaultMetadataScope) scope).state() == DefaultMetadataScope.State.FINAL)
- {
+ if (scope.state() == DefaultMetadataScope.State.FINAL) {
scope = new DefaultMetadataScope(scope);
if (elements instanceof List<?>) {
- ((List<MetadataScope>) elements).set(n, scope);
+ ((List<DefaultMetadataScope>) elements).set(n, scope);
} else {
/*
* Not a list. Delete all the remaining parts, substitute the value
* and reinsert everything in the same order.
*/
- final MetadataScope[] remaining = new MetadataScope[elements.size() - n];
+ final DefaultMetadataScope[] remaining = new DefaultMetadataScope[elements.size() - n];
remaining[0] = scope;
n = 1;
it.remove();
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
index 13177ed..8a99d2e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
@@ -33,6 +33,11 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.temporal.TemporalDate;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115_2;
+
/**
* Identification of a significant collection point within an operation.
@@ -138,7 +143,7 @@
trigger = object.getTrigger();
context = object.getContext();
sequence = object.getSequence();
- time = object.getDateOfOccurrence();
+ time = TemporalDate.toTemporal(object.getTime());
expectedObjectives = copyCollection(object.getExpectedObjectives(), Objective.class);
relatedPass = object.getRelatedPass();
relatedSensors = copyCollection(object.getRelatedSensors(), Instrument.class);
@@ -286,8 +291,8 @@
*
* @since 1.5
*/
- @Override
@XmlElement(name = "time", required = true)
+ @UML(identifier="time", obligation=MANDATORY, specification=ISO_19115_2)
public Temporal getDateOfOccurrence() {
return time;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
index 355f11c..7da3c4d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
@@ -68,7 +68,7 @@
"types",
"functions",
"extents",
- "objectiveOccurrences",
+ "objectiveOccurences",
"pass",
"sensingInstruments"
})
@@ -77,7 +77,7 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 3312985886806161441L;
+ private static final long serialVersionUID = 8273806197892815938L;
/**
* Priority applied to the target.
@@ -108,7 +108,7 @@
* Event or events associated with objective completion.
*/
@SuppressWarnings("serial")
- private Collection<Event> objectiveOccurrences;
+ private Collection<Event> objectiveOccurences;
/**
* Pass of the platform over the objective.
@@ -145,7 +145,7 @@
types = copyCollection(object.getTypes(), ObjectiveType.class);
functions = copyCollection(object.getFunctions(), InternationalString.class);
extents = copyCollection(object.getExtents(), Extent.class);
- objectiveOccurrences = copyCollection(object.getObjectiveOccurences(), Event.class);
+ objectiveOccurences = copyCollection(object.getObjectiveOccurences(), Event.class);
pass = copyCollection(object.getPass(), PlatformPass.class);
sensingInstruments = copyCollection(object.getSensingInstruments(), Instrument.class);
}
@@ -295,45 +295,27 @@
/**
* Returns the event or events associated with objective completion.
*
- * @return events associated with objective completion.
- *
- * @since 1.0
- */
- @XmlElement(name = "objectiveOccurence", required = true)
- public Collection<Event> getObjectiveOccurrences() {
- return objectiveOccurrences = nonNullCollection(objectiveOccurrences, Event.class);
- }
-
- /**
- * @deprecated Renamed {@link #getObjectiveOccurrences()}.
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * This method is misspelled (missing "r"). Its name may be fixed in GeoAPI 4.0.</div>
*
* @return events associated with objective completion.
*/
@Override
- @Deprecated
+ @XmlElement(name = "objectiveOccurence", required = true)
public Collection<Event> getObjectiveOccurences() {
- return getObjectiveOccurrences();
+ return objectiveOccurences = nonNullCollection(objectiveOccurences, Event.class);
}
/**
* Sets the event or events associated with objective completion.
*
- * @param newValues the new objective occurrences values.
- *
- * @since 1.0
- */
- public void setObjectiveOccurrences(final Collection<? extends Event> newValues) {
- objectiveOccurrences = writeCollection(newValues, objectiveOccurrences, Event.class);
- }
-
- /**
- * @deprecated Renamed {@link #setObjectiveOccurrences(Collection)}.
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * This method is misspelled (missing "r"). Its name may be fixed in GeoAPI 4.0.</div>
*
* @param newValues the new objective occurrences values.
*/
- @Deprecated
public void setObjectiveOccurences(final Collection<? extends Event> newValues) {
- setObjectiveOccurrences(newValues);
+ objectiveOccurences = writeCollection(newValues, objectiveOccurences, Event.class);
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/AbstractParty.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/AbstractParty.java
index 143fe50..7d413cb 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/AbstractParty.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/AbstractParty.java
@@ -30,10 +30,11 @@
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.xml.bind.NonMarshalledAuthority;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Individual;
-import org.opengis.metadata.citation.Organisation;
-import org.opengis.metadata.citation.Party;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -44,6 +45,14 @@
* <div class="preformat">{@code CI_Party}
* {@code └─name……} Name of the party.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code Party} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -69,7 +78,8 @@
DefaultIndividual.class,
DefaultOrganisation.class
})
-public class AbstractParty extends ISOMetadata implements Party {
+@UML(identifier="CI_Party", specification=ISO_19115)
+public class AbstractParty extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -110,10 +120,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Party)
*/
- public AbstractParty(final Party object) {
+ public AbstractParty(final AbstractParty object) {
super(object);
if (object != null) {
name = object.getName();
@@ -122,47 +130,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link Individual} or {@link Organisation},
- * then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
- * Note that if the given object implements more than one of the above-cited interfaces,
- * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code AbstractParty}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code AbstractParty} instance is created using the
- * {@linkplain #AbstractParty(Party) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static AbstractParty castOrCopy(final Party object) {
- if (object instanceof Individual) {
- return DefaultIndividual.castOrCopy((Individual) object);
- }
- if (object instanceof Organisation) {
- return DefaultOrganisation.castOrCopy((Organisation) object);
- }
- if (object == null || object instanceof AbstractParty) {
- return (AbstractParty) object;
- }
- return new AbstractParty(object);
- }
-
- /**
* Return the name of the party.
*
* @return name of the party.
*/
- @Override
@XmlElement(name = "name")
+ @UML(identifier="name", obligation=CONDITIONAL, specification=ISO_19115)
public InternationalString getName() {
return name;
}
@@ -219,8 +192,8 @@
*
* @return contact information for the party.
*/
- @Override
@XmlElement(name = "contactInfo")
+ @UML(identifier="contactInfo", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Contact> getContactInfo() {
return contactInfo = nonNullCollection(contactInfo, Contact.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/Citations.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/Citations.java
index 972fe9b..853bdf2 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/Citations.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/Citations.java
@@ -40,6 +40,9 @@
import org.apache.sis.system.SystemListener;
import org.apache.sis.metadata.iso.DefaultIdentifier; // For javadoc
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* A set of predefined constants and static methods working on {@linkplain Citation citations}.
@@ -772,10 +775,10 @@
* Found a possible match. We will take the code space in account only if it is defined
* by both identifiers. If a code space is undefined, we consider that we have a match.
*/
- if (identifier != null) {
- final String codeSpace = identifier.getCodeSpace();
- if (codeSpace != null) {
- final String cs = citId.getCodeSpace();
+ if (identifier instanceof ReferenceIdentifier) {
+ final String codeSpace = ((ReferenceIdentifier) identifier).getCodeSpace();
+ if (codeSpace != null && citId instanceof ReferenceIdentifier) {
+ final String cs = ((ReferenceIdentifier) citId).getCodeSpace();
if (cs != null && !equalsFiltered(codeSpace, cs)) {
continue; // Check other identifiers.
}
@@ -797,7 +800,8 @@
final CharSequence localPart = code.subSequence(++s, length);
for (it = citIds.iterator(); it.hasNext();) {
final Identifier id = it.next();
- if (equalsFiltered(codeSpace, id.getCodeSpace()) && equalsFiltered(localPart, id.getCode())) {
+ final String cs = (id instanceof ReferenceIdentifier) ? ((ReferenceIdentifier) id).getCodeSpace() : null;
+ if (equalsFiltered(codeSpace, cs) && equalsFiltered(localPart, id.getCode())) {
return true;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultAddress.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultAddress.java
index 76f50f1..d658155 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultAddress.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultAddress.java
@@ -56,7 +56,7 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -1709738216789373888L;
+ private static final long serialVersionUID = 1357443146723845129L;
/**
* State, province of the location.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitation.java
index a39a945..1ccc78e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitation.java
@@ -44,6 +44,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Standardized resource reference.
@@ -206,7 +211,7 @@
*
* @see #castOrCopy(Citation)
*/
- @SuppressWarnings({"this-escape", "deprecation"})
+ @SuppressWarnings("this-escape")
public DefaultCitation(final Citation object) {
super(object);
if (object != null) {
@@ -221,8 +226,11 @@
series = object.getSeries();
otherCitationDetails = object.getOtherCitationDetails();
collectiveTitle = object.getCollectiveTitle();
- onlineResources = copyCollection(object.getOnlineResources(), OnlineResource.class);
- graphics = copyCollection(object.getGraphics(), BrowseGraphic.class);
+ if (object instanceof DefaultCitation) {
+ final DefaultCitation c = (DefaultCitation) object;
+ onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class);
+ graphics = copyCollection(c.getGraphics(), BrowseGraphic.class);
+ }
final String id1 = object.getISBN();
final String id2 = object.getISSN();
if (id1 != null || id2 != null) {
@@ -659,8 +667,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="onlineResource", obligation=OPTIONAL, specification=ISO_19115)
public Collection<OnlineResource> getOnlineResources() {
return onlineResources = nonNullCollection(onlineResources, OnlineResource.class);
}
@@ -683,8 +691,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="graphic", obligation=OPTIONAL, specification=ISO_19115)
public Collection<BrowseGraphic> getGraphics() {
return graphics = nonNullCollection(graphics, BrowseGraphic.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java
index 8f75d6a..3a9d3dd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java
@@ -27,6 +27,11 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.temporal.TemporalDate;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Reference date and event used to describe it.
@@ -119,8 +124,12 @@
public DefaultCitationDate(final CitationDate object) {
super(object);
if (object != null) {
- date = TemporalDate.toTemporal(object.getDate());
dateType = object.getDateType();
+ if (object instanceof DefaultCitationDate) {
+ date = ((DefaultCitationDate) object).getReferenceDate();
+ } else {
+ date = TemporalDate.toTemporal(object.getDate());
+ }
}
}
@@ -181,8 +190,8 @@
*
* @since 1.5
*/
- @Override
@XmlElement(name = "date", required = true)
+ @UML(identifier="date", obligation=MANDATORY, specification=ISO_19115)
public Temporal getReferenceDate() {
return date;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultContact.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultContact.java
index 99f6a6b..f63fedc 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultContact.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultContact.java
@@ -38,8 +38,12 @@
import org.apache.sis.xml.privy.LegacyNamespaces;
import org.apache.sis.util.privy.CollectionsExt;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.TelephoneType;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -78,7 +82,7 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 2972124992825717056L;
+ private static final long serialVersionUID = -969735574940462381L;
/**
* Telephone numbers at which the organization or individual may be contacted.
@@ -144,12 +148,19 @@
public DefaultContact(final Contact object) {
super(object);
if (object != null) {
- phones = copyCollection(object.getPhones(), Telephone.class);
- addresses = copyCollection(object.getAddresses(), Address.class);
- onlineResources = copyCollection(object.getOnlineResources(), OnlineResource.class);
hoursOfService = object.getHoursOfService();
contactInstructions = object.getContactInstructions();
- contactType = object.getContactType();
+ if (object instanceof DefaultContact) {
+ final DefaultContact c = (DefaultContact) object;
+ phones = copyCollection(c.getPhones(), Telephone.class);
+ addresses = copyCollection(c.getAddresses(), Address.class);
+ onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class);
+ contactType = c.getContactType();
+ } else {
+ phones = singleton(object.getPhone(), Telephone.class);
+ addresses = singleton(object.getAddress(), Address.class);
+ onlineResources = singleton(object.getOnlineResource(), OnlineResource.class);
+ }
}
}
@@ -185,8 +196,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="phone", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Telephone> getPhones() {
return phones = nonNullCollection(phones, Telephone.class);
}
@@ -225,8 +236,8 @@
/**
* Returns telephone numbers at which the organization or individual may be contacted.
- * This method returns the first telephone number associated to {@link TelephoneType#VOICE}
- * or {@link TelephoneType#FACSIMILE FACSIMILE}.
+ * This method returns the first telephone number associated to {@code TelephoneType.VOICE}
+ * or {@code TelephoneType.FACSIMILE FACSIMILE}.
*
* @return telephone numbers at which the organization or individual may be contacted, or {@code null}.
*
@@ -240,16 +251,19 @@
Telephone phone = null;
if (FilterByVersion.LEGACY_METADATA.accept()) {
final Collection<Telephone> phones = getPhones();
- if (phones != null) { // May be null on marshalling.
- TelephoneType ignored = null;
+ if (phones != null) { // May be null on marshalling.
+ CodeList<?> ignored = null;
for (final Telephone c : phones) {
- final TelephoneType type = c.getNumberType();
- if (type == TelephoneType.VOICE || type == TelephoneType.FACSIMILE) {
- if (phone == null) {
- phone = c;
+ if (c instanceof DefaultTelephone) {
+ String name;
+ final CodeList<?> type = ((DefaultTelephone) c).numberType;
+ if (type != null && ("VOICE".equals(name = type.name()) || "FACSIMILE".equals(name))) {
+ if (phone == null) {
+ phone = c;
+ }
+ } else if (ignored == null) {
+ ignored = type;
}
- } else if (ignored == null) {
- ignored = type;
}
}
if (ignored != null) {
@@ -258,7 +272,7 @@
* because we want the property to appear as "TelephoneType[FOO]" instead of "FOO".
*/
Context.warningOccured(Context.current(), DefaultContact.class, "getPhone",
- Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored.toString());
+ Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored);
}
}
}
@@ -282,10 +296,10 @@
} else {
newValues = new ArrayList<>(4);
for (String number : newValue.getVoices()) {
- newValues.add(new DefaultTelephone(number, TelephoneType.VOICE));
+ newValues.add(new DefaultTelephone(number, UnsupportedCodeList.VOICE));
}
for (String number : newValue.getFacsimiles()) {
- newValues.add(new DefaultTelephone(number, TelephoneType.FACSIMILE));
+ newValues.add(new DefaultTelephone(number, UnsupportedCodeList.FACSIMILE));
}
}
}
@@ -299,8 +313,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="address", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Address> getAddresses() {
return addresses = nonNullCollection(addresses, Address.class);
}
@@ -355,8 +369,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="onlineResource", obligation=OPTIONAL, specification=ISO_19115)
public Collection<OnlineResource> getOnlineResources() {
return onlineResources = nonNullCollection(onlineResources, OnlineResource.class);
}
@@ -464,9 +478,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "contactType")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="contactType", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getContactType() {
return contactType;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultIndividual.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultIndividual.java
index e4da2f8..2184ddd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultIndividual.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultIndividual.java
@@ -23,13 +23,23 @@
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Individual;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
* Information about the party if the party is an individual.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code Individual} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -48,7 +58,8 @@
"positionName"
})
@XmlRootElement(name = "CI_Individual")
-public class DefaultIndividual extends AbstractParty implements Individual {
+@UML(identifier="CI_Individual", specification=ISO_19115)
+public class DefaultIndividual extends AbstractParty {
/**
* Serial number for inter-operability with different versions.
*/
@@ -87,10 +98,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Individual)
*/
- public DefaultIndividual(final Individual object) {
+ public DefaultIndividual(final DefaultIndividual object) {
super(object);
if (object != null) {
positionName = object.getPositionName();
@@ -98,37 +107,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultIndividual}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultIndividual} instance is created using the
- * {@linkplain #DefaultIndividual(Individual) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultIndividual castOrCopy(final Individual object) {
- if (object == null || object instanceof DefaultIndividual) {
- return (DefaultIndividual) object;
- }
- return new DefaultIndividual(object);
- }
-
- /**
* Returns position of the individual in an organization, or {@code null} if none.
*
* @return position of the individual in an organization, or {@code null} if none.
*/
- @Override
@XmlElement(name = "positionName")
+ @UML(identifier="positionName", obligation=CONDITIONAL, specification=ISO_19115)
public InternationalString getPositionName() {
return positionName;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java
index c190272..c19fd68 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java
@@ -28,6 +28,11 @@
import org.apache.sis.xml.bind.gco.URIAdapter;
import org.apache.sis.metadata.iso.ISOMetadata;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about on-line sources from which the dataset, specification, or
@@ -67,7 +72,7 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 2627991335953178610L;
+ private static final long serialVersionUID = 1413613911128890864L;
/**
* Location (address) for on-line access using a Uniform Resource Locator address or
@@ -142,7 +147,9 @@
name = object.getName();
description = object.getDescription();
function = object.getFunction();
- protocolRequest = object.getProtocolRequest();
+ if (object instanceof DefaultOnlineResource) {
+ protocolRequest = ((DefaultOnlineResource) object).getProtocolRequest();
+ }
}
}
@@ -329,9 +336,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "protocolRequest")
@XmlJavaTypeAdapter(StringAdapter.Since2014.class)
+ @UML(identifier="protocolRequest", obligation=OPTIONAL, specification=ISO_19115)
public String getProtocolRequest() {
return protocolRequest;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java
index bda3d51..2483bd4 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java
@@ -23,14 +23,24 @@
import org.opengis.metadata.citation.Contact;
import org.opengis.metadata.identification.BrowseGraphic;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Individual;
-import org.opengis.metadata.citation.Organisation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
* Information about the party if the party is an organization.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code Organisation} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -50,7 +60,8 @@
"individual"
})
@XmlRootElement(name = "CI_Organisation")
-public class DefaultOrganisation extends AbstractParty implements Organisation {
+@UML(identifier="CI_Organisation", specification=ISO_19115)
+public class DefaultOrganisation extends AbstractParty {
/**
* Serial number for inter-operability with different versions.
*/
@@ -66,7 +77,7 @@
* Individuals in the named organization.
*/
@SuppressWarnings("serial")
- private Collection<Individual> individual;
+ private Collection<DefaultIndividual> individual;
/**
* Constructs an initially empty organization.
@@ -84,12 +95,12 @@
*/
public DefaultOrganisation(final CharSequence name,
final BrowseGraphic logo,
- final Individual individual,
+ final DefaultIndividual individual,
final Contact contactInfo)
{
super(name, contactInfo);
this.logo = singleton(logo, BrowseGraphic.class);
- this.individual = singleton(individual, Individual.class);
+ this.individual = singleton(individual, DefaultIndividual.class);
}
/**
@@ -98,49 +109,22 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Organisation)
*/
- public DefaultOrganisation(final Organisation object) {
+ public DefaultOrganisation(final DefaultOrganisation object) {
super(object);
if (object != null) {
logo = copyCollection(object.getLogo(), BrowseGraphic.class);
- individual = copyCollection(object.getIndividual(), Individual.class);
+ individual = copyCollection(object.getIndividual(), DefaultIndividual.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultOrganisation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultOrganisation} instance is created using the
- * {@linkplain #DefaultOrganisation(Organisation) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultOrganisation castOrCopy(final Organisation object) {
- if (object == null || object instanceof DefaultOrganisation) {
- return (DefaultOrganisation) object;
- }
- return new DefaultOrganisation(object);
- }
-
- /**
* Returns the graphics identifying organization.
*
* @return graphics identifying organization, or an empty collection if there is none.
*/
- @Override
@XmlElement(name = "logo")
+ @UML(identifier="logo", obligation=CONDITIONAL, specification=ISO_19115)
public Collection<BrowseGraphic> getLogo() {
return logo = nonNullCollection(logo, BrowseGraphic.class);
}
@@ -157,20 +141,30 @@
/**
* Returns the individuals in the named organization.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Individual} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return individuals in the named organization, or an empty collection.
*/
- @Override
@XmlElement(name = "individual")
- public Collection<Individual> getIndividual() {
- return individual = nonNullCollection(individual, Individual.class);
+ @UML(identifier="individual", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultIndividual> getIndividual() {
+ return individual = nonNullCollection(individual, DefaultIndividual.class);
}
/**
* Sets the individuals in the named organization.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Individual} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new individuals in the named organization.
*/
- public void setIndividual(final Collection<? extends Individual> newValues) {
- individual = writeCollection(newValues, individual, Individual.class);
+ public void setIndividual(final Collection<? extends DefaultIndividual> newValues) {
+ individual = writeCollection(newValues, individual, DefaultIndividual.class);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java
index c8e0224..d6ae634 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java
@@ -28,9 +28,12 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.metadata.code.CI_RoleCode;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -43,6 +46,14 @@
* {@code │ └─name……………} Name of the party.
* {@code └─role………………………} Function performed by the responsible party.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code Responsibility} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -68,7 +79,8 @@
@XmlSeeAlso({
DefaultResponsibleParty.class
})
-public class DefaultResponsibility extends ISOMetadata implements Responsibility {
+@UML(identifier="CI_Responsibility", specification=ISO_19115)
+public class DefaultResponsibility extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -89,7 +101,7 @@
* Information about the parties.
*/
@SuppressWarnings("serial")
- private Collection<Party> parties;
+ private Collection<AbstractParty> parties;
/**
* Constructs an initially empty responsible party.
@@ -104,10 +116,10 @@
* @param extent spatial or temporal extent of the role, or {@code null}.
* @param party information about the party, or {@code null}.
*/
- public DefaultResponsibility(final Role role, final Extent extent, final Party party) {
+ public DefaultResponsibility(final Role role, final Extent extent, final AbstractParty party) {
this.role = role;
this.extents = singleton(extent, Extent.class);
- this.parties = singleton(party, Party.class);
+ this.parties = singleton(party, AbstractParty.class);
}
/**
@@ -116,41 +128,29 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Responsibility)
*/
- public DefaultResponsibility(final Responsibility object) {
+ public DefaultResponsibility(final DefaultResponsibility object) {
super(object);
if (object != null) {
this.role = object.getRole();
this.extents = copyCollection(object.getExtents(), Extent.class);
- this.parties = copyCollection(object.getParties(), Party.class);
+ this.parties = copyCollection(object.getParties(), AbstractParty.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultResponsibility}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultResponsibility} instance is created using the
- * {@linkplain #DefaultResponsibility(Responsibility) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * Responsibility contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
+ * Bridge constructor for {@link DefaultResponsibleParty#DefaultResponsibleParty(ResponsibleParty)}.
*/
- public static DefaultResponsibility castOrCopy(final Responsibility object) {
- if (object == null || object instanceof DefaultResponsibility) {
- return (DefaultResponsibility) object;
+ DefaultResponsibility(final ResponsibleParty object) {
+ super(object);
+ if (object != null) {
+ this.role = object.getRole();
+ if (object instanceof DefaultResponsibility) {
+ final DefaultResponsibility c = (DefaultResponsibility) object;
+ this.extents = copyCollection(c.getExtents(), Extent.class);
+ this.parties = copyCollection(c.getParties(), AbstractParty.class);
+ }
}
- return new DefaultResponsibility(object);
}
/**
@@ -158,9 +158,9 @@
*
* @return function performed by the responsible party.
*/
- @Override
@XmlElement(name = "role", required = true)
@XmlJavaTypeAdapter(CI_RoleCode.Since2014.class)
+ @UML(identifier="role", obligation=MANDATORY, specification=ISO_19115)
public Role getRole() {
return role;
}
@@ -180,8 +180,8 @@
*
* @return the spatial or temporal extents of the role.
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="extent", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Extent> getExtents() {
return extents = nonNullCollection(extents, Extent.class);
}
@@ -198,21 +198,31 @@
/**
* Returns information about the parties.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Party} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information about the parties.
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<Party> getParties() {
- return parties = nonNullCollection(parties, Party.class);
+ @UML(identifier="party", obligation=MANDATORY, specification=ISO_19115)
+ public Collection<AbstractParty> getParties() {
+ return parties = nonNullCollection(parties, AbstractParty.class);
}
/**
* Sets information about the parties.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Party} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues new information about the parties.
*/
- public void setParties(final Collection<? extends Party> newValues) {
- parties = writeCollection(newValues, parties, Party.class);
+ public void setParties(final Collection<? extends AbstractParty> newValues) {
+ parties = writeCollection(newValues, parties, AbstractParty.class);
}
@@ -242,7 +252,7 @@
}
@XmlElement(name = "party", required = true)
- private Collection<Party> getParty() {
+ private Collection<AbstractParty> getParty() {
return FilterByVersion.CURRENT_METADATA.accept() ? getParties() : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
index 4917733..45cece3 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
@@ -33,12 +33,6 @@
import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Individual;
-import org.opengis.metadata.citation.Organisation;
-import org.opengis.metadata.citation.Responsibility;
-
/**
* Identification of, and means of communication with, person(s) and
@@ -51,8 +45,11 @@
* {@code └─party…………………………} Information about the parties.
* {@code └─name…………………} Name of the party.</div>
*
- * @deprecated As of ISO 19115:2014, the {@code ResponsibleParty} type has been replaced by {@code Responsibility}
- * to allow more flexible associations of individuals, organizations, and roles.
+ * <div class="warning"><b>Upcoming API change — deprecation</b><br>
+ * As of ISO 19115:2014, the {@code ResponsibleParty} type has been replaced by {@code Responsibility}
+ * to allow more flexible associations of individuals, organisations, and roles.
+ * This {@code ResponsibleParty} interface may be deprecated in GeoAPI 4.0.
+ * </div>
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
@@ -60,7 +57,6 @@
* @version 1.4
* @since 0.3
*/
-@Deprecated(since="1.0")
@XmlType(name = "CI_ResponsibleParty_Type", namespace = LegacyNamespaces.GMD, propOrder = {
"individualName",
"organisationName",
@@ -96,14 +92,29 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Responsibility)
*/
- public DefaultResponsibleParty(final Responsibility object) {
+ public DefaultResponsibleParty(final DefaultResponsibility object) {
super(object);
}
/**
+ * Constructs a new instance initialized with the values from the specified metadata object.
+ * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the
+ * given object are not recursively copied.
+ *
+ * @param object The metadata to copy values from, or {@code null} if none.
+ *
+ * @see #castOrCopy(ResponsibleParty)
+ */
+ public DefaultResponsibleParty(final ResponsibleParty object) {
+ super(object);
+ if (object != null && !(object instanceof DefaultResponsibility)) {
+ setIndividualName(object.getIndividualName());
+ setOrganisationName(object.getOrganisationName());
+ }
+ }
+
+ /**
* Returns a SIS metadata implementation with the values of the given arbitrary implementation.
* This method performs the first applicable action in the following choices:
*
@@ -112,7 +123,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code DefaultResponsibleParty}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code DefaultResponsibleParty} instance is created using the
- * {@linkplain #DefaultResponsibleParty(Responsibility) copy constructor} and returned.
+ * {@linkplain #DefaultResponsibleParty(ResponsibleParty) copy constructor} and returned.
* Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -121,7 +132,7 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static DefaultResponsibleParty castOrCopy(final Responsibility object) {
+ public static DefaultResponsibleParty castOrCopy(final ResponsibleParty object) {
if (object == null || object instanceof DefaultResponsibleParty) {
return (DefaultResponsibleParty) object;
}
@@ -140,12 +151,12 @@
* @see #getPositionName()
*/
private InternationalString getIndividual(final boolean position) {
- final Collection<Party> parties = getParties();
- InternationalString name = getName(parties, Individual.class, position);
+ final Collection<AbstractParty> parties = getParties();
+ InternationalString name = getName(parties, DefaultIndividual.class, position);
if (name == null && parties != null) {
- for (final Party party : parties) {
- if (party instanceof Organisation) {
- name = getName(((Organisation) party).getIndividual(), Individual.class, position);
+ for (final AbstractParty party : parties) {
+ if (party instanceof DefaultOrganisation) {
+ name = getName(((DefaultOrganisation) party).getIndividual(), DefaultIndividual.class, position);
if (name != null) {
break;
}
@@ -165,20 +176,20 @@
* @see #getIndividualName()
* @see #getPositionName()
*/
- private static InternationalString getName(final Collection<? extends Party> parties,
- final Class<? extends Party> type, final boolean position)
+ private static InternationalString getName(final Collection<? extends AbstractParty> parties,
+ final Class<? extends AbstractParty> type, final boolean position)
{
InternationalString name = null;
if (parties != null) { // May be null on marshalling.
- for (final Party party : parties) {
+ for (final AbstractParty party : parties) {
if (type.isInstance(party)) {
if (name != null) {
LegacyPropertyAdapter.warnIgnoredExtraneous(type, DefaultResponsibleParty.class,
- position ? "getPositionName" : (type == Individual.class)
+ position ? "getPositionName" : (type == DefaultIndividual.class)
? "getIndividualName" : "getOrganisationName");
break;
}
- name = position ? ((Individual) party).getPositionName() : party.getName();
+ name = position ? ((DefaultIndividual) party).getPositionName() : party.getName();
}
}
}
@@ -189,22 +200,22 @@
* Sets the name of the first party of the given type.
* If no existing party is found, generate a new party using the given creator.
*/
- private void setName(final Class<? extends Party> type, final boolean position, final InternationalString name,
- final Function<InternationalString,Party> creator)
+ private void setName(final Class<? extends AbstractParty> type, final boolean position, final InternationalString name,
+ final Function<InternationalString,AbstractParty> creator)
{
- final Collection<Party> parties = getParties();
+ final Collection<AbstractParty> parties = getParties();
checkWritePermission(valueIfDefined(parties));
if (parties != null) { // May be null on unmarshalling.
- final Iterator<Party> it = parties.iterator();
+ final Iterator<AbstractParty> it = parties.iterator();
while (it.hasNext()) {
- final Party party = it.next();
- if (party instanceof AbstractParty && type.isInstance(party)) {
+ final AbstractParty party = it.next();
+ if (type.isInstance(party)) {
if (position) {
((DefaultIndividual) party).setPositionName(name);
} else {
- ((AbstractParty) party).setName(name);
+ party.setName(name);
}
- if (((AbstractParty) party).isEmpty()) {
+ if (party.isEmpty()) {
it.remove();
}
return;
@@ -212,7 +223,7 @@
}
}
if (name != null) { // If no party and name is null, there is nothing to set.
- final Party party = creator.apply(name);
+ final AbstractParty party = creator.apply(name);
if (parties != null) { // May be null on unmarshalling.
parties.add(party);
} else {
@@ -226,9 +237,9 @@
* Only one of {@code individualName}, {@link #getOrganisationName() organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
- * <p>This implementation returns the name of the first {@link Individual} found in the collection of
+ * <p>This implementation returns the name of the first {@code Individual} found in the collection of
* {@linkplain #getParties() parties}. If no individual is found in the parties, then this method fallbacks
- * on the first {@linkplain Organisation#getIndividual() organisation member}.</p>
+ * on the first organisation member.</p>
*
* @return name, surname, given name and title of the responsible person, or {@code null}.
*
@@ -248,7 +259,7 @@
* Only one of {@code individualName}, {@link #getOrganisationName() organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
- * <p>This implementation sets the name of the first {@link Individual} found in the collection of
+ * <p>This implementation sets the name of the first {@code Individual} found in the collection of
* {@linkplain #getParties() parties}, or create a new individual if no existing instance was found.</p>
*
* @param newValue the new individual name, or {@code null} if none.
@@ -257,13 +268,13 @@
*/
@Deprecated(since="1.0")
public void setIndividualName(final String newValue) {
- setName(Individual.class, false, Types.toInternationalString(newValue), DefaultResponsibleParty::individual);
+ setName(DefaultIndividual.class, false, Types.toInternationalString(newValue), DefaultResponsibleParty::individual);
}
/**
* Generates a new individual from the given name.
*/
- private static Party individual(final InternationalString name) {
+ private static AbstractParty individual(final InternationalString name) {
return new DefaultIndividual(name, null, null);
}
@@ -272,7 +283,7 @@
* {@link #getIndividualName() individualName}, {@code organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
- * <p>This implementation returns the name of the first {@link Organisation}
+ * <p>This implementation returns the name of the first {@code Organisation}
* found in the collection of {@linkplain #getParties() parties}.</p>
*
* @return name of the responsible organization, or {@code null}.
@@ -284,7 +295,7 @@
@Dependencies("getParties")
@XmlElement(name = "organisationName")
public InternationalString getOrganisationName() {
- return getName(getParties(), Organisation.class, false);
+ return getName(getParties(), DefaultOrganisation.class, false);
}
/**
@@ -292,7 +303,7 @@
* {@link #getIndividualName() individualName}, {@code organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
- * <p>This implementation sets the name of the first {@link Organisation} found in the collection of
+ * <p>This implementation sets the name of the first {@code Organisation} found in the collection of
* {@linkplain #getParties() parties}, or create a new organization if no existing instance was found.</p>
*
* @param newValue the new organization name, or {@code null} if none.
@@ -301,13 +312,13 @@
*/
@Deprecated(since="1.0")
public void setOrganisationName(final InternationalString newValue) {
- setName(Organisation.class, false, newValue, DefaultResponsibleParty::organisation);
+ setName(DefaultOrganisation.class, false, newValue, DefaultResponsibleParty::organisation);
}
/**
* Generates a new organization from the given name.
*/
- private static Party organisation(final InternationalString name) {
+ private static AbstractParty organisation(final InternationalString name) {
return new DefaultOrganisation(name, null, null, null);
}
@@ -316,9 +327,9 @@
* {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName}
* and {@code positionName} shall be provided.
*
- * <p>This implementation returns the position of the first {@link Individual} found in the collection of
+ * <p>This implementation returns the position of the first {@code Individual} found in the collection of
* {@linkplain #getParties() parties}. If no individual is found in the parties, then this method fallbacks
- * on the first {@linkplain Organisation#getIndividual() organisation member}.</p>
+ * on the first organisation member.</p>
*
* @return role or position of the responsible person, or {@code null}
*
@@ -337,7 +348,7 @@
* {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName}
* and {@code positionName} shall be provided.
*
- * <p>This implementation sets the position name of the first {@link Individual} found in the collection of
+ * <p>This implementation sets the position name of the first {@code Individual} found in the collection of
* {@linkplain #getParties() parties}, or create a new individual if no existing instance was found.</p>
*
* @param newValue the new position name, or {@code null} if none.
@@ -352,7 +363,7 @@
/**
* Generates a new position from the given name.
*/
- private static Party position(final InternationalString name) {
+ private static AbstractParty position(final InternationalString name) {
return new DefaultIndividual(null, name, null);
}
@@ -371,9 +382,9 @@
@Dependencies("getParties")
@XmlElement(name = "contactInfo")
public Contact getContactInfo() {
- final Collection<Party> parties = getParties();
+ final Collection<AbstractParty> parties = getParties();
if (parties != null) { // May be null on marshalling.
- for (final Party party : parties) {
+ for (final AbstractParty party : parties) {
final Collection<? extends Contact> contacts = party.getContactInfo();
if (contacts != null) { // May be null on marshalling.
for (final Contact contact : contacts) {
@@ -399,19 +410,17 @@
*/
@Deprecated(since="1.0")
public void setContactInfo(final Contact newValue) {
- final Collection<Party> parties = getParties();
+ final Collection<AbstractParty> parties = getParties();
checkWritePermission(valueIfDefined(parties));
if (parties != null) { // May be null on unmarshalling.
- final Iterator<Party> it = parties.iterator();
+ final Iterator<AbstractParty> it = parties.iterator();
while (it.hasNext()) {
- final Party party = it.next();
- if (party instanceof AbstractParty) {
- ((AbstractParty) party).setContactInfo(newValue != null ? Collections.singleton(newValue) : null);
- if (((AbstractParty) party).isEmpty()) {
- it.remove();
- }
- return;
+ final AbstractParty party = it.next();
+ party.setContactInfo(newValue != null ? Collections.singleton(newValue) : null);
+ if (party.isEmpty()) {
+ it.remove();
}
+ return;
}
}
/*
@@ -419,7 +428,7 @@
* it should be an individual or an organization. Arbitrarily choose an individual for now.
*/
if (newValue != null) {
- final Party party = new DefaultIndividual(null, null, newValue);
+ final AbstractParty party = new DefaultIndividual(null, null, newValue);
if (parties != null) {
parties.add(party);
} else {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultTelephone.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
index c560ce5..6c0e433 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
@@ -32,8 +32,14 @@
import org.apache.sis.xml.bind.metadata.code.CI_TelephoneTypeCode;
import org.apache.sis.metadata.internal.Dependencies;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.TelephoneType;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.pending.geoapi.evolution.InterimType;
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -96,7 +102,7 @@
/**
* Type of telephone number.
*/
- private TelephoneType numberType;
+ CodeList<?> numberType;
/**
* Constructs a default telephone.
@@ -109,10 +115,8 @@
*
* @param number the telephone number, or {@code null}.
* @param numberType the type of telephone number, or {@code null}.
- *
- * @since 0.5
*/
- public DefaultTelephone(final String number, final TelephoneType numberType) {
+ DefaultTelephone(final String number, final CodeList<?> numberType) {
this.number = number;
this.numberType = numberType;
}
@@ -129,8 +133,13 @@
public DefaultTelephone(final Telephone object) {
super(object);
if (object != null) {
- number = object.getNumber();
- numberType = object.getNumberType();
+ if (object instanceof DefaultTelephone) {
+ number = ((DefaultTelephone) object).getNumber();
+ numberType = ((DefaultTelephone) object).numberType;
+ } else {
+ setVoices(object.getVoices());
+ setFacsimiles(object.getFacsimiles());
+ }
}
}
@@ -166,9 +175,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "number", required = true)
@XmlJavaTypeAdapter(StringAdapter.Since2014.class)
+ @UML(identifier="number", obligation=MANDATORY, specification=ISO_19115)
public String getNumber() {
return number;
}
@@ -187,26 +196,63 @@
/**
* Returns the type of telephone number, or {@code null} if none.
+ * If non-null, the type can be {@code "VOICE"}, {@code "FACSIMILE"} or {@code "SMS"}.
+ *
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The return type will be changed to the {@code TelephoneType} code list
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
*
* @return type of telephone number, or {@code null} if none.
*
* @since 0.5
*/
- @Override
+ @InterimType(UnsupportedCodeList.class)
@XmlElement(name = "numberType")
@XmlJavaTypeAdapter(CI_TelephoneTypeCode.Since2014.class)
- public TelephoneType getNumberType() {
+ @UML(identifier="numberType", obligation=OPTIONAL, specification=ISO_19115)
+ public CodeList<?> getNumberType() {
return numberType;
}
/**
* Sets the type of telephone number.
+ * If non-null, the type can only be {@code "VOICE"}, {@code "FACSIMILE"} or {@code "SMS"}.
+ *
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The argument type will be changed to the {@code TelephoneType} code list when GeoAPI will provide it
+ * (tentatively in GeoAPI 3.1). In the meantime, users can define their own code list class as below:
+ *
+ * {@snippet lang="java" :
+ * final class UnsupportedCodeList extends CodeList<UnsupportedCodeList> {
+ * private static final List<UnsupportedCodeList> VALUES = new ArrayList<UnsupportedCodeList>();
+ *
+ * // Need to declare at least one code list element.
+ * public static final UnsupportedCodeList MY_CODE_LIST = new UnsupportedCodeList("MY_CODE_LIST");
+ *
+ * private UnsupportedCodeList(String name) {
+ * super(name, VALUES);
+ * }
+ *
+ * public static UnsupportedCodeList valueOf(String code) {
+ * return valueOf(UnsupportedCodeList.class, code);
+ * }
+ *
+ * @Override
+ * public UnsupportedCodeList[] family() {
+ * synchronized (VALUES) {
+ * return VALUES.toArray(new UnsupportedCodeList[VALUES.size()]);
+ * }
+ * }
+ * }
+ * }
+ * </div>
*
* @param newValue the new type of telephone number.
*
* @since 0.5
*/
- public void setNumberType(final TelephoneType newValue) {
+ public void setNumberType(final CodeList<?> newValue) {
checkWritePermission(numberType);
numberType = newValue;
}
@@ -275,7 +321,7 @@
* @return telephone numbers by which individuals can speak to the responsible organization or individual.
*
* @deprecated As of ISO 19115:2014, replaced by a {@linkplain #getNumber() number}
- * with {@link TelephoneType#VOICE}.
+ * with {@code TelephoneType.VOICE}.
*/
@Override
@Deprecated(since="1.0")
@@ -283,9 +329,9 @@
@XmlElement(name = "voice", namespace = LegacyNamespaces.GMD)
public final Collection<String> getVoices() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
- return new LegacyTelephones(getOwner(), TelephoneType.VOICE);
+ return new LegacyTelephones(getOwner(), UnsupportedCodeList.VOICE);
}
- return null; // Marshalling newer ISO 19115-3 document.
+ return null;
}
/**
@@ -296,7 +342,7 @@
* @param newValues the new telephone numbers, or {@code null} if none.
*
* @deprecated As of ISO 19115:2014, replaced by a {@linkplain #setNumber(String) number}
- * with {@link TelephoneType#VOICE}.
+ * code {@code TelephoneType.VOICE}.
*/
@Deprecated(since="1.0")
public void setVoices(final Collection<? extends String> newValues) {
@@ -311,7 +357,7 @@
* @return telephone numbers of a facsimile machine for the responsible organization or individual.
*
* @deprecated As of ISO 19115:2014, replaced by a {@linkplain #getNumber() number}
- * with {@link TelephoneType#FACSIMILE}.
+ * code {@code TelephoneType.FACSIMILE}.
*/
@Override
@Deprecated(since="1.0")
@@ -319,7 +365,7 @@
@XmlElement(name = "facsimile", namespace = LegacyNamespaces.GMD)
public final Collection<String> getFacsimiles() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
- return new LegacyTelephones(getOwner(), TelephoneType.FACSIMILE);
+ return new LegacyTelephones(getOwner(), UnsupportedCodeList.FACSIMILE);
}
return null; // Marshalling newer ISO 19115-3 document.
}
@@ -332,7 +378,7 @@
* @param newValues the new telephone number, or {@code null} if none.
*
* @deprecated As of ISO 19115:2014, replaced by a {@linkplain #setNumber(String) number}
- * with {@link TelephoneType#FACSIMILE}.
+ * with {@code TelephoneType.FACSIMILE}.
*/
@Deprecated(since="1.0")
public void setFacsimiles(final Collection<? extends String> newValues) {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/LegacyTelephones.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
index 2c8e409..bbdd961 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
@@ -21,8 +21,8 @@
import org.opengis.metadata.citation.Telephone;
import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.TelephoneType;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -35,14 +35,14 @@
final class LegacyTelephones extends LegacyPropertyAdapter<String,Telephone> {
/**
* The type of telephone number.
- * Either {@link TelephoneType#VOICE} or {@link TelephoneType#FACSIMILE}.
+ * Either {@code UnsupportedCodeList.VOICE} or {@code UnsupportedCodeList.FACSIMILE}.
*/
- private final TelephoneType type;
+ private final CodeList<?> type;
/**
* Wraps the given telephone list for the given type.
*/
- LegacyTelephones(final Collection<Telephone> telephones, final TelephoneType type) {
+ LegacyTelephones(final Collection<Telephone> telephones, final CodeList<?> type) {
super(telephones);
this.type = type;
}
@@ -60,8 +60,13 @@
*/
@Override
protected String unwrap(final Telephone container) {
- if (container != null && type.equals(container.getNumberType())) {
- return container.getNumber();
+ if (container instanceof DefaultTelephone) {
+ final CodeList<?> ct = ((DefaultTelephone) container).numberType;
+ if (ct != null) {
+ if (type.name().equals(ct.name())) {
+ return ((DefaultTelephone) container).getNumber();
+ }
+ }
}
return null;
}
@@ -72,10 +77,10 @@
@Override
protected boolean update(final Telephone container, final String value) {
if (container instanceof DefaultTelephone) {
- final TelephoneType ct = container.getNumberType();
- if (ct == null || ct.equals(type)) {
+ final CodeList<?> ct = ((DefaultTelephone) container).numberType;
+ if (ct == null || type.name().equals(ct.name())) {
if (ct == null) {
- ((DefaultTelephone) container).setNumberType(type);
+ ((DefaultTelephone) container).numberType = type;
}
((DefaultTelephone) container).setNumber(value);
return true;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultConstraints.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultConstraints.java
index 546a873..18e38c7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultConstraints.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultConstraints.java
@@ -28,16 +28,18 @@
import org.opengis.metadata.constraint.Constraints;
import org.opengis.metadata.constraint.LegalConstraints;
import org.opengis.metadata.constraint.SecurityConstraints;
+import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.metadata.MD_Releasability;
import org.apache.sis.xml.bind.metadata.MD_Scope;
-import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
-import org.opengis.metadata.constraint.Releasability;
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
/**
@@ -108,13 +110,13 @@
* Information concerning the parties to whom the resource can or cannot be released.
*/
@SuppressWarnings("serial")
- private Releasability releasability;
+ private DefaultReleasability releasability;
/**
* Party responsible for the resource constraints.
*/
@SuppressWarnings("serial")
- private Collection<Responsibility> responsibleParties;
+ private Collection<DefaultResponsibility> responsibleParties;
/**
* Constructs an initially empty constraints.
@@ -144,11 +146,14 @@
super(object);
if (object != null) {
useLimitations = copyCollection(object.getUseLimitations(), InternationalString.class);
- constraintApplicationScope = object.getConstraintApplicationScope();
- graphics = copyCollection(object.getGraphics(), BrowseGraphic.class);
- references = copyCollection(object.getReferences(), Citation.class);
- releasability = object.getReleasability();
- responsibleParties = copyCollection(object.getResponsibleParties(), Responsibility.class);
+ if (object instanceof DefaultConstraints) {
+ final DefaultConstraints c = (DefaultConstraints) object;
+ constraintApplicationScope = c.getConstraintApplicationScope();
+ graphics = copyCollection(c.getGraphics(), BrowseGraphic.class);
+ references = copyCollection(c.getReferences(), Citation.class);
+ releasability = c.getReleasability();
+ responsibleParties = copyCollection(c.getResponsibleParties(), DefaultResponsibility.class);
+ }
}
}
@@ -219,9 +224,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "constraintApplicationScope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ @UML(identifier="constraintApplicationScope", obligation=OPTIONAL, specification=ISO_19115)
public Scope getConstraintApplicationScope() {
return constraintApplicationScope;
}
@@ -245,8 +250,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="graphic", obligation=OPTIONAL, specification=ISO_19115)
public Collection<BrowseGraphic> getGraphics() {
return graphics = nonNullCollection(graphics, BrowseGraphic.class);
}
@@ -270,8 +275,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="reference", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getReferences() {
return references = nonNullCollection(references, Citation.class);
}
@@ -290,25 +295,35 @@
/**
* Returns information concerning the parties to whom the resource can or cannot be released.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The return type will be changed to the {@code Releasability} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information concerning the parties to whom the resource can or cannot be released, or {@code null} if none.
*
* @since 0.5
*/
- @Override
@XmlElement(name = "releasability")
@XmlJavaTypeAdapter(MD_Releasability.Since2014.class)
- public Releasability getReleasability() {
+ @UML(identifier="releasability", obligation=OPTIONAL, specification=ISO_19115)
+ public DefaultReleasability getReleasability() {
return releasability;
}
/**
* Sets the information concerning the parties to whom the resource.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The argument type will be changed to the {@code Releasability} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValue the new information concerning the parties to whom the resource can or cannot be released.
*
* @since 0.5
*/
- public void setReleasability(final Releasability newValue) {
+ public void setReleasability(final DefaultReleasability newValue) {
checkWritePermission(releasability);
releasability = newValue;
}
@@ -316,25 +331,35 @@
/**
* Returns the parties responsible for the resource constraints.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Responsibility} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return parties responsible for the resource constraints.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<Responsibility> getResponsibleParties() {
- return responsibleParties = nonNullCollection(responsibleParties, Responsibility.class);
+ @UML(identifier="responsibleParty", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultResponsibility> getResponsibleParties() {
+ return responsibleParties = nonNullCollection(responsibleParties, DefaultResponsibility.class);
}
/**
* Sets the parties responsible for the resource constraints.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Responsibility} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new parties responsible for the resource constraints.
*
* @since 0.5
*/
- public void setResponsibleParties(final Collection<? extends Responsibility> newValues) {
- responsibleParties = writeCollection(newValues, responsibleParties, Responsibility.class);
+ public void setResponsibleParties(final Collection<? extends DefaultResponsibility> newValues) {
+ responsibleParties = writeCollection(newValues, responsibleParties, DefaultResponsibility.class);
}
@@ -369,7 +394,7 @@
}
@XmlElement(name = "responsibleParty")
- private Collection<Responsibility> getResponsibleParty() {
+ private Collection<DefaultResponsibility> getResponsibleParty() {
return FilterByVersion.CURRENT_METADATA.accept() ? getResponsibleParties() : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultReleasability.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultReleasability.java
index 0575585..5c55f90 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultReleasability.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/constraint/DefaultReleasability.java
@@ -24,14 +24,24 @@
import org.opengis.metadata.constraint.Restriction;
import org.apache.sis.metadata.iso.ISOMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.constraint.Releasability;
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
/**
* Information about resource release constraints.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code Releasability} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -51,7 +61,8 @@
"disseminationConstraints"
})
@XmlRootElement(name = "MD_Releasability")
-public class DefaultReleasability extends ISOMetadata implements Releasability {
+@UML(identifier="MD_Releasability", specification=ISO_19115)
+public class DefaultReleasability extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -61,7 +72,7 @@
* Party to which the release statement applies.
*/
@SuppressWarnings("serial")
- private Collection<Responsibility> addressees;
+ private Collection<DefaultResponsibility> addressees;
/**
* Release statement.
@@ -87,61 +98,44 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Releasability)
*/
- public DefaultReleasability(final Releasability object) {
+ public DefaultReleasability(final DefaultReleasability object) {
super(object);
if (object != null) {
- addressees = copyCollection(object.getAddressees(), Responsibility.class);
+ addressees = copyCollection(object.getAddressees(), DefaultResponsibility.class);
statement = object.getStatement();
disseminationConstraints = copyCollection(object.getDisseminationConstraints(), Restriction.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultReleasability}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultReleasability} instance is created using the
- * {@linkplain #DefaultReleasability(Releasability) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultReleasability castOrCopy(final Releasability object) {
- if (object == null || object instanceof DefaultReleasability) {
- return (DefaultReleasability) object;
- }
- return new DefaultReleasability(object);
- }
-
- /**
* Returns the parties to which the release statement applies.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Responsibility} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return parties to which the release statement applies.
*/
- @Override
@XmlElement(name = "addressee")
- public Collection<Responsibility> getAddressees() {
- return addressees = nonNullCollection(addressees, Responsibility.class);
+ @UML(identifier="addressee", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultResponsibility> getAddressees() {
+ return addressees = nonNullCollection(addressees, DefaultResponsibility.class);
}
/**
* Sets the parties to which the release statement applies.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Responsibility} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new parties.
*/
- public void setAddressees(final Collection<? extends Responsibility> newValues) {
- addressees = writeCollection(newValues, addressees, Responsibility.class);
+ public void setAddressees(final Collection<? extends DefaultResponsibility> newValues) {
+ addressees = writeCollection(newValues, addressees, DefaultResponsibility.class);
}
/**
@@ -149,8 +143,8 @@
*
* @return release statement, or {@code null} if none.
*/
- @Override
@XmlElement(name = "statement")
+ @UML(identifier="statement", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getStatement() {
return statement;
}
@@ -170,8 +164,8 @@
*
* @return components in determining releasability.
*/
- @Override
@XmlElement(name = "disseminationConstraints")
+ @UML(identifier="disseminationConstraints", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Restriction> getDisseminationConstraints() {
return disseminationConstraints = nonNullCollection(disseminationConstraints, Restriction.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultAttributeGroup.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultAttributeGroup.java
index 0aa5264..340219c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultAttributeGroup.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultAttributeGroup.java
@@ -24,8 +24,11 @@
import org.opengis.metadata.content.RangeDimension;
import org.apache.sis.metadata.iso.ISOMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.AttributeGroup;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -36,6 +39,14 @@
* <div class="preformat">{@code MD_AttributeGroup}
* {@code └─contentType……} Content type</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code AttributeGroup} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -56,7 +67,8 @@
"attributes"
})
@XmlRootElement(name = "MD_AttributeGroup")
-public class DefaultAttributeGroup extends ISOMetadata implements AttributeGroup {
+@UML(identifier="MD_AttributeGroup", specification=ISO_19115)
+public class DefaultAttributeGroup extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -97,10 +109,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(AttributeGroup)
*/
- public DefaultAttributeGroup(final AttributeGroup object) {
+ public DefaultAttributeGroup(final DefaultAttributeGroup object) {
super(object);
if (object != null) {
contentTypes = copyCollection(object.getContentTypes(), CoverageContentType.class);
@@ -109,37 +119,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultAttributeGroup}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultAttributeGroup} instance is created using the
- * {@linkplain #DefaultAttributeGroup(AttributeGroup) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultAttributeGroup castOrCopy(final AttributeGroup object) {
- if (object == null || object instanceof DefaultAttributeGroup) {
- return (DefaultAttributeGroup) object;
- }
- return new DefaultAttributeGroup(object);
- }
-
- /**
* Returns the types of information represented by the value(s).
*
* @return the types of information represented by the value(s).
*/
- @Override
@XmlElement(name = "contentType", required = true)
+ @UML(identifier="contentType", obligation=MANDATORY, specification=ISO_19115)
public Collection<CoverageContentType> getContentTypes() {
return contentTypes = nonNullCollection(contentTypes, CoverageContentType.class);
}
@@ -158,8 +143,8 @@
*
* @return information on an attribute of the resource.
*/
- @Override
@XmlElement(name = "attribute")
+ @UML(identifier="attribute", obligation=OPTIONAL, specification=ISO_19115)
public Collection<RangeDimension> getAttributes() {
return attributes = nonNullCollection(attributes, RangeDimension.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultBand.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultBand.java
index a8898f2..f103ef4 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultBand.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultBand.java
@@ -34,6 +34,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.content.PolarizationOrientation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Range of wavelengths in the electromagnetic spectrum.
@@ -145,9 +150,12 @@
public DefaultBand(final Band object) {
super(object);
if (object != null) {
- boundMin = object.getBoundMin();
- boundMax = object.getBoundMax();
- boundUnits = object.getBoundUnits();
+ if (object instanceof DefaultBand) {
+ final DefaultBand c = (DefaultBand) object;
+ boundMin = c.getBoundMin();
+ boundMax = c.getBoundMax();
+ boundUnits = c.getBoundUnits();
+ }
peakResponse = object.getPeakResponse();
toneGradation = object.getToneGradation();
bandBoundaryDefinition = object.getBandBoundaryDefinition();
@@ -190,10 +198,10 @@
*
* @since 0.5
*/
- @Override
@ValueRange(minimum = 0)
@XmlElement(name = "boundMin")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="boundMin", obligation=OPTIONAL, specification=ISO_19115)
public Double getBoundMin() {
return boundMin;
}
@@ -222,10 +230,10 @@
*
* @since 0.5
*/
- @Override
@ValueRange(minimum = 0)
@XmlElement(name = "boundMax")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="boundMax", obligation=OPTIONAL, specification=ISO_19115)
public Double getBoundMax() {
return boundMax;
}
@@ -254,9 +262,9 @@
*
* @see org.apache.sis.measure.Units#NANOMETRE
*/
- @Override
@XmlElement(name = "boundUnits")
@XmlJavaTypeAdapter(UnitAdapter.Since2014.class)
+ @UML(identifier="boundUnits", obligation=OPTIONAL, specification=ISO_19115)
public Unit<Length> getBoundUnits() {
return boundUnits;
}
@@ -295,6 +303,39 @@
}
/**
+ * Returns the units of data as a unit of length.
+ *
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * As of ISO 19115:2014, the units of wavelength is rather {@code boundUnits}.
+ * The restriction for units of length in this {@code units} property may be relaxed in GeoAPI 4.0.
+ * </div>
+ *
+ * @return The units of data.
+ */
+ @Override
+ public Unit<Length> getUnits() {
+ final Unit<?> units = super.getUnits();
+ return (units != null) ? units.asType(Length.class) : null;
+ }
+
+ /**
+ * Sets the units of data as a unit of length.
+ *
+ * <div class="warning"><b>Upcoming precondition change — relaxation</b><br>
+ * The current implementation requires the unit to be an instance of {@code Unit<Length>},
+ * otherwise a {@link ClassCastException} is thrown. This is because the value returned by
+ * {@link #getUnits()} was restricted by ISO 19115:2003 to units of length.
+ * However this restriction may be relaxed in GeoAPI 4.0.
+ * </div>
+ *
+ * @param newValue The new units of data as an instance of {@code Unit<Length>}.
+ */
+ @Override
+ public void setUnits(final Unit<?> newValue) {
+ super.setUnits(newValue != null ? newValue.asType(Length.class) : null);
+ }
+
+ /**
* Returns the wavelength at which the response is the highest.
* The units of measurement is given by {@link #getBoundUnits()}.
*
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
index 34f33f2..220b758 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
@@ -38,8 +38,10 @@
import org.apache.sis.xml.bind.metadata.MD_Identifier;
import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.AttributeGroup;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -100,7 +102,7 @@
* Information on attribute groups of the resource.
*/
@SuppressWarnings("serial")
- private Collection<AttributeGroup> attributeGroups;
+ private Collection<DefaultAttributeGroup> attributeGroups;
/**
* Provides the description of the specific range elements of a coverage.
@@ -127,9 +129,11 @@
super(object);
if (object != null) {
attributeDescription = object.getAttributeDescription();
- processingLevelCode = object.getProcessingLevelCode();
- attributeGroups = copyCollection(object.getAttributeGroups(), AttributeGroup.class);
rangeElementDescriptions = copyCollection(object.getRangeElementDescriptions(), RangeElementDescription.class);
+ if (object instanceof DefaultCoverageDescription) {
+ processingLevelCode = ((DefaultCoverageDescription) object).getProcessingLevelCode();
+ attributeGroups = copyCollection(((DefaultCoverageDescription) object).getAttributeGroups(), DefaultAttributeGroup.class);
+ }
}
}
@@ -194,9 +198,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "processingLevelCode")
@XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
+ @UML(identifier="processingLevelCode", obligation=OPTIONAL, specification=ISO_19115)
public Identifier getProcessingLevelCode() {
return processingLevelCode;
}
@@ -216,25 +220,35 @@
/**
* Returns information on attribute groups of the resource.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code AttributeGroup} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information on attribute groups of the resource.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<AttributeGroup> getAttributeGroups() {
- return attributeGroups = nonNullCollection(attributeGroups, AttributeGroup.class);
+ @UML(identifier="attributeGroup", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultAttributeGroup> getAttributeGroups() {
+ return attributeGroups = nonNullCollection(attributeGroups, DefaultAttributeGroup.class);
}
/**
* Sets information on attribute groups of the resource.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code AttributeGroup} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new information on attribute groups of the resource.
*
* @since 0.5
*/
- public void setAttributeGroups(final Collection<? extends AttributeGroup> newValues) {
- attributeGroups = writeCollection(newValues, attributeGroups, AttributeGroup.class);
+ public void setAttributeGroups(final Collection<? extends DefaultAttributeGroup> newValues) {
+ attributeGroups = writeCollection(newValues, attributeGroups, DefaultAttributeGroup.class);
}
/**
@@ -252,9 +266,9 @@
public CoverageContentType getContentType() {
CoverageContentType type = null;
if (FilterByVersion.LEGACY_METADATA.accept()) {
- final Collection<AttributeGroup> groups = getAttributeGroups();
+ final Collection<DefaultAttributeGroup> groups = getAttributeGroups();
if (groups != null) { // May be null on marshalling.
- for (final AttributeGroup g : groups) {
+ for (final DefaultAttributeGroup g : groups) {
final Collection<? extends CoverageContentType> contentTypes = g.getContentTypes();
if (contentTypes != null) { // May be null on marshalling.
for (final CoverageContentType t : contentTypes) {
@@ -285,13 +299,11 @@
public void setContentType(final CoverageContentType newValue) {
checkWritePermission(valueIfDefined(attributeGroups));
final Collection<CoverageContentType> newValues = CollectionsExt.singletonOrEmpty(newValue);
- Collection<AttributeGroup> groups = attributeGroups;
+ Collection<DefaultAttributeGroup> groups = attributeGroups;
if (groups != null) {
- for (final AttributeGroup group : groups) {
- if (group instanceof DefaultAttributeGroup) {
- ((DefaultAttributeGroup) group).setContentTypes(newValues);
- return;
- }
+ for (final DefaultAttributeGroup group : groups) {
+ group.setContentTypes(newValues);
+ return; // Actually stop at the first instance.
}
}
final DefaultAttributeGroup group = new DefaultAttributeGroup();
@@ -299,7 +311,7 @@
if (groups != null) {
groups.add(group);
} else {
- groups = Collections.singleton(group);
+ groups = Collections.<DefaultAttributeGroup>singleton(group);
}
setAttributeGroups(groups);
}
@@ -318,24 +330,24 @@
@XmlElement(name = "dimension", namespace = LegacyNamespaces.GMD)
public final Collection<RangeDimension> getDimensions() {
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
- return new LegacyPropertyAdapter<RangeDimension,AttributeGroup>(getAttributeGroups()) {
+ return new LegacyPropertyAdapter<RangeDimension,DefaultAttributeGroup>(getAttributeGroups()) {
/** Stores a legacy value into the new kind of value. */
- @Override protected AttributeGroup wrap(final RangeDimension value) {
+ @Override protected DefaultAttributeGroup wrap(final RangeDimension value) {
final DefaultAttributeGroup container = new DefaultAttributeGroup();
container.setAttributes(CollectionsExt.singletonOrEmpty(value));
return container;
}
/** Extracts the legacy value from the new kind of value. */
- @Override protected RangeDimension unwrap(final AttributeGroup container) {
+ @Override protected RangeDimension unwrap(final DefaultAttributeGroup container) {
return getSingleton(container.getAttributes(), RangeDimension.class,
this, DefaultCoverageDescription.class, "getDimensions");
}
/** Updates the legacy value in an existing instance of the new kind of value. */
- @Override protected boolean update(final AttributeGroup container, final RangeDimension value) {
+ @Override protected boolean update(final DefaultAttributeGroup container, final RangeDimension value) {
if (container instanceof DefaultAttributeGroup) {
- ((DefaultAttributeGroup) container).setAttributes(CollectionsExt.singletonOrEmpty(value));
+ container.setAttributes(CollectionsExt.singletonOrEmpty(value));
return true;
}
return false;
@@ -399,7 +411,7 @@
* If (and only if) marshalling an older standard version, we omit this attribute.
*/
@XmlElement(name = "attributeGroup")
- private Collection<AttributeGroup> getAttributeGroup() {
+ private Collection<DefaultAttributeGroup> getAttributeGroup() {
return FilterByVersion.CURRENT_METADATA.accept() ? getAttributeGroups() : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
index 5853bc5..f6f78e7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
@@ -34,8 +34,11 @@
import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.FeatureTypeInfo;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -103,7 +106,7 @@
* Subset of feature types from cited feature catalogue occurring in resource.
*/
@SuppressWarnings("serial")
- private Collection<FeatureTypeInfo> featureTypes;
+ private Collection<DefaultFeatureTypeInfo> featureTypes;
/**
* Complete bibliographic reference to one or more external feature catalogues.
@@ -131,9 +134,14 @@
if (object != null) {
compliant = object.isCompliant();
includedWithDataset = object.isIncludedWithDataset();
- locales = copyMap(object.getLocalesAndCharsets(), Locale.class);
- featureTypes = copyCollection(object.getFeatureTypeInfo(), FeatureTypeInfo.class);
featureCatalogueCitations = copyCollection(object.getFeatureCatalogueCitations(), Citation.class);
+ if (object instanceof DefaultFeatureCatalogueDescription) {
+ locales = copyMap(((DefaultFeatureCatalogueDescription) object).getLocalesAndCharsets(), Locale.class);
+ featureTypes = copyCollection(((DefaultFeatureCatalogueDescription) object).getFeatureTypeInfo(), DefaultFeatureTypeInfo.class);
+ } else {
+ setLanguages(copyCollection(object.getLanguages(), Locale.class));
+ setFeatureTypes(object.getFeatureTypes());
+ }
}
}
@@ -190,7 +198,7 @@
*
* @since 1.0
*/
- @Override
+ @UML(identifier="locale", obligation=CONDITIONAL, specification=ISO_19115)
// @XmlElement at the end of this class.
public Map<Locale,Charset> getLocalesAndCharsets() {
return locales = nonNullMap(locales, Locale.class);
@@ -259,25 +267,35 @@
/**
* Returns the subset of feature types from cited feature catalogue occurring in resource.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code FeatureTypeInfo} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return subset of feature types occurring in resource.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<FeatureTypeInfo> getFeatureTypeInfo() {
- return featureTypes = nonNullCollection(featureTypes, FeatureTypeInfo.class);
+ @UML(identifier="featureTypes", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultFeatureTypeInfo> getFeatureTypeInfo() {
+ return featureTypes = nonNullCollection(featureTypes, DefaultFeatureTypeInfo.class);
}
/**
* Sets the subset of feature types from cited feature catalogue occurring in resource.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code FeatureTypeInfo} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new feature types.
*
* @since 0.5
*/
- public void setFeatureTypeInfo(final Collection<? extends FeatureTypeInfo> newValues) {
- featureTypes = writeCollection(newValues, featureTypes, FeatureTypeInfo.class);
+ public void setFeatureTypeInfo(final Collection<? extends DefaultFeatureTypeInfo> newValues) {
+ featureTypes = writeCollection(newValues, featureTypes, DefaultFeatureTypeInfo.class);
}
/**
@@ -293,21 +311,21 @@
@XmlElement(name = "featureTypes", namespace = LegacyNamespaces.GMD)
public final Collection<GenericName> getFeatureTypes() {
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
- return new LegacyPropertyAdapter<GenericName,FeatureTypeInfo>(getFeatureTypeInfo()) {
+ return new LegacyPropertyAdapter<GenericName,DefaultFeatureTypeInfo>(getFeatureTypeInfo()) {
/** Stores a legacy value into the new kind of value. */
- @Override protected FeatureTypeInfo wrap(final GenericName value) {
+ @Override protected DefaultFeatureTypeInfo wrap(final GenericName value) {
return new DefaultFeatureTypeInfo(value);
}
/** Extracts the legacy value from the new kind of value. */
- @Override protected GenericName unwrap(final FeatureTypeInfo container) {
+ @Override protected GenericName unwrap(final DefaultFeatureTypeInfo container) {
return container.getFeatureTypeName();
}
/** Updates the legacy value in an existing instance of the new kind of value. */
- @Override protected boolean update(final FeatureTypeInfo container, final GenericName value) {
+ @Override protected boolean update(final DefaultFeatureTypeInfo container, final GenericName value) {
if (container instanceof DefaultFeatureTypeInfo) {
- ((DefaultFeatureTypeInfo) container).setFeatureTypeName(value);
+ container.setFeatureTypeName(value);
return true;
}
return false;
@@ -370,7 +388,7 @@
* If (and only if) marshalling an older standard version, we omit this attribute.
*/
@XmlElement(name = "featureTypes")
- private Collection<FeatureTypeInfo> getFeatureTypesInfo() {
+ private Collection<DefaultFeatureTypeInfo> getFeatureTypesInfo() {
return FilterByVersion.CURRENT_METADATA.accept() ? getFeatureTypeInfo() : null;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java
index 93c4f3e..74ebd7f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java
@@ -25,13 +25,24 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import static org.apache.sis.metadata.privy.ImplementationHelper.ensurePositive;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.FeatureTypeInfo;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
* Information about the occurring feature type.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code FeatureTypeInfo} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -56,7 +67,8 @@
"featureInstanceCount"
})
@XmlRootElement(name = "MD_FeatureTypeInfo")
-public class DefaultFeatureTypeInfo extends ISOMetadata implements FeatureTypeInfo {
+@UML(identifier="MD_FeatureTypeInfo", specification=ISO_19115)
+public class DefaultFeatureTypeInfo extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -100,10 +112,8 @@
* metadata instances can also be obtained by unmarshalling an invalid XML document.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(FeatureTypeInfo)
*/
- public DefaultFeatureTypeInfo(final FeatureTypeInfo object) {
+ public DefaultFeatureTypeInfo(final DefaultFeatureTypeInfo object) {
super(object);
if (object != null) {
featureTypeName = object.getFeatureTypeName();
@@ -112,39 +122,14 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultFeatureTypeInfo}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultFeatureTypeInfo} instance is created using the
- * {@linkplain #DefaultFeatureTypeInfo(FeatureTypeInfo) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultFeatureTypeInfo castOrCopy(final FeatureTypeInfo object) {
- if (object == null || object instanceof DefaultFeatureTypeInfo) {
- return (DefaultFeatureTypeInfo) object;
- }
- return new DefaultFeatureTypeInfo(object);
- }
-
- /**
* Returns the name of the feature type.
*
* @return name of the feature type.
*
* @see org.apache.sis.feature.DefaultFeatureType#getName()
*/
- @Override
@XmlElement(name = "featureTypeName", required = true)
+ @UML(identifier="featureTypeName", obligation=MANDATORY, specification=ISO_19115)
public GenericName getFeatureTypeName() {
return featureTypeName;
}
@@ -164,9 +149,9 @@
*
* @return the number of occurrence of feature instances for this feature types, or {@code null} if none.
*/
- @Override
@ValueRange(minimum = 1)
@XmlElement(name = "featureInstanceCount")
+ @UML(identifier="featureInstanceCount", obligation=OPTIONAL, specification=ISO_19115)
public Integer getFeatureInstanceCount() {
return featureInstanceCount;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
index aeb259f..506a0db 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
@@ -33,8 +33,11 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.gco.InternationalStringAdapter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.SampleDimension;
+// Specific to the main branch:
+import org.opengis.metadata.content.Band;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -110,8 +113,10 @@
super(object);
if (object != null) {
sequenceIdentifier = object.getSequenceIdentifier();
- description = object.getDescription();
- names = copyCollection(object.getNames(), Identifier.class);
+ description = object.getDescriptor();
+ if (object instanceof DefaultRangeDimension) {
+ names = copyCollection(((DefaultRangeDimension) object).getNames(), Identifier.class);
+ }
}
}
@@ -121,7 +126,7 @@
*
* <ul>
* <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link SampleDimension}, then this method
+ * <li>Otherwise if the given object is an instance of {@code SampleDimension}, then this method
* delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.</li>
* <li>Otherwise if the given object is already an instance of
* {@code DefaultRangeDimension}, then it is returned unchanged.</li>
@@ -136,8 +141,8 @@
* given object itself), or {@code null} if the argument was null.
*/
public static DefaultRangeDimension castOrCopy(final RangeDimension object) {
- if (object instanceof SampleDimension) {
- return DefaultSampleDimension.castOrCopy((SampleDimension) object);
+ if (object instanceof Band) {
+ return DefaultBand.castOrCopy((Band) object);
}
// Intentionally tested after the sub-interfaces.
if (object == null || object instanceof DefaultRangeDimension) {
@@ -174,9 +179,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "description")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="description", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDescription() {
return description;
}
@@ -230,8 +235,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="name", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Identifier> getNames() {
return names = nonNullCollection(names, Identifier.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
index 2be6ff4..fe1e286 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
@@ -37,8 +37,11 @@
import org.apache.sis.xml.bind.metadata.MI_RangeElementDescription;
import static org.apache.sis.metadata.privy.ImplementationHelper.ensurePositive;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.SampleDimension;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -49,6 +52,14 @@
* <div class="preformat">{@code MD_SampleDimension}
* {@code └─units………………………} Units of data in each dimension included in the resource.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code SampleDimension} interface.
+ * </div>
+ *
* <h2>Terminology</h2>
* <i>Data values</i> should be physical values expressed in the unit of measurement
* given by {@link #getUnits()}. <i>Cell values</i> are values stored in the device,
@@ -88,7 +99,8 @@
})
@XmlRootElement(name = "MD_SampleDimension")
@XmlSeeAlso({DefaultBand.class, DefaultRangeDimension.class})
-public class DefaultSampleDimension extends DefaultRangeDimension implements SampleDimension {
+@UML(identifier="MD_SampleDimension", specification=ISO_19115)
+public class DefaultSampleDimension extends DefaultRangeDimension {
/**
* Serial number for inter-operability with different versions.
*/
@@ -194,57 +206,50 @@
* metadata instances can also be obtained by unmarshalling an invalid XML document.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(SampleDimension)
*/
- public DefaultSampleDimension(final SampleDimension object) {
+ public DefaultSampleDimension(final DefaultSampleDimension object) {
super(object);
if (object != null) {
- minValue = object.getMinValue();
- maxValue = object.getMaxValue();
- meanValue = object.getMeanValue();
- numberOfValues = object.getNumberOfValues();
- standardDeviation = object.getStandardDeviation();
- units = object.getUnits();
- scaleFactor = object.getScaleFactor();
- offset = object.getOffset();
- transferFunctionType = object.getTransferFunctionType();
- bitsPerValue = object.getBitsPerValue();
- nominalSpatialResolution = object.getNominalSpatialResolution();
- otherPropertyType = object.getOtherPropertyType();
- otherProperty = object.getOtherProperty();
+ init(object);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is is an instance of {@link Band}, then this
- * method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultSampleDimension}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultSampleDimension} instance is created using the
- * {@linkplain #DefaultSampleDimension(SampleDimension) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
+ * Initializes this sample dimension to the values of the given object.
*/
- public static DefaultSampleDimension castOrCopy(final SampleDimension object) {
- if (object instanceof Band) {
- return DefaultBand.castOrCopy((Band) object);
+ private void init(final DefaultSampleDimension object) {
+ minValue = object.getMinValue();
+ maxValue = object.getMaxValue();
+ meanValue = object.getMeanValue();
+ numberOfValues = object.getNumberOfValues();
+ standardDeviation = object.getStandardDeviation();
+ units = object.getUnits();
+ scaleFactor = object.getScaleFactor();
+ offset = object.getOffset();
+ transferFunctionType = object.getTransferFunctionType();
+ bitsPerValue = object.getBitsPerValue();
+ nominalSpatialResolution = object.getNominalSpatialResolution();
+ otherPropertyType = object.getOtherPropertyType();
+ otherProperty = object.getOtherProperty();
+ }
+
+ /**
+ * Bridge constructor for {@link DefaultBand#DefaultBand(Band)}.
+ */
+ DefaultSampleDimension(final Band object) {
+ super(object);
+ if (object != null) {
+ if (object instanceof DefaultSampleDimension) {
+ init((DefaultSampleDimension) object);
+ } else {
+ maxValue = object.getMaxValue();
+ minValue = object.getMinValue();
+ units = object.getUnits();
+ scaleFactor = object.getScaleFactor();
+ offset = object.getOffset();
+ bitsPerValue = object.getBitsPerValue();
+ }
}
- //-- Intentionally tested after the sub-interfaces.
- if (object == null || object instanceof DefaultSampleDimension) {
- return (DefaultSampleDimension) object;
- }
- return new DefaultSampleDimension(object);
}
/**
@@ -252,10 +257,10 @@
*
* @return the number of values used in a thematic classification resource, or {@code null} if none.
*/
- @Override
@ValueRange(minimum = 0)
@XmlElement(name = "numberOfValues")
@XmlJavaTypeAdapter(GO_Integer.Since2014.class)
+ @UML(identifier="numberOfValues", obligation=OPTIONAL, specification=ISO_19115)
public Integer getNumberOfValues() {
return numberOfValues;
}
@@ -279,8 +284,8 @@
*
* @return minimum value of data values in each dimension included in the resource, or {@code null} if unspecified.
*/
- @Override
@XmlElement(name = "minValue")
+ @UML(identifier="minValue", obligation=OPTIONAL, specification=ISO_19115)
public Double getMinValue() {
return minValue;
}
@@ -302,8 +307,8 @@
*
* @return maximum value of data values in each dimension included in the resource, or {@code null} if unspecified.
*/
- @Override
@XmlElement(name = "maxValue")
+ @UML(identifier="maxValue", obligation=OPTIONAL, specification=ISO_19115)
public Double getMaxValue() {
return maxValue;
}
@@ -325,9 +330,9 @@
*
* @return the mean value of data values in each dimension included in the resource, or {@code null} if none.
*/
- @Override
@XmlElement(name = "meanValue")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="meanValue", obligation=OPTIONAL, specification=ISO_19115)
public Double getMeanValue() {
return meanValue;
}
@@ -349,9 +354,9 @@
*
* @return standard deviation of data values in each dimension included in the resource, or {@code null} if none.
*/
- @Override
@XmlElement(name = "standardDeviation")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="standardDeviation", obligation=OPTIONAL, specification=ISO_19115)
public Double getStandardDeviation() {
return standardDeviation;
}
@@ -372,8 +377,8 @@
*
* @return the units of data in the dimension, or {@code null} if unspecified.
*/
- @Override
@XmlElement(name = "units")
+ @UML(identifier="units", obligation=CONDITIONAL, specification=ISO_19115)
public Unit<?> getUnits() {
return units;
}
@@ -393,8 +398,8 @@
*
* @return scale factor which has been applied to the cell value, or {@code null} if none.
*/
- @Override
@XmlElement(name = "scaleFactor")
+ @UML(identifier="scaleFactor", obligation=OPTIONAL, specification=ISO_19115)
public Double getScaleFactor() {
return scaleFactor;
}
@@ -414,8 +419,8 @@
*
* @return the physical value corresponding to a cell value of zero, or {@code null} if none.
*/
- @Override
@XmlElement(name = "offset")
+ @UML(identifier="offset", obligation=OPTIONAL, specification=ISO_19115)
public Double getOffset() {
return offset;
}
@@ -441,7 +446,6 @@
*
* @return type of transfer function, or {@code null}.
*/
- @Override
public TransferFunctionType getTransferFunctionType() {
return transferFunctionType;
}
@@ -463,9 +467,9 @@
* @return maximum number of significant bits in the uncompressed representation
* for the value in each band of each pixel, or {@code null} if none.
*/
- @Override
@ValueRange(minimum = 1)
@XmlElement(name = "bitsPerValue")
+ @UML(identifier="bitsPerValue", obligation=OPTIONAL, specification=ISO_19115)
public Integer getBitsPerValue() {
return bitsPerValue;
}
@@ -492,7 +496,6 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "rangeElementDescription")
@XmlJavaTypeAdapter(MI_RangeElementDescription.Since2014.class)
public Collection<RangeElementDescription> getRangeElementDescriptions() {
@@ -522,7 +525,6 @@
*
* @return smallest distance between which separate points can be distinguished, or {@code null}.
*/
- @Override
@ValueRange(minimum = 0, isMinIncluded = false)
public Double getNominalSpatialResolution() {
return nominalSpatialResolution;
@@ -547,9 +549,9 @@
*
* @return type of other attribute description, or {@code null} if none.
*/
- @Override
@XmlElement(name = "otherPropertyType")
@XmlJavaTypeAdapter(GO_RecordType.Since2014.class)
+ @UML(identifier="otherPropertyType", obligation=OPTIONAL, specification=ISO_19115)
public RecordType getOtherPropertyType() {
return otherPropertyType;
}
@@ -570,9 +572,9 @@
*
* @return instance of other/attributeType that defines attributes, or {@code null} if none.
*/
- @Override
@XmlElement(name = "otherProperty")
@XmlJavaTypeAdapter(GO_Record.Since2014.class)
+ @UML(identifier="otherProperty", obligation=OPTIONAL, specification=ISO_19115)
public Record getOtherProperty() {
return otherProperty;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java
index 26c845b..0ebb08e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java
@@ -22,9 +22,9 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.opengis.util.InternationalString;
import org.opengis.metadata.distribution.Format;
import org.opengis.metadata.distribution.DataFile;
-import org.opengis.util.InternationalString;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.bind.FilterByVersion;
@@ -126,11 +126,14 @@
public DefaultDataFile(final DataFile object) {
super(object);
if (object != null) {
- fileName = object.getFileName();
- fileDescription = object.getFileDescription();
- fileType = object.getFileType();
- featureTypes = copyCollection(object.getFeatureTypes(), LocalName.class);
- fileFormat = object.getFileFormat();
+ if (object instanceof DefaultDataFile) {
+ DefaultDataFile df = (DefaultDataFile) object;
+ fileName = df.getFileName();
+ fileDescription = df.getFileDescription();
+ fileType = df.getFileType();
+ }
+ featureTypes = copyCollection(object.getFeatureTypes(), LocalName.class);
+ fileFormat = object.getFileFormat();
}
}
@@ -167,7 +170,6 @@
* @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileName()
* @since 1.0
*/
- @Override
@XmlElement(name = "fileName", required = true)
public URI getFileName() {
return fileName;
@@ -193,7 +195,6 @@
* @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileDescription()
* @since 1.0
*/
- @Override
@XmlElement(name = "fileDescription", required = true)
public InternationalString getFileDescription() {
return fileDescription;
@@ -219,7 +220,6 @@
* @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileType()
* @since 1.0
*/
- @Override
@XmlElement(name = "fileType", required = true)
@XmlJavaTypeAdapter(MimeFileTypeAdapter.class)
public String getFileType() {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
index d660af7..72455b0 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
@@ -36,6 +36,11 @@
import org.apache.sis.util.privy.CollectionsExt;
import static org.apache.sis.metadata.privy.ImplementationHelper.ensurePositive;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Technical means and media by which a resource is obtained from the distributor.
@@ -134,9 +139,14 @@
unitsOfDistribution = object.getUnitsOfDistribution();
transferSize = object.getTransferSize();
onLines = copyCollection(object.getOnLines(), OnlineResource.class);
- offLines = copyCollection(object.getOffLines(), Medium.class);
- transferFrequency = object.getTransferFrequency();
- distributionFormats = copyCollection(object.getDistributionFormats(), Format.class);
+ if (object instanceof DefaultDigitalTransferOptions) {
+ final DefaultDigitalTransferOptions c = (DefaultDigitalTransferOptions) object;
+ offLines = copyCollection(c.getOffLines(), Medium.class);
+ transferFrequency = c.getTransferFrequency();
+ distributionFormats = copyCollection(c.getDistributionFormats(), Format.class);
+ } else {
+ offLines = singleton(object.getOffLine(), Medium.class);
+ }
}
}
@@ -240,8 +250,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "offLine")
+ @UML(identifier="offLine", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Medium> getOffLines() {
Collection<Medium> c = offLines = nonNullCollection(offLines, Medium.class);
if (c != null && c.size() > 1 && FilterByVersion.LEGACY_METADATA.accept()) {
@@ -295,7 +305,6 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "transferFrequency")
@XmlJavaTypeAdapter(TM_Duration.Since2014.class)
public TemporalAmount getTransferFrequency() {
@@ -321,8 +330,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="distributionFormat", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Format> getDistributionFormats() {
return distributionFormats = nonNullCollection(distributionFormats, Format.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java
index d922d17..b0f1367 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java
@@ -30,6 +30,11 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.bind.gco.InternationalStringAdapter;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about the distributor of and options for obtaining the resource.
@@ -115,10 +120,12 @@
public DefaultDistribution(final Distribution object) {
super(object);
if (object != null) {
- description = object.getDescription();
distributionFormats = copyCollection(object.getDistributionFormats(), Format.class);
distributors = copyCollection(object.getDistributors(), Distributor.class);
transferOptions = copyCollection(object.getTransferOptions(), DigitalTransferOptions.class);
+ if (object instanceof DefaultDistribution) {
+ description = ((DefaultDistribution) object).getDescription();
+ }
}
}
@@ -154,9 +161,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "description")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="description", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDescription() {
return description;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultFormat.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultFormat.java
index e522d47..67063f1 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultFormat.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultFormat.java
@@ -37,6 +37,12 @@
import org.apache.sis.util.privy.CollectionsExt;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Description of the computer language construct that specifies the representation
@@ -154,11 +160,17 @@
public DefaultFormat(final Format object) {
super(object);
if (object != null) {
- formatSpecificationCitation = object.getFormatSpecificationCitation();
amendmentNumber = object.getAmendmentNumber();
fileDecompressionTechnique = object.getFileDecompressionTechnique();
- media = copyCollection(object.getMedia(), Medium.class);
formatDistributors = copyCollection(object.getFormatDistributors(), Distributor.class);
+ if (object instanceof DefaultFormat) {
+ formatSpecificationCitation = ((DefaultFormat) object).getFormatSpecificationCitation();
+ media = copyCollection(((DefaultFormat) object).getMedia(), Medium.class);
+ } else {
+ setSpecification(object.getSpecification());
+ setVersion(object.getVersion());
+ setName(object.getName());
+ }
}
}
@@ -194,9 +206,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "formatSpecificationCitation", required = true)
@XmlJavaTypeAdapter(CI_Citation.Since2014.class)
+ @UML(identifier="formatSpecificationCitation", obligation=MANDATORY, specification=ISO_19115)
public Citation getFormatSpecificationCitation() {
return formatSpecificationCitation;
}
@@ -401,9 +413,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "medium")
@XmlJavaTypeAdapter(MD_Medium.Since2014.class)
+ @UML(identifier="medium", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Medium> getMedia() {
return media = nonNullCollection(media, Medium.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultMedium.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
index 4b41ed3..746e184 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
@@ -44,9 +44,11 @@
import org.apache.sis.util.privy.CodeLists;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.AbstractSet;
-import java.util.Iterator;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
/**
@@ -89,7 +91,7 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 2657393801067168091L;
+ private static final long serialVersionUID = 7751002701087451894L;
/**
* Name of the medium on which the resource can be received.
@@ -101,7 +103,8 @@
* Density at which the data is recorded.
* If non-null, then the number shall be greater than zero.
*/
- private Double density;
+ @SuppressWarnings("serial")
+ private Collection<Double> densities;
/**
* Units of measure for the recording density.
@@ -151,12 +154,14 @@
super(object);
if (object != null) {
name = object.getName();
- density = object.getDensity();
+ densities = copyCollection(object.getDensities(), Double.class);
densityUnits = object.getDensityUnits();
volumes = object.getVolumes();
mediumFormats = copyCollection(object.getMediumFormats(), MediumFormat.class);
mediumNote = object.getMediumNote();
- identifiers = singleton(object.getIdentifier(), Identifier.class);
+ if (object instanceof DefaultMedium) {
+ identifiers = singleton(((DefaultMedium) object).getIdentifier(), Identifier.class);
+ }
}
}
@@ -224,12 +229,12 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "density")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
@ValueRange(minimum = 0, isMinIncluded = false)
+ @UML(identifier="density", obligation=OPTIONAL, specification=ISO_19115)
public Double getDensity() {
- return density;
+ return LegacyPropertyAdapter.getSingleton(densities, Double.class, null, DefaultMedium.class, "getDensity");
}
/**
@@ -242,9 +247,9 @@
* @since 0.5
*/
public void setDensity(final Double newValue) {
- checkWritePermission(density);
+ checkWritePermission(valueIfDefined(densities));
if (ensurePositive(DefaultMedium.class, "density", true, newValue)) {
- density = newValue;
+ densities = writeCollection(CollectionsExt.singletonOrEmpty(newValue), densities, Double.class);
}
}
@@ -259,28 +264,7 @@
@XmlElement(name = "density", namespace = LegacyNamespaces.GMD)
public Collection<Double> getDensities() {
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
- return new AbstractSet<Double>() {
- /** Returns 0 if empty, or 1 if a density has been specified. */
- @Override public int size() {
- return getDensity() != null ? 1 : 0;
- }
-
- /** Returns an iterator over 0 or 1 element. Current iterator implementation is unmodifiable. */
- @Override public Iterator<Double> iterator() {
- return CollectionsExt.singletonOrEmpty(getDensity()).iterator();
- }
-
- /** Adds an element only if the set is empty. This method is invoked by JAXB at unmarshalling time. */
- @Override public boolean add(final Double newValue) {
- if (isEmpty()) {
- setDensity(newValue);
- return true;
- } else {
- LegacyPropertyAdapter.warnIgnoredExtraneous(Double.class, DefaultMedium.class, "setDensities");
- return false;
- }
- }
- };
+ return densities = nonNullCollection(densities, Double.class);
}
/**
@@ -290,7 +274,7 @@
*/
@Deprecated(since="1.0")
public void setDensities(final Collection<? extends Double> newValues) {
- setDensity(LegacyPropertyAdapter.getSingleton(newValues, Double.class, null, DefaultMedium.class, "setDensities"));
+ densities = writeCollection(newValues, densities, Double.class);
}
/**
@@ -387,9 +371,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "identifier")
@XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
+ @UML(identifier="identifier", obligation=OPTIONAL, specification=ISO_19115)
public Identifier getIdentifier() {
return super.getIdentifier();
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
index 207f5ce..0740782 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
@@ -32,6 +32,11 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.temporal.TemporalDate;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Common ways in which the resource may be obtained or received, and related instructions
@@ -129,11 +134,13 @@
super(object);
if (object != null) {
fees = object.getFees();
- plannedAvailableDateTime = object.getPlannedAvailableDate();
+ plannedAvailableDateTime = TemporalDate.toTemporal(object.getPlannedAvailableDateTime());
orderingInstructions = object.getOrderingInstructions();
turnaround = object.getTurnaround();
- orderOptionsType = object.getOrderOptionsType();
- orderOptions = object.getOrderOptions();
+ if (object instanceof DefaultStandardOrderProcess) {
+ orderOptionsType = ((DefaultStandardOrderProcess) object).getOrderOptionsType();
+ orderOptions = ((DefaultStandardOrderProcess) object).getOrderOptions();
+ }
}
}
@@ -205,7 +212,6 @@
*
* @see #getFees()
*/
- @Override
public Currency getCurrency() {
return currency;
}
@@ -258,8 +264,8 @@
*
* @since 1.5
*/
- @Override
@XmlElement(name = "plannedAvailableDateTime")
+ @UML(identifier="plannedAvailableDateTime", obligation=OPTIONAL, specification=ISO_19115)
public Temporal getPlannedAvailableDate() {
return plannedAvailableDateTime;
}
@@ -330,9 +336,9 @@
*
* @see org.apache.sis.util.iso.DefaultRecord#getRecordType()
*/
- @Override
@XmlElement(name = "orderOptionsType")
@XmlJavaTypeAdapter(GO_RecordType.Since2014.class)
+ @UML(identifier="orderOptionsType", obligation=OPTIONAL, specification=ISO_19115)
public RecordType getOrderOptionsType() {
return orderOptionsType;
}
@@ -360,9 +366,9 @@
* when he ordered the resource. We presume that this is not a record to be filled by the user for new
* orders, otherwise this method would need to be a factory rather than a getter.
*/
- @Override
@XmlElement(name = "orderOptions")
@XmlJavaTypeAdapter(GO_Record.Since2014.class)
+ @UML(identifier="orderOptions", obligation=OPTIONAL, specification=ISO_19115)
public Record getOrderOptions() {
return orderOptions;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
index 6d540c9..9fe2c6a 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
@@ -30,6 +30,11 @@
import org.apache.sis.metadata.privy.ReferencingServices;
import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Extent with respect to date/time and spatial boundaries.
@@ -113,7 +118,9 @@
super(object);
if (object != null) {
spatialExtent = copyCollection(object.getSpatialExtent(), GeographicExtent.class);
- verticalExtent = object.getVerticalExtent();
+ if (object instanceof DefaultSpatialTemporalExtent) {
+ verticalExtent = ((DefaultSpatialTemporalExtent) object).getVerticalExtent();
+ }
}
}
@@ -169,8 +176,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "verticalExtent")
+ @UML(identifier="verticalExtent", obligation=OPTIONAL, specification=ISO_19115)
public VerticalExtent getVerticalExtent() {
return verticalExtent;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
index 4adaddf..953f61f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
@@ -36,8 +36,8 @@
import org.apache.sis.xml.NilObject;
import org.apache.sis.xml.NilReason;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
index d9b1e63..2ebc7bf 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
@@ -34,9 +34,6 @@
import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
-
/**
* Vertical domain of dataset.
@@ -277,14 +274,14 @@
* bounds, then the corresponding bounds of the intersection result will also be NaN.</p>
*
* @param other the vertical extent to intersect with this extent.
- * @throws MismatchedCoordinateMetadataException if the two extents do not use the same datum, ignoring metadata.
+ * @throws IllegalArgumentException if the two extents do not use the same datum, ignoring metadata.
*
* @see Extents#intersection(VerticalExtent, VerticalExtent)
* @see org.apache.sis.geometry.GeneralEnvelope#intersect(Envelope)
*
* @since 0.8
*/
- public void intersect(final VerticalExtent other) throws MismatchedCoordinateMetadataException {
+ public void intersect(final VerticalExtent other) throws IllegalArgumentException {
checkWritePermission(value());
Double min = other.getMinimumValue();
Double max = other.getMaximumValue();
@@ -311,7 +308,7 @@
}
}
} catch (UnsupportedOperationException | FactoryException | ClassCastException | TransformException e) {
- throw new MismatchedCoordinateMetadataException(Errors.format(Errors.Keys.IncompatiblePropertyValue_1, "verticalCRS"), e);
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatiblePropertyValue_1, "verticalCRS"), e);
}
if (minimumValue != null && maximumValue != null && minimumValue > maximumValue) {
minimumValue = maximumValue = NilReason.MISSING.createNilObject(Double.class);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
index e4a5d16..012f9b3 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
@@ -75,9 +75,10 @@
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
import static org.apache.sis.metadata.privy.ReferencingServices.AUTHALIC_RADIUS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+// Specific to the main branch:
+import org.opengis.metadata.identification.DataIdentification;
+import org.opengis.referencing.datum.VerticalDatumType;
+import org.apache.sis.pending.geoapi.evolution.Interim;
/**
@@ -156,8 +157,8 @@
if (metadata != null) {
Set<Extent> union = null;
for (final Identification id : nonNull(metadata.getIdentificationInfo())) {
- if (id != null) { // Should not be allowed, but we are paranoiac.
- final Collection<? extends Extent> extents = id.getExtents();
+ if (id instanceof DataIdentification) {
+ final Collection<? extends Extent> extents = ((DataIdentification) id).getExtents();
if (extents != result && !isNullOrEmpty(extents)) {
if (result == null) {
result = extents;
@@ -201,9 +202,11 @@
final Extents m = new Extents();
try {
for (final Identification id : nonNull(metadata.getIdentificationInfo())) {
- if (id != null) for (final Extent extent : nonNull(id.getExtents())) {
- if (extent != null) {
- m.addHorizontal(extent);
+ if (id instanceof DataIdentification) {
+ for (final Extent extent : nonNull(((DataIdentification) id).getExtents())) {
+ if (extent != null) {
+ m.addHorizontal(extent);
+ }
}
}
}
@@ -227,7 +230,7 @@
* @return the union of all geographic bounding boxes found in all extents.
* @throws InvalidMetadataException if an envelope cannot be transformed to a geographic bounding box.
*
- * @see CoordinateReferenceSystem#getDomains()
+ * @see org.apache.sis.referencing.AbstractIdentifiedObject#getDomains()
* @see org.apache.sis.referencing.CRS#getDomainOfValidity(CoordinateReferenceSystem)
*
* @since 1.4
@@ -326,7 +329,7 @@
*/
if (!Boolean.FALSE.equals(element.getInclusion())) {
for (final Geometry geometry : nonNull(((BoundingPolygon) extent).getPolygons())) {
- final Envelope envelope = geometry.getEnvelope();
+ final Envelope envelope = Interim.getEnvelope(geometry);
if (envelope != null) {
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
if (crs != null) {
@@ -369,13 +372,13 @@
*
* <ul class="verbose">
* <li><p><b>Choice based on realization method</b><br>
- * Only the extents associated (indirectly, through their CRS) to the same non-null {@link RealizationMethod}
+ * Only the extents associated (indirectly, through their CRS) to the same non-null {@link VerticalDatumType}
* will be taken in account. If all realization methods are absent, then this method conservatively uses only
* the first vertical extent. Otherwise the realization method used for filtering the vertical extents is:</p>
*
* <ul>
- * <li>{@link RealizationMethod#GEOID} if at least one extent uses this realization method.</li>
- * <li>Otherwise, {@link RealizationMethod#TIDAL} if at least one extent uses this realization method.</li>
+ * <li>{@link VerticalDatumType#GEOIDAL} if at least one extent uses this realization method.</li>
+ * <li>Otherwise, {@link VerticalDatumType#DEPTH} if at least one extent uses this realization method.</li>
* <li>Otherwise, the first non-null realization type found in iteration order.</li>
* </ul>
*
@@ -418,18 +421,18 @@
@OptionalCandidate
public static MeasurementRange<Double> getVerticalRange(final Extent extent) {
MeasurementRange<Double> range = null;
- RealizationMethod selectedMethod = null;
+ VerticalDatumType selectedMethod = null;
if (extent != null) try {
for (final VerticalExtent element : nonNull(extent.getVerticalElements())) {
Double min = element.getMinimumValue();
Double max = element.getMaximumValue();
final VerticalCRS crs = element.getVerticalCRS();
- RealizationMethod method = null;
+ VerticalDatumType method = null;
Unit<?> unit = null;
if (crs != null) {
final VerticalDatum datum = crs.getDatum();
if (datum != null) {
- method = datum.getRealizationMethod().orElse(method);
+ method = datum.getVerticalDatumType();
}
final CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(0);
unit = axis.getUnit();
@@ -455,9 +458,9 @@
* height in which case we forget all previous ranges and use the new one instead.
*/
if (method != selectedMethod) {
- if (selectedMethod == RealizationMethod.GEOID ||
- (method != RealizationMethod.GEOID &&
- method != RealizationMethod.TIDAL))
+ if (selectedMethod == VerticalDatumType.GEOIDAL ||
+ (method != VerticalDatumType.GEOIDAL &&
+ method != VerticalDatumType.DEPTH))
{
continue;
}
@@ -759,7 +762,7 @@
* @param e2 the second extent, or {@code null}.
* @return the intersection (may be any of the {@code e1} or {@code e2} argument if unchanged),
* or {@code null} if the two given extents are null.
- * @throws MismatchedCoordinateMetadataException if the two extents do not use the same datum, ignoring metadata.
+ * @throws IllegalArgumentException if the two extents do not use the same datum, ignoring metadata.
*
* @see DefaultVerticalExtent#intersect(VerticalExtent)
*
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java
index 30fb1db..330d3fd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java
@@ -52,8 +52,13 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.AssociatedResource;
+// Specific to the main branch:
+import java.util.List;
+import java.util.ArrayList;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -249,7 +254,7 @@
* Provides aggregate dataset information.
*/
@SuppressWarnings("serial")
- private Collection<AssociatedResource> associatedResources;
+ private Collection<DefaultAssociatedResource> associatedResources;
/**
* Constructs an initially empty identification.
@@ -301,20 +306,25 @@
credits = copyCollection(object.getCredits(), String.class);
status = copyCollection(object.getStatus(), Progress.class);
pointOfContacts = copyCollection(object.getPointOfContacts(), ResponsibleParty.class);
- spatialRepresentationTypes = copyCollection(object.getSpatialRepresentationTypes(), SpatialRepresentationType.class);
- spatialResolutions = copyCollection(object.getSpatialResolutions(), Resolution.class);
- temporalResolutions = copyCollection(object.getTemporalResolutions(), TemporalAmount.class);
- topicCategories = copyCollection(object.getTopicCategories(), TopicCategory.class);
- extents = copyCollection(object.getExtents(), Extent.class);
- additionalDocumentations = copyCollection(object.getAdditionalDocumentations(), Citation.class);
- processingLevel = object.getProcessingLevel();
resourceMaintenances = copyCollection(object.getResourceMaintenances(), MaintenanceInformation.class);
graphicOverviews = copyCollection(object.getGraphicOverviews(), BrowseGraphic.class);
resourceFormats = copyCollection(object.getResourceFormats(), Format.class);
descriptiveKeywords = copyCollection(object.getDescriptiveKeywords(), Keywords.class);
resourceSpecificUsages = copyCollection(object.getResourceSpecificUsages(), Usage.class);
resourceConstraints = copyCollection(object.getResourceConstraints(), Constraints.class);
- associatedResources = copyCollection(object.getAssociatedResources(), AssociatedResource.class);
+ if (object instanceof AbstractIdentification) {
+ final AbstractIdentification c = (AbstractIdentification) object;
+ spatialRepresentationTypes = copyCollection(c.getSpatialRepresentationTypes(), SpatialRepresentationType.class);
+ spatialResolutions = copyCollection(c.getSpatialResolutions(), Resolution.class);
+ temporalResolutions = copyCollection(c.getTemporalResolutions(), TemporalAmount.class);
+ topicCategories = copyCollection(c.getTopicCategories(), TopicCategory.class);
+ extents = copyCollection(c.getExtents(), Extent.class);
+ additionalDocumentations = copyCollection(c.getAdditionalDocumentations(), Citation.class);
+ processingLevel = c.getProcessingLevel();
+ associatedResources = copyCollection(c.getAssociatedResources(), DefaultAssociatedResource.class);
+ } else {
+ setAggregationInfo(object.getAggregationInfo());
+ }
}
}
@@ -506,8 +516,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "spatialRepresentationType")
+ @UML(identifier="spatialRepresentationType", obligation=OPTIONAL, specification=ISO_19115)
public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
return spatialRepresentationTypes = nonNullCollection(spatialRepresentationTypes, SpatialRepresentationType.class);
}
@@ -531,8 +541,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "spatialResolution")
+ @UML(identifier="spatialResolution", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Resolution> getSpatialResolutions() {
return spatialResolutions = nonNullCollection(spatialResolutions, Resolution.class);
}
@@ -555,8 +565,8 @@
*
* @since 1.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="temporalResolution", obligation=OPTIONAL, specification=ISO_19115)
public Collection<TemporalAmount> getTemporalResolutions() {
return temporalResolutions = nonNullCollection(temporalResolutions, TemporalAmount.class);
}
@@ -579,8 +589,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "topicCategory")
+ @UML(identifier="topicCategory", obligation=CONDITIONAL, specification=ISO_19115)
public Collection<TopicCategory> getTopicCategories() {
return topicCategories = nonNullCollection(topicCategories, TopicCategory.class);
}
@@ -603,8 +613,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "extent")
+ @UML(identifier="extent", obligation=CONDITIONAL, specification=ISO_19115)
public Collection<Extent> getExtents() {
return extents = nonNullCollection(extents, Extent.class);
}
@@ -627,8 +637,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="additionalDocumentation", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getAdditionalDocumentations() {
return additionalDocumentations = nonNullCollection(additionalDocumentations, Citation.class);
}
@@ -651,9 +661,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "processingLevel")
@XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
+ @UML(identifier="processingLevel", obligation=OPTIONAL, specification=ISO_19115)
public Identifier getProcessingLevel() {
return processingLevel;
}
@@ -799,25 +809,35 @@
/**
* Provides associated resource information.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code AssociatedResource} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return associated resource information.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<AssociatedResource> getAssociatedResources() {
- return associatedResources = nonNullCollection(associatedResources, AssociatedResource.class);
+ @UML(identifier="associatedResource", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultAssociatedResource> getAssociatedResources() {
+ return associatedResources = nonNullCollection(associatedResources, DefaultAssociatedResource.class);
}
/**
* Sets associated resource information.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code AssociatedResource} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new associated resources.
*
* @since 0.5
*/
- public void setAssociatedResources(final Collection<? extends AssociatedResource> newValues) {
- associatedResources = writeCollection(newValues, associatedResources, AssociatedResource.class);
+ public void setAssociatedResources(final Collection<? extends DefaultAssociatedResource> newValues) {
+ associatedResources = writeCollection(newValues, associatedResources, DefaultAssociatedResource.class);
}
/**
@@ -833,16 +853,20 @@
@XmlElement(name = "aggregationInfo", namespace = LegacyNamespaces.GMD)
public Collection<AggregateInformation> getAggregationInfo() {
if (!FilterByVersion.LEGACY_METADATA.accept()) return null;
- return new LegacyPropertyAdapter<AggregateInformation,AssociatedResource>(getAssociatedResources()) {
- @Override protected AssociatedResource wrap(final AggregateInformation value) {
- return value;
+ return new LegacyPropertyAdapter<AggregateInformation,DefaultAssociatedResource>(getAssociatedResources()) {
+ @Override protected DefaultAssociatedResource wrap(final AggregateInformation value) {
+ return DefaultAssociatedResource.castOrCopy(value);
}
- @Override protected AggregateInformation unwrap(final AssociatedResource container) {
- return DefaultAggregateInformation.castOrCopy(container);
+ @Override protected AggregateInformation unwrap(final DefaultAssociatedResource container) {
+ if (container instanceof AggregateInformation) {
+ return (AggregateInformation) container;
+ } else {
+ return new DefaultAggregateInformation(container);
+ }
}
- @Override protected boolean update(final AssociatedResource container, final AggregateInformation value) {
+ @Override protected boolean update(final DefaultAssociatedResource container, final AggregateInformation value) {
return container == value;
}
}.validOrNull();
@@ -857,7 +881,20 @@
*/
@Deprecated(since="1.0")
public void setAggregationInfo(final Collection<? extends AggregateInformation> newValues) {
- setAssociatedResources(newValues);
+ checkWritePermission(associatedResources);
+ /*
+ * We can not invoke getAggregationInfo().setValues(newValues) because this method
+ * is invoked by the constructor, which is itself invoked at JAXB marshalling time,
+ * in which case getAggregationInfo() may return null.
+ */
+ List<DefaultAssociatedResource> r = null;
+ if (newValues != null) {
+ r = new ArrayList<DefaultAssociatedResource>(newValues.size());
+ for (final AggregateInformation value : newValues) {
+ r.add(DefaultAssociatedResource.castOrCopy(value));
+ }
+ }
+ setAssociatedResources(r);
}
@@ -880,9 +917,6 @@
* Invoked by JAXB at both marshalling and unmarshalling time.
* This attribute has been added by ISO 19115:2014 standard.
* If (and only if) marshalling an older standard version, we omit this attribute.
- *
- * @todo Currently, the {@code XmlJavaTypeAdapter} used here just internally converts {@code Duration} objects
- * into {@code PeriodDuration} objects. Need to add support for {@code IntervalLength} in the future.
*/
@XmlElement(name = "temporalResolution")
private Collection<TemporalAmount> getTemporalResolution() {
@@ -895,7 +929,7 @@
}
@XmlElement(name = "associatedResource")
- private Collection<AssociatedResource> getAssociatedResource() {
+ private Collection<DefaultAssociatedResource> getAssociatedResource() {
return FilterByVersion.CURRENT_METADATA.accept() ? getAssociatedResources() : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
index 81b7e9c..e3edc37 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
@@ -34,12 +34,9 @@
import org.apache.sis.xml.bind.metadata.code.DS_AssociationTypeCode;
import org.apache.sis.xml.bind.metadata.code.DS_InitiativeTypeCode;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.AssociatedResource;
-
/**
- * Aggregate dataset information.
+ * Associated resource information.
* The following properties are mandatory or conditional (i.e. mandatory under some circumstances)
* in a well-formed metadata according ISO 19115:
*
@@ -50,8 +47,14 @@
* {@code │ └─date……………………………} Reference date for the cited resource.
* {@code └─name………………………………………} Citation information about the associated resource.</div>
*
- * According ISO 19115, at least one of {@linkplain #getAggregateDataSetName() aggregate dataset name}
- * and {@linkplain #getAggregateDataSetIdentifier() aggregate dataset identifier} shall be provided.
+ * According ISO 19115, at least one of {@linkplain #getName() name} and
+ * {@linkplain #getMetadataReference() metadata reference} shall be provided.
+ *
+ * <div class="warning"><b>Upcoming API change — renaming</b><br>
+ * As of ISO 19115:2014, {@code AggregateInformation} has been renamed {@code AssociatedResource}.
+ * This class will be replaced by {@link DefaultAssociatedResource} when GeoAPI will provide the
+ * {@code AssociatedResource} interface (tentatively in GeoAPI 3.1 or 4.0).
+ * </div>
*
* <h2>Limitations</h2>
* <ul>
@@ -67,10 +70,7 @@
* @author Cullen Rombach (Image Matters)
* @version 1.4
* @since 0.3
- *
- * @deprecated As of ISO 19115:2014, replaced by {@link DefaultAssociatedResource}.
*/
-@Deprecated(since="1.0")
@XmlType(name = "MD_AggregateInformation_Type", namespace = LegacyNamespaces.GMD, propOrder = {
"aggregateDataSetName",
"aggregateDataSetIdentifier",
@@ -92,15 +92,26 @@
/**
* Constructs a new instance initialized with the values from the specified metadata object.
+ *
+ * @param object The metadata to copy values from.
+ */
+ DefaultAggregateInformation(final DefaultAssociatedResource object) {
+ super(object);
+ }
+
+ /**
+ * Constructs a new instance initialized with the values from the specified metadata object.
* This is a <em>shallow</em> copy constructor, because the other metadata contained in the
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(AssociatedResource)
*/
- public DefaultAggregateInformation(final AssociatedResource object) {
+ public DefaultAggregateInformation(final AggregateInformation object) {
super(object);
+ if (object != null && !(object instanceof DefaultAssociatedResource)) {
+ setAggregateDataSetName(object.getAggregateDataSetName());
+ setAggregateDataSetIdentifier(object.getAggregateDataSetIdentifier());
+ }
}
/**
@@ -112,7 +123,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code DefaultAggregateInformation}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code DefaultAggregateInformation} instance is created using the
- * {@linkplain #DefaultAggregateInformation(AssociatedResource) copy constructor} and returned.
+ * {@linkplain #DefaultAggregateInformation(AggregateInformation) copy constructor} and returned.
* Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -121,7 +132,7 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static DefaultAggregateInformation castOrCopy(final AssociatedResource object) {
+ public static DefaultAggregateInformation castOrCopy(final AggregateInformation object) {
if (object == null || object instanceof DefaultAggregateInformation) {
return (DefaultAggregateInformation) object;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java
index 760eb8f..1a24179 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java
@@ -28,8 +28,13 @@
import org.apache.sis.xml.bind.metadata.code.DS_InitiativeTypeCode;
import org.apache.sis.metadata.iso.ISOMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.AssociatedResource;
+// Specific to the main branch:
+import org.opengis.metadata.identification.AggregateInformation;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -69,7 +74,8 @@
"metadataReference"
})
@XmlRootElement(name = "MD_AssociatedResource")
-public class DefaultAssociatedResource extends ISOMetadata implements AssociatedResource {
+@UML(identifier="MD_AssociatedResource", specification=ISO_19115)
+public class DefaultAssociatedResource extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -116,41 +122,43 @@
/**
* Constructs a new instance initialized with the values from the specified metadata object.
+ * This is a constructor for {@link DefaultAggregateInformation} constructor only.
+ *
+ * @param object The metadata to copy values from.
+ */
+ DefaultAssociatedResource(final DefaultAssociatedResource object) {
+ this.associationType = object.associationType;
+ this.initiativeType = object.initiativeType;
+ this.name = object.name;
+ this.metadataReference = object.metadataReference;
+ }
+
+ /**
+ * Constructs a new instance initialized with the values from the specified metadata object.
* This is a <em>shallow</em> copy constructor, because the other metadata contained in the
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(AssociatedResource)
*/
- public DefaultAssociatedResource(final AssociatedResource object) {
+ DefaultAssociatedResource(final AggregateInformation object) {
if (object != null) {
- this.name = object.getName();
this.associationType = object.getAssociationType();
this.initiativeType = object.getInitiativeType();
- this.metadataReference = object.getMetadataReference();
+ if (object instanceof DefaultAssociatedResource) {
+ this.name = ((DefaultAssociatedResource) object).getName();
+ this.metadataReference = ((DefaultAssociatedResource) object).getMetadataReference();
+ }
}
}
/**
* Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultAssociatedResource}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultAssociatedResource} instance is created using the
- * {@linkplain #DefaultAssociatedResource(AssociatedResource) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
*
* @param object the object to get as a SIS implementation, or {@code null} if none.
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static DefaultAssociatedResource castOrCopy(final AssociatedResource object) {
+ static DefaultAssociatedResource castOrCopy(final AggregateInformation object) {
if (object == null || object instanceof DefaultAssociatedResource) {
return (DefaultAssociatedResource) object;
}
@@ -162,9 +170,9 @@
*
* @return Citation information about the associated resource, or {@code null} if none.
*/
- @Override
@XmlElement(name = "name")
@XmlJavaTypeAdapter(CI_Citation.Since2014.class)
+ @UML(identifier="name", obligation=CONDITIONAL, specification=ISO_19115)
public Citation getName() {
return name;
}
@@ -184,9 +192,9 @@
*
* @return type of relation between the resources.
*/
- @Override
@XmlElement(name = "associationType", required = true)
@XmlJavaTypeAdapter(DS_AssociationTypeCode.Since2014.class)
+ @UML(identifier="associationType", obligation=MANDATORY, specification=ISO_19115)
public AssociationType getAssociationType() {
return associationType;
}
@@ -206,9 +214,9 @@
*
* @return the type of initiative under which the associated resource was produced, or {@code null} if none.
*/
- @Override
@XmlElement(name = "initiativeType")
@XmlJavaTypeAdapter(DS_InitiativeTypeCode.Since2014.class)
+ @UML(identifier="initiativeType", obligation=OPTIONAL, specification=ISO_19115)
public InitiativeType getInitiativeType() {
return initiativeType;
}
@@ -228,9 +236,9 @@
*
* @return reference to the metadata of the associated resource, or {@code null} if none.
*/
- @Override
@XmlElement(name = "metadataReference")
@XmlJavaTypeAdapter(CI_Citation.Since2014.class)
+ @UML(identifier="metadataReference", obligation=CONDITIONAL, specification=ISO_19115)
public Citation getMetadataReference() {
return metadataReference;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
index d6be803..dbb04de 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
@@ -31,6 +31,11 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.gcx.MimeFileTypeAdapter;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Graphic that provides an illustration of the dataset (should include a legend for the graphic).
@@ -129,8 +134,10 @@
fileName = object.getFileName();
fileDescription = object.getFileDescription();
fileType = object.getFileType();
- imageConstraints = copyCollection(object.getImageConstraints(), Constraints.class);
- linkages = copyCollection(object.getLinkages(), OnlineResource.class);
+ if (object instanceof DefaultBrowseGraphic) {
+ imageConstraints = copyCollection(((DefaultBrowseGraphic) object).getImageConstraints(), Constraints.class);
+ linkages = copyCollection(((DefaultBrowseGraphic) object).getLinkages(), OnlineResource.class);
+ }
}
}
@@ -235,8 +242,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="imageContraints", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Constraints> getImageConstraints() {
return imageConstraints = nonNullCollection(imageConstraints, Constraints.class);
}
@@ -259,8 +266,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="linkage", obligation=OPTIONAL, specification=ISO_19115)
public Collection<OnlineResource> getLinkages() {
return linkages = nonNullCollection(linkages, OnlineResource.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
index a87b1a6..214eac6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
@@ -34,14 +34,23 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.iso.Names;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.CoupledResource;
-import org.opengis.metadata.identification.OperationMetadata;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
* Links a given operation name with a resource identified by an "identifier".
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code CoupledResource} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -67,7 +76,8 @@
"legacyName" // Legacy ISO 19139:2007 way to write scoped name
})
@XmlRootElement(name = "SV_CoupledResource", namespace = Namespaces.SRV)
-public class DefaultCoupledResource extends ISOMetadata implements CoupledResource {
+@UML(identifier="SV_CoupledResource", specification=ISO_19115)
+public class DefaultCoupledResource extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -95,7 +105,7 @@
* The service operation.
*/
@SuppressWarnings("serial")
- private OperationMetadata operation;
+ private DefaultOperationMetadata operation;
/**
* Constructs an initially empty coupled resource.
@@ -114,7 +124,7 @@
public DefaultCoupledResource(final ScopedName name,
final Citation reference,
final DataIdentification resource,
- final OperationMetadata operation)
+ final DefaultOperationMetadata operation)
{
this.scopedName = name;
this.resourceReferences = singleton(reference, Citation.class);
@@ -128,10 +138,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(CoupledResource)
*/
- public DefaultCoupledResource(final CoupledResource object) {
+ public DefaultCoupledResource(final DefaultCoupledResource object) {
super(object);
if (object != null) {
this.scopedName = object.getScopedName();
@@ -142,38 +150,13 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultCoupledResource}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultCoupledResource} instance is created using the
- * {@linkplain #DefaultCoupledResource(CoupledResource) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultCoupledResource castOrCopy(final CoupledResource object) {
- if (object == null || object instanceof DefaultCoupledResource) {
- return (DefaultCoupledResource) object;
- }
- return new DefaultCoupledResource(object);
- }
-
- /**
* Returns scoped identifier of the resource in the context of the given service instance.
*
* @return identifier of the resource, or {@code null} if none.
*/
- @Override
@XmlElement(name = "scopedName")
@XmlJavaTypeAdapter(GO_GenericName.Since2014.class)
+ @UML(identifier="scopedName", obligation=OPTIONAL, specification=ISO_19115)
public ScopedName getScopedName() {
return scopedName;
}
@@ -193,8 +176,8 @@
*
* @return references to the resource on which the services operates.
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="resourceReference", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getResourceReferences() {
return resourceReferences = nonNullCollection(resourceReferences, Citation.class);
}
@@ -213,8 +196,8 @@
*
* @return tightly coupled resources.
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="resource", obligation=OPTIONAL, specification=ISO_19115)
public Collection<DataIdentification> getResources() {
return resources = nonNullCollection(resources, DataIdentification.class);
}
@@ -231,23 +214,33 @@
/**
* Returns the service operation.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The return type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return the service operation, or {@code null} if none.
*/
- @Override
@XmlElement(name = "operation")
@XmlJavaTypeAdapter(SV_OperationMetadata.Since2014.class)
- public OperationMetadata getOperation() {
+ @UML(identifier="operation", obligation=OPTIONAL, specification=ISO_19115)
+ public DefaultOperationMetadata getOperation() {
return operation;
}
/**
* Sets a new service operation.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The argument type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValue the new service operation.
*/
- public void setOperation(final OperationMetadata newValue) {
+ public void setOperation(final DefaultOperationMetadata newValue) {
checkWritePermission(operation);
- operation = newValue;
+ this.operation = newValue;
}
@@ -272,7 +265,7 @@
@XmlElement(name = "operationName", namespace = LegacyNamespaces.SRV)
private String getOperationName() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
- final OperationMetadata operation = getOperation();
+ final DefaultOperationMetadata operation = getOperation();
if (operation != null) {
return operation.getOperationName();
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
index 473041e..8fe5c05 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
@@ -39,6 +39,12 @@
import java.util.stream.Collectors;
import org.opengis.metadata.identification.CharacterSet;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.xml.bind.metadata.code.MD_CharacterSetCode;
+
/**
* Information required to identify a dataset.
@@ -155,7 +161,11 @@
public DefaultDataIdentification(final DataIdentification object) {
super(object);
if (object != null) {
- locales = copyMap(object.getLocalesAndCharsets(), Locale.class);
+ if (object instanceof DefaultDataIdentification) {
+ locales = copyMap(((DefaultDataIdentification) object).getLocalesAndCharsets(), Locale.class);
+ } else {
+ setLanguages(object.getLanguages());
+ }
environmentDescription = object.getEnvironmentDescription();
supplementalInformation = object.getSupplementalInformation();
}
@@ -195,7 +205,7 @@
*
* @since 1.0
*/
- @Override
+ @UML(identifier="defaultLocale+otherLocale", obligation=CONDITIONAL, specification=ISO_19115)
// @XmlElement at the end of this class.
public Map<Locale,Charset> getLocalesAndCharsets() {
return locales = nonNullMap(locales, Locale.class);
@@ -263,7 +273,7 @@
@Dependencies("getLocalesAndCharsets")
// @XmlElement at the end of this class.
public Collection<CharacterSet> getCharacterSets() {
- return getLocalesAndCharsets().values().stream().map(CharacterSet::fromCharset).collect(Collectors.toSet());
+ return getLocalesAndCharsets().values().stream().map(MD_CharacterSetCode::fromCharset).collect(Collectors.toSet());
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywordClass.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywordClass.java
index 6dfb650..9918263 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywordClass.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywordClass.java
@@ -26,9 +26,6 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.KeywordClass;
-
/**
* Specification of a class to categorize keywords in a domain-specific vocabulary
@@ -41,6 +38,14 @@
* {@code ├─title………………………} Name by which the cited resource is known.
* {@code └─date…………………………} Reference date for the cited resource.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code KeywordClass} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -61,7 +66,7 @@
"ontology"
})
@XmlRootElement(name = "MD_KeywordClass")
-public class DefaultKeywordClass extends ISOMetadata implements KeywordClass {
+public class DefaultKeywordClass extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -107,10 +112,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(KeywordClass)
*/
- public DefaultKeywordClass(final KeywordClass object) {
+ public DefaultKeywordClass(final DefaultKeywordClass object) {
super(object);
if (object != null) {
className = object.getClassName();
@@ -120,36 +123,10 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultKeywordClass}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultKeywordClass} instance is created using the
- * {@linkplain #DefaultKeywordClass(KeywordClass) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultKeywordClass castOrCopy(final KeywordClass object) {
- if (object == null || object instanceof DefaultKeywordClass) {
- return (DefaultKeywordClass) object;
- }
- return new DefaultKeywordClass(object);
- }
-
- /**
* Returns a label for the keyword category in natural language.
*
* @return the keyword category in natural language.
*/
- @Override
@XmlElement(name = "className", required = true)
public InternationalString getClassName() {
return className;
@@ -170,7 +147,6 @@
*
* @return URI of concept in the ontology, or {@code null} if none.
*/
- @Override
@XmlElement(name = "conceptIdentifier")
public URI getConceptIdentifier() {
return conceptIdentifier;
@@ -191,7 +167,6 @@
*
* @return a reference that binds the keyword class to a formal conceptualization.
*/
- @Override
@XmlElement(name = "ontology", required = true)
public Citation getOntology() {
return ontology;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywords.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywords.java
index 018e3af..4773446 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywords.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultKeywords.java
@@ -29,8 +29,10 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.KeywordClass;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -91,7 +93,7 @@
* to the standardized {@linkplain #getType() keyword type} codes.
*/
@SuppressWarnings("serial")
- private KeywordClass keywordClass;
+ private DefaultKeywordClass keywordClass;
/**
* Constructs an initially empty keywords.
@@ -227,25 +229,34 @@
* Returns the user-defined categorization of groups of keywords that extend or
* are orthogonal to the standardized {@linkplain #getType() keyword type} codes.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code KeywordClass} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return user-defined categorization of groups of keywords, or {@code null} if none.
*
* @since 0.5
*/
- @Override
@XmlElement(name = "keywordClass")
@XmlJavaTypeAdapter(MD_KeywordClass.Since2014.class)
- public KeywordClass getKeywordClass() {
+ @UML(identifier="keywordClass", obligation=OPTIONAL, specification=ISO_19115)
+ public DefaultKeywordClass getKeywordClass() {
return keywordClass;
}
/**
* Sets the user-defined categorization of groups of keywords.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The argument type will be changed to the {@code KeywordClass} interface when GeoAPI will provide it
+ * (tentatively in GeoAPI 3.1).</div>
+ *
* @param newValue new user-defined categorization of groups of keywords.
*
* @since 0.5
*/
- public void setKeywordClass(final KeywordClass newValue) {
+ public void setKeywordClass(final DefaultKeywordClass newValue) {
checkWritePermission(keywordClass);
keywordClass = newValue;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationChainMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationChainMetadata.java
index 65609a0..ba87b29 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationChainMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationChainMetadata.java
@@ -26,9 +26,11 @@
import org.apache.sis.util.iso.Types;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.OperationChainMetadata;
-import org.opengis.metadata.identification.OperationMetadata;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -43,6 +45,14 @@
* {@code └─connectPoint………………………………………………} Handle for accessing the service interface.
* {@code └─linkage…………………………………………………} Location for on-line access using a URL address or similar addressing scheme.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code OperationChainMetadata} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -64,11 +74,12 @@
"operations"
})
@XmlRootElement(name = "SV_OperationChainMetadata", namespace = Namespaces.SRV)
-public class DefaultOperationChainMetadata extends ISOMetadata implements OperationChainMetadata {
+@UML(identifier="SV_OperationChainMetadata", specification=ISO_19115)
+public class DefaultOperationChainMetadata extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
- private static final long serialVersionUID = 4132508877114835287L;
+ private static final long serialVersionUID = 4132508877114835286L;
/**
* The name as used by the service for this chain.
@@ -86,7 +97,7 @@
* Information about the operations applied by the chain.
*/
@SuppressWarnings("serial")
- private List<OperationMetadata> operations;
+ private List<DefaultOperationMetadata> operations;
/**
* Constructs an initially empty operation chain metadata.
@@ -109,50 +120,23 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(OperationChainMetadata)
*/
- public DefaultOperationChainMetadata(final OperationChainMetadata object) {
+ public DefaultOperationChainMetadata(final DefaultOperationChainMetadata object) {
super(object);
if (object != null) {
this.name = object.getName();
this.description = object.getDescription();
- this.operations = copyList(object.getOperations(), OperationMetadata.class);
+ this.operations = copyList(object.getOperations(), DefaultOperationMetadata.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultOperationChainMetadata}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultOperationChainMetadata} instance is created using the
- * {@linkplain #DefaultOperationChainMetadata(OperationChainMetadata) copy constructor}
- * and returned. Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultOperationChainMetadata castOrCopy(final OperationChainMetadata object) {
- if (object == null || object instanceof DefaultOperationChainMetadata) {
- return (DefaultOperationChainMetadata) object;
- }
- return new DefaultOperationChainMetadata(object);
- }
-
- /**
* Returns the name as used by the service for this chain.
*
* @return name as used by the service for this chain.
*/
- @Override
@XmlElement(name = "name", namespace = Namespaces.SRV, required = true)
+ @UML(identifier="name", obligation=MANDATORY, specification=ISO_19115)
public InternationalString getName() {
return name;
}
@@ -172,8 +156,8 @@
*
* @return narrative explanation of the services in the chain and resulting output, or {@code null} if none.
*/
- @Override
@XmlElement(name = "description", namespace = Namespaces.SRV)
+ @UML(identifier="description", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDescription() {
return description;
}
@@ -191,20 +175,30 @@
/**
* Returns information about the operations applied by the chain.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information about the operations applied by the chain.
*/
- @Override
@XmlElement(name = "operation", namespace = Namespaces.SRV, required = true)
- public List<OperationMetadata> getOperations() {
- return operations = nonNullList(operations, OperationMetadata.class);
+ @UML(identifier="operation", obligation=MANDATORY, specification=ISO_19115)
+ public List<DefaultOperationMetadata> getOperations() {
+ return operations = nonNullList(operations, DefaultOperationMetadata.class);
}
/**
* Sets the information about the operations applied by the chain.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new information about the operations applied by the chain.
*/
- public void setOperations(final List<? extends OperationMetadata> newValues) {
- operations = writeList(newValues, operations, OperationMetadata.class);
+ public void setOperations(final List<? extends DefaultOperationMetadata> newValues) {
+ operations = writeList(newValues, operations, DefaultOperationMetadata.class);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java
index aeb27cd..bfc6423 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java
@@ -28,9 +28,14 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.DistributedComputingPlatform;
-import org.opengis.metadata.identification.OperationMetadata;
+// Specific to the main branch:
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.opengis.util.CodeList;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.xml.bind.metadata.code.DCPList;
/**
@@ -43,6 +48,14 @@
* {@code └─connectPoint………………………………………………} Handle for accessing the service interface.
* {@code └─linkage…………………………………………………} Location for on-line access using a URL address or similar addressing scheme.</div>
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code OperationMetadata} interface.
+ * </div>
+ *
* <h2>Limitations</h2>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -69,11 +82,12 @@
"dependsOn"
})
@XmlRootElement(name = "SV_OperationMetadata", namespace = Namespaces.SRV)
-public class DefaultOperationMetadata extends ISOMetadata implements OperationMetadata {
+@UML(identifier="SV_OperationMetadata", specification=ISO_19115)
+public class DefaultOperationMetadata extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
- private static final long serialVersionUID = -6120853428175790473L;
+ private static final long serialVersionUID = -3513177609655567627L;
/**
* An unique identifier for this interface.
@@ -84,7 +98,7 @@
* Distributed computing platforms on which the operation has been implemented.
*/
@SuppressWarnings("serial")
- private Collection<DistributedComputingPlatform> distributedComputingPlatforms;
+ private Collection<CodeList<?>> distributedComputingPlatforms;
/**
* Free text description of the intent of the operation and the results of the operation.
@@ -114,7 +128,7 @@
* List of operation that must be completed immediately.
*/
@SuppressWarnings("serial")
- private List<OperationMetadata> dependsOn;
+ private List<DefaultOperationMetadata> dependsOn;
/**
* Constructs an initially empty operation metadata.
@@ -123,76 +137,33 @@
}
/**
- * Constructs a new operation metadata initialized to the specified values.
- *
- * @param operationName an unique identifier for this interface.
- * @param platform distributed computing platforms on which the operation has been implemented.
- * @param connectPoint handle for accessing the service interface.
- */
- public DefaultOperationMetadata(final String operationName,
- final DistributedComputingPlatform platform,
- final OnlineResource connectPoint)
- {
- this.operationName = operationName;
- this.distributedComputingPlatforms = singleton(platform, DistributedComputingPlatform.class);
- this.connectPoints = singleton(connectPoint, OnlineResource.class);
- }
-
- /**
* Constructs a new instance initialized with the values from the specified metadata object.
* This is a <em>shallow</em> copy constructor, because the other metadata contained in the
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(OperationMetadata)
*/
@SuppressWarnings({"unchecked", "rawtypes"})
- public DefaultOperationMetadata(final OperationMetadata object) {
+ public DefaultOperationMetadata(final DefaultOperationMetadata object) {
super(object);
if (object != null) {
this.operationName = object.getOperationName();
- this.distributedComputingPlatforms = copyCollection(object.getDistributedComputingPlatforms(), DistributedComputingPlatform.class);
+ this.distributedComputingPlatforms = copyCollection(object.getDistributedComputingPlatforms(), (Class) CodeList.class);
this.operationDescription = object.getOperationDescription();
this.invocationName = object.getInvocationName();
this.connectPoints = copyCollection(object.getConnectPoints(), OnlineResource.class);
this.parameters = copySet(object.getParameters(), (Class) ParameterDescriptor.class);
- this.dependsOn = copyList(object.getDependsOn(), OperationMetadata.class);
+ this.dependsOn = copyList(object.getDependsOn(), DefaultOperationMetadata.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultOperationMetadata}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultOperationMetadata} instance is created using the
- * {@linkplain #DefaultOperationMetadata(OperationMetadata) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultOperationMetadata castOrCopy(final OperationMetadata object) {
- if (object == null || object instanceof DefaultOperationMetadata) {
- return (DefaultOperationMetadata) object;
- }
- return new DefaultOperationMetadata(object);
- }
-
- /**
* Returns an unique identifier for this interface.
*
* @return an unique identifier for this interface.
*/
- @Override
@XmlElement(name = "operationName", required = true)
+ @UML(identifier="operationName", obligation=MANDATORY, specification=ISO_19115)
public String getOperationName() {
return operationName;
}
@@ -210,21 +181,58 @@
/**
* Returns the distributed computing platforms (DCPs) on which the operation has been implemented.
*
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The element type will be changed to the {@code DistributedComputingPlatform} code list
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return distributed computing platforms on which the operation has been implemented.
*/
- @Override
+ @SuppressWarnings("unchecked")
+ @XmlJavaTypeAdapter(DCPList.class)
@XmlElement(name = "distributedComputingPlatform", required = true)
- public Collection<DistributedComputingPlatform> getDistributedComputingPlatforms() {
- return distributedComputingPlatforms = nonNullCollection(distributedComputingPlatforms, DistributedComputingPlatform.class);
+ @UML(identifier="distributedComputingPlatform", obligation=MANDATORY, specification=ISO_19115)
+ public Collection<CodeList<?>> getDistributedComputingPlatforms() {
+ return distributedComputingPlatforms = nonNullCollection(distributedComputingPlatforms, (Class) CodeList.class);
}
/**
* Sets the distributed computing platforms on which the operation has been implemented.
*
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The element type will be changed to the {@code DistributedComputingPlatform} code list when GeoAPI will provide
+ * it (tentatively in GeoAPI 3.1). In the meantime, users can define their own code list class as below:
+ *
+ * {@snippet lang="java" :
+ * final class UnsupportedCodeList extends CodeList<UnsupportedCodeList> {
+ * private static final List<UnsupportedCodeList> VALUES = new ArrayList<UnsupportedCodeList>();
+ *
+ * // Need to declare at least one code list element.
+ * public static final UnsupportedCodeList MY_CODE_LIST = new UnsupportedCodeList("MY_CODE_LIST");
+ *
+ * private UnsupportedCodeList(String name) {
+ * super(name, VALUES);
+ * }
+ *
+ * public static UnsupportedCodeList valueOf(String code) {
+ * return valueOf(UnsupportedCodeList.class, code);
+ * }
+ *
+ * @Override
+ * public UnsupportedCodeList[] family() {
+ * synchronized (VALUES) {
+ * return VALUES.toArray(new UnsupportedCodeList[VALUES.size()]);
+ * }
+ * }
+ * }
+ * }
+ * </div>
+ *
* @param newValues the new distributed computing platforms on which the operation has been implemented.
*/
- public void setDistributedComputingPlatforms(final Collection<? extends DistributedComputingPlatform> newValues) {
- distributedComputingPlatforms = writeCollection(newValues, distributedComputingPlatforms, DistributedComputingPlatform.class);
+ @SuppressWarnings("unchecked")
+ public void setDistributedComputingPlatforms(final Collection<? extends CodeList<?>> newValues) {
+ distributedComputingPlatforms = writeCollection(newValues, distributedComputingPlatforms, (Class) CodeList.class);
}
/**
@@ -232,8 +240,8 @@
*
* @return free text description of the intent of the operation and the results of the operation, or {@code null} if none.
*/
- @Override
@XmlElement(name = "operationDescription")
+ @UML(identifier="operationDescription", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getOperationDescription() {
return operationDescription;
}
@@ -254,8 +262,8 @@
* @return the name used to invoke this interface within the context of the distributed computing platforms,
* or {@code null} if none.
*/
- @Override
@XmlElement(name = "invocationName")
+ @UML(identifier="invocationName", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getInvocationName() {
return invocationName;
}
@@ -275,8 +283,8 @@
*
* @return handle for accessing the service interface.
*/
- @Override
@XmlElement(name = "connectPoint", required = true)
+ @UML(identifier="connectPoint", obligation=MANDATORY, specification=ISO_19115)
public Collection<OnlineResource> getConnectPoints() {
return connectPoints = nonNullCollection(connectPoints, OnlineResource.class);
}
@@ -299,9 +307,9 @@
*
* @return the parameters that are required for this interface, or an empty collection if none.
*/
- @Override
@XmlElement(name = "parameter")
@SuppressWarnings({"unchecked", "rawtypes"})
+ @UML(identifier="parameters", obligation=OPTIONAL, specification=ISO_19115)
public Collection<ParameterDescriptor<?>> getParameters() {
return parameters = nonNullCollection(parameters, (Class) ParameterDescriptor.class);
}
@@ -319,20 +327,30 @@
/**
* Returns the list of operation that must be completed immediately before current operation is invoked.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return list of operation that must be completed immediately, or an empty list if none.
*/
- @Override
@XmlElement(name = "dependsOn")
- public List<OperationMetadata> getDependsOn() {
- return dependsOn = nonNullList(dependsOn, OperationMetadata.class);
+ @UML(identifier="dependsOn", obligation=OPTIONAL, specification=ISO_19115)
+ public List<DefaultOperationMetadata> getDependsOn() {
+ return dependsOn = nonNullList(dependsOn, DefaultOperationMetadata.class);
}
/**
* Sets the list of operation that must be completed before current operation is invoked.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new list of operation.
*/
- public void setDependsOn(final List<? extends OperationMetadata> newValues) {
- dependsOn = writeList(newValues, dependsOn, OperationMetadata.class);
+ public void setDependsOn(final List<? extends DefaultOperationMetadata> newValues) {
+ dependsOn = writeList(newValues, dependsOn, DefaultOperationMetadata.class);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultResolution.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultResolution.java
index 30eeff3..5d040dd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultResolution.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultResolution.java
@@ -32,6 +32,11 @@
import org.apache.sis.util.resources.Messages;
import static org.apache.sis.metadata.privy.ImplementationHelper.ensurePositive;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Level of detail expressed as a scale factor or a ground distance.
@@ -166,13 +171,13 @@
super(object);
if (object != null) {
for (byte p=SCALE; p<=TEXT; p++) {
- final Object c;
+ Object c = null;
switch (p) {
case SCALE: c = object.getEquivalentScale(); break;
- case DISTANCE: c = object.getDistance(); break;
- case VERTICAL: c = object.getVertical(); break;
- case ANGULAR: c = object.getAngularDistance(); break;
- case TEXT: c = object.getLevelOfDetail(); break;
+ case DISTANCE: c = object.getDistance(); break;
+ case VERTICAL: if (c instanceof DefaultResolution) c = ((DefaultResolution) object).getVertical(); break;
+ case ANGULAR: if (c instanceof DefaultResolution) c = ((DefaultResolution) object).getAngularDistance(); break;
+ case TEXT: if (c instanceof DefaultResolution) c = ((DefaultResolution) object).getLevelOfDetail(); break;
default: throw new AssertionError(p);
}
if (c != null) {
@@ -289,9 +294,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "vertical")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="vertical", obligation=CONDITIONAL, specification=ISO_19115)
@ValueRange(minimum=0, isMinIncluded=false)
public Double getVertical() {
return (property == VERTICAL) ? (Double) value : null;
@@ -322,9 +327,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "angularDistance")
@XmlJavaTypeAdapter(GO_Real.Since2014.class)
+ @UML(identifier="angularDistance", obligation=CONDITIONAL, specification=ISO_19115)
@ValueRange(minimum=0, isMinIncluded=false)
public Double getAngularDistance() {
return (property == ANGULAR) ? (Double) value : null;
@@ -355,9 +360,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "levelOfDetail")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="levelOfDetail", obligation=CONDITIONAL, specification=ISO_19115)
public InternationalString getLevelOfDetail() {
return (property == TEXT) ? (InternationalString) value : null;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java
index 1e86ce0..bf87bb7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java
@@ -29,11 +29,15 @@
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.bind.FilterByVersion;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.CoupledResource;
-import org.opengis.metadata.identification.CouplingType;
-import org.opengis.metadata.identification.OperationChainMetadata;
-import org.opengis.metadata.identification.OperationMetadata;
+// Specific to the main branch:
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.opengis.util.CodeList;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.xml.bind.metadata.code.SV_CouplingType;
/**
@@ -115,13 +119,13 @@
/**
* Type of coupling between service and associated data (if exist).
*/
- private CouplingType couplingType;
+ private CodeList<?> couplingType;
/**
* Further description of the data coupling in the case of tightly coupled services.
*/
@SuppressWarnings("serial")
- private Collection<CoupledResource> coupledResources;
+ private Collection<DefaultCoupledResource> coupledResources;
/**
* References to the resource on which the service operates.
@@ -145,7 +149,7 @@
* Information about the operations that comprise the service.
*/
@SuppressWarnings("serial")
- private Collection<OperationMetadata> containsOperations;
+ private Collection<DefaultOperationMetadata> containsOperations;
/**
* Information on the resources that the service operates on.
@@ -157,7 +161,7 @@
* Information about the chain applied by the service.
*/
@SuppressWarnings("serial")
- private Collection<OperationChainMetadata> containsChain;
+ private Collection<DefaultOperationChainMetadata> containsChain;
/**
* Constructs an initially empty service identification.
@@ -191,18 +195,19 @@
*/
public DefaultServiceIdentification(final ServiceIdentification object) {
super(object);
- if (object != null) {
- serviceType = object.getServiceType();
- serviceTypeVersions = copyCollection(object.getServiceTypeVersions(), String.class);
- accessProperties = object.getAccessProperties();
- couplingType = object.getCouplingType();
- coupledResources = copyCollection(object.getCoupledResources(), CoupledResource.class);
- operatedDatasets = copyCollection(object.getOperatedDatasets(), Citation.class);
- profiles = copyCollection(object.getProfiles(), Citation.class);
- serviceStandards = copyCollection(object.getServiceStandards(), Citation.class);
- containsOperations = copyCollection(object.getContainsOperations(), OperationMetadata.class);
- operatesOn = copyCollection(object.getOperatesOn(), DataIdentification.class);
- containsChain = copyCollection(object.getContainsChain(), OperationChainMetadata.class);
+ if (object instanceof DefaultServiceIdentification) {
+ final DefaultServiceIdentification c = (DefaultServiceIdentification) object;
+ serviceType = c.getServiceType();
+ serviceTypeVersions = copyCollection(c.getServiceTypeVersions(), String.class);
+ accessProperties = c.getAccessProperties();
+ couplingType = c.getCouplingType();
+ coupledResources = copyCollection(c.getCoupledResources(), DefaultCoupledResource.class);
+ operatedDatasets = copyCollection(c.getOperatedDatasets(), Citation.class);
+ profiles = copyCollection(c.getProfiles(), Citation.class);
+ serviceStandards = copyCollection(c.getServiceStandards(), Citation.class);
+ containsOperations = copyCollection(c.getContainsOperations(), DefaultOperationMetadata.class);
+ operatesOn = copyCollection(c.getOperatesOn(), DataIdentification.class);
+ containsChain = copyCollection(c.getContainsChain(), DefaultOperationChainMetadata.class);
}
}
@@ -239,8 +244,8 @@
*
* @return a service type name.
*/
- @Override
@XmlElement(name = "serviceType", required = true)
+ @UML(identifier="serviceType", obligation=MANDATORY, specification=ISO_19115)
public GenericName getServiceType() {
return serviceType;
}
@@ -260,8 +265,8 @@
*
* @return the versions of the service.
*/
- @Override
@XmlElement(name = "serviceTypeVersion")
+ @UML(identifier="serviceTypeVersion", obligation=OPTIONAL, specification=ISO_19115)
public Collection<String> getServiceTypeVersions() {
return serviceTypeVersions = nonNullCollection(serviceTypeVersions, String.class);
}
@@ -282,8 +287,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "accessProperties")
+ @UML(identifier="accessProperties", obligation=OPTIONAL, specification=ISO_19115)
public StandardOrderProcess getAccessProperties() {
return accessProperties;
@@ -304,20 +309,55 @@
/**
* Returns type of coupling between service and associated data (if exist).
*
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The return type will be changed to the {@code CouplingType} code list
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return type of coupling between service and associated data, or {@code null} if none.
*/
- @Override
+ @XmlJavaTypeAdapter(SV_CouplingType.class)
@XmlElement(name = "couplingType")
- public CouplingType getCouplingType() {
+ @UML(identifier="couplingType", obligation=CONDITIONAL, specification=ISO_19115)
+ public CodeList<?> getCouplingType() {
return couplingType;
}
/**
* Sets the type of coupling between service and associated data.
*
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The argument type will be changed to the {@code CouplingType} code list when GeoAPI will provide it
+ * (tentatively in GeoAPI 3.1). In the meantime, users can define their own code list class as below:
+ *
+ * {@snippet lang="java" :
+ * final class UnsupportedCodeList extends CodeList<UnsupportedCodeList> {
+ * private static final List<UnsupportedCodeList> VALUES = new ArrayList<UnsupportedCodeList>();
+ *
+ * // Need to declare at least one code list element.
+ * public static final UnsupportedCodeList MY_CODE_LIST = new UnsupportedCodeList("MY_CODE_LIST");
+ *
+ * private UnsupportedCodeList(String name) {
+ * super(name, VALUES);
+ * }
+ *
+ * public static UnsupportedCodeList valueOf(String code) {
+ * return valueOf(UnsupportedCodeList.class, code);
+ * }
+ *
+ * @Override
+ * public UnsupportedCodeList[] family() {
+ * synchronized (VALUES) {
+ * return VALUES.toArray(new UnsupportedCodeList[VALUES.size()]);
+ * }
+ * }
+ * }
+ * }
+ * </div>
+ *
* @param newValue the new type of coupling between service and associated data.
*/
- public void setCouplingType(final CouplingType newValue) {
+ public void setCouplingType(final CodeList<?> newValue) {
checkWritePermission(couplingType);
couplingType = newValue;
}
@@ -325,21 +365,31 @@
/**
* Returns further description(s) of the data coupling in the case of tightly coupled services.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code CoupledResource} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return further description(s) of the data coupling in the case of tightly coupled services.
*/
- @Override
@XmlElement(name = "coupledResource")
- public Collection<CoupledResource> getCoupledResources() {
- return coupledResources = nonNullCollection(coupledResources, CoupledResource.class);
+ @UML(identifier="coupledResource", obligation=CONDITIONAL, specification=ISO_19115)
+ public Collection<DefaultCoupledResource> getCoupledResources() {
+ return coupledResources = nonNullCollection(coupledResources, DefaultCoupledResource.class);
}
/**
* Sets further description(s) of the data coupling in the case of tightly coupled services.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code CoupledResource} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new further description(s) of the data coupling.
*/
- public void setCoupledResources(final Collection<? extends CoupledResource> newValues) {
- coupledResources = writeCollection(newValues, coupledResources, CoupledResource.class);
+ public void setCoupledResources(final Collection<? extends DefaultCoupledResource> newValues) {
+ coupledResources = writeCollection(newValues, coupledResources, DefaultCoupledResource.class);
}
/**
@@ -349,8 +399,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="operatedDataset", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getOperatedDatasets() {
return operatedDatasets = nonNullCollection(operatedDatasets, Citation.class);
}
@@ -373,8 +423,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="profile", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getProfiles() {
return profiles = nonNullCollection(profiles, Citation.class);
}
@@ -395,8 +445,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="serviceStandard", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getServiceStandards() {
return serviceStandards = nonNullCollection(serviceStandards, Citation.class);
}
@@ -415,21 +465,31 @@
/**
* Provides information about the operations that comprise the service.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information about the operations that comprise the service.
*/
- @Override
@XmlElement(name = "containsOperations")
- public Collection<OperationMetadata> getContainsOperations() {
- return containsOperations = nonNullCollection(containsOperations, OperationMetadata.class);
+ @UML(identifier="containsOperations", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultOperationMetadata> getContainsOperations() {
+ return containsOperations = nonNullCollection(containsOperations, DefaultOperationMetadata.class);
}
/**
* Sets information(s) about the operations that comprise the service.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new information(s) about the operations that comprise the service.
*/
- public void setContainsOperations(final Collection<? extends OperationMetadata> newValues) {
- containsOperations = writeCollection(newValues, containsOperations, OperationMetadata.class);
+ public void setContainsOperations(final Collection<? extends DefaultOperationMetadata> newValues) {
+ containsOperations = writeCollection(newValues, containsOperations, DefaultOperationMetadata.class);
}
/**
@@ -437,8 +497,8 @@
*
* @return information on the resources that the service operates on.
*/
- @Override
@XmlElement(name = "operatesOn")
+ @UML(identifier="operatesOn", obligation=OPTIONAL, specification=ISO_19115)
public Collection<DataIdentification> getOperatesOn() {
return operatesOn = nonNullCollection(operatesOn, DataIdentification.class);
}
@@ -455,25 +515,35 @@
/**
* Provides information about the chain applied by the service.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationChainMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return information about the chain applied by the service.
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
- public Collection<OperationChainMetadata> getContainsChain() {
- return containsChain = nonNullCollection(containsChain, OperationChainMetadata.class);
+ @UML(identifier="containsChain", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultOperationChainMetadata> getContainsChain() {
+ return containsChain = nonNullCollection(containsChain, DefaultOperationChainMetadata.class);
}
/**
* Sets the information about the chain applied by the service.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code OperationChainMetadata} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues the new information about the chain applied by the service.
*
* @since 0.5
*/
- public void setContainsChain(final Collection<? extends OperationChainMetadata> newValues) {
- containsChain = writeCollection(newValues, containsChain, OperationChainMetadata.class);
+ public void setContainsChain(final Collection<? extends DefaultOperationChainMetadata> newValues) {
+ containsChain = writeCollection(newValues, containsChain, DefaultOperationChainMetadata.class);
}
@@ -513,7 +583,7 @@
}
@XmlElement(name = "containsChain")
- private Collection<OperationChainMetadata> getOperationChain() {
+ private Collection<DefaultOperationChainMetadata> getOperationChain() {
return FilterByVersion.CURRENT_METADATA.accept() ? getContainsChain() : null;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java
index 5e0330e..7aec6bf 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java
@@ -41,6 +41,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Brief description of ways in which the resource(s) is/are currently or has been used.
@@ -165,12 +170,20 @@
super(object);
if (object != null) {
specificUsage = object.getSpecificUsage();
- usageDates = copyCollection(object.getUsageDates(), TemporalPrimitive.class);
userDeterminedLimitations = object.getUserDeterminedLimitations();
userContactInfo = copyCollection(object.getUserContactInfo(), ResponsibleParty.class);
- responses = copyCollection(object.getResponses(), InternationalString.class);
- additionalDocumentation = copyCollection(object.getAdditionalDocumentation(), Citation.class);
- identifiedIssues = copyCollection(object.getIdentifiedIssues(), Citation.class);
+ if (object instanceof DefaultUsage) {
+ final var c = (DefaultUsage) object;
+ usageDates = copyCollection(c.getUsageDates(), TemporalPrimitive.class);
+ responses = copyCollection(c.getResponses(), InternationalString.class);
+ additionalDocumentation = copyCollection(c.getAdditionalDocumentation(), Citation.class);
+ identifiedIssues = copyCollection(c.getIdentifiedIssues(), Citation.class);
+ } else {
+ Date t = object.getUsageDate();
+ if (t != null) {
+ usageDates = List.of(TemporalObjects.createInstant(TemporalDate.toTemporal(t)));
+ }
+ }
}
}
@@ -266,9 +279,9 @@
*
* @since 1.5
*/
- @Override
@XmlElement(name = "usageDateTime")
@XmlJavaTypeAdapter(TM_Primitive.Since2014.class)
+ @UML(identifier="usageDateTime", obligation=OPTIONAL, specification=ISO_19115)
public Collection<TemporalPrimitive> getUsageDates() {
return usageDates = nonNullCollection(usageDates, TemporalPrimitive.class);
}
@@ -358,8 +371,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="response", obligation=OPTIONAL, specification=ISO_19115)
public Collection<InternationalString> getResponses() {
return responses = nonNullCollection(responses, InternationalString.class);
}
@@ -382,8 +395,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="additionalDocumentation", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getAdditionalDocumentation() {
return additionalDocumentation = nonNullCollection(additionalDocumentation, Citation.class);
}
@@ -407,8 +420,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="identifiedIssues", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getIdentifiedIssues() {
return identifiedIssues = nonNullCollection(identifiedIssues, Citation.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/OperationName.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/OperationName.java
index 110dcdf..31e09be 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/OperationName.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/OperationName.java
@@ -21,52 +21,32 @@
import java.util.Collection;
import org.apache.sis.util.privy.Strings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Collections;
-import java.io.Serializable;
-import org.opengis.metadata.citation.OnlineResource;
-import org.opengis.metadata.identification.CoupledResource;
-import org.opengis.metadata.identification.DistributedComputingPlatform;
-import org.opengis.metadata.identification.OperationMetadata;
-
/**
- * An {@code OperationMetadata} placeholder to be replaced later by a reference to another {@link OperationMetadata}.
+ * An {@code OperationMetadata} placeholder to be replaced later by a reference to another {@code OperationMetadata}.
* This temporary place holder is used when the operation name is unmarshalled before the actual operation definition.
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class OperationName implements OperationMetadata, Serializable {
+final class OperationName extends DefaultOperationMetadata {
/**
* For cross-version compatibility.
*/
- private static final long serialVersionUID = -7958898214063034276L;
-
- /**
- * The operation name.
- */
- private final String operationName;
+ private static final long serialVersionUID = 7221543581387125873L;
/**
* Creates a new placeholder for the operation of the given name.
*/
OperationName(final String operationName) {
- this.operationName = operationName;
+ setOperationName(operationName);
}
/**
- * Returns the operation name.
- */
- @Override public String getOperationName() {return operationName;}
- @Override public Collection<DistributedComputingPlatform> getDistributedComputingPlatforms() {return Collections.emptySet();}
- @Override public Collection<OnlineResource> getConnectPoints() {return Collections.emptySet();}
-
- /**
* Returns a string representation of this placeholder.
*/
@Override
public String toString() {
- return Strings.bracket("OperationMetadata", operationName);
+ return Strings.bracket("OperationMetadata", getOperationName());
}
/**
@@ -79,25 +59,23 @@
* <p>This method is invoked at unmarshalling time for resolving the {@code OperationMetadata} instance which
* were identified only by a name in a {@code <srv:operationName>} element.</p>
*/
- static void resolve(final Collection<OperationMetadata> containsOperations, final Collection<CoupledResource> coupledResources) {
- final Map<String,OperationMetadata> byName = new HashMap<>();
- for (final OperationMetadata operation : containsOperations) {
+ static void resolve(final Collection<DefaultOperationMetadata> containsOperations, final Collection<DefaultCoupledResource> coupledResources) {
+ final Map<String,DefaultOperationMetadata> byName = new HashMap<>();
+ for (final DefaultOperationMetadata operation : containsOperations) {
add(byName, operation.getOperationName(), operation);
}
- for (final CoupledResource resource : coupledResources) {
- if (resource instanceof DefaultCoupledResource) {
- OperationMetadata operation = resource.getOperation();
- if (operation instanceof OperationName) {
- final String name = operation.getOperationName();
+ for (final DefaultCoupledResource resource : coupledResources) {
+ DefaultOperationMetadata operation = resource.getOperation();
+ if (operation instanceof OperationName) {
+ final String name = operation.getOperationName();
+ operation = byName.get(name);
+ if (operation == null) {
operation = byName.get(name);
if (operation == null) {
- operation = byName.get(name);
- if (operation == null) {
- continue;
- }
+ continue;
}
- ((DefaultCoupledResource) resource).setOperation(operation);
}
+ resource.setOperation(operation);
}
}
}
@@ -106,9 +84,9 @@
* Adds the given operation in the given map under the given name. If an entry already exists for the given name,
* then this method sets the value to {@code null} for meaning that we have duplicated values for that name.
*/
- private static void add(final Map<String,OperationMetadata> byName, final String name, final OperationMetadata operation) {
+ private static void add(final Map<String,DefaultOperationMetadata> byName, final String name, final DefaultOperationMetadata operation) {
final boolean exists = byName.containsKey(name);
- final OperationMetadata previous = byName.put(name, operation);
+ final DefaultOperationMetadata previous = byName.put(name, operation);
if (previous != operation && (previous != null || exists)) {
byName.put(name, null); // Mark the entry as duplicated.
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/package-info.java
index 6db83b5..e21af16 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/package-info.java
@@ -47,8 +47,8 @@
* {@code ├─} {@linkplain org.opengis.metadata.identification.AssociationType Association type}<br>
* {@code ├─} {@linkplain org.opengis.metadata.identification.InitiativeType Initiative type}<br>
* {@code ├─} {@linkplain org.opengis.metadata.identification.TopicCategory Topic category}<br>
- * {@code ├─} {@linkplain org.opengis.metadata.identification.CouplingType Coupling type}<br>
- * {@code └─} {@linkplain org.opengis.metadata.identification.DistributedComputingPlatform Distributed computing platform}<br>
+ * {@code ├─} Coupling type}<br>
+ * {@code └─} Distributed computing platform}<br>
* </td><td class="sep" style="width: 50%; white-space: nowrap">
* {@linkplain org.apache.sis.metadata.iso.identification.AbstractIdentification Identification} «abstract»<br>
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.identification.DefaultResolution Resolution}<br>
@@ -63,12 +63,12 @@
* {@code └─} {@linkplain org.opengis.metadata.identification.InitiativeType Initiative type} «code list»<br>
* {@linkplain org.apache.sis.metadata.iso.identification.DefaultDataIdentification Data identification}<br>
* {@linkplain org.apache.sis.metadata.iso.identification.DefaultServiceIdentification Service identification}<br>
- * {@code ├─} {@linkplain org.opengis.metadata.identification.CouplingType Coupling type} «code list»<br>
+ * {@code ├─} Coupling type} «code list»<br>
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.identification.DefaultCoupledResource Coupled resource}<br>
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.identification.DefaultOperationMetadata Operation metadata}<br>
- * {@code │ ├─} {@linkplain org.opengis.metadata.identification.DistributedComputingPlatform Distributed computing platform} «code list»<br>
+ * {@code │ ├─} Distributed computing platform} «code list»<br>
* {@code │ └─} {@linkplain org.apache.sis.parameter.DefaultParameterDescriptor Parameter descriptor}<br>
- * {@code │ └─} {@linkplain org.opengis.parameter.ParameterDirection Parameter direction} «enum»<br>
+ * {@code │ └─} Parameter direction} «enum»<br>
* {@code └─} {@linkplain org.apache.sis.metadata.iso.identification.DefaultOperationChainMetadata Operation chain metadata}<br>
* </td></tr></table>
*
@@ -115,12 +115,10 @@
@XmlJavaTypeAdapter(CI_Citation.class),
@XmlJavaTypeAdapter(CI_OnlineResource.class),
@XmlJavaTypeAdapter(CI_ResponsibleParty.class),
- @XmlJavaTypeAdapter(DCPList.class),
@XmlJavaTypeAdapter(EX_Extent.class),
@XmlJavaTypeAdapter(GO_DateTime.class),
@XmlJavaTypeAdapter(GO_GenericName.class),
@XmlJavaTypeAdapter(MD_AggregateInformation.class),
- @XmlJavaTypeAdapter(MD_AssociatedResource.class),
@XmlJavaTypeAdapter(MD_BrowseGraphic.class),
@XmlJavaTypeAdapter(MD_CharacterSetCode.class),
@XmlJavaTypeAdapter(MD_Constraints.class),
@@ -138,7 +136,6 @@
@XmlJavaTypeAdapter(MD_TopicCategoryCode.class),
@XmlJavaTypeAdapter(MD_Usage.class),
@XmlJavaTypeAdapter(SV_CoupledResource.class),
- @XmlJavaTypeAdapter(SV_CouplingType.class),
@XmlJavaTypeAdapter(SV_OperationMetadata.class),
@XmlJavaTypeAdapter(SV_OperationChainMetadata.class),
@XmlJavaTypeAdapter(SV_Parameter.class),
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultLineage.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultLineage.java
index 4faa4c3..e448b84 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultLineage.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultLineage.java
@@ -32,8 +32,11 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.metadata.MD_Scope;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -144,10 +147,12 @@
super(object);
if (object != null) {
statement = object.getStatement();
- scope = object.getScope();
- additionalDocumentation = copyCollection(object.getAdditionalDocumentation(), Citation.class);
processSteps = copyCollection(object.getProcessSteps(), ProcessStep.class);
sources = copyCollection(object.getSources(), Source.class);
+ if (object instanceof DefaultLineage) {
+ scope = ((DefaultLineage) object).getScope();
+ additionalDocumentation = copyCollection(((DefaultLineage) object).getAdditionalDocumentation(), Citation.class);
+ }
}
}
@@ -206,9 +211,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "scope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ @UML(identifier="scope", obligation=OPTIONAL, specification=ISO_19115)
public Scope getScope() {
return scope;
}
@@ -232,8 +237,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="additionalDocumentation", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getAdditionalDocumentation() {
return additionalDocumentation = nonNullCollection(additionalDocumentation, Citation.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
index a360ecc..75d222d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
@@ -43,8 +43,11 @@
import org.opengis.metadata.citation.ResponsibleParty;
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -188,12 +191,15 @@
rationale = object.getRationale();
stepDateTime = toInstant(object.getDate());
processors = copyCollection(object.getProcessors(), ResponsibleParty.class);
- references = copyCollection(object.getReferences(), Citation.class);
sources = copyCollection(object.getSources(), Source.class);
- scope = object.getScope();
outputs = copyCollection(object.getOutputs(), Source.class);
processingInformation = object.getProcessingInformation();
reports = copyCollection(object.getReports(), ProcessStepReport.class);
+ if (object instanceof DefaultProcessStep) {
+ final var c = (DefaultProcessStep) object;
+ references = copyCollection(c.getReferences(), Citation.class);
+ scope = c.getScope();
+ }
}
}
@@ -271,7 +277,6 @@
*
* @since 1.0
*/
- @Override
@XmlElement(name = "stepDateTime")
@XmlJavaTypeAdapter(TM_Primitive.Since2014.class)
public TemporalPrimitive getStepDateTime() {
@@ -303,9 +308,6 @@
public Date getDate() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
Date date = TemporalObjects.getAnyDate(getStepDateTime());
- if (date == null) {
- date = ProcessStep.super.getDate();
- }
return date;
}
return null;
@@ -369,8 +371,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="reference", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getReferences() {
return references = nonNullCollection(references, Citation.class);
}
@@ -393,9 +395,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "scope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ @UML(identifier="scope", obligation=OPTIONAL, specification=ISO_19115)
public Scope getScope() {
return scope;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultSource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultSource.java
index f1b4889..8eb22bb 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultSource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultSource.java
@@ -45,8 +45,12 @@
import org.apache.sis.metadata.internal.Dependencies;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -190,14 +194,19 @@
super(object);
if (object != null) {
description = object.getDescription();
- sourceSpatialResolution = object.getSourceSpatialResolution();
sourceReferenceSystem = object.getSourceReferenceSystem();
sourceCitation = object.getSourceCitation();
- sourceMetadata = copyCollection(object.getSourceMetadata(), Citation.class);
- scope = object.getScope();
sourceSteps = copyCollection(object.getSourceSteps(), ProcessStep.class);
processedLevel = object.getProcessedLevel();
resolution = object.getResolution();
+ if (object instanceof DefaultSource) {
+ sourceSpatialResolution = ((DefaultSource) object).getSourceSpatialResolution();
+ sourceMetadata = copyCollection(((DefaultSource) object).getSourceMetadata(), Citation.class);
+ scope = ((DefaultSource) object).getScope();
+ } else {
+ setScaleDenominator(object.getScaleDenominator());
+ setSourceExtents(object.getSourceExtents());
+ }
}
}
@@ -254,9 +263,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "sourceSpatialResolution")
@XmlJavaTypeAdapter(MD_Resolution.Since2014.class)
+ @UML(identifier="sourceSpatialResolution", obligation=OPTIONAL, specification=ISO_19115)
public Resolution getSourceSpatialResolution() {
return sourceSpatialResolution;
}
@@ -376,8 +385,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="sourceMetadata", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Citation> getSourceMetadata() {
return sourceMetadata = nonNullCollection(sourceMetadata, Citation.class);
}
@@ -401,9 +410,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "scope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ @UML(identifier="scope", obligation=CONDITIONAL, specification=ISO_19115)
public Scope getScope() {
return scope;
}
@@ -441,7 +450,7 @@
scope = new DefaultScope(scope);
this.scope = scope;
} else {
- return Collections.unmodifiableCollection(scope.getExtents());
+ return Collections.singleton(scope.getExtent());
}
}
return ((DefaultScope) scope).getExtents();
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java
index d24789d..b3272dd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java
@@ -34,6 +34,7 @@
* defined by ISO 19115-3:2016 schema.
*/
@Override
+ @SuppressWarnings("deprecation")
public AttributeType unmarshal(GO_CharacterString value) {
return new LegacyFeatureType(LegacyFeatureType.ADAPTER.unmarshal(value));
}
@@ -43,6 +44,7 @@
* {@link DefaultScopeDescription}.
*/
@Override
+ @SuppressWarnings("deprecation")
public GO_CharacterString marshal(AttributeType value) {
return LegacyFeatureType.ADAPTER.marshal(LegacyFeatureType.wrap(value));
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
index 252077d..92be00c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
@@ -43,8 +43,11 @@
import org.opengis.metadata.citation.ResponsibleParty;
import org.opengis.temporal.PeriodDuration;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
/**
@@ -91,6 +94,11 @@
private static final long serialVersionUID = -7934472150551882812L;
/**
+ * New code list item defined in ISO 19115:2014.
+ */
+ private static final DateType NEXT_UPDATE = DateType.valueOf("NEXT_UPDATE");
+
+ /**
* Frequency with which changes and additions are made to the resource after the
* initial resource is completed.
*/
@@ -156,11 +164,18 @@
super(object);
if (object != null) {
maintenanceAndUpdateFrequency = object.getMaintenanceAndUpdateFrequency();
- maintenanceDates = copyCollection(object.getMaintenanceDates(), CitationDate.class);
userDefinedMaintenanceFrequency = object.getUserDefinedMaintenanceFrequency();
- maintenanceScopes = copyCollection(object.getMaintenanceScopes(), Scope.class);
maintenanceNotes = copyCollection(object.getMaintenanceNotes(), InternationalString.class);
- contacts = copyCollection(object.getContacts(), ResponsibleParty.class);
+ if (object instanceof DefaultMaintenanceInformation) {
+ final DefaultMaintenanceInformation c = (DefaultMaintenanceInformation) object;
+ maintenanceDates = copyCollection(c.getMaintenanceDates(), CitationDate.class);
+ maintenanceScopes = copyCollection(c.getMaintenanceScopes(), Scope.class);
+ contacts = copyCollection(c.getContacts(), ResponsibleParty.class);
+ } else {
+ setDateOfNextUpdate(object.getDateOfNextUpdate());
+ setUpdateScopes(object.getUpdateScopes());
+ setUpdateScopeDescriptions(object.getUpdateScopeDescriptions());
+ }
}
}
@@ -219,8 +234,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="maintenanceDate", obligation=OPTIONAL, specification=ISO_19115)
public Collection<CitationDate> getMaintenanceDates() {
return maintenanceDates = nonNullCollection(maintenanceDates, CitationDate.class);
}
@@ -243,8 +258,8 @@
* @return scheduled revision date, or {@code null}.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getMaintenanceDates()} in order to enable inclusion
- * of a {@link DateType} to describe the type of the date. Note that {@link DateType#NEXT_UPDATE}
- * was added to that code list.
+ * of a {@link DateType} to describe the type of the date. The associated date type is
+ * {@code DateType.valueOf("NEXT_UPDATE")}.
*/
@Override
@Deprecated(since="1.0")
@@ -253,9 +268,9 @@
public Date getDateOfNextUpdate() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
final Collection<CitationDate> dates = getMaintenanceDates();
- if (dates != null) { // May be null on XML marshalling.
+ if (dates != null) { // May be null on XML marshalling.
for (final CitationDate date : dates) {
- if (date.getDateType() == DateType.NEXT_UPDATE) {
+ if (date.getDateType() == NEXT_UPDATE) {
return date.getDate();
}
}
@@ -278,7 +293,7 @@
final Iterator<CitationDate> it = dates.iterator();
while (it.hasNext()) {
final CitationDate date = it.next();
- if (date.getDateType() == DateType.NEXT_UPDATE) {
+ if (date.getDateType() == NEXT_UPDATE) {
if (newValue == null) {
it.remove();
return;
@@ -291,7 +306,7 @@
}
if (newValue != null) {
@SuppressWarnings("removal")
- final var date = new DefaultCitationDate(newValue, DateType.NEXT_UPDATE);
+ final var date = new DefaultCitationDate(newValue, NEXT_UPDATE);
if (dates != null) {
dates.add(date);
} else {
@@ -339,8 +354,8 @@
*
* @since 0.5
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="maintenanceScope", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Scope> getMaintenanceScopes() {
return maintenanceScopes = nonNullCollection(maintenanceScopes, Scope.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultScope.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultScope.java
index a58349d..f576f30 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultScope.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultScope.java
@@ -26,8 +26,14 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+import org.apache.sis.metadata.internal.Dependencies;
+import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
+import org.apache.sis.util.privy.CollectionsExt;
/**
@@ -117,8 +123,12 @@
super(object);
if (object != null) {
level = object.getLevel();
- extents = copyCollection(object.getExtents(), Extent.class);
levelDescription = copyCollection(object.getLevelDescription(), ScopeDescription.class);
+ if (object instanceof DefaultScope) {
+ extents = copyCollection(((DefaultScope) object).getExtents(), Extent.class);
+ } else {
+ extents = singleton(object.getExtent(), Extent.class);
+ }
}
}
@@ -175,8 +185,8 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "extent")
+ @UML(identifier="extent", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Extent> getExtents() {
return extents = nonNullCollection(extents, Extent.class);
}
@@ -193,6 +203,34 @@
}
/**
+ * Information about the spatial, vertical and temporal extent of the data specified by the scope.
+ * This method fetches the value from the {@linkplain #getExtents() extents} collection.
+ *
+ * @return Information about the extent of the data, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #getExtents()}.
+ */
+ @Override
+ @Deprecated
+ @Dependencies("getExtents")
+ public Extent getExtent() {
+ return LegacyPropertyAdapter.getSingleton(getExtents(), Extent.class, null, DefaultScope.class, "getExtent");
+ }
+
+ /**
+ * Sets information about the spatial, vertical and temporal extent of the data specified by the scope.
+ * This method stores the value in the {@linkplain #setExtents(Collection) extents} collection.
+ *
+ * @param newValue The new extent.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #setExtents(Collection)}.
+ */
+ @Deprecated
+ public void setExtent(final Extent newValue) {
+ setExtents(CollectionsExt.singletonOrEmpty(newValue));
+ }
+
+ /**
* Returns detailed descriptions about the level of the data specified by the scope.
*
* @return detailed description about the level of the data.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java
index 2bf7d32..34605c7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java
@@ -34,6 +34,7 @@
* defined by ISO 19115-3:2016 schema.
*/
@Override
+ @SuppressWarnings("deprecation")
public FeatureType unmarshal(GO_CharacterString value) {
return new LegacyFeatureType(LegacyFeatureType.ADAPTER.unmarshal(value));
}
@@ -43,6 +44,7 @@
* {@link DefaultScopeDescription}.
*/
@Override
+ @SuppressWarnings("deprecation")
public GO_CharacterString marshal(FeatureType value) {
return LegacyFeatureType.ADAPTER.marshal(LegacyFeatureType.wrap(value));
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/package-info.java
index e66ec57..c5774b8 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/package-info.java
@@ -41,8 +41,8 @@
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.DefaultExtendedElementInformation Extended element information}<br>
* {@code └─} {@linkplain org.apache.sis.metadata.iso.DefaultIdentifier Identifier}<br>
* {@linkplain org.opengis.util.CodeList Code list}<br>
- * {@code ├─} {@linkplain org.opengis.metadata.Datatype Data type}<br>
- * {@code └─} {@linkplain org.opengis.annotation.Obligation Obligation}<br>
+ * {@code ├─} {@linkplain org.opengis.metadata.Datatype Data type}<br>
+ * {@code └─} {@linkplain org.opengis.metadata.Obligation Obligation}<br>
* </td><td class="sep" style="width: 50%; white-space: nowrap">
* {@linkplain org.apache.sis.metadata.iso.DefaultMetadata Metadata}<br>
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.DefaultMetadataScope Metadata scope}<br>
@@ -51,7 +51,7 @@
* {@code ├─} {@linkplain org.apache.sis.metadata.iso.DefaultMetadataExtensionInformation Metadata extension information}<br>
* {@code │ └─} {@linkplain org.apache.sis.metadata.iso.DefaultExtendedElementInformation Extended element information}<br>
* {@code │ ├─} {@linkplain org.opengis.metadata.Datatype Data type} «code list»<br>
- * {@code │ └─} {@linkplain org.opengis.annotation.Obligation Obligation} «code list»<br>
+ * {@code │ └─} {@linkplain org.opengis.metadata.Obligation Obligation} «code list»<br>
* {@code └─} {@linkplain org.apache.sis.metadata.iso.DefaultIdentifier Identifier}<br>
* </td></tr></table>
*
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractDataEvaluation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractDataEvaluation.java
index 8ff2b9c..32bb11b 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractDataEvaluation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractDataEvaluation.java
@@ -20,16 +20,13 @@
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.DataEvaluation;
-import org.opengis.metadata.quality.FullInspection;
-import org.opengis.metadata.quality.IndirectEvaluation;
-import org.opengis.metadata.quality.SampleBasedInspection;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Data evaluation method.
- * See the {@link DataEvaluation} GeoAPI interface for more details.
*
* <h2>Limitations</h2>
* <ul>
@@ -52,7 +49,8 @@
DefaultIndirectEvaluation.class,
DefaultSampleBasedInspection.class
})
-public class AbstractDataEvaluation extends DefaultEvaluationMethod implements DataEvaluation {
+@UML(identifier="DQ_DataEvaluation", specification=UNSPECIFIED)
+public class AbstractDataEvaluation extends DefaultEvaluationMethod {
/**
* Serial number for inter-operability with different versions.
*/
@@ -70,49 +68,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(DataEvaluation)
*/
- public AbstractDataEvaluation(final DataEvaluation object) {
+ public AbstractDataEvaluation(final AbstractDataEvaluation object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link IndirectEvaluation},
- * {@link SampleBasedInspection} or {@link FullInspection}, then this method delegates to
- * the {@code castOrCopy(…)} method of the corresponding SIS subclass.
- * Note that if the given object implements more than one of the above-cited interfaces,
- * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code AbstractDataEvaluation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code AbstractDataEvaluation} instance is created using the
- * {@linkplain #AbstractDataEvaluation(DataEvaluation) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static AbstractDataEvaluation castOrCopy(final DataEvaluation object) {
- if (object instanceof FullInspection) {
- return DefaultFullInspection.castOrCopy((FullInspection) object);
- }
- if (object instanceof SampleBasedInspection) {
- return DefaultSampleBasedInspection.castOrCopy((SampleBasedInspection) object);
- }
- if (object instanceof IndirectEvaluation) {
- return DefaultIndirectEvaluation.castOrCopy((IndirectEvaluation) object);
- }
- if (object == null || object instanceof AbstractDataEvaluation) {
- return (AbstractDataEvaluation) object;
- }
- return new AbstractDataEvaluation(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractElement.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractElement.java
index 1042670..8db20c8 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractElement.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractElement.java
@@ -31,12 +31,12 @@
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.quality.Result;
import org.opengis.metadata.quality.Element;
-import org.opengis.metadata.quality.Usability;
import org.opengis.metadata.quality.Completeness;
import org.opengis.metadata.quality.ThematicAccuracy;
import org.opengis.metadata.quality.PositionalAccuracy;
import org.opengis.metadata.quality.LogicalConsistency;
import org.opengis.metadata.quality.EvaluationMethodType;
+import org.opengis.metadata.quality.Usability;
import org.opengis.util.InternationalString;
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.gco.InternationalStringAdapter;
@@ -46,11 +46,11 @@
import org.apache.sis.xml.privy.LegacyNamespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.TemporalQuality;
-import org.opengis.metadata.quality.EvaluationMethod;
-import org.opengis.metadata.quality.MeasureReference;
-import org.opengis.metadata.quality.Metaquality;
+// Specific to the main branch:
+import org.opengis.metadata.quality.TemporalAccuracy;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -118,14 +118,12 @@
/**
* Reference to measure used.
*/
- @SuppressWarnings("serial")
- private MeasureReference measureReference;
+ private DefaultMeasureReference measureReference;
/**
* Evaluation information.
*/
- @SuppressWarnings("serial")
- private EvaluationMethod evaluationMethod;
+ private DefaultEvaluationMethod evaluationMethod;
/**
* Value (or set of values) obtained from applying a data quality measure.
@@ -167,14 +165,17 @@
public AbstractElement(final Element object) {
super(object);
if (object != null) {
- standaloneQualityReportDetails = object.getStandaloneQualityReportDetails();
- if ((measureReference = object.getMeasureReference()) == null) {
- final var candidate = new DefaultMeasureReference();
- if (candidate.setLegacy(object)) measureReference = candidate;
+ if (object instanceof AbstractElement) {
+ final AbstractElement impl = (AbstractElement) object;
+ standaloneQualityReportDetails = impl.getStandaloneQualityReportDetails();
+ evaluationMethod = impl.getEvaluationMethod();
+ derivedElements = copyCollection(impl.getDerivedElements(), Element.class);
+ if ((measureReference = impl.getMeasureReference()) == null) {
+ final var candidate = new DefaultMeasureReference();
+ if (candidate.setLegacy(object)) measureReference = candidate;
+ }
}
- evaluationMethod = object.getEvaluationMethod();
- results = copyCollection(object.getResults(), Result.class);
- derivedElements = copyCollection(object.getDerivedElements(), Element.class);
+ results = copyCollection(object.getResults(), Result.class);
}
}
@@ -185,8 +186,7 @@
* <ul>
* <li>If the given object is {@code null}, then this method returns {@code null}.</li>
* <li>Otherwise if the given object is an instance of {@link PositionalAccuracy},
- * {@link TemporalQuality}, {@link ThematicAccuracy}, {@link LogicalConsistency},
- * {@link Completeness}, {@link Usability} or {@link Metaquality},
+ * {@link ThematicAccuracy}, {@link LogicalConsistency} or {@link Completeness},
* then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
* Note that if the given object implements more than one of the above-cited interfaces,
* then the {@code castOrCopy(…)} method to be used is unspecified.</li>
@@ -206,8 +206,8 @@
if (object instanceof PositionalAccuracy) {
return AbstractPositionalAccuracy.castOrCopy((PositionalAccuracy) object);
}
- if (object instanceof TemporalQuality) {
- return AbstractTemporalQuality.castOrCopy((TemporalQuality) object);
+ if (object instanceof TemporalAccuracy) {
+ return AbstractTemporalQuality.castOrCopy((TemporalAccuracy) object);
}
if (object instanceof ThematicAccuracy) {
return AbstractThematicAccuracy.castOrCopy((ThematicAccuracy) object);
@@ -221,9 +221,6 @@
if (object instanceof Usability) {
return DefaultUsability.castOrCopy((Usability) object);
}
- if (object instanceof Metaquality) {
- return AbstractMetaquality.castOrCopy((Metaquality) object);
- }
// Intentionally tested after the sub-interfaces.
if (object == null || object instanceof AbstractElement) {
return (AbstractElement) object;
@@ -239,9 +236,9 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "standaloneQualityReportDetails")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="standaloneQualityReportDetails", obligation=OPTIONAL, specification=UNSPECIFIED)
public InternationalString getStandaloneQualityReportDetails() {
return standaloneQualityReportDetails;
}
@@ -265,10 +262,10 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "measure", required = false)
- public MeasureReference getMeasureReference() {
- return (measureReference != null) ? measureReference : Element.super.getMeasureReference();
+ @UML(identifier="measure", obligation=OPTIONAL, specification=UNSPECIFIED)
+ public DefaultMeasureReference getMeasureReference() {
+ return measureReference;
}
/**
@@ -278,7 +275,7 @@
*
* @since 1.3
*/
- public void setMeasureReference(final MeasureReference newValues) {
+ public void setMeasureReference(final DefaultMeasureReference newValues) {
checkWritePermission(measureReference);
measureReference = newValues;
}
@@ -289,8 +286,8 @@
*
* @see #getEvaluationMethodProperty(Function)
*/
- private <V> V getMeasureReferenceProperty(final Function<MeasureReference,V> getter) {
- final MeasureReference m = getMeasureReference();
+ private <V> V getMeasureReferenceProperty(final Function<DefaultMeasureReference,V> getter) {
+ final DefaultMeasureReference m = getMeasureReference();
return (m != null) && FilterByVersion.LEGACY_METADATA.accept() ? getter.apply(m) : null;
}
@@ -302,10 +299,10 @@
*/
private <V> void setMeasureReferenceProperty(final BiConsumer<DefaultMeasureReference,V> setter, final V newValue) {
if (newValue != null) {
- if (!(measureReference instanceof DefaultMeasureReference)) {
- measureReference = new DefaultMeasureReference(measureReference);
+ if (measureReference == null) {
+ measureReference = new DefaultMeasureReference();
}
- setter.accept((DefaultMeasureReference) measureReference, newValue);
+ setter.accept(measureReference, newValue);
}
}
@@ -324,17 +321,14 @@
if (!FilterByVersion.LEGACY_METADATA.accept()) {
return null;
}
- MeasureReference m = getMeasureReference();
+ DefaultMeasureReference m = getMeasureReference();
if (m == null) {
if (state() == State.FINAL) {
return Collections.emptyList();
}
setMeasureReference(m = new DefaultMeasureReference());
}
- if (m instanceof DefaultMeasureReference) {
- return ((DefaultMeasureReference) m).getNamesOfMeasure();
- }
- return Collections.unmodifiableCollection(m.getNamesOfMeasure());
+ return m.getNamesOfMeasure();
}
/**
@@ -363,7 +357,7 @@
@Dependencies("getMeasureReference")
@XmlElement(name = "measureIdentification", namespace = LegacyNamespaces.GMD)
public Identifier getMeasureIdentification() {
- return getMeasureReferenceProperty(MeasureReference::getMeasureIdentification);
+ return getMeasureReferenceProperty(DefaultMeasureReference::getMeasureIdentification);
}
/**
@@ -390,7 +384,7 @@
@Dependencies("getMeasureReference")
@XmlElement(name = "measureDescription", namespace = LegacyNamespaces.GMD)
public InternationalString getMeasureDescription() {
- return getMeasureReferenceProperty(MeasureReference::getMeasureDescription);
+ return getMeasureReferenceProperty(DefaultMeasureReference::getMeasureDescription);
}
/**
@@ -412,9 +406,9 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "evaluationMethod", required = false)
- public EvaluationMethod getEvaluationMethod() {
+ @UML(identifier="evaluationMethod", obligation=OPTIONAL, specification=UNSPECIFIED)
+ public DefaultEvaluationMethod getEvaluationMethod() {
return evaluationMethod;
}
@@ -425,7 +419,7 @@
*
* @since 1.3
*/
- public void setEvaluationMethod(final EvaluationMethod newValue) {
+ public void setEvaluationMethod(final DefaultEvaluationMethod newValue) {
checkWritePermission(evaluationMethod);
evaluationMethod = newValue;
}
@@ -436,8 +430,8 @@
*
* @see #getMeasureReferenceProperty(Function)
*/
- private <V> V getEvaluationMethodProperty(final Function<EvaluationMethod,V> getter) {
- final EvaluationMethod m = getEvaluationMethod();
+ private <V> V getEvaluationMethodProperty(final Function<DefaultEvaluationMethod,V> getter) {
+ final DefaultEvaluationMethod m = getEvaluationMethod();
return (m != null) && FilterByVersion.LEGACY_METADATA.accept() ? getter.apply(m) : null;
}
@@ -449,10 +443,10 @@
*/
private <V> void setEvaluationMethodProperty(final BiConsumer<DefaultEvaluationMethod,V> setter, final V newValue) {
if (newValue != null) {
- if (!(evaluationMethod instanceof DefaultEvaluationMethod)) {
- evaluationMethod = new DefaultEvaluationMethod(evaluationMethod);
+ if (evaluationMethod == null) {
+ evaluationMethod = new DefaultEvaluationMethod();
}
- setter.accept((DefaultEvaluationMethod) evaluationMethod, newValue);
+ setter.accept(evaluationMethod, newValue);
}
}
@@ -468,7 +462,7 @@
@Dependencies("getEvaluationMethod")
@XmlElement(name = "evaluationMethodType", namespace = LegacyNamespaces.GMD)
public EvaluationMethodType getEvaluationMethodType() {
- return getEvaluationMethodProperty(EvaluationMethod::getEvaluationMethodType);
+ return getEvaluationMethodProperty(DefaultEvaluationMethod::getEvaluationMethodType);
}
/**
@@ -495,7 +489,7 @@
@Dependencies("getEvaluationMethod")
@XmlElement(name = "evaluationMethodDescription", namespace = LegacyNamespaces.GMD)
public InternationalString getEvaluationMethodDescription() {
- return getEvaluationMethodProperty(EvaluationMethod::getEvaluationMethodDescription);
+ return getEvaluationMethodProperty(DefaultEvaluationMethod::getEvaluationMethodDescription);
}
/**
@@ -522,7 +516,7 @@
@Dependencies("getEvaluationMethod")
@XmlElement(name = "evaluationProcedure", namespace = LegacyNamespaces.GMD)
public Citation getEvaluationProcedure() {
- return getEvaluationMethodProperty(EvaluationMethod::getEvaluationProcedure);
+ return getEvaluationMethodProperty(DefaultEvaluationMethod::getEvaluationProcedure);
}
/**
@@ -552,7 +546,7 @@
@XmlElement(name = "dateTime", namespace = LegacyNamespaces.GMD)
public Collection<Date> getDates() {
if (FilterByVersion.LEGACY_METADATA.accept()) {
- EvaluationMethod m = getEvaluationMethod();
+ DefaultEvaluationMethod m = getEvaluationMethod();
if (m == null) {
if (state() == State.FINAL) {
return Collections.emptyList();
@@ -609,8 +603,8 @@
*
* @since 1.3
*/
- @Override
// @XmlElement at the end of this class.
+ @UML(identifier="derivedElement", obligation=OPTIONAL, specification=UNSPECIFIED)
public Collection<Element> getDerivedElements() {
return derivedElements = nonNullCollection(derivedElements, Element.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractMetaquality.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractMetaquality.java
index 3bec132..b01ace4 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractMetaquality.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractMetaquality.java
@@ -20,11 +20,9 @@
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Metaquality;
-import org.opengis.metadata.quality.Confidence;
-import org.opengis.metadata.quality.Representativity;
-import org.opengis.metadata.quality.Homogeneity;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -56,7 +54,8 @@
DefaultRepresentativity.class,
DefaultHomogeneity.class
})
-public class AbstractMetaquality extends AbstractElement implements Metaquality {
+@UML(identifier="DQ_Metaquality", specification=UNSPECIFIED)
+public class AbstractMetaquality extends AbstractElement {
/**
* Serial number for inter-operability with different versions.
*/
@@ -74,50 +73,9 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Metaquality)
*/
@SuppressWarnings("unchecked")
- public AbstractMetaquality(final Metaquality object) {
+ public AbstractMetaquality(final AbstractMetaquality object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link Confidence}, {@link Representativity} or {@link Homogeneity},
- * then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
- * Note that if the given object implements more than one of the above-cited interfaces,
- * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code AbstractMetaquality}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code AbstractMetaquality} instance is created using the
- * {@linkplain #AbstractMetaquality(Metaquality) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static AbstractMetaquality castOrCopy(final Metaquality object) {
- if (object instanceof Confidence) {
- return DefaultConfidence.castOrCopy((Confidence) object);
- }
- if (object instanceof Representativity) {
- return DefaultRepresentativity.castOrCopy((Representativity) object);
- }
- if (object instanceof Homogeneity) {
- return DefaultHomogeneity.castOrCopy((Homogeneity) object);
- }
- // Intentionally tested after the sub-interfaces.
- if (object == null || object instanceof AbstractMetaquality) {
- return (AbstractMetaquality) object;
- }
- return new AbstractMetaquality(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractResult.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractResult.java
index e758c03..acb908f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractResult.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractResult.java
@@ -29,9 +29,11 @@
import org.apache.sis.xml.bind.metadata.MD_Scope;
import org.apache.sis.xml.bind.gco.GO_Temporal;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.DescriptiveResult;
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -98,9 +100,10 @@
*/
public AbstractResult(final Result object) {
super(object);
- if (object != null) {
- resultScope = object.getResultScope();
- dateTime = object.getDateTime();
+ if (object instanceof AbstractResult) {
+ final AbstractResult impl = (AbstractResult) object;
+ resultScope = impl.getResultScope();
+ dateTime = impl.getDateTime();
}
}
@@ -111,7 +114,7 @@
* <ul>
* <li>If the given object is {@code null}, then this method returns {@code null}.</li>
* <li>Otherwise if the given object is an instance of {@link ConformanceResult},
- * {@link QuantitativeResult}, {@link DescriptiveResult} or {@link CoverageResult},
+ * {@link QuantitativeResult} or {@link CoverageResult},
* then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
* Note that if the given object implements more than one of the above-cited interfaces,
* then the {@code castOrCopy(…)} method to be used is unspecified.</li>
@@ -134,9 +137,6 @@
if (object instanceof ConformanceResult) {
return DefaultConformanceResult.castOrCopy((ConformanceResult) object);
}
- if (object instanceof DescriptiveResult) {
- return DefaultDescriptiveResult.castOrCopy((DescriptiveResult) object);
- }
if (object instanceof CoverageResult) {
return DefaultCoverageResult.castOrCopy((CoverageResult) object);
}
@@ -154,9 +154,9 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "resultScope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ @UML(identifier="resultScope", obligation=OPTIONAL, specification=UNSPECIFIED)
public Scope getResultScope() {
return resultScope;
}
@@ -182,9 +182,9 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "dateTime")
@XmlJavaTypeAdapter(GO_Temporal.Since2014.class)
+ @UML(identifier="dateTime", obligation=OPTIONAL, specification=UNSPECIFIED)
public Temporal getDateTime() {
return dateTime;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractTemporalQuality.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractTemporalQuality.java
index 7284686..f0d9e6d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractTemporalQuality.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractTemporalQuality.java
@@ -24,8 +24,9 @@
import org.opengis.metadata.quality.AccuracyOfATimeMeasurement;
import org.opengis.metadata.quality.TemporalAccuracy;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.TemporalQuality;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -58,7 +59,8 @@
DefaultTemporalValidity.class
})
@SuppressWarnings("deprecation")
-public class AbstractTemporalQuality extends AbstractElement implements TemporalQuality {
+@UML(identifier="DQ_TemporalQuality", specification=UNSPECIFIED)
+public class AbstractTemporalQuality extends AbstractElement implements TemporalAccuracy {
/**
* Serial number for inter-operability with different versions.
*/
@@ -77,9 +79,9 @@
*
* @param object the metadata to copy values from, or {@code null} if none.
*
- * @see #castOrCopy(TemporalQuality)
+ * @see #castOrCopy(TemporalAccuracy)
*/
- public AbstractTemporalQuality(final TemporalQuality object) {
+ public AbstractTemporalQuality(final TemporalAccuracy object) {
super(object);
}
@@ -97,7 +99,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code AbstractTemporalQuality}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code AbstractTemporalQuality} instance is created using the
- * {@linkplain #AbstractTemporalQuality(TemporalQuality) copy constructor} and returned.
+ * {@linkplain #AbstractTemporalQuality(TemporalAccuracy) copy constructor} and returned.
* Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -106,7 +108,7 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static AbstractTemporalQuality castOrCopy(final TemporalQuality object) {
+ public static AbstractTemporalQuality castOrCopy(final TemporalAccuracy object) {
if (object instanceof AccuracyOfATimeMeasurement) {
return DefaultAccuracyOfATimeMeasurement.castOrCopy((AccuracyOfATimeMeasurement) object);
}
@@ -116,9 +118,6 @@
if (object instanceof TemporalValidity) {
return DefaultTemporalValidity.castOrCopy((TemporalValidity) object);
}
- if (object instanceof TemporalAccuracy) {
- return AbstractTemporalAccuracy.castOrCopy((TemporalAccuracy) object);
- }
if (object == null || object instanceof AbstractTemporalQuality) {
return (AbstractTemporalQuality) object;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractThematicAccuracy.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractThematicAccuracy.java
index dde77a7..40b5346 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractThematicAccuracy.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/AbstractThematicAccuracy.java
@@ -23,8 +23,8 @@
import org.opengis.metadata.quality.ThematicClassificationCorrectness;
import org.opengis.metadata.quality.QuantitativeAttributeAccuracy;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.NonQuantitativeAttributeCorrectness;
+// Specific to the main branch:
+import org.opengis.metadata.quality.NonQuantitativeAttributeAccuracy;
/**
@@ -87,7 +87,7 @@
* <ul>
* <li>If the given object is {@code null}, then this method returns {@code null}.</li>
* <li>Otherwise if the given object is an instance of {@link QuantitativeAttributeAccuracy},
- * {@link NonQuantitativeAttributeCorrectness} or {@link ThematicClassificationCorrectness},
+ * {@link NonQuantitativeAttributeAccuracy} or {@link ThematicClassificationCorrectness},
* then this method delegates to the {@code castOrCopy(…)} method of the corresponding
* SIS subclass. Note that if the given object implements more than one of the above-cited
* interfaces, then the {@code castOrCopy(…)} method to be used is unspecified.</li>
@@ -107,8 +107,8 @@
if (object instanceof QuantitativeAttributeAccuracy) {
return DefaultQuantitativeAttributeAccuracy.castOrCopy((QuantitativeAttributeAccuracy) object);
}
- if (object instanceof NonQuantitativeAttributeCorrectness) {
- return DefaultNonQuantitativeAttributeCorrectness.castOrCopy((NonQuantitativeAttributeCorrectness) object);
+ if (object instanceof NonQuantitativeAttributeAccuracy) {
+ return DefaultNonQuantitativeAttributeCorrectness.castOrCopy((NonQuantitativeAttributeAccuracy) object);
}
if (object instanceof ThematicClassificationCorrectness) {
return DefaultThematicClassificationCorrectness.castOrCopy((ThematicClassificationCorrectness) object);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultAggregationDerivation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultAggregationDerivation.java
index df88548..e1a39d9 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultAggregationDerivation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultAggregationDerivation.java
@@ -19,13 +19,13 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.AggregationDerivation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Aggregation or derivation method.
- * See the {@link AggregationDerivation} GeoAPI interface for more details.
*
* <h2>Limitations</h2>
* <ul>
@@ -43,7 +43,8 @@
*/
@XmlType(name = "DQ_AggregationDerivation_Type")
@XmlRootElement(name = "DQ_AggregationDerivation")
-public class DefaultAggregationDerivation extends DefaultEvaluationMethod implements AggregationDerivation {
+@UML(identifier="DQ_AggregationDerivation", specification=UNSPECIFIED)
+public class DefaultAggregationDerivation extends DefaultEvaluationMethod {
/**
* Serial number for inter-operability with different versions.
*/
@@ -61,35 +62,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(AggregationDerivation)
*/
- public DefaultAggregationDerivation(final AggregationDerivation object) {
+ public DefaultAggregationDerivation(final DefaultAggregationDerivation object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultAggregationDerivation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultAggregationDerivation} instance is created using the
- * {@linkplain #DefaultAggregationDerivation(AggregationDerivation) copy constructor}
- * and returned. Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultAggregationDerivation castOrCopy(final AggregationDerivation object) {
- if (object == null || object instanceof DefaultAggregationDerivation) {
- return (DefaultAggregationDerivation) object;
- }
- return new DefaultAggregationDerivation(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultBasicMeasure.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultBasicMeasure.java
index 6b67edd..cc69315 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultBasicMeasure.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultBasicMeasure.java
@@ -23,14 +23,15 @@
import org.opengis.util.InternationalString;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Description;
-import org.opengis.metadata.quality.BasicMeasure;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Data quality basic measure.
- * See the {@link BasicMeasure} GeoAPI interface for more details.
* The following property is mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQM_BasicMeasure}
@@ -60,7 +61,8 @@
"valueType"
})
@XmlRootElement(name = "DQM_BasicMeasure", namespace = Namespaces.DQM)
-public class DefaultBasicMeasure extends ISOMetadata implements BasicMeasure {
+@UML(identifier="DQM_BasicMeasure", specification=UNSPECIFIED)
+public class DefaultBasicMeasure extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -82,7 +84,7 @@
* Illustration of the use of a data quality measure.
*/
@SuppressWarnings("serial")
- private Description example;
+ private DefaultMeasureDescription example;
/**
* Value type for the result of the basic measure.
@@ -102,10 +104,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(BasicMeasure)
*/
- public DefaultBasicMeasure(final BasicMeasure object) {
+ public DefaultBasicMeasure(final DefaultBasicMeasure object) {
super(object);
if (object != null) {
name = object.getName();
@@ -116,37 +116,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code BasicMeasure}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code BasicMeasure} instance is created using the
- * {@linkplain #DefaultBasicMeasure(BasicMeasure) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultBasicMeasure castOrCopy(final BasicMeasure object) {
- if (object == null || object instanceof DefaultBasicMeasure) {
- return (DefaultBasicMeasure) object;
- }
- return new DefaultBasicMeasure(object);
- }
-
- /**
* Returns the name of the data quality basic measure.
*
* @return name of the data quality basic measure.
*/
- @Override
@XmlElement(name = "name", required = true)
+ @UML(identifier="name", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getName() {
return name;
}
@@ -166,8 +141,8 @@
*
* @return definition of the data quality basic measure.
*/
- @Override
@XmlElement(name = "definition", required = true)
+ @UML(identifier="definition", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getDefinition() {
return definition;
}
@@ -187,9 +162,9 @@
*
* @return usage example, or {@code null} if none.
*/
- @Override
@XmlElement(name = "example")
- public Description getExample() {
+ @UML(identifier="example", obligation=OPTIONAL, specification=UNSPECIFIED)
+ public DefaultMeasureDescription getExample() {
return example;
}
@@ -198,7 +173,7 @@
*
* @param newValues the new basic measure example.
*/
- public void setExample(final Description newValues) {
+ public void setExample(final DefaultMeasureDescription newValues) {
checkWritePermission(example);
example = newValues;
}
@@ -208,8 +183,8 @@
*
* @return value type of the result for the basic measure.
*/
- @Override
@XmlElement(name = "valueType", required = true)
+ @UML(identifier="valueType", obligation=MANDATORY, specification=UNSPECIFIED)
public TypeName getValueType() {
return valueType;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConfidence.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConfidence.java
index 3566066..f642dd4 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConfidence.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConfidence.java
@@ -19,13 +19,13 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Confidence;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Trustworthiness of a data quality result.
- * See the {@link Confidence} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_Confidence}
@@ -48,7 +48,8 @@
*/
@XmlType(name = "DQ_Confidence_Type")
@XmlRootElement(name = "DQ_Confidence")
-public class DefaultConfidence extends AbstractMetaquality implements Confidence {
+@UML(identifier="DQ_Confidence", specification=UNSPECIFIED)
+public class DefaultConfidence extends AbstractMetaquality {
/**
* Serial number for inter-operability with different versions.
*/
@@ -65,35 +66,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Confidence)
*/
- public DefaultConfidence(final Confidence object) {
+ public DefaultConfidence(final DefaultConfidence object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultConfidence}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultConfidence} instance is created using the
- * {@linkplain #DefaultConfidence(Confidence) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultConfidence castOrCopy(final Confidence object) {
- if (object == null || object instanceof DefaultConfidence) {
- return (DefaultConfidence) object;
- }
- return new DefaultConfidence(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultCoverageResult.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultCoverageResult.java
index b69dada..89eb5cf 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultCoverageResult.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultCoverageResult.java
@@ -30,6 +30,11 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.privy.LegacyNamespaces;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
+
/**
* Result of a data quality measure organising the measured values as a coverage.
@@ -134,9 +139,11 @@
spatialRepresentationType = object.getSpatialRepresentationType();
resultSpatialRepresentation = object.getResultSpatialRepresentation();
resultContentDescription = object.getResultContentDescription();
- resultContent = copyCollection(object.getResultContent(), RangeDimension.class);
resultFormat = object.getResultFormat();
resultFile = object.getResultFile();
+ if (object instanceof DefaultCoverageResult) {
+ resultContent = copyCollection(((DefaultCoverageResult) object).getResultContent(), RangeDimension.class);
+ }
}
}
@@ -215,8 +222,8 @@
*
* @since 1.3
*/
- @Override
// @XmlElement(name = "resultContent") // Pending new ISO 19157 version.
+ @UML(identifier="resultContent", obligation=CONDITIONAL, specification=UNSPECIFIED)
public Collection<RangeDimension> getResultContent() {
return resultContent = nonNullCollection(resultContent, RangeDimension.class);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDataQuality.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDataQuality.java
index 9f8f254..4d64c33 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDataQuality.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDataQuality.java
@@ -30,8 +30,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.quality.Scope;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.StandaloneQualityReportInformation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
+import org.apache.sis.metadata.iso.ISOMetadata;
/**
@@ -97,7 +100,7 @@
* Can be used for providing more details than reported as standard metadata.
*/
@SuppressWarnings("serial")
- private StandaloneQualityReportInformation standaloneQualityReport;
+ private DefaultEvaluationReportInformation standaloneQualityReport;
/**
* Constructs an initially empty data quality.
@@ -113,6 +116,7 @@
*
* @since 0.5
*/
+ @SuppressWarnings("deprecation")
public DefaultDataQuality(final ScopeCode level) {
if (level != null) {
scope = new DefaultScope(level);
@@ -141,10 +145,12 @@
public DefaultDataQuality(final DataQuality object) {
super(object);
if (object != null) {
- scope = object.getScope();
- reports = copyCollection(object.getReports(), Element.class);
- standaloneQualityReport = object.getStandaloneQualityReport();
- lineage = object.getLineage();
+ scope = object.getScope();
+ reports = copyCollection(object.getReports(), Element.class);
+ lineage = object.getLineage();
+ if (object instanceof DefaultDataQuality) {
+ standaloneQualityReport = ((DefaultDataQuality) object).getStandaloneQualityReport();
+ }
}
}
@@ -222,9 +228,9 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "standaloneQualityReport")
- public StandaloneQualityReportInformation getStandaloneQualityReport() {
+ @UML(identifier="standaloneQualityReport", obligation=OPTIONAL, specification=UNSPECIFIED)
+ public DefaultEvaluationReportInformation getStandaloneQualityReport() {
return standaloneQualityReport;
}
@@ -235,7 +241,7 @@
*
* @since 1.3
*/
- public void setStandaloneQualityReport(final StandaloneQualityReportInformation newValue) {
+ public void setStandaloneQualityReport(final DefaultEvaluationReportInformation newValue) {
checkWritePermission(standaloneQualityReport);
standaloneQualityReport = newValue;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDescriptiveResult.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDescriptiveResult.java
index a41261d..00366eb 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDescriptiveResult.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultDescriptiveResult.java
@@ -22,13 +22,14 @@
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.DescriptiveResult;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Data quality descriptive result.
- * See the {@link DescriptiveResult} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_DescriptiveResult}
@@ -52,7 +53,8 @@
"statement"
})
@XmlRootElement(name = "DQ_DescriptiveResult")
-public class DefaultDescriptiveResult extends AbstractResult implements DescriptiveResult {
+@UML(identifier="DQ_DescriptiveResult", specification=UNSPECIFIED)
+public class DefaultDescriptiveResult extends AbstractResult {
/**
* Serial number for inter-operability with different versions.
*/
@@ -85,10 +87,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(DescriptiveResult)
*/
- public DefaultDescriptiveResult(final DescriptiveResult object) {
+ public DefaultDescriptiveResult(final DefaultDescriptiveResult object) {
super(object);
if (object != null) {
statement = object.getStatement();
@@ -96,37 +96,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultDescriptiveResult}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultDescriptiveResult} instance is created using the
- * {@linkplain #DefaultDescriptiveResult(DescriptiveResult) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultDescriptiveResult castOrCopy(final DescriptiveResult object) {
- if (object == null || object instanceof DefaultDescriptiveResult) {
- return (DefaultDescriptiveResult) object;
- }
- return new DefaultDescriptiveResult(object);
- }
-
- /**
* Returns the textual expression of the descriptive result.
*
* @return textual expression of the result.
*/
- @Override
@XmlElement(name = "statement", required = true)
+ @UML(identifier="statement", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getStatement() {
return statement;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
index 256a171..6460f48 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
@@ -37,15 +37,14 @@
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
import static org.apache.sis.metadata.privy.ImplementationHelper.valueIfDefined;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.EvaluationMethod;
-import org.opengis.metadata.quality.DataEvaluation;
-import org.opengis.metadata.quality.AggregationDerivation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Description of the evaluation method and procedure applied.
- * See the {@link EvaluationMethod} GeoAPI interface for more details.
*
* <h2>Limitations</h2>
* <ul>
@@ -73,7 +72,8 @@
AbstractDataEvaluation.class,
DefaultAggregationDerivation.class
})
-public class DefaultEvaluationMethod extends ISOMetadata implements EvaluationMethod {
+@UML(identifier="DQ_EvaluationMethod", specification=UNSPECIFIED)
+public class DefaultEvaluationMethod extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -294,10 +294,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(EvaluationMethod)
*/
- public DefaultEvaluationMethod(final EvaluationMethod object) {
+ public DefaultEvaluationMethod(final DefaultEvaluationMethod object) {
super(object);
if (object != null) {
evaluationMethodType = object.getEvaluationMethodType();
@@ -309,48 +307,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link DataEvaluation} or {@link AggregationDerivation},
- * then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
- * Note that if the given object implements more than one of the above-cited interfaces,
- * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultEvaluationMethod}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultEvaluationMethod} instance is created using the
- * {@linkplain #DefaultEvaluationMethod(EvaluationMethod) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultEvaluationMethod castOrCopy(final EvaluationMethod object) {
- if (object instanceof DataEvaluation) {
- return AbstractDataEvaluation.castOrCopy((DataEvaluation) object);
- }
- if (object instanceof AggregationDerivation) {
- return DefaultAggregationDerivation.castOrCopy((AggregationDerivation) object);
- }
- // Intentionally tested after the sub-interfaces.
- if (object == null || object instanceof DefaultEvaluationMethod) {
- return (DefaultEvaluationMethod) object;
- }
- return new DefaultEvaluationMethod(object);
- }
-
- /**
* Returns the type of method used to evaluate quality of the data.
*
* @return type of method used to evaluate quality, or {@code null} if none.
*/
- @Override
@XmlElement(name = "evaluationMethodType")
+ @UML(identifier="evaluationMethodType", obligation=OPTIONAL, specification=UNSPECIFIED)
public EvaluationMethodType getEvaluationMethodType() {
return evaluationMethodType;
}
@@ -370,8 +332,8 @@
*
* @return description of the evaluation method, or {@code null} if none.
*/
- @Override
@XmlElement(name = "evaluationMethodDescription")
+ @UML(identifier="evaluationMethodDescription", obligation=OPTIONAL, specification=UNSPECIFIED)
public InternationalString getEvaluationMethodDescription() {
return evaluationMethodDescription;
}
@@ -391,8 +353,8 @@
*
* @return reference to the procedure information, or {@code null} if none.
*/
- @Override
@XmlElement(name = "evaluationProcedure")
+ @UML(identifier="evaluationProcedure", obligation=OPTIONAL, specification=UNSPECIFIED)
public Citation getEvaluationProcedure() {
return evaluationProcedure;
}
@@ -412,8 +374,8 @@
*
* @return documents referenced in data quality evaluation method.
*/
- @Override
@XmlElement(name = "referenceDoc")
+ @UML(identifier="referenceDoc", obligation=OPTIONAL, specification=UNSPECIFIED)
public Collection<Citation> getReferenceDocuments() {
return referenceDocuments = nonNullCollection(referenceDocuments, Citation.class);
}
@@ -434,8 +396,8 @@
*
* @return date or range of dates on which a data quality measure was applied.
*/
- @Override
@XmlElement(name = "dateTime")
+ @UML(identifier="dateTime", obligation=OPTIONAL, specification=UNSPECIFIED)
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Collection<Temporal> getDates() {
if (Semaphores.query(Semaphores.NULL_COLLECTION)) {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationReportInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationReportInformation.java
index d29283b..e53b528 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationReportInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationReportInformation.java
@@ -22,13 +22,14 @@
import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Citation;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.StandaloneQualityReportInformation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Reference to an external standalone quality report.
- * See the {@link StandaloneQualityReportInformation} GeoAPI interface for more details.
* The following property is mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_Element}
@@ -54,7 +55,8 @@
"abstract"
})
@XmlRootElement(name = "DQ_StandaloneQualityReportInformation")
-public class DefaultEvaluationReportInformation extends ISOMetadata implements StandaloneQualityReportInformation {
+@UML(identifier="DQ_StandaloneQualityReportInformation", specification=UNSPECIFIED)
+public class DefaultEvaluationReportInformation extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -84,10 +86,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(StandaloneQualityReportInformation)
*/
- public DefaultEvaluationReportInformation(final StandaloneQualityReportInformation object) {
+ public DefaultEvaluationReportInformation(final DefaultEvaluationReportInformation object) {
super(object);
if (object != null) {
reportReference = object.getReportReference();
@@ -96,37 +96,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultEvaluationReportInformation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultEvaluationReportInformation} instance is created using the
- * {@linkplain #DefaultEvaluationReportInformation(StandaloneQualityReportInformation) copy constructor}
- * and returned. Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultEvaluationReportInformation castOrCopy(final StandaloneQualityReportInformation object) {
- if (object instanceof StandaloneQualityReportInformation) {
- return DefaultEvaluationReportInformation.castOrCopy((DefaultEvaluationReportInformation) object);
- }
- return new DefaultEvaluationReportInformation(object);
- }
-
- /**
* Returns the reference to the associated standalone quality report.
*
* @return reference of the standalone quality report.
*/
- @Override
@XmlElement(name = "reportReference", required = true)
+ @UML(identifier="reportReference", obligation=MANDATORY, specification=UNSPECIFIED)
public Citation getReportReference() {
return reportReference;
}
@@ -146,8 +121,8 @@
*
* @return abstract of the standalone quality report.
*/
- @Override
@XmlElement(name = "abstract", required = true)
+ @UML(identifier="abstract", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getAbstract() {
return summary;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultFullInspection.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultFullInspection.java
index e90f302..d51797c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultFullInspection.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultFullInspection.java
@@ -19,13 +19,13 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.FullInspection;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Full inspection.
- * See the {@link FullInspection} GeoAPI interface for more details.
*
* <h2>Limitations</h2>
* <ul>
@@ -43,7 +43,8 @@
*/
@XmlType(name = "DQ_FullInspection_Type")
@XmlRootElement(name = "DQ_FullInspection")
-public class DefaultFullInspection extends AbstractDataEvaluation implements FullInspection {
+@UML(identifier="DQ_FullInspection", specification=UNSPECIFIED)
+public class DefaultFullInspection extends AbstractDataEvaluation {
/**
* Serial number for inter-operability with different versions.
*/
@@ -61,35 +62,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(FullInspection)
*/
- public DefaultFullInspection(final FullInspection object) {
+ public DefaultFullInspection(final DefaultFullInspection object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultFullInspection}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultFullInspection} instance is created using the
- * {@linkplain #DefaultFullInspection(FullInspection) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultFullInspection castOrCopy(final FullInspection object) {
- if (object == null || object instanceof DefaultFullInspection) {
- return (DefaultFullInspection) object;
- }
- return new DefaultFullInspection(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultHomogeneity.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultHomogeneity.java
index 914eece..7155a84 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultHomogeneity.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultHomogeneity.java
@@ -19,13 +19,13 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Homogeneity;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Expected or tested uniformity of the results obtained for a data quality evaluation.
- * See the {@link Homogeneity} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_Homogeneity}
@@ -48,7 +48,8 @@
*/
@XmlType(name = "DQ_Homogeneity_Type")
@XmlRootElement(name = "DQ_Homogeneity")
-public class DefaultHomogeneity extends AbstractMetaquality implements Homogeneity {
+@UML(identifier="DQ_Homogeneity", specification=UNSPECIFIED)
+public class DefaultHomogeneity extends AbstractMetaquality {
/**
* Serial number for inter-operability with different versions.
*/
@@ -65,35 +66,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Homogeneity)
*/
- public DefaultHomogeneity(final Homogeneity object) {
+ public DefaultHomogeneity(final DefaultHomogeneity object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultHomogeneity}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultHomogeneity} instance is created using the
- * {@linkplain #DefaultHomogeneity(Homogeneity) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultHomogeneity castOrCopy(final Homogeneity object) {
- if (object == null || object instanceof DefaultHomogeneity) {
- return (DefaultHomogeneity) object;
- }
- return new DefaultHomogeneity(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultIndirectEvaluation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultIndirectEvaluation.java
index 507721f..a37eefe 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultIndirectEvaluation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultIndirectEvaluation.java
@@ -22,13 +22,14 @@
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.IndirectEvaluation;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Indirect evaluation.
- * See the {@link IndirectEvaluation} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_IndirectEvaluation}
@@ -52,7 +53,8 @@
"deductiveSource"
})
@XmlRootElement(name = "DQ_IndirectEvaluation")
-public class DefaultIndirectEvaluation extends AbstractDataEvaluation implements IndirectEvaluation {
+@UML(identifier="DQ_IndirectEvaluation", specification=UNSPECIFIED)
+public class DefaultIndirectEvaluation extends AbstractDataEvaluation {
/**
* Serial number for inter-operability with different versions.
*/
@@ -85,10 +87,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(IndirectEvaluation)
*/
- public DefaultIndirectEvaluation(final IndirectEvaluation object) {
+ public DefaultIndirectEvaluation(final DefaultIndirectEvaluation object) {
super(object);
if (object != null) {
deductiveSource = object.getDeductiveSource();
@@ -96,37 +96,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultIndirectEvaluation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultIndirectEvaluation} instance is created using the
- * {@linkplain #DefaultIndirectEvaluation(IndirectEvaluation) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultIndirectEvaluation castOrCopy(final IndirectEvaluation object) {
- if (object == null || object instanceof DefaultIndirectEvaluation) {
- return (DefaultIndirectEvaluation) object;
- }
- return new DefaultIndirectEvaluation(object);
- }
-
- /**
* Returns the information on which data are used as sources in deductive evaluation method.
*
* @return information on which data are used.
*/
- @Override
@XmlElement(name = "deductiveSource", required = true)
+ @UML(identifier="deductiveSource", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getDeductiveSource() {
return deductiveSource;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureDescription.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureDescription.java
index 892101f..c5b99f0 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureDescription.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureDescription.java
@@ -24,8 +24,11 @@
import org.apache.sis.util.iso.Types;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Description;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -54,7 +57,8 @@
"extendedDescription"
})
@XmlRootElement(name = "DQM_Description", namespace = Namespaces.DQM)
-public class DefaultMeasureDescription extends ISOMetadata implements Description {
+@UML(identifier="DQM_Description", specification=UNSPECIFIED)
+public class DefaultMeasureDescription extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -93,10 +97,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Description)
*/
- public DefaultMeasureDescription(final Description object) {
+ public DefaultMeasureDescription(final DefaultMeasureDescription object) {
super(object);
if (object != null) {
textDescription = object.getTextDescription();
@@ -105,37 +107,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultMeasureDescription}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultMeasureDescription} instance is created using the
- * {@linkplain #DefaultMeasureDescription(Description) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultMeasureDescription castOrCopy(final Description object) {
- if (object == null || object instanceof DefaultMeasureDescription) {
- return (DefaultMeasureDescription) object;
- }
- return new DefaultMeasureDescription(object);
- }
-
- /**
* Returns the text description.
*
* @return text description.
*/
- @Override
@XmlElement(name = "textDescription", required = true)
+ @UML(identifier="textDescription", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getTextDescription() {
return textDescription;
}
@@ -155,8 +132,8 @@
*
* @return description illustration, or {@code null} if none.
*/
- @Override
@XmlElement(name = "extendedDescription")
+ @UML(identifier="extendedDescription", obligation=OPTIONAL, specification=UNSPECIFIED)
public BrowseGraphic getExtendedDescription() {
return extendedDescription;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureReference.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureReference.java
index cfd4a3e..a92bd39 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureReference.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultMeasureReference.java
@@ -26,13 +26,15 @@
import org.apache.sis.util.privy.CollectionsExt;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.MeasureReference;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Reference to the measure used.
- * See the {@link MeasureReference} GeoAPI interface for more details.
*
* <h2>Limitations</h2>
* <ul>
@@ -54,7 +56,8 @@
"measureDescription"
})
@XmlRootElement(name = "DQ_MeasureReference")
-public class DefaultMeasureReference extends ISOMetadata implements MeasureReference {
+@UML(identifier="DQ_MeasureReference", specification=UNSPECIFIED)
+public class DefaultMeasureReference extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -101,10 +104,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(MeasureReference)
*/
- public DefaultMeasureReference(final MeasureReference object) {
+ public DefaultMeasureReference(final DefaultMeasureReference object) {
super(object);
if (object != null) {
measureIdentification = object.getMeasureIdentification();
@@ -114,31 +115,6 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultMeasureReference}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultMeasureReference} instance is created using the
- * {@linkplain #DefaultMeasureReference(MeasureReference) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultMeasureReference castOrCopy(final MeasureReference object) {
- if (object == null || object instanceof DefaultMeasureReference) {
- return (DefaultMeasureReference) object;
- }
- return new DefaultMeasureReference(object);
- }
-
- /**
* Initializes a measure reference from the deprecated properties of the given element.
* This is used for transition from legacy ISO 19115 to newer ISO 19157 model.
*/
@@ -154,8 +130,8 @@
*
* @return code identifying a registered measure, or {@code null} if none.
*/
- @Override
@XmlElement(name = "measureIdentification")
+ @UML(identifier="measureIdentification", obligation=OPTIONAL, specification=UNSPECIFIED)
public Identifier getMeasureIdentification() {
return measureIdentification;
}
@@ -175,8 +151,8 @@
*
* @return names of the test applied to the data.
*/
- @Override
@XmlElement(name = "nameOfMeasure")
+ @UML(identifier="nameOfMeasure", obligation=CONDITIONAL, specification=UNSPECIFIED)
public Collection<InternationalString> getNamesOfMeasure() {
return namesOfMeasure = nonNullCollection(namesOfMeasure, InternationalString.class);
}
@@ -195,8 +171,8 @@
*
* @return description of the measure, or {@code null}.
*/
- @Override
@XmlElement(name = "measureDescription")
+ @UML(identifier="measureDescription", obligation=OPTIONAL, specification=UNSPECIFIED)
public InternationalString getMeasureDescription() {
return measureDescription;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultNonQuantitativeAttributeCorrectness.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultNonQuantitativeAttributeCorrectness.java
index 0e88084..2540a74 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultNonQuantitativeAttributeCorrectness.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultNonQuantitativeAttributeCorrectness.java
@@ -21,13 +21,13 @@
import jakarta.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.quality.NonQuantitativeAttributeAccuracy;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.NonQuantitativeAttributeCorrectness;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Correctness of non-quantitative attributes.
- * See the {@link NonQuantitativeAttributeCorrectness} GeoAPI interface for more details.
* The following property is mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_CompletenessOmission}
@@ -53,8 +53,9 @@
DefaultNonQuantitativeAttributeAccuracy.class
})
@SuppressWarnings("deprecation")
+@UML(identifier="DQ_NonQuantitativeAttributeCorrectness", specification=UNSPECIFIED)
public class DefaultNonQuantitativeAttributeCorrectness extends AbstractThematicAccuracy
- implements NonQuantitativeAttributeCorrectness
+ implements NonQuantitativeAttributeAccuracy
{
/**
* Serial number for inter-operability with different versions.
@@ -74,9 +75,9 @@
*
* @param object the metadata to copy values from, or {@code null} if none.
*
- * @see #castOrCopy(NonQuantitativeAttributeCorrectness)
+ * @see #castOrCopy(NonQuantitativeAttributeAccuracy)
*/
- public DefaultNonQuantitativeAttributeCorrectness(final NonQuantitativeAttributeCorrectness object) {
+ public DefaultNonQuantitativeAttributeCorrectness(final NonQuantitativeAttributeAccuracy object) {
super(object);
}
@@ -89,7 +90,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code DefaultNonQuantitativeAttributeCorrectness}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code DefaultNonQuantitativeAttributeCorrectness} instance is created using the
- * {@linkplain #DefaultNonQuantitativeAttributeCorrectness(NonQuantitativeAttributeCorrectness) copy constructor}
+ * {@linkplain #DefaultNonQuantitativeAttributeCorrectness(NonQuantitativeAttributeAccuracy) copy constructor}
* and returned. Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -98,10 +99,7 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static DefaultNonQuantitativeAttributeCorrectness castOrCopy(final NonQuantitativeAttributeCorrectness object) {
- if (object instanceof NonQuantitativeAttributeAccuracy) {
- return DefaultNonQuantitativeAttributeAccuracy.castOrCopy((NonQuantitativeAttributeAccuracy) object);
- }
+ public static DefaultNonQuantitativeAttributeCorrectness castOrCopy(final NonQuantitativeAttributeAccuracy object) {
if (object == null || object instanceof DefaultNonQuantitativeAttributeCorrectness) {
return (DefaultNonQuantitativeAttributeCorrectness) object;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultQualityMeasure.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultQualityMeasure.java
index 6358b39..93f45c6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultQualityMeasure.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultQualityMeasure.java
@@ -26,17 +26,16 @@
import org.opengis.metadata.Identifier;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Measure;
-import org.opengis.metadata.quality.BasicMeasure;
-import org.opengis.metadata.quality.Description;
-import org.opengis.metadata.quality.SourceReference;
-import org.opengis.metadata.quality.ValueStructure;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Data quality measure.
- * See the {@link Measure} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQM_Measure}
@@ -68,14 +67,14 @@
"definition",
"description",
"valueType",
- "valueStructure",
"examples",
"basicMeasure",
"sourceReferences",
"parameters"
})
@XmlRootElement(name = "DQM_Measure", namespace = Namespaces.DQM)
-public class DefaultQualityMeasure extends ISOMetadata implements Measure {
+@UML(identifier="DQM_Measure", specification=UNSPECIFIED)
+public class DefaultQualityMeasure extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -109,7 +108,7 @@
* Definition of the fundamental concept for the data quality measure.
*/
@SuppressWarnings("serial")
- private BasicMeasure basicMeasure;
+ private DefaultBasicMeasure basicMeasure;
/**
* Definition of the fundamental concept for the data quality measure.
@@ -123,13 +122,13 @@
* needed to establish the result of applying the measure.
*/
@SuppressWarnings("serial")
- private Description description;
+ private DefaultMeasureDescription description;
/**
* Reference to the source of an item that has been adopted from an external source.
*/
@SuppressWarnings("serial")
- private Collection<SourceReference> sourceReferences;
+ private Collection<DefaultSourceReference> sourceReferences;
/**
* Value type for reporting a data quality result.
@@ -138,11 +137,6 @@
private TypeName valueType;
/**
- * Structure for reporting a complex data quality result.
- */
- private ValueStructure valueStructure;
-
- /**
* Auxiliary variable used by the data quality measure, including its name, definition and optionally its description.
*/
@SuppressWarnings("serial")
@@ -152,7 +146,7 @@
* Illustration of the use of a data quality measure.
*/
@SuppressWarnings("serial")
- private Collection<Description> examples;
+ private Collection<DefaultMeasureDescription> examples;
/**
* Constructs an initially empty element.
@@ -166,11 +160,9 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Measure)
*/
@SuppressWarnings({"unchecked", "rawtypes"})
- public DefaultQualityMeasure(final Measure object) {
+ public DefaultQualityMeasure(final DefaultQualityMeasure object) {
super(object);
if (object != null) {
measureIdentifier = object.getMeasureIdentifier();
@@ -180,46 +172,20 @@
definition = object.getDefinition();
description = object.getDescription();
valueType = object.getValueType();
- valueStructure = object.getValueStructure();
- examples = copyCollection(object.getExamples(), Description.class);
+ examples = copyCollection(object.getExamples(), DefaultMeasureDescription.class);
basicMeasure = object.getBasicMeasure();
- sourceReferences = copyCollection(object.getSourceReferences(), SourceReference.class);
+ sourceReferences = copyCollection(object.getSourceReferences(), DefaultSourceReference.class);
parameters = copyCollection(object.getParameters(), (Class) ParameterDescriptor.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultQualityMeasure}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultQualityMeasure} instance is created using the
- * {@linkplain #DefaultQualityMeasure(Measure) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultQualityMeasure castOrCopy(final Measure object) {
- if (object instanceof DefaultQualityMeasure) {
- return (DefaultQualityMeasure) object;
- }
- return new DefaultQualityMeasure(object);
- }
-
- /**
* Returns the value uniquely identifying the measure within a namespace.
*
* @return value uniquely identifying the measure within a namespace.
*/
- @Override
@XmlElement(name = "measureIdentifier", required = true)
+ @UML(identifier="measureIdentifier", obligation=MANDATORY, specification=UNSPECIFIED)
public Identifier getMeasureIdentifier() {
return measureIdentifier;
}
@@ -239,8 +205,8 @@
*
* @return name of the data quality measure applied to the data.
*/
- @Override
@XmlElement(name = "name", required = true)
+ @UML(identifier="name", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getName() {
return name;
}
@@ -261,8 +227,8 @@
*
* @return others recognized names, abbreviations or short names.
*/
- @Override
@XmlElement(name = "alias")
+ @UML(identifier="alias", obligation=OPTIONAL, specification=UNSPECIFIED)
public Collection<InternationalString> getAliases() {
return aliases = nonNullCollection(aliases, InternationalString.class);
}
@@ -281,8 +247,8 @@
*
* @return names of the data quality element for which quality is reported.
*/
- @Override
@XmlElement(name = "elementName", required = true)
+ @UML(identifier="elementName", obligation=MANDATORY, specification=UNSPECIFIED)
public Collection<TypeName> getElementNames() {
return elementNames = nonNullCollection(elementNames, TypeName.class);
}
@@ -301,9 +267,9 @@
*
* @return predefined basic measure on which this measure is based, or {@code null} if none.
*/
- @Override
@XmlElement(name = "basicMeasure")
- public BasicMeasure getBasicMeasure() {
+ @UML(identifier="basicMeasure", obligation=CONDITIONAL, specification=UNSPECIFIED)
+ public DefaultBasicMeasure getBasicMeasure() {
return basicMeasure;
}
@@ -312,7 +278,7 @@
*
* @param newValue the new basic measure.
*/
- public void setBasicMeasure(final BasicMeasure newValue) {
+ public void setBasicMeasure(final DefaultBasicMeasure newValue) {
checkWritePermission(basicMeasure);
basicMeasure = newValue;
}
@@ -324,8 +290,8 @@
*
* @return definition of the fundamental concept for the data quality measure.
*/
- @Override
@XmlElement(name = "definition", required = true)
+ @UML(identifier="definition", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getDefinition() {
return definition;
}
@@ -347,9 +313,9 @@
*
* @return description of data quality measure, or {@code null} if none.
*/
- @Override
@XmlElement(name = "description")
- public Description getDescription() {
+ @UML(identifier="description", obligation=CONDITIONAL, specification=UNSPECIFIED)
+ public DefaultMeasureDescription getDescription() {
return description;
}
@@ -358,7 +324,7 @@
*
* @param newValue the new measure description.
*/
- public void setDescription(final Description newValue) {
+ public void setDescription(final DefaultMeasureDescription newValue) {
checkWritePermission(description);
description = newValue;
}
@@ -368,10 +334,10 @@
*
* @return references to the source.
*/
- @Override
@XmlElement(name = "sourceReference")
- public Collection<SourceReference> getSourceReferences() {
- return sourceReferences = nonNullCollection(sourceReferences, SourceReference.class);
+ @UML(identifier="sourceReference", obligation=CONDITIONAL, specification=UNSPECIFIED)
+ public Collection<DefaultSourceReference> getSourceReferences() {
+ return sourceReferences = nonNullCollection(sourceReferences, DefaultSourceReference.class);
}
/**
@@ -379,8 +345,8 @@
*
* @param newValues the new source references.
*/
- public void setSourceReferences(final Collection<? extends SourceReference> newValues) {
- sourceReferences = writeCollection(newValues, sourceReferences, SourceReference.class);
+ public void setSourceReferences(final Collection<? extends DefaultSourceReference> newValues) {
+ sourceReferences = writeCollection(newValues, sourceReferences, DefaultSourceReference.class);
}
/**
@@ -388,8 +354,8 @@
*
* @return value type for reporting a data quality result.
*/
- @Override
@XmlElement(name = "valueType", required = true)
+ @UML(identifier="valueType", obligation=MANDATORY, specification=UNSPECIFIED)
public TypeName getValueType() {
return valueType;
}
@@ -405,27 +371,6 @@
}
/**
- * Returns the structure for reporting a complex data quality result.
- *
- * @return structure for reporting a complex data quality result, or {@code null} if none.
- */
- @Override
- @XmlElement(name = "valueStructure")
- public ValueStructure getValueStructure() {
- return valueStructure;
- }
-
- /**
- * Sets the structure for reporting a complex data quality result.
- *
- * @param newValue the new measure value structure.
- */
- public void setValueStructure(final ValueStructure newValue) {
- checkWritePermission(valueStructure);
- valueStructure = newValue;
- }
-
- /**
* Returns auxiliary variable(s) used by the data quality measure.
* It shall include its name, definition and value type.
*
@@ -435,9 +380,9 @@
*
* @return auxiliary variable(s) used by data quality measure.
*/
- @Override
@XmlElement(name = "parameter")
@SuppressWarnings({"unchecked", "rawtypes"})
+ @UML(identifier="parameter", obligation=CONDITIONAL, specification=UNSPECIFIED)
public Collection<ParameterDescriptor<?>> getParameters() {
return parameters = nonNullCollection(parameters, (Class) ParameterDescriptor.class);
}
@@ -457,10 +402,10 @@
*
* @return examples of applying the measure or the result obtained for the measure.
*/
- @Override
@XmlElement(name = "example")
- public Collection<Description> getExamples() {
- return examples = nonNullCollection(examples, Description.class);
+ @UML(identifier="example", obligation=OPTIONAL, specification=UNSPECIFIED)
+ public Collection<DefaultMeasureDescription> getExamples() {
+ return examples = nonNullCollection(examples, DefaultMeasureDescription.class);
}
/**
@@ -468,7 +413,7 @@
*
* @param newValues the new examples.
*/
- public void setExamples(final Collection<? extends Description> newValues) {
- examples = writeCollection(newValues, examples, Description.class);
+ public void setExamples(final Collection<? extends DefaultMeasureDescription> newValues) {
+ examples = writeCollection(newValues, examples, DefaultMeasureDescription.class);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultRepresentativity.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultRepresentativity.java
index dab48a9..d48ab94 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultRepresentativity.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultRepresentativity.java
@@ -19,13 +19,13 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Representativity;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
* Degree to which the sample used has produced a result which is representation of the data.
- * See the {@link Representativity} GeoAPI interface for more details.
* The following properties are mandatory in a well-formed metadata according ISO 19157:
*
* <div class="preformat">{@code DQ_Representativity}
@@ -48,7 +48,8 @@
*/
@XmlType(name = "DQ_Representativity_Type")
@XmlRootElement(name = "DQ_Representativity")
-public class DefaultRepresentativity extends AbstractMetaquality implements Representativity {
+@UML(identifier="DQ_Representativity", specification=UNSPECIFIED)
+public class DefaultRepresentativity extends AbstractMetaquality {
/**
* Serial number for inter-operability with different versions.
*/
@@ -65,35 +66,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Representativity)
*/
- public DefaultRepresentativity(final Representativity object) {
+ public DefaultRepresentativity(final DefaultRepresentativity object) {
super(object);
}
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultRepresentativity}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultRepresentativity} instance is created using the
- * {@linkplain #DefaultRepresentativity(Representativity) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultRepresentativity castOrCopy(final Representativity object) {
- if (object == null || object instanceof DefaultRepresentativity) {
- return (DefaultRepresentativity) object;
- }
- return new DefaultRepresentativity(object);
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSampleBasedInspection.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSampleBasedInspection.java
index f7e95cb..a064e53 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSampleBasedInspection.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSampleBasedInspection.java
@@ -21,8 +21,10 @@
import jakarta.xml.bind.annotation.XmlRootElement;
import org.opengis.util.InternationalString;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.SampleBasedInspection;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -54,7 +56,8 @@
"samplingRatio"
})
@XmlRootElement(name = "DQ_SampleBasedInspection")
-public class DefaultSampleBasedInspection extends AbstractDataEvaluation implements SampleBasedInspection {
+@UML(identifier="DQ_SampleBasedInspection", specification=UNSPECIFIED)
+public class DefaultSampleBasedInspection extends AbstractDataEvaluation {
/**
* Serial number for inter-operability with different versions.
*/
@@ -90,10 +93,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(SampleBasedInspection)
*/
- public DefaultSampleBasedInspection(final SampleBasedInspection object) {
+ public DefaultSampleBasedInspection(final DefaultSampleBasedInspection object) {
super(object);
if (object != null) {
samplingScheme = object.getSamplingScheme();
@@ -103,37 +104,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultSampleBasedInspection}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultSampleBasedInspection} instance is created using the
- * {@linkplain #DefaultSampleBasedInspection(SampleBasedInspection) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultSampleBasedInspection castOrCopy(final SampleBasedInspection object) {
- if (object == null || object instanceof DefaultSampleBasedInspection) {
- return (DefaultSampleBasedInspection) object;
- }
- return new DefaultSampleBasedInspection(object);
- }
-
- /**
* Returns the information of the type of sampling scheme and description of the sampling procedure.
*
* @return sampling scheme and sampling procedure.
*/
- @Override
@XmlElement(name = "samplingScheme", required = true)
+ @UML(identifier="samplingScheme", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getSamplingScheme() {
return samplingScheme;
}
@@ -153,8 +129,8 @@
*
* @return information on lots.
*/
- @Override
@XmlElement(name = "lotDescription", required = true)
+ @UML(identifier="lotDescription", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getLotDescription() {
return lotDescription;
}
@@ -174,8 +150,8 @@
*
* @return average number of samples extracted for inspection.
*/
- @Override
@XmlElement(name = "samplingRatio", required = true)
+ @UML(identifier="samplingRatio", obligation=MANDATORY, specification=UNSPECIFIED)
public InternationalString getSamplingRatio() {
return samplingRatio;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultScope.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultScope.java
index 30d1f40..bf70d67 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultScope.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultScope.java
@@ -20,13 +20,6 @@
import org.opengis.metadata.quality.Scope;
import org.opengis.metadata.maintenance.ScopeCode;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Collection;
-import org.opengis.metadata.extent.Extent;
-import org.apache.sis.metadata.internal.Dependencies;
-import org.apache.sis.metadata.iso.legacy.LegacyPropertyAdapter;
-import org.apache.sis.util.privy.CollectionsExt;
-
/**
* Description of the data specified by the scope.
@@ -80,7 +73,7 @@
*
* @see #castOrCopy(Scope)
*/
- public DefaultScope(final org.opengis.metadata.maintenance.Scope object) {
+ public DefaultScope(final Scope object) {
super(object);
}
@@ -102,38 +95,10 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static DefaultScope castOrCopy(final org.opengis.metadata.maintenance.Scope object) {
+ public static DefaultScope castOrCopy(final Scope object) {
if (object == null || object instanceof DefaultScope) {
return (DefaultScope) object;
}
return new DefaultScope(object);
}
-
- /**
- * Information about the spatial, vertical and temporal extent of the data specified by the scope.
- * This method fetches the value from the {@linkplain #getExtents() extents} collection.
- *
- * @return information about the extent of the data, or {@code null}.
- *
- * @deprecated As of ISO 19115:2014, replaced by {@link #getExtents()}.
- */
- @Override
- @Deprecated(since="1.0")
- @Dependencies("getExtents")
- public Extent getExtent() {
- return LegacyPropertyAdapter.getSingleton(getExtents(), Extent.class, null, DefaultScope.class, "getExtent");
- }
-
- /**
- * Sets information about the spatial, vertical and temporal extent of the data specified by the scope.
- * This method stores the value in the {@linkplain #setExtents(Collection) extents} collection.
- *
- * @param newValue the new extent.
- *
- * @deprecated As of ISO 19115:2014, replaced by {@link #setExtents(Collection)}.
- */
- @Deprecated(since="1.0")
- public void setExtent(final Extent newValue) {
- setExtents(CollectionsExt.singletonOrEmpty(newValue));
- }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSourceReference.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSourceReference.java
index b8cf6ca..6a69eb7 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSourceReference.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultSourceReference.java
@@ -22,8 +22,10 @@
import org.opengis.metadata.citation.Citation;
import org.apache.sis.xml.Namespaces;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.SourceReference;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.UNSPECIFIED;
/**
@@ -49,7 +51,8 @@
*/
@XmlType(name = "DQM_SourceReference_Type", namespace = Namespaces.DQM)
@XmlRootElement(name = "DQM_SourceReference", namespace = Namespaces.DQM)
-public class DefaultSourceReference extends ISOMetadata implements SourceReference {
+@UML(identifier="DQM_SourceReference", specification=UNSPECIFIED)
+public class DefaultSourceReference extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -73,10 +76,8 @@
* given object are not recursively copied.
*
* @param object the metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(SourceReference)
*/
- public DefaultSourceReference(final SourceReference object) {
+ public DefaultSourceReference(final DefaultSourceReference object) {
super(object);
if (object != null) {
citation = object.getCitation();
@@ -84,37 +85,12 @@
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultSourceReference}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultSourceReference} instance is created using the
- * {@linkplain #DefaultSourceReference(SourceReference) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation, because the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultSourceReference castOrCopy(final SourceReference object) {
- if (object == null || object instanceof DefaultSourceReference) {
- return (DefaultSourceReference) object;
- }
- return new DefaultSourceReference(object);
- }
-
- /**
* Returns the references to the source.
*
* @return reference to the source.
*/
- @Override
@XmlElement(name = "citation", required = true)
+ @UML(identifier="citation", obligation=MANDATORY, specification=UNSPECIFIED)
public Citation getCitation() {
return citation;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
index 682c784..657aeb2 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
@@ -67,7 +67,6 @@
// @XmlJavaTypeAdapter(DQM_Measure.class), // Not directly referenced, but a "weak" association exists.
@XmlJavaTypeAdapter(DQM_Parameter.class),
@XmlJavaTypeAdapter(DQM_SourceReference.class),
- @XmlJavaTypeAdapter(DQM_ValueStructure.class),
@XmlJavaTypeAdapter(GO_Temporal.class),
@XmlJavaTypeAdapter(GO_DateTime.class),
@XmlJavaTypeAdapter(GO_GenericName.class),
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
index ade3127..1aa2a10 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
@@ -27,8 +27,8 @@
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.bind.metadata.MD_Scope;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
/**
@@ -84,8 +84,8 @@
*/
public AbstractSpatialRepresentation(final SpatialRepresentation object) {
super(object);
- if (object != null) {
- scope = object.getScope();
+ if (object instanceof AbstractSpatialRepresentation) {
+ scope = ((AbstractSpatialRepresentation) object).getScope();
}
}
@@ -96,7 +96,6 @@
*
* @since 1.3
*/
- @Override
@XmlElement(name = "scope")
@XmlJavaTypeAdapter(MD_Scope.Since2014.class)
public Scope getScope() {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/DefaultDimension.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/DefaultDimension.java
index 662f68e..041c08b 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/DefaultDimension.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/spatial/DefaultDimension.java
@@ -32,6 +32,11 @@
import org.apache.sis.util.ArgumentChecks;
import static org.apache.sis.metadata.privy.ImplementationHelper.ensurePositive;
+// Specific to the main branch:
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Axis properties.
@@ -142,8 +147,10 @@
dimensionName = object.getDimensionName();
dimensionSize = object.getDimensionSize();
resolution = object.getResolution();
- dimensionTitle = object.getDimensionTitle();
- dimensionDescription = object.getDimensionDescription();
+ if (object instanceof DefaultDimension) {
+ dimensionTitle = ((DefaultDimension) object).getDimensionTitle();
+ dimensionDescription = ((DefaultDimension) object).getDimensionDescription();
+ }
}
}
@@ -253,9 +260,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "dimensionTitle")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="dimensionTitle", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDimensionTitle() {
return dimensionTitle;
}
@@ -279,9 +286,9 @@
*
* @since 0.5
*/
- @Override
@XmlElement(name = "dimensionDescription")
@XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
+ @UML(identifier="dimensionDescription", obligation=OPTIONAL, specification=ISO_19115)
public InternationalString getDimensionDescription() {
return dimensionDescription;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java
index b49daea..c98cf18 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java
@@ -31,7 +31,7 @@
* defined in the {@link org.opengis.metadata} package and sub-packages. That standard is identified in SIS by the
* {@link org.apache.sis.metadata.MetadataStandard#ISO_19115} constant. Other standards are defined as well,
* for example the {@link org.apache.sis.metadata.MetadataStandard#ISO_19123} constant stands for the standards
- * defined by the interfaces in the {@link org.opengis.coverage} package and sub-packages.
+ * defined by the interfaces in the {@code org.opengis.coverage} package and sub-packages.
*
* <p>For each interface, the collection of declared getter methods defines its <dfn>properties</dfn>
* (or <dfn>attributes</dfn>). If a {@link org.opengis.annotation.UML} annotation is attached to the getter method,
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/Identifiers.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/Identifiers.java
index 61e52aa..6c442f6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/Identifiers.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/Identifiers.java
@@ -33,6 +33,9 @@
import org.apache.sis.xml.NilObject;
import org.apache.sis.xml.NilReason;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Methods working on {@link Identifier} instances.
@@ -96,7 +99,7 @@
* </ul>
*
* Use {@code toCodeSpace(…)} method when assigning values to be returned by methods like
- * {@link Identifier#getCodeSpace()}, since those values are likely to be compared without special
+ * {@link ReferenceIdentifier#getCodeSpace()}, since those values are likely to be compared without special
* care about ignorable identifier characters. But if the intent is to format a more complex string
* like WKT or {@code toString()}, then we suggest to use {@code getIdentifier(citation, true)} instead,
* which will produce the same result but preserving the ignorable characters, which can be useful
@@ -123,8 +126,12 @@
* Unicode identifiers. If a codespace exists, then the code does not need to begin
* with a "Unicode identifier start" (it may be a "Unicode identifier part").
*/
- final String cs = Strings.trimOrNull(id.getCodeSpace());
- if (cs == null) {
+ String cs = null;
+ if (id instanceof ReferenceIdentifier) {
+ cs = Strings.trimOrNull(((ReferenceIdentifier) id).getCodeSpace());
+ }
+ if (cs == null || cs.isEmpty()) {
+ cs = null;
isUnicode = CharSequences.isUnicodeIdentifier(candidate);
} else {
isUnicode = CharSequences.isUnicodeIdentifier(cs);
@@ -212,8 +219,8 @@
return Citations.identifierMatches(authority, other);
}
}
- if (codeSpace != null) {
- final String other = identifier.getCodeSpace();
+ if (codeSpace != null && identifier instanceof ReferenceIdentifier) {
+ final String other = ((ReferenceIdentifier) identifier).getCodeSpace();
if (other != null) {
return CharSequences.equalsFiltered(codeSpace, other, Characters.Filter.UNICODE_IDENTIFIER, true);
}
@@ -236,12 +243,12 @@
* @return {@code TRUE} or {@code FALSE} on match or mismatch respectively, or {@code null} if this method
* cannot determine if there is a match or mismatch.
*/
- public static Boolean hasCommonIdentifier(final Iterable<? extends Identifier> id1,
- final Iterable<? extends Identifier> id2)
+ public static Boolean hasCommonIdentifier(final Iterable<? extends ReferenceIdentifier> id1,
+ final Iterable<? extends ReferenceIdentifier> id2)
{
if (id1 != null && id2 != null) {
boolean hasFound = false;
- for (final Identifier identifier : id1) {
+ for (final ReferenceIdentifier identifier : id1) {
final Citation authority = identifier.getAuthority();
final String codeSpace = identifier.getCodeSpace();
for (final Identifier other : id2) {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/NameToIdentifier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/NameToIdentifier.java
index 752fb62..5191c49 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/NameToIdentifier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/NameToIdentifier.java
@@ -122,6 +122,14 @@
}
/**
+ * Returns {@code null} since names are not versioned.
+ */
+ @Override
+ public String getVersion() {
+ return null;
+ }
+
+ /**
* Returns a hash code value for this object.
*/
@Override
@@ -193,7 +201,7 @@
* @param toSearch the identifier to check for equality.
* @return {@code true} if the identifier to search is found in the given set of identifiers.
*/
- public static boolean isHeuristicMatchForIdentifier(final Iterable<? extends Identifier> identifiers, final String toSearch) {
+ public static boolean isHeuristicMatchForIdentifier(final Iterable<? extends ReferenceIdentifier> identifiers, final String toSearch) {
if (toSearch != null && identifiers != null) {
int s = toSearch.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR);
if (s < 0) {
@@ -208,7 +216,7 @@
do {
final String codespace = toSearch.substring(0, s).trim();
final String code = toSearch.substring(++s).trim();
- for (final Identifier id : identifiers) {
+ for (final ReferenceIdentifier id : identifiers) {
if (codespace.equalsIgnoreCase(id.getCodeSpace()) && code.equalsIgnoreCase(id.getCode())) {
return true;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java
index 78a54e6..0cff418 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java
@@ -36,6 +36,9 @@
import org.apache.sis.system.OptionalDependency;
import org.apache.sis.system.Modules;
+// Specific to the main branch:
+import org.opengis.util.TypeName;
+
/**
* Provides access to services defined in the {@code org.apache.sis.referencing} module.
@@ -250,6 +253,16 @@
// ╚═════════════════════════════════════════════════════════════════════════════╝
/**
+ * Returns the name of the type of values.
+ *
+ * @param parameter parameter for which to get the name of type of values, or {@code null}.
+ * @return name of type of values, or {@code null} if not supported by given implementation.
+ */
+ public TypeName getValueType(ParameterDescriptor<?> parameter) {
+ return null;
+ }
+
+ /**
* Returns a fully implemented parameter descriptor.
*
* @param <T> the type of values.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleAttributeType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleAttributeType.java
index 962e717..c970126 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleAttributeType.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleAttributeType.java
@@ -22,21 +22,17 @@
import org.opengis.util.InternationalString;
import org.opengis.util.TypeName;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-
/**
* A simple attribute type containing only a name and a class of values.
* Such simple type are suitable for use in ISO 19103 {@link org.opengis.util.RecordType}
- * in addition to ISO 19109 {@link org.opengis.feature.FeatureType}.
+ * in addition to ISO 19109 {@code org.opengis.feature.FeatureType}.
*
* @author Martin Desruisseaux (Geomatys)
*
* @param <V> the type of attribute value.
*/
-public final class SimpleAttributeType<V> implements AttributeType<V>, Type, Serializable {
+public final class SimpleAttributeType<V> implements Type, Serializable {
/**
* For cross-version compatibility.
*/
@@ -69,7 +65,6 @@
*
* @return the name of this attribute type.
*/
- @Override
public GenericName getName() {
return name;
}
@@ -89,7 +84,6 @@
*
* @return the class of value for attributes of this type.
*/
- @Override
public Class<V> getValueClass() {
return valueClass;
}
@@ -99,7 +93,6 @@
*
* @return always 1.
*/
- @Override
public int getMinimumOccurs() {
return 1;
}
@@ -109,7 +102,6 @@
*
* @return always 1.
*/
- @Override
public int getMaximumOccurs() {
return 1;
}
@@ -119,7 +111,6 @@
*
* @return always {@code null}.
*/
- @Override
public V getDefaultValue() {
return null;
}
@@ -129,17 +120,26 @@
*
* @return always {@code null}.
*/
- @Override
public InternationalString getDefinition() {
return null;
}
/**
- * Unsupported operation.
+ * Not used for this simple attribute type.
+ *
+ * @return always {@code null}.
*/
- @Override
- public Attribute<V> newInstance() {
- throw new UnsupportedOperationException();
+ public InternationalString getDesignation() {
+ return null;
+ }
+
+ /**
+ * Not used for this simple attribute type.
+ *
+ * @return always {@code null}.
+ */
+ public InternationalString getDescription() {
+ return null;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleCitation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleCitation.java
index ef28b60..32ffb58 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleCitation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleCitation.java
@@ -23,6 +23,16 @@
import org.apache.sis.util.SimpleInternationalString;
import org.apache.sis.util.privy.Strings;
+// Specific to the main branch:
+import java.util.Date;
+import java.util.Collection;
+import java.util.Collections;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.PresentationForm;
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.metadata.citation.Series;
+
/**
* A trivial implementation of {@link Citation} containing only a title.
@@ -66,6 +76,26 @@
}
/**
+ * Methods inherited from the {@link Citation} interface which are not of interest to this
+ * {@code SimpleCitation} implementation.
+ *
+ * @return an empty list.
+ */
+ @Override public Collection<? extends InternationalString> getAlternateTitles() {return Collections.emptyList();}
+ @Override public Collection<? extends CitationDate> getDates() {return Collections.emptyList();}
+ @Override public InternationalString getEdition() {return null;}
+ @Override public Date getEditionDate() {return null;}
+ @Override public Collection<? extends Identifier> getIdentifiers() {return Collections.emptyList();}
+ @Override public Collection<? extends ResponsibleParty> getCitedResponsibleParties() {return Collections.emptyList();}
+ @Override public Collection<PresentationForm> getPresentationForms() {return Collections.emptyList();}
+ @Override public Series getSeries() {return null;}
+ @Override public InternationalString getOtherCitationDetails() {return null;}
+ @Override public String getISBN() {return null;}
+ @Override public String getISSN() {return null;}
+ @Deprecated
+ @Override public InternationalString getCollectiveTitle() {return null;}
+
+ /**
* Compares the given object with this citation for equality.
*
* @param obj the object to compare with this citation.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleExtent.java
index 0c3f18d..195b46c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleExtent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleExtent.java
@@ -23,6 +23,9 @@
import org.opengis.metadata.extent.VerticalExtent;
import static org.apache.sis.util.privy.CollectionsExt.singletonOrEmpty;
+// Specific to the main branch:
+import org.opengis.util.InternationalString;
+
/**
* A trivial implementation of {@link Extent} containing only geographic, vertical and temporal extent.
@@ -63,6 +66,7 @@
this.temporalElements = temporalElements;
}
+ @Override public InternationalString getDescription() {return null;}
@Override public Collection<GeographicExtent> getGeographicElements() {return singletonOrEmpty(geographicElements);}
@Override public Collection<VerticalExtent> getVerticalElements() {return singletonOrEmpty(verticalElements);}
@Override public Collection<TemporalExtent> getTemporalElements() {return singletonOrEmpty(temporalElements);}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleFormat.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleFormat.java
index c60f33a..5ac0d5a 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleFormat.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleFormat.java
@@ -22,8 +22,8 @@
import org.opengis.metadata.distribution.Format;
import org.apache.sis.util.privy.Strings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Citation;
+// Specific to the main branch:
+import org.opengis.metadata.distribution.Distributor;
/**
@@ -67,13 +67,68 @@
}
/**
- * Citation / URL of the specification format.
+ * @deprecated Replaced by {@link #getTitle()}
*
- * @return citation / URL of the specification format.
+ * @return name of a subset, profile, or product specification of the format, or {@code null}.
*/
@Override
- public Citation getFormatSpecificationCitation() {
- return this;
+ @Deprecated
+ public InternationalString getSpecification() {
+ return getTitle();
+ }
+
+ /**
+ * @deprecated Replaced by {@link #getAlternateTitles()}
+ *
+ * @return name of the data transfer format(s).
+ */
+ @Override
+ @Deprecated
+ public InternationalString getName() {
+ return super.getTitle();
+ }
+
+ /**
+ * @deprecated Replaced by {@link #getEdition()}
+ *
+ * @return version of the format.
+ */
+ @Override
+ @Deprecated
+ public InternationalString getVersion() {
+ return getEdition();
+ }
+
+ /**
+ * Amendment number of the format version.
+ *
+ * @return amendment number of the format version, or {@code null}.
+ */
+ @Override
+ public InternationalString getAmendmentNumber() {
+ return null;
+ }
+
+ /**
+ * Recommendations of algorithms or processes that can be applied to read
+ * or expand resources to which compression techniques have been applied.
+ *
+ * @return processes that can be applied to read resources to which compression techniques have been applied,
+ * or {@code null}.
+ */
+ @Override
+ public InternationalString getFileDecompressionTechnique() {
+ return null;
+ }
+
+ /**
+ * Provides information about the distributor's format.
+ *
+ * @return information about the distributor's format.
+ */
+ @Override
+ public Collection<? extends Distributor> getFormatDistributors() {
+ return Collections.emptyList();
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifiedObject.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifiedObject.java
index c1b001c..6f0ae78 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifiedObject.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifiedObject.java
@@ -32,8 +32,11 @@
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.metadata.extent.Extent;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
+// Specific to the main branch:
+import java.util.Set;
+import java.util.Collection;
+import java.util.Collections;
+import org.opengis.util.GenericName;
/**
@@ -92,6 +95,34 @@
}
/**
+ * Method required by the {@link IdentifiedObject} interface.
+ * Current implementation returns an empty set.
+ *
+ * <p>If a future version allows this method to returns a non-empty set,
+ * revisit {@link #equals(Object, ComparisonMode)}.</p>
+ *
+ * @return the identifiers, or an empty set if none.
+ */
+ @Override
+ public final Set<ReferenceIdentifier> getIdentifiers() {
+ return Collections.emptySet();
+ }
+
+ /**
+ * Method required by the {@link IdentifiedObject} interface.
+ * Current implementation returns an empty set.
+ *
+ * <p>If a future version allows this method to returns a non-empty set,
+ * revisit {@link #equals(Object, ComparisonMode)}.</p>
+ *
+ * @return the aliases, or an empty set if none.
+ */
+ @Override
+ public final Collection<GenericName> getAlias() {
+ return Collections.emptySet();
+ }
+
+ /**
* Method required by most {@link IdentifiedObject} sub-interfaces.
* Current implementation returns {@code null}.
*
@@ -124,15 +155,17 @@
}
/**
- * Returns a narrative explanation of the role of this object.
- * The default implementation returns {@link Identifier#getDescription()}.
+ * Method required by the {@link IdentifiedObject} interface.
+ * Current implementation returns {@code null}.
*
- * @return a narrative explanation of the role of this object.
+ * <p>If a future version allows this method to returns a non-null value,
+ * revisit {@link #equals(Object, ComparisonMode)}.</p>
+ *
+ * @return the remarks, or {@code null} if none.
*/
- public Optional<InternationalString> getDescription() {
- @SuppressWarnings("LocalVariableHidesMemberVariable")
- final Identifier name = this.name;
- return Optional.ofNullable((name != null) ? name.getDescription() : null);
+ @Override
+ public final InternationalString getRemarks() {
+ return null;
}
/**
@@ -191,12 +224,23 @@
}
/**
+ * Throws an exception in all cases, since this object can't be formatted in a valid WKT.
+ *
+ * @return the Well Known Text.
+ * @throws UnsupportedOperationException always thrown.
+ */
+ @Override
+ public String toWKT() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Returns a pseudo-WKT representation for debugging purpose.
*/
@Override
public String toString() {
@SuppressWarnings("LocalVariableHidesMemberVariable")
- final Identifier name = this.name;
+ final ReferenceIdentifier name = this.name;
final String code, codespace;
final Citation authority;
if (name != null) {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifier.java
index c2b49c3..5abb883 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleIdentifier.java
@@ -138,6 +138,15 @@
}
/**
+ * Returns a natural language description of the meaning of the code value.
+ *
+ * @return natural language description, or {@code null} if none.
+ */
+ public InternationalString getDescription() {
+ return null;
+ }
+
+ /**
* An optional free text.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleMetadata.java
index 2a89923..306aaa2 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/simple/SimpleMetadata.java
@@ -32,10 +32,22 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Map;
-import java.nio.charset.Charset;
-import org.opengis.metadata.MetadataScope;
+// Specific to the main branch:
+import java.util.Date;
+import org.opengis.metadata.ApplicationSchemaInformation;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.MetadataExtensionInformation;
+import org.opengis.metadata.PortrayalCatalogueReference;
+import org.opengis.metadata.citation.Series;
+import org.opengis.metadata.maintenance.MaintenanceInformation;
+import org.opengis.metadata.spatial.SpatialRepresentation;
+import org.opengis.metadata.acquisition.AcquisitionInformation;
+import org.opengis.metadata.constraint.Constraints;
+import org.opengis.metadata.content.ContentInformation;
+import org.opengis.metadata.distribution.Distribution;
+import org.opengis.metadata.distribution.Format;
+import org.opengis.metadata.quality.DataQuality;
+import org.opengis.referencing.ReferenceSystem;
/**
@@ -47,8 +59,8 @@
* <p>Unless specified otherwise, all methods in this class returns {@code null} or an empty collection by default.
* The exceptions to this rules are the following methods:</p>
* <ul>
- * <li>{@link #getMetadataScopes()} returns {@code this}</li>
- * <li>{@link #getResourceScope()} returns {@link ScopeCode#DATASET}</li>
+ * <li>{@code getMetadataScopes()} returns {@code this}</li>
+ * <li>{@code getResourceScope()} returns {@link ScopeCode#DATASET}</li>
* <li>{@link #getIdentificationInfo()} returns {@code this}</li>
* <li>{@link #getCitation()} returns {@code this}</li>
* <li>{@link #getSpatialRepresentationTypes()} returns {@link SpatialRepresentationType#VECTOR}</li>
@@ -67,7 +79,7 @@
*
* @author Johann Sorel (Geomatys)
*/
-public class SimpleMetadata implements Metadata, MetadataScope, DataIdentification, Citation {
+public class SimpleMetadata implements Metadata, DataIdentification, Citation {
/**
* Creates a new metadata object.
*/
@@ -75,34 +87,82 @@
}
/**
+ * Unique identifier for this metadata record.
+ */
+ @Override
+ public String getFileIdentifier() {
+ return null;
+ }
+
+ /**
* Language(s) used for documenting metadata.
* Also the language(s) used within the data.
*/
@Override
- public Map<Locale,Charset> getLocalesAndCharsets() {
- return Collections.emptyMap();
+ public Collection<Locale> getLanguages() {
+ return Collections.emptySet(); // We use 'Set' because we handle 'Locale' like a CodeList.
}
/**
- * The scope or type of resource for which metadata is provided.
- * This method returns {@code this} for allowing call to {@link #getResourceScope()}.
- *
- * @see #getResourceScope()
- * @see #getName()
+ * Language(s) used for documenting metadata.
+ * Also the language(s) used within the data.
*/
@Override
- public Collection<MetadataScope> getMetadataScopes() {
- return Collections.singleton(this);
+ public Locale getLanguage() {
+ return null;
}
/**
- * Code for the metadata scope, fixed to {@link ScopeCode#DATASET} by default. This is part of the information
- * provided by {@link #getMetadataScopes()}. The {@code DATASET} default value is consistent with the fact that
+ * Language(s) used for documenting metadata.
+ * Also the language(s) used within the data.
+ */
+ @Override
+ public Collection<Locale> getLocales() {
+ return Collections.emptySet(); // We use 'Set' because we handle 'Locale' like a CodeList.
+ }
+
+ /**
+ * The character coding standard used for the metadata set.
+ * Also the character coding standard(s) used for the dataset.
+ */
+ @Override
+ public Collection<CharacterSet> getCharacterSets() {
+ return Collections.emptySet(); // We use 'Set' because we handle 'Charset' like a CodeList.
+ }
+
+ /**
+ * The character coding standard used for the metadata set.
+ * Also the character coding standard(s) used for the dataset.
+ */
+ @Override
+ public CharacterSet getCharacterSet() {
+ return null;
+ }
+
+ /**
+ * Identification of the parent metadata record.
+ */
+ @Override
+ public String getParentIdentifier() {
+ return null;
+ }
+
+ /**
+ * Code for the metadata scope, fixed to {@link ScopeCode#DATASET} by default.
+ * The {@code DATASET} default value is consistent with the fact that
* {@code SimpleMetadata} implements {@link DataIdentification}.
*/
@Override
- public ScopeCode getResourceScope() {
- return ScopeCode.DATASET;
+ public Collection<ScopeCode> getHierarchyLevels() {
+ return Collections.singleton(ScopeCode.DATASET);
+ }
+
+ /**
+ * Description of the metadata scope.
+ */
+ @Override
+ public Collection<String> getHierarchyLevelNames() {
+ return Collections.emptySet();
}
/**
@@ -117,7 +177,56 @@
* Date(s) associated with the metadata.
*/
@Override
- public Collection<CitationDate> getDateInfo() {
+ public Date getDateStamp() {
+ return null;
+ }
+
+ /**
+ * Citation(s) for the standard(s) to which the metadata conform.
+ */
+ @Override
+ public String getMetadataStandardName() {
+ return null;
+ }
+
+ /**
+ * As of ISO 19115:2014, replaced by {@code getMetadataStandards()}
+ * followed by {@link Citation#getEdition()}.
+ */
+ @Override
+ public String getMetadataStandardVersion() {
+ return null;
+ }
+
+ /**
+ * Online location(s) where the metadata is available.
+ */
+ @Override
+ public String getDataSetUri() {
+ return null;
+ }
+
+ /**
+ * Digital representation of spatial information in the dataset.
+ */
+ @Override
+ public Collection<SpatialRepresentation> getSpatialRepresentationInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Description of the spatial and temporal reference systems used in the dataset.
+ */
+ @Override
+ public Collection<ReferenceSystem> getReferenceSystemInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information describing metadata extensions.
+ */
+ @Override
+ public Collection<MetadataExtensionInformation> getMetadataExtensionInfo() {
return Collections.emptyList();
}
@@ -131,7 +240,6 @@
* @see #getPointOfContacts()
* @see #getSpatialRepresentationTypes()
* @see #getSpatialResolutions()
- * @see #getTemporalResolutions()
* @see #getTopicCategories()
* @see #getExtents()
* @see #getResourceFormats()
@@ -142,6 +250,70 @@
return Collections.singleton(this);
}
+ /**
+ * Information about the feature and coverage characteristics.
+ */
+ @Override
+ public Collection<ContentInformation> getContentInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about the distributor of and options for obtaining the resource(s).
+ */
+ @Override
+ public Distribution getDistributionInfo() {
+ return null;
+ }
+
+ /**
+ * Overall assessment of quality of a resource(s).
+ */
+ @Override
+ public Collection<DataQuality> getDataQualityInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about the catalogue of rules defined for the portrayal of a resource(s).
+ */
+ @Override
+ public Collection<PortrayalCatalogueReference> getPortrayalCatalogueInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Restrictions on the access and use of metadata.
+ */
+ @Override
+ public Collection<Constraints> getMetadataConstraints() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about the conceptual schema of a dataset.
+ */
+ @Override
+ public Collection<ApplicationSchemaInformation> getApplicationSchemaInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about the acquisition of the data.
+ */
+ @Override
+ public Collection<AcquisitionInformation> getAcquisitionInformation() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about the frequency of metadata updates, and the scope of those updates.
+ */
+ @Override
+ public MaintenanceInformation getMetadataMaintenance() {
+ return null;
+ }
+
/* -------------------------------------------------------------------------------------------------
* Implementation of the DataIdentification object returned by Metadata.getIdentificationInfo().
@@ -167,6 +339,42 @@
}
/**
+ * Summary of the intentions with which the resource was developed.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public InternationalString getPurpose() {
+ return null;
+ }
+
+ /**
+ * Recognition of those who contributed to the resource.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<String> getCredits() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Status of the resource.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Progress> getStatus() {
+ return Collections.emptySet(); // We use 'Set' because 'Progress' is a CodeList.
+ }
+
+ /**
+ * Identification of, and means of communication with, person(s) and organisations associated with the resource(s).
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<ResponsibleParty> getPointOfContacts() {
+ return Collections.emptyList();
+ }
+
+ /**
* Methods used to spatially represent geographic information.
* This is part of the information returned by {@link #getIdentificationInfo()}.
* Default implementation returns {@link SpatialRepresentationType#VECTOR}.
@@ -178,6 +386,15 @@
}
/**
+ * Factor which provides a general understanding of the density of spatial data in the resource.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Resolution> getSpatialResolutions() {
+ return Collections.emptyList();
+ }
+
+ /**
* Main theme(s) of the resource.
* This is part of the information returned by {@link #getIdentificationInfo()}.
* Default implementation returns {@link TopicCategory#LOCATION}.
@@ -197,6 +414,89 @@
return Collections.emptyList();
}
+ /**
+ * Information about the frequency of resource updates, and the scope of those updates.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<MaintenanceInformation> getResourceMaintenances() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Graphic that illustrates the resource(s) (should include a legend for the graphic).
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<BrowseGraphic> getGraphicOverviews() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Description of the format of the resource(s).
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Format> getResourceFormats() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Category keywords, their type, and reference source.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Keywords> getDescriptiveKeywords() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Basic information about specific application(s) for which the resource(s)
+ * has/have been or is being used by different users.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Usage> getResourceSpecificUsages() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Information about constraints which apply to the resource(s).
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public Collection<Constraints> getResourceConstraints() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @deprecated As of ISO 19115:2014, replaced by {@code getAssociatedResources()}.
+ */
+ @Override
+ @Deprecated
+ public Collection<AggregateInformation> getAggregationInfo() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Description of the resource in the producer's processing environment, including items
+ * such as the software, the computer operating system, file name, and the dataset size.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public InternationalString getEnvironmentDescription() {
+ return null;
+ }
+
+ /**
+ * Any other descriptive information about the resource.
+ * This is part of the information returned by {@link #getIdentificationInfo()}.
+ */
+ @Override
+ public InternationalString getSupplementalInformation() {
+ return null;
+ }
+
/* -------------------------------------------------------------------------------------------------
* Implementation of the Citation object returned by DataIdentification.getCitation().
@@ -212,6 +512,61 @@
}
/**
+ * Short names or other language names by which the cited information is known.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Collection<InternationalString> getAlternateTitles() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Reference dates for the cited resource.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Collection<CitationDate> getDates() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Version of the cited resource.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public InternationalString getEdition() {
+ return null;
+ }
+
+ /**
+ * Date of the edition.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Date getEditionDate() {
+ return null;
+ }
+
+ /**
+ * Unique identifier for the resource.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Collection<Identifier> getIdentifiers() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Role, name, contact and position information for individuals or organisations
+ * that are responsible for the resource.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Collection<ResponsibleParty> getCitedResponsibleParties() {
+ return Collections.emptyList();
+ }
+
+ /**
* Mode in which the resource is represented.
* This is part of the information returned by {@link #getCitation()}.
* Default implementation returns {@link PresentationForm#TABLE_DIGITAL}.
@@ -221,4 +576,49 @@
public Collection<PresentationForm> getPresentationForms() {
return Collections.singleton(PresentationForm.TABLE_DIGITAL);
}
+
+ /**
+ * Information about the series, or aggregate dataset, of which the dataset is a part.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public Series getSeries() {
+ return null;
+ }
+
+ /**
+ * Other information required to complete the citation that is not recorded elsewhere.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public InternationalString getOtherCitationDetails() {
+ return null;
+ }
+
+ /**
+ * @deprecated Removed as of ISO 19115:2014.
+ */
+ @Override
+ @Deprecated
+ public InternationalString getCollectiveTitle() {
+ return null;
+ }
+
+ /**
+ * International Standard Book Number.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public String getISBN() {
+ return null;
+ }
+
+ /**
+ * International Standard Serial Number.
+ * This is part of the information returned by {@link #getCitation()}.
+ */
+ @Override
+ public String getISSN() {
+ return null;
+ }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/Dispatcher.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/Dispatcher.java
index 14fba02..89f8169 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/Dispatcher.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/Dispatcher.java
@@ -36,8 +36,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 branch:
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
/**
@@ -160,9 +160,14 @@
*/
Object value;
try {
- method = supercede(method);
- if (method == null) return null;
+ final long nb = nullValues;
value = fetchValue(source.getLookupInfo(method.getDeclaringClass()), method);
+ if (value == null) {
+ nullValues = nb;
+ method = supercede(method);
+ if (method == null) return null;
+ value = fetchValue(source.getLookupInfo(method.getDeclaringClass()), method);
+ }
} catch (ReflectiveOperationException | SQLException | MetadataStoreException e) {
throw new BackingStoreException(error(method), e);
}
@@ -331,7 +336,7 @@
private static Method supercede(Method method) throws NoSuchMethodException {
if (method.getDeclaringClass() == ResponsibleParty.class) {
if ("getRole".equals(method.getName())) {
- method = Responsibility.class.getMethod("getRole");
+ method = DefaultResponsibility.class.getMethod("getRole");
} else {
/*
* `getIndividualName()`, `getOrganisationName()`, `getPositionName()` and
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataFallback.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataFallback.java
index bebd13d..2ca216f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataFallback.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataFallback.java
@@ -32,8 +32,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -80,7 +80,7 @@
ArgumentChecks.ensureNonNull("type", type);
ArgumentChecks.ensureNonEmpty("identifier", identifier);
Object value;
- if (ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (CodeList.class.isAssignableFrom(type)) {
try {
value = getCodeList(type, identifier);
} catch (IllegalArgumentException e) {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java
index 804509f..287f7f1 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java
@@ -77,8 +77,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.Interim;
/**
@@ -672,8 +672,8 @@
* be present in the database in order to ensure foreigner key constraints, but
* those tables are not used in any way by the org.apache.sis.metadata.sql package.
*/
- if (metadata instanceof ControlledVocabulary) {
- identifier = Types.getCodeName((ControlledVocabulary) metadata);
+ if (metadata instanceof CodeList<?>) {
+ identifier = Types.getCodeName((CodeList<?>) metadata);
} else if (metadata instanceof Enum<?>) {
identifier = ((Enum<?>) metadata).name();
} else {
@@ -739,8 +739,8 @@
* Note that if a metadata dependency is not found, we can stop the whole process immediately.
*/
if (value != null) {
- if (value instanceof ControlledVocabulary) {
- value = Types.getCodeName((ControlledVocabulary) value);
+ if (value instanceof CodeList<?>) {
+ value = Types.getCodeName((CodeList<?>) value);
} else if (value instanceof Enum<?>) {
value = ((Enum<?>) value).name();
} else {
@@ -852,7 +852,7 @@
*
* @param <T> the parameterized type of the {@code type} argument.
* @param type the interface to implement (e.g. {@link org.opengis.metadata.citation.Citation}),
- * or the {@link ControlledVocabulary} type ({@link CodeList} or some {@link Enum}).
+ * or the {@code ControlledVocabulary} type ({@link CodeList} or some {@link Enum}).
* @param identifier the identifier of the record for the metadata entity to be created.
* This is usually the primary key of the record to search for.
* @return an implementation of the required interface, or the code list element.
@@ -883,7 +883,7 @@
*/
private Object lookup(final Class<?> type, final String identifier, boolean verify) throws MetadataStoreException {
Object value;
- if (ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (CodeList.class.isAssignableFrom(type)) {
try {
value = getCodeList(type, identifier);
} catch (IllegalArgumentException e) {
@@ -988,7 +988,7 @@
* the name between bracket is a subtype of the given `type` argument.
*/
final Class<?> type = TableHierarchy.subType(info.getMetadataType(), toSearch.identifier);
- final Class<?> returnType = method.getReturnType();
+ final Class<?> returnType = Interim.getReturnType(method);
final boolean wantCollection = Collection.class.isAssignableFrom(returnType);
final Class<?> elementType = (wantCollection || Classes.isParameterizedProperty(returnType)) ? Classes.boundOfParameterizedProperty(method) : returnType;
final boolean isMetadata = standard.isMetadata(elementType);
@@ -1075,12 +1075,8 @@
* @throws IllegalArgumentException if there is no value for the given name and the code cannot be created.
*/
@SuppressWarnings("unchecked")
- static ControlledVocabulary getCodeList(final Class<?> type, final String name) {
- if (type.isEnum()) {
- return (ControlledVocabulary) CodeLists.forEnumName(type.asSubclass(Enum.class), name);
- } else {
- return CodeLists.getOrCreate(type.asSubclass(CodeList.class), name);
- }
+ static CodeList<?> getCodeList(final Class<?> type, final String name) {
+ return CodeLists.getOrCreate(type.asSubclass(CodeList.class), name);
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataWriter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataWriter.java
index ae6b925..c2b6c7f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataWriter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataWriter.java
@@ -30,9 +30,9 @@
import java.sql.SQLException;
import javax.sql.DataSource;
import java.lang.reflect.Modifier;
+import org.opengis.util.FactoryException;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
-import org.opengis.util.FactoryException;
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
@@ -51,8 +51,9 @@
import org.apache.sis.util.privy.Strings;
import org.apache.sis.xml.IdentifiedObject;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -190,8 +191,8 @@
boolean success = false;
try {
try (Statement stmt = connection.createStatement()) {
- if (metadata instanceof ControlledVocabulary) {
- identifier = addCode(stmt, (ControlledVocabulary) metadata);
+ if (metadata instanceof CodeList<?>) {
+ identifier = addCode(stmt, (CodeList<?>) metadata);
} else {
identifier = add(stmt, metadata, new IdentityHashMap<>(), null);
}
@@ -315,7 +316,7 @@
*/
int maxLength = maximumValueLength;
Class<?> rt = colTypes.get(column);
- final boolean isCodeList = ControlledVocabulary.class.isAssignableFrom(rt); // Accept also some enums.
+ final boolean isCodeList = CodeList.class.isAssignableFrom(rt);
if (isCodeList || standard.isMetadata(rt)) {
/*
* Found a reference to another metadata. Remind that column for creating a foreign key
@@ -405,8 +406,8 @@
for (final Map.Entry<String,Object> entry : asSingletons.entrySet()) {
Object value = entry.getValue();
final Class<?> type = value.getClass();
- if (ControlledVocabulary.class.isAssignableFrom(type)) {
- value = addCode(stmt, (ControlledVocabulary) value);
+ if (CodeList.class.isAssignableFrom(type)) {
+ value = addCode(stmt, (CodeList<?>) value);
} else if (type.isEnum()) {
value = ((Enum<?>) value).name();
} else if (standard.isMetadata(type)) {
@@ -483,7 +484,7 @@
for (final Map.Entry<String,FKey> entry : foreigners.entrySet()) {
final FKey fkey = entry.getValue();
Class<?> rt = fkey.tableType;
- final boolean isCodeList = ControlledVocabulary.class.isAssignableFrom(rt);
+ final boolean isCodeList = CodeList.class.isAssignableFrom(rt);
final String primaryKey;
if (isCodeList) {
primaryKey = CODE_COLUMN;
@@ -643,11 +644,9 @@
/**
* Adds a code list if it is not already present. This is used only in order to enforce
* foreigner key constraints in the database. The value of CodeList tables are not used
- * at parsing time. Enumerations are handled as if they were CodeLists; we do not use
- * the native SQL {@code ENUM} type for making easier to add new values when a standard
- * is updated.
+ * at parsing time.
*/
- private String addCode(final Statement stmt, final ControlledVocabulary code) throws SQLException {
+ private String addCode(final Statement stmt, final CodeList<?> code) throws SQLException {
assert Thread.holdsLock(this);
final String table = getTableName(code.getClass());
final Set<String> columns = getExistingColumns(table);
@@ -702,9 +701,11 @@
for (final Identifier id : identifiers) {
identifier = Strings.trimOrNull(id.getCode());
if (identifier != null) {
- final String cs = Strings.trimOrNull(id.getCodeSpace());
- if (cs != null) {
- identifier = cs + Constants.DEFAULT_SEPARATOR + identifier;
+ if (id instanceof ReferenceIdentifier) {
+ final String cs = Strings.trimOrNull(((ReferenceIdentifier) id).getCodeSpace());
+ if (cs != null) {
+ identifier = cs + Constants.DEFAULT_SEPARATOR + identifier;
+ }
}
break;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/Interim.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/Interim.java
new file mode 100644
index 0000000..54a86ce
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/Interim.java
@@ -0,0 +1,68 @@
+/*
+ * 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.pending.geoapi.evolution;
+
+import java.lang.reflect.Method;
+import static java.util.logging.Logger.getLogger;
+import org.opengis.geometry.Envelope;
+import org.opengis.geometry.Geometry;
+import org.apache.sis.util.Static;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.system.Modules;
+
+
+/**
+ * Temporary methods used until a new major GeoAPI release provides the missing functionalities.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since 0.8
+ */
+public final class Interim extends Static {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private Interim() {
+ }
+
+ /**
+ * Returns the return type of the given method, or the interim type if the method is annotated
+ * with {@link InterimType}.
+ *
+ * @param method the method from which to get the return type.
+ * @return the return type or the interim type.
+ */
+ public static Class<?> getReturnType(final Method method) {
+ final InterimType an = method.getAnnotation(InterimType.class);
+ return (an != null) ? an.value() : method.getReturnType();
+ }
+
+ /**
+ * Invokes {@code Geometry.getEnvelope()} if that method exists.
+ *
+ * @param geometry the geometry from which to get the envelope.
+ * @return the geometry envelope, or {@code null} if none.
+ */
+ public static Envelope getEnvelope(final Geometry geometry) {
+ try {
+ return (Envelope) geometry.getClass().getMethod("getEnvelope").invoke(geometry);
+ } catch (ReflectiveOperationException | ClassCastException e) {
+ Logging.recoverableException(getLogger(Modules.METADATA), Interim.class, "getEnvelope", e);
+ return null;
+ }
+ }
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/InterimType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/InterimType.java
new file mode 100644
index 0000000..8c48b7a
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/InterimType.java
@@ -0,0 +1,44 @@
+/*
+ * 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.pending.geoapi.evolution;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
+
+
+/**
+ * Identifies an interim class to use until an official GeoAPI class or interface is released.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since 0.8
+ *
+ * @see Interim#getReturnType(Method)
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InterimType {
+ /**
+ * The interim Apache SIS class to use until the GeoAPI class or interface is released.
+ *
+ * @return Apache SIS class to use in the interim.
+ */
+ Class<?> value();
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeList.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeList.java
new file mode 100644
index 0000000..e949e74
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeList.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 desruisseaux.
+ *
+ * Licensed 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.pending.geoapi.evolution;
+
+import java.util.List;
+import java.util.ArrayList;
+import org.opengis.annotation.UML;
+import org.opengis.util.CodeList;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
+
+/**
+ * Placeholder for code list not yet available in GeoAPI.
+ * Currently defines constants mostly for {@code org.opengis.metadata.citation.TelephoneType},
+ * but constants for other code list can be constructed like below:
+ *
+ * {@snippet lang="java" :
+ * operation.getDistributedComputingPlatforms().add(UnsupportedCodeList.valueOf("SOAP"));
+ * }
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since 0.5
+ */
+public final class UnsupportedCodeList extends CodeList<UnsupportedCodeList> {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 7205015191869240829L;
+
+ /**
+ * The list of constants defined in this code list.
+ */
+ private static final List<UnsupportedCodeList> VALUES = new ArrayList<UnsupportedCodeList>(3);
+
+ /**
+ * A frequently used code list element.
+ */
+ @UML(identifier="voice", obligation=CONDITIONAL, specification=ISO_19115)
+ public static final CodeList<?> VOICE = new UnsupportedCodeList("VOICE");
+
+ /**
+ * A frequently used code list element.
+ */
+ @UML(identifier="facsimile", obligation=CONDITIONAL, specification=ISO_19115)
+ public static final CodeList<?> FACSIMILE = new UnsupportedCodeList("FACSIMILE");
+
+ /**
+ * A frequently used code list element.
+ */
+ @UML(identifier="WebServices", obligation=CONDITIONAL, specification=ISO_19115)
+ public static final CodeList<?> WEB_SERVICES = new UnsupportedCodeList("WEB_SERVICES");
+
+ /**
+ * Constructor for new code list element.
+ *
+ * @param name The code list name.
+ */
+ private UnsupportedCodeList(String name) {
+ super(name, VALUES);
+ }
+
+ /**
+ * Returns the list of codes of the same kind than this code list element.
+ *
+ * @return All code values for this code list.
+ */
+ @Override
+ public UnsupportedCodeList[] family() {
+ synchronized (VALUES) {
+ return VALUES.toArray(new UnsupportedCodeList[VALUES.size()]);
+ }
+ }
+
+ /**
+ * Returns the telephone type that matches the given string, or returns a new one if none match it.
+ *
+ * @param code The name of the code to fetch or to create.
+ * @return A code matching the given name.
+ */
+ public static UnsupportedCodeList valueOf(String code) {
+ return valueOf(UnsupportedCodeList.class, code);
+ }
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeListAdapter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeListAdapter.java
new file mode 100644
index 0000000..d0cf585
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/UnsupportedCodeListAdapter.java
@@ -0,0 +1,164 @@
+/*
+ * 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.pending.geoapi.evolution;
+
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+import org.opengis.util.CodeList;
+import org.apache.sis.util.iso.Types;
+import org.apache.sis.xml.bind.Context;
+import org.apache.sis.xml.bind.cat.CodeListUID;
+
+
+/**
+ * An adapter for {@link UnsupportedCodeList}, in order to implement the ISO 19115-3 standard.
+ * See {@link org.apache.sis.xml.bind.cat.CodeListAdapter} for more information.
+ *
+ * @param <ValueType> The subclass implementing this adapter.
+ *
+ * @author Cédric Briançon (Geomatys)
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.5
+ * @since 0.5
+ */
+public abstract class UnsupportedCodeListAdapter<ValueType extends UnsupportedCodeListAdapter<ValueType>>
+ extends XmlAdapter<ValueType,CodeList<?>>
+{
+ /**
+ * The value of the {@link CodeList}.
+ */
+ protected CodeListUID identifier;
+
+ /**
+ * Empty constructor for subclasses only.
+ */
+ protected UnsupportedCodeListAdapter() {
+ }
+
+ /**
+ * Creates a wrapper for a {@link CodeList}, in order to handle the format specified in ISO-19139.
+ *
+ * @param value the value of the {@link CodeList} to be marshalled.
+ */
+ protected UnsupportedCodeListAdapter(final CodeListUID value) {
+ identifier = value;
+ }
+
+ /**
+ * Wraps the code into an adapter.
+ * Most implementations will be like below:
+ *
+ * {@snippet lang="java" :
+ * return new ValueType(value);
+ * }
+ *
+ * @param value the value of {@link CodeList} to be marshalled.
+ * @return the wrapper for the code list value.
+ */
+ protected abstract ValueType wrap(CodeListUID value);
+
+ /**
+ * Returns the name of the code list class.
+ *
+ * @return the code list class name.
+ */
+ protected abstract String getCodeListName();
+
+ /**
+ * Substitutes the adapter value read from an XML stream by the object which will
+ * contains the value. JAXB calls automatically this method at unmarshalling time.
+ *
+ * @param adapter the adapter for this metadata value.
+ * @return a code list which represents the metadata value.
+ */
+ @Override
+ public final CodeList<?> unmarshal(final ValueType adapter) {
+ if (adapter == null) {
+ return null;
+ }
+ return Types.forCodeName(UnsupportedCodeList.class, adapter.identifier.toString(), true);
+ }
+
+ /**
+ * Substitutes the code list by the adapter to be marshalled into an XML file or stream.
+ * JAXB calls automatically this method at marshalling time.
+ *
+ * @param value the code list value.
+ * @return the adapter for the given code list.
+ */
+ @Override
+ public final ValueType marshal(final CodeList<?> value) {
+ if (value == null) {
+ return null;
+ }
+ final String name = value.name();
+ final int length = name.length();
+ final StringBuilder buffer = new StringBuilder(length);
+ final String codeListValue = toIdentifier(name, buffer, false);
+ buffer.setLength(0);
+ return wrap(new CodeListUID(Context.current(), getCodeListName(), codeListValue,
+ null, toIdentifier(name, buffer, true)));
+ }
+
+ /**
+ * Converts the given Java constant name to something hopefully close to the UML identifier,
+ * or close to the textual value to put in the XML. This method convert the Java constant name
+ * to camel case if {@code isValue} is {@code true}, or to lower cases with word separated by
+ * spaces if {@code isValue} is {@code true}.
+ *
+ * @param name The Java constant name (e.g. {@code WEB_SERVICES}).
+ * @param buffer An initially empty buffer to use for creating the identifier.
+ * @param isValue {@code false} for the {@code codeListValue} attribute, or {@code true} for the XML value.
+ * @return The identifier (e.g. {@code "webServices"} or {@code "Web services"}).
+ */
+ protected String toIdentifier(final String name, final StringBuilder buffer, final boolean isValue) {
+ final int length = name.length();
+ boolean toUpper = isValue;
+ for (int i=0; i<length;) {
+ int c = name.codePointAt(i);
+ i += Character.charCount(c);
+ if (c == '_') {
+ if (isValue) {
+ c = ' ';
+ } else {
+ toUpper = true;
+ continue;
+ }
+ }
+ if (toUpper) {
+ c = Character.toUpperCase(c);
+ toUpper = false;
+ } else {
+ c = Character.toLowerCase(c);
+ }
+ buffer.appendCodePoint(c);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Invoked by JAXB on marshalling. Subclasses must override this
+ * method with the appropriate {@code @XmlElement} annotation.
+ *
+ * @return The {@code CodeList} value to be marshalled.
+ */
+ public abstract CodeListUID getElement();
+
+ /*
+ * We do not define setter method (even abstract) since it seems to confuse JAXB.
+ * It is subclasses responsibility to define the setter method.
+ */
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/package-info.java
new file mode 100644
index 0000000..eca7531
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/package-info.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides a transition path for new GeoAPI elements not yet published in a formal release.
+ * We try to avoid putting a copy of those new elements in Apache SIS, since it would break
+ * compatibility when they would be removed in favor of GeoAPI elements. The approach taken
+ * is rather to use in the new API the most immediate parent available in a GeoAPI release.
+ * For example for new code list classes, this is {@code CodeList<?>}. The Javadoc for such
+ * API shall contain a warning. See {@code warning-templates.txt} for some proposals.
+ *
+ * <p><STRONG>Do not use!</STRONG></p>
+ *
+ * This package is for internal use by SIS only. Classes in this package
+ * may change in incompatible ways in any future version without notice.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since 0.5
+ */
+package org.apache.sis.pending.geoapi.evolution;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/warning-templates.txt b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/warning-templates.txt
new file mode 100644
index 0000000..1172b94
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/evolution/warning-templates.txt
@@ -0,0 +1,33 @@
+Suggestions for the Javadoc of methods having a CodeList<?> return type
+(replace "NewCodeList" and "3.1" by appropriate values):
+
+ *
+ * <div class="warning"><b>Upcoming API change — specialization</b><br>
+ * The argument type will be changed to the {@code NewCodeList} code list when GeoAPI will provide it
+ * (tentatively in GeoAPI 3.1). In the meantime, users can define their own code list class as below:
+ *
+ * {@snippet lang="java" :
+ * final class UnsupportedCodeList extends CodeList<UnsupportedCodeList> {
+ * private static final List<UnsupportedCodeList> VALUES = new ArrayList<UnsupportedCodeList>();
+ *
+ * // Need to declare at least one code list element.
+ * public static final UnsupportedCodeList MY_CODE_LIST = new UnsupportedCodeList("MY_CODE_LIST");
+ *
+ * private UnsupportedCodeList(String name) {
+ * super(name, VALUES);
+ * }
+ *
+ * public static UnsupportedCodeList valueOf(String code) {
+ * return valueOf(UnsupportedCodeList.class, code);
+ * }
+ *
+ * @Override
+ * public UnsupportedCodeList[] family() {
+ * synchronized (VALUES) {
+ * return VALUES.toArray(new UnsupportedCodeList[VALUES.size()]);
+ * }
+ * }
+ * }
+ * }
+ * </div>
+ *
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CompoundCurve.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/IndeterminateValue.java
similarity index 71%
rename from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CompoundCurve.java
rename to endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/IndeterminateValue.java
index 28cb6ff..7377346 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CompoundCurve.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/IndeterminateValue.java
@@ -14,21 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries;
+package org.apache.sis.pending.geoapi.temporal;
+
+import java.util.Locale;
/**
+ * Indications that a temporal position is not precisely known.
*
- * @todo
- * @author Johann Sorel (Geomatys
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#compound_curve
+ * @author Martin Desruisseaux (Geomatys)
*/
-public interface CompoundCurve extends Curve {
+public enum IndeterminateValue {
+ UNKNOWN, NOW, BEFORE, AFTER;
- public static final String TYPE = "COMPOUNDCURVE";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
+ public String identifier() {
+ return name().toLowerCase(Locale.US);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Instant.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Instant.java
new file mode 100644
index 0000000..02b3685
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Instant.java
@@ -0,0 +1,57 @@
+/*
+ * 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.pending.geoapi.temporal;
+
+import java.util.Optional;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAmount;
+import org.opengis.temporal.TemporalPrimitive;
+
+
+/**
+ * Placeholder for a GeoAPI interfaces not present in GeoAPI 3.0.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 1.5
+ * @version 1.5
+ */
+public interface Instant extends TemporalPrimitive {
+ /**
+ * Returns the date, time or position on the time-scale represented by this primitive.
+ */
+ Temporal getPosition();
+
+ /**
+ * Returns the reason why the temporal position is missing or inaccurate.
+ *
+ * @return the reason why the position is indeterminate.
+ */
+ default Optional<IndeterminateValue> getIndeterminatePosition() {
+ return Optional.empty();
+ }
+
+ /**
+ * Returns the distance from this instant to another instant or a period (optional operation).
+ */
+ default TemporalAmount distance(TemporalPrimitive other) {
+ throw new UnsupportedOperationException();
+ }
+
+ default TemporalOperatorName findRelativePosition(TemporalPrimitive other) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Period.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Period.java
new file mode 100644
index 0000000..1212795
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/Period.java
@@ -0,0 +1,55 @@
+/*
+ * 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.pending.geoapi.temporal;
+
+import java.time.temporal.TemporalAmount;
+import org.opengis.temporal.TemporalPrimitive;
+
+
+/**
+ * Placeholder for a GeoAPI interfaces not present in GeoAPI 3.0.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 1.5
+ */
+public interface Period extends TemporalPrimitive {
+ /**
+ * Links this period to the instant at which it ends.
+ *
+ * @return The beginning instant.
+ */
+ Instant getBeginning();
+
+ /**
+ * Links this period to the instant at which it ends.
+ *
+ * @return The end instant.
+ */
+ Instant getEnding();
+
+ /**
+ * Returns the duration of this period (optional operation).
+ */
+ default TemporalAmount length() {
+ return getBeginning().distance(getEnding());
+ }
+
+ default TemporalOperatorName findRelativePosition(TemporalPrimitive other) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/TemporalOperatorName.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/TemporalOperatorName.java
new file mode 100644
index 0000000..50a05aa
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/TemporalOperatorName.java
@@ -0,0 +1,54 @@
+/*
+ * 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.pending.geoapi.temporal;
+
+import java.util.Optional;
+
+
+/**
+ * Placeholder for GeoAPI 3.1 interfaces (not yet released).
+ * Shall not be visible in public API, as it will be deleted after next GeoAPI release.
+ */
+@SuppressWarnings("doclint:missing")
+public enum TemporalOperatorName {
+ AFTER, BEFORE(AFTER), BEGINS, BEGUN_BY(BEGINS), CONTAINS, DURING(CONTAINS),
+ EQUALS, OVERLAPS, MEETS, ENDS,
+ OVERLAPPED_BY(OVERLAPS), MET_BY(MEETS), ENDED_BY(ENDS), ANY_INTERACTS;
+
+ static {
+ EQUALS.reversed = EQUALS;
+ ANY_INTERACTS.reversed = ANY_INTERACTS;
+ }
+
+ private TemporalOperatorName reversed;
+
+ private TemporalOperatorName() {
+ }
+
+ private TemporalOperatorName(TemporalOperatorName r) {
+ reversed = r;
+ r.reversed = this;
+ }
+
+ public String identifier() {
+ return name().toLowerCase();
+ }
+
+ public Optional<TemporalOperatorName> reversed() {
+ return Optional.of(reversed);
+ }
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/package-info.java
similarity index 68%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
copy to endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/package-info.java
index 05e9c3c..f5965ef 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/Bezier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/geoapi/temporal/package-info.java
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
/**
+ * Placeholder for GeoAPI interfaces not present in GeoAPI 3.0.
*
- * @author Johann Sorel (Geomatys)
+ * <STRONG>Do not use!</STRONG>
+ *
+ * This package is for internal use by SIS only. Classes in this package
+ * may change in incompatible ways in any future version without notice.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 1.5
*/
-@UML(identifier="Bezier", specification=ISO_19107) // section 7.13.7
-public interface Bezier extends PolynomialSpline, BSplineCurve{
-
-}
+package org.apache.sis.pending.geoapi.temporal;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultInstant.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultInstant.java
index 4ab36a6..8ef0761 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultInstant.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultInstant.java
@@ -29,12 +29,11 @@
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.IndeterminateValue;
-import org.opengis.temporal.IndeterminatePositionException;
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
+import org.apache.sis.pending.geoapi.temporal.Instant;
+import org.apache.sis.pending.geoapi.temporal.IndeterminateValue;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -260,7 +259,7 @@
if (canTestAfter && ((TimeMethods) comparators).isAfter .test(t1, t2)) return TemporalOperatorName.AFTER;
if (canTestEqual && ((TimeMethods) comparators).isEqual .test(t1, t2)) return TemporalOperatorName.EQUALS;
}
- throw new IndeterminatePositionException(Errors.format(Errors.Keys.IndeterminatePosition));
+ throw new DateTimeException(Errors.format(Errors.Keys.IndeterminatePosition));
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriod.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriod.java
index f5a506a..0db49a9 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriod.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriod.java
@@ -26,10 +26,10 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.privy.LazyCandidate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.Period;
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Instant;
+import org.apache.sis.pending.geoapi.temporal.Period;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java
index c0372e7..0ef273b 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java
@@ -20,11 +20,6 @@
import java.time.temporal.TemporalAmount;
import org.opengis.temporal.PeriodDuration;
-// Specific to the geoapi-3.1 branch:
-import java.time.temporal.Temporal;
-import java.time.temporal.TemporalUnit;
-import java.util.List;
-
/**
* Default implementation of GeoAPI period duration.
@@ -49,11 +44,6 @@
this.duration = duration;
}
- @Override public List<TemporalUnit> getUnits() {return duration.getUnits();}
- @Override public long get (TemporalUnit unit) {return duration.get(unit);}
- @Override public Temporal addTo (Temporal temporal) {return duration.addTo(temporal);}
- @Override public Temporal subtractFrom(Temporal temporal) {return duration.subtractFrom(temporal);}
-
/** String representation. */
@Override public String toString() {
return duration.toString();
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/GeneralDuration.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/GeneralDuration.java
index 6cd1724..894d4c6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/GeneralDuration.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/GeneralDuration.java
@@ -37,10 +37,9 @@
import org.apache.sis.util.privy.UnmodifiableArrayList;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.IndeterminateValue;
-import org.opengis.temporal.IndeterminatePositionException;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Instant;
+import org.apache.sis.pending.geoapi.temporal.IndeterminateValue;
/**
@@ -146,7 +145,7 @@
return null; // Avoid fetching the current time now.
}
}
- throw new IndeterminatePositionException(Errors.format(Errors.Keys.IndeterminatePosition));
+ throw new DateTimeException(Errors.format(Errors.Keys.IndeterminatePosition));
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalObjects.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalObjects.java
index 027c086..72877de 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalObjects.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalObjects.java
@@ -22,10 +22,10 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.IndeterminateValue;
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.Period;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.IndeterminateValue;
+import org.apache.sis.pending.geoapi.temporal.Instant;
+import org.apache.sis.pending.geoapi.temporal.Period;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultNameFactory.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultNameFactory.java
index 3ce5f70..665bc05 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultNameFactory.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultNameFactory.java
@@ -256,7 +256,6 @@
*
* @since 1.3
*/
- @Override
public TypeName createTypeName(final NameSpace scope, final CharSequence name, final Type javaType) {
return pool.unique(new DefaultTypeName(scope, name, javaType));
}
@@ -274,7 +273,6 @@
* @see Names#createMemberName(CharSequence, String, CharSequence, TypeName)
* @see Names#createMemberName(CharSequence, String, CharSequence, Class)
*/
- @Override
public MemberName createMemberName(final NameSpace scope, final CharSequence name, final TypeName attributeType) {
return pool.unique(new DefaultMemberName(scope, name, attributeType));
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecord.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecord.java
index a7ef38b..7e435c0 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecord.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecord.java
@@ -174,9 +174,25 @@
*
* @return the dictionary of all (<var>name</var>, <var>value</var>) pairs in this record.
*
- * @see RecordType#getFieldTypes()
+ * @see RecordType#getMemberTypes()
+ *
+ * @deprecated Renamed {@link #getFields()} for consistency with the 2015 revision of ISO 19103 standard.
*/
@Override
+ @Deprecated
+ public Map<MemberName, Object> getAttributes() {
+ return getFields();
+ }
+
+ /**
+ * Returns the dictionary of all (<var>name</var>, <var>value</var>) pairs in this record.
+ * This method returns a view which will delegate all {@code get} and {@code put} operations to
+ * the {@link #locate(MemberName)} and {@link #set(MemberName, Object)} methods respectively.
+ *
+ * @return the dictionary of all (<var>name</var>, <var>value</var>) pairs in this record.
+ *
+ * @since 1.1
+ */
public Map<MemberName, Object> getFields() {
if (values == null) { // Should never be null, except temporarily at XML unmarshalling time.
return Map.of();
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java
index 8b29bd6..f556a04 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordSchema.java
@@ -39,9 +39,6 @@
import org.apache.sis.converter.SurjectiveConverter;
import org.apache.sis.util.privy.Strings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-
/**
* A collection of record types in a given namespace.
@@ -87,14 +84,13 @@
/**
* The factory to use for creating names.
* This is the factory given at construction time.
+ *
+ * <div class="warning"><b>Upcoming API change</b> — generalization<br>
+ * This field type will be changed to the {@link NameFactory} interface when that interface
+ * will provide a {@code createMemberName(…)} method (tentatively in GeoAPI 3.1).
+ * </div>
*/
- protected final NameFactory nameFactory;
-
- /**
- * The helper class to use for mapping Java classes to {@code TypeName} instances, or {@code null} if not needed.
- * This helper class is needed only if {@link #nameFactory} is not an instance of {@link DefaultNameFactory}.
- */
- private final TypeNames typeFactory;
+ protected final DefaultNameFactory nameFactory;
/**
* The namespace of {@link RecordType} to be created by this class.
@@ -126,17 +122,21 @@
/**
* Creates a new schema of the given name.
*
+ * <div class="warning"><b>Upcoming API change</b> — generalization<br>
+ * This type of the first argument will be changed to the {@link NameFactory} interface when
+ * that interface will provide a {@code createMemberName(…)} method (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param nameFactory the factory to use for creating names, or {@code null} for the default factory.
* @param parent the parent namespace, or {@code null} if none.
* @param schemaName the name of the new schema.
*/
- public DefaultRecordSchema(NameFactory nameFactory, final NameSpace parent, final CharSequence schemaName) {
+ public DefaultRecordSchema(DefaultNameFactory nameFactory, final NameSpace parent, final CharSequence schemaName) {
ArgumentChecks.ensureNonNull("schemaName", schemaName);
if (nameFactory == null) {
nameFactory = DefaultNameFactory.provider();
}
this.nameFactory = nameFactory;
- this.typeFactory = (nameFactory instanceof DefaultNameFactory) ? null : new TypeNames(nameFactory);
this.namespace = nameFactory.createNameSpace(nameFactory.createLocalName(parent, schemaName), null);
this.description = new WeakValueHashMap<>(TypeName.class);
this.attributeTypes = new ConcurrentHashMap<>();
@@ -192,7 +192,7 @@
* If a record type already exists for the given name, verify that it contains the same fields.
*/
final Iterator<Map.Entry<CharSequence,Class<?>>> it1 = fields.entrySet().iterator();
- final Iterator<Map.Entry<MemberName,Type>> it2 = record.getFieldTypes().entrySet().iterator();
+ final Iterator<Map.Entry<MemberName,Type>> it2 = record.getMemberTypes().entrySet().iterator();
boolean hasNext;
while ((hasNext = it1.hasNext()) == it2.hasNext()) {
if (!hasNext) {
@@ -203,7 +203,7 @@
if (!e2.getKey().tip().toString().equals(e1.toString())) {
break; // Member names differ.
}
- if (!((AttributeType) e2.getValue()).getValueClass().equals(e1.getValue())) {
+ if (!((SimpleAttributeType) e2.getValue()).getValueClass().equals(e1.getValue())) {
break; // Value classes differ.
}
}
@@ -227,12 +227,7 @@
if (valueClass == Void.TYPE) {
throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2, "valueClass", "void"));
}
- final TypeName name;
- if (nameFactory instanceof DefaultNameFactory) {
- name = ((DefaultNameFactory) nameFactory).toTypeName(valueClass);
- } else {
- name = typeFactory.toTypeName(nameFactory, valueClass);
- }
+ final TypeName name = nameFactory.toTypeName(valueClass);
type = new SimpleAttributeType<>(name, valueClass);
final Type old = attributeTypes.putIfAbsent(valueClass, type);
if (old != null) { // May happen if the type has been computed concurrently.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java
index 55bb94d..9e7965f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultRecordType.java
@@ -44,9 +44,6 @@
import org.apache.sis.converter.SurjectiveConverter;
import org.apache.sis.metadata.privy.RecordSchemaSIS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.NameFactory;
-
/**
* An immutable definition of the type of a {@linkplain DefaultRecord record}.
@@ -98,7 +95,7 @@
*
* @see #getContainer()
*/
- @SuppressWarnings({"serial", "deprecation"})
+ @SuppressWarnings("serial")
private final RecordSchema container;
/**
@@ -113,11 +110,11 @@
*
* @param other the {@code RecordType} to copy.
*/
- @SuppressWarnings({"deprecation", "this-escape"})
+ @SuppressWarnings("this-escape")
public DefaultRecordType(final RecordType other) {
typeName = other.getTypeName();
container = other.getContainer();
- fieldTypes = computeTransientFields(other.getFieldTypes());
+ fieldTypes = computeTransientFields(other.getMemberTypes());
}
/**
@@ -196,7 +193,7 @@
*/
@Deprecated(since = "1.5", forRemoval = true)
DefaultRecordType(final TypeName typeName, final RecordSchema container,
- final Map<? extends CharSequence, ? extends Type> fields, final NameFactory nameFactory)
+ final Map<? extends CharSequence, ? extends Type> fields, final DefaultNameFactory nameFactory)
{
this.typeName = typeName;
this.container = container;
@@ -333,8 +330,28 @@
* </div>
*
* @return the dictionary of (<var>name</var>, <var>type</var>) pairs, or an empty map if none.
+ *
+ * @deprecated Renamed {@link #getFieldTypes()} for consistency with the 2015 revision of ISO 19103 standard.
*/
@Override
+ @Deprecated
+ public Map<MemberName,Type> getMemberTypes() {
+ return getFieldTypes();
+ }
+
+ /**
+ * Returns the dictionary of all (<var>name</var>, <var>type</var>) pairs in this record type.
+ * The returned map is unmodifiable.
+ *
+ * <div class="note"><b>Comparison with Java reflection:</b>
+ * If we think about this {@code RecordType} as equivalent to a {@code Class} instance, then
+ * this method can be though as the related to the Java {@link Class#getFields()} method.
+ * </div>
+ *
+ * @return the dictionary of (<var>name</var>, <var>type</var>) pairs, or an empty map if none.
+ *
+ * @since 1.1
+ */
public Map<MemberName,Type> getFieldTypes() {
return ObjectConverters.derivedValues(fieldIndices(), MemberName.class, new SurjectiveConverter<Integer,Type>() {
@Override public Class<Integer> getSourceClass() {return Integer.class;}
@@ -404,7 +421,7 @@
*/
@Override
public boolean isInstance(final Record record) {
- return (record != null) && getMembers().containsAll(record.getFields().keySet());
+ return (record != null) && getMembers().containsAll(record.getAttributes().keySet());
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultTypeName.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultTypeName.java
index 38350ca..95c2495 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultTypeName.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/DefaultTypeName.java
@@ -254,7 +254,7 @@
if (object == null || object instanceof DefaultTypeName) {
return (DefaultTypeName) object;
}
- return new DefaultTypeName(object.scope(), object.toInternationalString(), object.toJavaType().orElse(null));
+ return new DefaultTypeName(object.scope(), object.toInternationalString(), null);
}
/**
@@ -267,7 +267,6 @@
*
* @since 1.3
*/
- @Override
public Optional<Type> toJavaType() {
return Optional.ofNullable(javaType);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Names.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Names.java
index 50ee62a..e6015be 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Names.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Names.java
@@ -333,7 +333,7 @@
{
ArgumentChecks.ensureNonNull("localPart", localPart);
ArgumentChecks.ensureNonNull("attributeType", attributeType);
- final NameFactory factory = DefaultNameFactory.provider();
+ final DefaultNameFactory factory = DefaultNameFactory.provider();
return factory.createMemberName(createNameSpace(factory, namespace, separator), localPart, attributeType);
}
@@ -422,9 +422,11 @@
if (type == null) {
return null;
}
- final Type t = type.toJavaType().orElse(null);
- if (t instanceof Class<?>) {
- return (Class<?>) t;
+ if (type instanceof DefaultTypeName) {
+ final Type t = ((DefaultTypeName) type).toJavaType().orElse(null);
+ if (t instanceof Class<?>) {
+ return (Class<?>) t;
+ }
}
ClassNotFoundException cause;
try {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/RecordDefinition.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/RecordDefinition.java
index 2cc1241..29ea763 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/RecordDefinition.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/RecordDefinition.java
@@ -31,8 +31,8 @@
import org.apache.sis.util.privy.CollectionsExt;
import org.apache.sis.pending.jdk.JDK19;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.metadata.simple.SimpleAttributeType;
/**
@@ -76,7 +76,7 @@
*/
Adapter(final RecordType recordType) {
this.recordType = recordType;
- computeTransientFields(recordType.getFieldTypes());
+ computeTransientFields(recordType.getMemberTypes());
}
/**
@@ -88,7 +88,7 @@
*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- computeTransientFields(recordType.getFieldTypes());
+ computeTransientFields(recordType.getMemberTypes());
}
/**
@@ -151,8 +151,8 @@
int i = 0;
for (final Map.Entry<? extends MemberName, ? extends Type> entry : fieldTypes.entrySet()) {
final Type type = entry.getValue();
- if (type instanceof AttributeType) {
- final Class<?> c = ((AttributeType) type).getValueClass();
+ if (type instanceof SimpleAttributeType) {
+ final Class<?> c = ((SimpleAttributeType) type).getValueClass();
if (c != Object.class) {
if (valueClasses == null) {
valueClasses = new Class<?>[size];
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
index 593db8d..fa970a2 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
@@ -49,9 +49,8 @@
import org.apache.sis.pending.jdk.JDK19;
import org.apache.sis.system.Modules;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.annotation.ResourceBundles;
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import java.io.InputStream;
/**
@@ -60,14 +59,14 @@
*
* <ul>
* <li>Methods for fetching the ISO name or description of a code list:<ul>
- * <li>{@link #getStandardName(Class)} for ISO name</li>
- * <li>{@link #getListName(ControlledVocabulary)} for ISO name</li>
- * <li>{@link #getDescription(Class)} for a description</li>
+ * <li>{@link #getStandardName(Class)} for ISO name</li>
+ * <li>{@link #getListName(CodeList)} for ISO name</li>
+ * <li>{@link #getDescription(Class)} for a description</li>
* </ul></li>
* <li>Methods for fetching the ISO name or description of a code value:<ul>
- * <li>{@link #getCodeName(ControlledVocabulary)} for ISO name,</li>
- * <li>{@link #getCodeTitle(ControlledVocabulary)} for a label or title</li>
- * <li>{@link #getDescription(ControlledVocabulary)} for a more verbose description</li>
+ * <li>{@link #getCodeName(CodeList)} for ISO name,</li>
+ * <li>{@link #getCodeTitle(CodeList)} for a label or title</li>
+ * <li>{@link #getDescription(CodeList)} for a more verbose description</li>
* </ul></li>
* <li>Methods for fetching an instance from a name (converse of above {@code get} methods):<ul>
* <li>{@link #forCodeName(Class, String, boolean)}</li>
@@ -80,7 +79,7 @@
* by a {@link CodeList} value. Such substitution can be done with:
*
* <ul>
- * <li>{@link #getCodeTitle(ControlledVocabulary)} for getting the {@link InternationalString} instance
+ * <li>{@link #getCodeTitle(CodeList)} for getting the {@link InternationalString} instance
* to store in a metadata property.</li>
* <li>{@link #forCodeTitle(CharSequence)} for retrieving the {@link CodeList} previously stored as an
* {@code InternationalString}.</li>
@@ -139,7 +138,7 @@
* <li><code>getStandardName({@linkplain org.opengis.metadata.citation.Citation}.class)</code>
* (an interface) returns {@code "CI_Citation"}.</li>
* <li><code>getStandardName({@linkplain org.opengis.referencing.cs.AxisDirection}.class)</code>
- * (a code list) returns {@code "AxisDirection"}.</li>
+ * (a code list) returns {@code "CS_AxisDirection"}.</li>
* </ul>
*
* <h4>Implementation note</h4>
@@ -181,7 +180,7 @@
* <h4>Examples</h4>
* <ul>
* <li>{@code getListName(ParameterDirection.IN_OUT)} returns {@code "SV_ParameterDirection"}.</li>
- * <li>{@code getListName(AxisDirection.NORTH)} returns {@code "AxisDirection"}.</li>
+ * <li>{@code getListName(AxisDirection.NORTH)} returns {@code "CS_AxisDirection"}.</li>
* <li>{@code getListName(TopicCategory.INLAND_WATERS)} returns {@code "MD_TopicCategoryCode"}.</li>
* <li>{@code getListName(ImagingCondition.BLURRED_IMAGE)} returns {@code "MD_ImagingConditionCode"}.</li>
* </ul>
@@ -189,11 +188,11 @@
* @param code the code for which to get the class name, or {@code null}.
* @return the ISO (preferred) or Java (fallback) class name, or {@code null} if the given code is null.
*/
- public static String getListName(final ControlledVocabulary code) {
+ public static String getListName(final CodeList<?> code) {
if (code == null) {
return null;
}
- final Class<?> type = (code instanceof Enum<?>) ? ((Enum<?>) code).getDeclaringClass() : code.getClass();
+ final Class<?> type = code.getClass();
final String id = getStandardName(type);
return (id != null) ? id : type.getSimpleName();
}
@@ -213,12 +212,12 @@
* @param code the code for which to get the name, or {@code null}.
* @return the UML identifiers or programmatic name for the given code, or {@code null} if the given code is null.
*
- * @see #getCodeLabel(ControlledVocabulary)
- * @see #getCodeTitle(ControlledVocabulary)
- * @see #getDescription(ControlledVocabulary)
+ * @see #getCodeLabel(CodeList)
+ * @see #getCodeTitle(CodeList)
+ * @see #getDescription(CodeList)
* @see #forCodeName(Class, String, boolean)
*/
- public static String getCodeName(final ControlledVocabulary code) {
+ public static String getCodeName(final CodeList<?> code) {
if (code == null) {
return null;
}
@@ -242,7 +241,7 @@
* Returns a unlocalized title for the given enumeration or code list value.
* This method builds a title using heuristics rules, which should give reasonable
* results without the need of resource bundles. For better results, consider using
- * {@link #getCodeTitle(ControlledVocabulary)} instead.
+ * {@link #getCodeTitle(CodeList)} instead.
*
* <p>The current heuristic implementation iterates over {@linkplain CodeList#names() all code names},
* selects the longest one excluding the {@linkplain CodeList#name() field name} if possible, then
@@ -258,11 +257,11 @@
* @param code the code from which to get a title, or {@code null}.
* @return a unlocalized title for the given code, or {@code null} if the given code is null.
*
- * @see #getCodeName(ControlledVocabulary)
- * @see #getCodeTitle(ControlledVocabulary)
- * @see #getDescription(ControlledVocabulary)
+ * @see #getCodeName(CodeList)
+ * @see #getCodeTitle(CodeList)
+ * @see #getDescription(CodeList)
*/
- public static String getCodeLabel(final ControlledVocabulary code) {
+ public static String getCodeLabel(final CodeList<?> code) {
if (code == null) {
return null;
}
@@ -278,7 +277,7 @@
/**
* Returns the title of the given enumeration or code list value. Title are usually much shorter than descriptions.
- * English titles are often the same as the {@linkplain #getCodeLabel(ControlledVocabulary) code labels}.
+ * English titles are often the same as the {@linkplain #getCodeLabel(CodeList) code labels}.
*
* <p>The code or enumeration value given in argument to this method can be retrieved from the returned title
* with the {@link #forCodeTitle(CharSequence)} method. See <cite>Substituting a free text by a code list</cite>
@@ -287,10 +286,10 @@
* @param code the code for which to get the title, or {@code null}.
* @return the title, or {@code null} if the given code is null.
*
- * @see #getDescription(ControlledVocabulary)
+ * @see #getDescription(CodeList)
* @see #forCodeTitle(CharSequence)
*/
- public static InternationalString getCodeTitle(final ControlledVocabulary code) {
+ public static InternationalString getCodeTitle(final CodeList<?> code) {
return (code != null) ? new CodeTitle(code) : null;
}
@@ -302,11 +301,11 @@
* @param code the code for which to get the localized description, or {@code null}.
* @return the description, or {@code null} if none or if the given code is null.
*
- * @see #getCodeTitle(ControlledVocabulary)
+ * @see #getCodeTitle(CodeList)
* @see #getDescription(Class)
*/
@OptionalCandidate
- public static InternationalString getDescription(final ControlledVocabulary code) {
+ public static InternationalString getDescription(final CodeList<?> code) {
if (code != null && hasResources(code.getClass())) {
return new Description(Description.resourceKey(code));
}
@@ -320,7 +319,7 @@
* @param type the GeoAPI interface or code list from which to get the description, or {@code null}.
* @return the description, or {@code null} if none or if the given type is {@code null}.
*
- * @see #getDescription(ControlledVocabulary)
+ * @see #getDescription(CodeList)
*/
@OptionalCandidate
public static InternationalString getDescription(final Class<?> type) {
@@ -363,6 +362,11 @@
private static final long serialVersionUID = -6202647167398898834L;
/**
+ * The class loader to use for fetching GeoAPI resources.
+ */
+ private static final ClassLoader CLASSLOADER = Types.class.getClassLoader();
+
+ /**
* Creates a new international string from the specified resource bundle and key.
*
* @param key the key for the resource to fetch.
@@ -376,7 +380,7 @@
*/
@Override
protected ResourceBundle getBundle(final Locale locale) {
- return ResourceBundles.descriptions(locale);
+ return ResourceBundle.getBundle("org.opengis.metadata.Descriptions", locale, CLASSLOADER);
}
/**
@@ -403,7 +407,7 @@
/**
* Returns the resource key for the given code list.
*/
- static String resourceKey(final ControlledVocabulary code) {
+ static String resourceKey(final CodeList<?> code) {
String key = getCodeName(code);
if (key.indexOf(SEPARATOR) < 0) {
key = getListName(code) + SEPARATOR + key;
@@ -429,15 +433,14 @@
/**
* The code list for which to create a title.
*/
- @SuppressWarnings("serial") // Enum and CodeList implementations are serializable.
- final ControlledVocabulary code;
+ final CodeList<?> code;
/**
* Creates a new international string for the given code list element.
*
* @param code the code list for which to create a title.
*/
- CodeTitle(final ControlledVocabulary code) {
+ CodeTitle(final CodeList<?> code) {
super(resourceKey(code));
this.code = code;
}
@@ -447,7 +450,7 @@
*/
@Override
protected ResourceBundle getBundle(final Locale locale) {
- return ResourceBundles.codeLists(locale);
+ return ResourceBundle.getBundle(CodeLists.RESOURCES, locale);
}
/**
@@ -470,34 +473,22 @@
}
/**
- * Returns all known values for the given type of code list or enumeration.
+ * Returns all known values for the given type of code list.
* Note that the size of the returned array may growth between different invocations of this method,
* since users can add their own codes to an existing list.
*
- * <h4>Performance note</h4>
- * This method works with both {@link Enum} and {@link CodeList}. However if the type is known to be
- * an {@code Enum}, then the standard {@link Class#getEnumConstants()} method is more efficient.
- *
* @param <T> the compile-time type given as the {@code codeType} parameter.
- * @param codeType the type of code list or enumeration.
- * @return the list of values for the given code list or enumeration, or an empty array if none.
+ * @param codeType the type of code list.
+ * @return the list of values for the given code list, or an empty array if none.
*
* @see Class#getEnumConstants()
*
* @deprecated This method depends on reflection, which is restricted in the context of Java Module System.
* Instead, {@code T.values()} static methods should be invoked directly as much as possible.
*/
- @SuppressWarnings("unchecked")
@Deprecated(since="1.5", forRemoval=true)
- public static <T extends ControlledVocabulary> T[] getCodeValues(final Class<T> codeType) {
- if (CodeList.class.isAssignableFrom(codeType)) {
- return (T[]) CodeList.values((Class) codeType);
- }
- final T[] codes = codeType.getEnumConstants();
- if (codes != null) {
- return codes;
- }
- return (T[]) Array.newInstance(codeType, 0);
+ public static <T extends CodeList<?>> T[] getCodeValues(final Class<T> codeType) {
+ return CodeLists.values(codeType);
}
/**
@@ -507,8 +498,8 @@
*
* <h4>Examples</h4>
* <ul>
- * <li>{@code forStandardName("CI_Citation")} returns <code>{@linkplain org.opengis.metadata.citation.Citation}.class</code></li>
- * <li>{@code forStandardName("AxisDirection")} returns <code>{@linkplain org.opengis.referencing.cs.AxisDirection}.class</code></li>
+ * <li>{@code forStandardName("CI_Citation")} returns <code>{@linkplain org.opengis.metadata.citation.Citation}.class</code></li>
+ * <li>{@code forStandardName("CS_AxisDirection")} returns <code>{@linkplain org.opengis.referencing.cs.AxisDirection}.class</code></li>
* </ul>
*
* <h4>Implementation note</h4>
@@ -537,9 +528,15 @@
return null;
}
if (typeForNames == null) {
- final Properties props;
+ final Class<Types> c = Types.class;
+ final InputStream in = c.getResourceAsStream("class-index.properties");
+ if (in == null) {
+ throw new MissingResourceException("class-index.properties", c.getName(), identifier);
+ }
+ final Properties props = new Properties();
try {
- props = ResourceBundles.classIndex();
+ props.load(in);
+ in.close();
} catch (IOException e) {
throw new BackingStoreException(e);
}
@@ -691,7 +688,7 @@
* The current implementation performs the following choice:
*
* <ul>
- * <li>If the given title is a value returned by a previous call to {@link #getCodeTitle(ControlledVocabulary)},
+ * <li>If the given title is a value returned by a previous call to {@link #getCodeTitle(CodeList)},
* returns the code or enumeration value used for creating that title.</li>
* <li>Otherwise returns {@code null}.</li>
* </ul>
@@ -699,11 +696,11 @@
* @param title the title for which to get a code or enumeration value, or {@code null}.
* @return the code or enumeration value associated with the given title, or {@code null}.
*
- * @see #getCodeTitle(ControlledVocabulary)
+ * @see #getCodeTitle(CodeList)
*
* @since 0.7
*/
- public static ControlledVocabulary forCodeTitle(final CharSequence title) {
+ public static CodeList<?> forCodeTitle(final CharSequence title) {
return (title instanceof CodeTitle) ? ((CodeTitle) title).code : null;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/class-index.properties b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/class-index.properties
new file mode 100644
index 0000000..ac30fa4
--- /dev/null
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/class-index.properties
@@ -0,0 +1,229 @@
+#
+# This is an automatically generated file. The same content is provided by GeoAPI 3.1
+# in the org.opengis.annotation package. Since this file does not exist in GeoAPI 3.0,
+# the Apache SIS branch for GeoAPI 3.0 maintains this copy (provided by the original
+# author).
+#
+CC_ConcatenatedOperation=org.opengis.referencing.operation.ConcatenatedOperation
+CC_Conversion=org.opengis.referencing.operation.Conversion
+CC_CoordinateOperation=org.opengis.referencing.operation.CoordinateOperation
+CC_Formula=org.opengis.referencing.operation.Formula
+CC_GeneralOperationParameter=org.opengis.parameter.GeneralParameterDescriptor
+CC_GeneralParameterValue=org.opengis.parameter.GeneralParameterValue
+CC_OperationMethod=org.opengis.referencing.operation.OperationMethod
+CC_OperationParameter=org.opengis.parameter.ParameterDescriptor
+CC_OperationParameterGroup=org.opengis.parameter.ParameterDescriptorGroup
+CC_ParameterValue=org.opengis.parameter.ParameterValue
+CC_ParameterValueGroup=org.opengis.parameter.ParameterValueGroup
+CC_PassThroughOperation=org.opengis.referencing.operation.PassThroughOperation
+CC_SingleOperation=org.opengis.referencing.operation.SingleOperation
+CC_Transformation=org.opengis.referencing.operation.Transformation
+CD_Datum=org.opengis.referencing.datum.Datum
+CD_Ellipsoid=org.opengis.referencing.datum.Ellipsoid
+CD_EngineeringDatum=org.opengis.referencing.datum.EngineeringDatum
+CD_GeodeticDatum=org.opengis.referencing.datum.GeodeticDatum
+CD_ImageDatum=org.opengis.referencing.datum.ImageDatum
+CD_PixelInCell=org.opengis.referencing.datum.PixelInCell
+CD_PrimeMeridian=org.opengis.referencing.datum.PrimeMeridian
+CD_TemporalDatum=org.opengis.referencing.datum.TemporalDatum
+CD_VerticalDatum=org.opengis.referencing.datum.VerticalDatum
+CD_VerticalDatumType=org.opengis.referencing.datum.VerticalDatumType
+CI_Address=org.opengis.metadata.citation.Address
+CI_Citation=org.opengis.metadata.citation.Citation
+CI_Contact=org.opengis.metadata.citation.Contact
+CI_Date=org.opengis.metadata.citation.CitationDate
+CI_DateTypeCode=org.opengis.metadata.citation.DateType
+CI_OnLineFunctionCode=org.opengis.metadata.citation.OnLineFunction
+CI_OnlineResource=org.opengis.metadata.citation.OnlineResource
+CI_PresentationFormCode=org.opengis.metadata.citation.PresentationForm
+CI_ResponsibleParty=org.opengis.metadata.citation.ResponsibleParty
+CI_RoleCode=org.opengis.metadata.citation.Role
+CI_Series=org.opengis.metadata.citation.Series
+CI_Telephone=org.opengis.metadata.citation.Telephone
+CS_AffineCS=org.opengis.referencing.cs.AffineCS
+CS_AxisDirection=org.opengis.referencing.cs.AxisDirection
+CS_CartesianCS=org.opengis.referencing.cs.CartesianCS
+CS_CoordinateSystem=org.opengis.referencing.cs.CoordinateSystem
+CS_CoordinateSystemAxis=org.opengis.referencing.cs.CoordinateSystemAxis
+CS_CylindricalCS=org.opengis.referencing.cs.CylindricalCS
+CS_EllipsoidalCS=org.opengis.referencing.cs.EllipsoidalCS
+CS_LinearCS=org.opengis.referencing.cs.LinearCS
+CS_PolarCS=org.opengis.referencing.cs.PolarCS
+CS_RangeMeaning=org.opengis.referencing.cs.RangeMeaning
+CS_SphericalCS=org.opengis.referencing.cs.SphericalCS
+CS_TimeCS=org.opengis.referencing.cs.TimeCS
+CS_UserDefinedCS=org.opengis.referencing.cs.UserDefinedCS
+CS_VerticalCS=org.opengis.referencing.cs.VerticalCS
+DQ_AbsoluteExternalPositionalAccuracy=org.opengis.metadata.quality.AbsoluteExternalPositionalAccuracy
+DQ_AccuracyOfATimeMeasurement=org.opengis.metadata.quality.AccuracyOfATimeMeasurement
+DQ_Completeness=org.opengis.metadata.quality.Completeness
+DQ_CompletenessCommission=org.opengis.metadata.quality.CompletenessCommission
+DQ_CompletenessOmission=org.opengis.metadata.quality.CompletenessOmission
+DQ_ConceptualConsistency=org.opengis.metadata.quality.ConceptualConsistency
+DQ_ConformanceResult=org.opengis.metadata.quality.ConformanceResult
+DQ_DataQuality=org.opengis.metadata.quality.DataQuality
+DQ_DomainConsistency=org.opengis.metadata.quality.DomainConsistency
+DQ_Element=org.opengis.metadata.quality.Element
+DQ_EvaluationMethodTypeCode=org.opengis.metadata.quality.EvaluationMethodType
+DQ_FormatConsistency=org.opengis.metadata.quality.FormatConsistency
+DQ_GriddedDataPositionalAccuracy=org.opengis.metadata.quality.GriddedDataPositionalAccuracy
+DQ_LogicalConsistency=org.opengis.metadata.quality.LogicalConsistency
+DQ_NonQuantitativeAttributeAccuracy=org.opengis.metadata.quality.NonQuantitativeAttributeAccuracy
+DQ_PositionalAccuracy=org.opengis.metadata.quality.PositionalAccuracy
+DQ_QuantitativeAttributeAccuracy=org.opengis.metadata.quality.QuantitativeAttributeAccuracy
+DQ_QuantitativeResult=org.opengis.metadata.quality.QuantitativeResult
+DQ_RelativeInternalPositionalAccuracy=org.opengis.metadata.quality.RelativeInternalPositionalAccuracy
+DQ_Result=org.opengis.metadata.quality.Result
+DQ_Scope=org.opengis.metadata.quality.Scope
+DQ_TemporalAccuracy=org.opengis.metadata.quality.TemporalAccuracy
+DQ_TemporalConsistency=org.opengis.metadata.quality.TemporalConsistency
+DQ_TemporalValidity=org.opengis.metadata.quality.TemporalValidity
+DQ_ThematicAccuracy=org.opengis.metadata.quality.ThematicAccuracy
+DQ_ThematicClassificationCorrectness=org.opengis.metadata.quality.ThematicClassificationCorrectness
+DQ_TopologicalConsistency=org.opengis.metadata.quality.TopologicalConsistency
+DS_AssociationTypeCode=org.opengis.metadata.identification.AssociationType
+DS_InitiativeTypeCode=org.opengis.metadata.identification.InitiativeType
+EX_BoundingPolygon=org.opengis.metadata.extent.BoundingPolygon
+EX_Extent=org.opengis.metadata.extent.Extent
+EX_GeographicBoundingBox=org.opengis.metadata.extent.GeographicBoundingBox
+EX_GeographicDescription=org.opengis.metadata.extent.GeographicDescription
+EX_GeographicExtent=org.opengis.metadata.extent.GeographicExtent
+EX_SpatialTemporalExtent=org.opengis.metadata.extent.SpatialTemporalExtent
+EX_TemporalExtent=org.opengis.metadata.extent.TemporalExtent
+EX_VerticalExtent=org.opengis.metadata.extent.VerticalExtent
+IO_IdentifiedObject=org.opengis.referencing.IdentifiedObject
+LE_Algorithm=org.opengis.metadata.lineage.Algorithm
+LE_NominalResolution=org.opengis.metadata.lineage.NominalResolution
+LE_ProcessStep=org.opengis.metadata.lineage.ProcessStep
+LE_ProcessStepReport=org.opengis.metadata.lineage.ProcessStepReport
+LE_Processing=org.opengis.metadata.lineage.Processing
+LE_Source=org.opengis.metadata.lineage.Source
+LI_Lineage=org.opengis.metadata.lineage.Lineage
+LI_ProcessStep=org.opengis.metadata.lineage.ProcessStep
+LI_Source=org.opengis.metadata.lineage.Source
+MD_AggregateInformation=org.opengis.metadata.identification.AggregateInformation
+MD_ApplicationSchemaInformation=org.opengis.metadata.ApplicationSchemaInformation
+MD_Band=org.opengis.metadata.content.Band
+MD_BrowseGraphic=org.opengis.metadata.identification.BrowseGraphic
+MD_CellGeometryCode=org.opengis.metadata.spatial.CellGeometry
+MD_CharacterSetCode=org.opengis.metadata.identification.CharacterSet
+MD_ClassificationCode=org.opengis.metadata.constraint.Classification
+MD_Constraints=org.opengis.metadata.constraint.Constraints
+MD_ContentInformation=org.opengis.metadata.content.ContentInformation
+MD_CoverageContentTypeCode=org.opengis.metadata.content.CoverageContentType
+MD_CoverageDescription=org.opengis.metadata.content.CoverageDescription
+MD_DataIdentification=org.opengis.metadata.identification.DataIdentification
+MD_DatatypeCode=org.opengis.metadata.Datatype
+MD_DigitalTransferOptions=org.opengis.metadata.distribution.DigitalTransferOptions
+MD_Dimension=org.opengis.metadata.spatial.Dimension
+MD_DimensionNameTypeCode=org.opengis.metadata.spatial.DimensionNameType
+MD_Distribution=org.opengis.metadata.distribution.Distribution
+MD_Distributor=org.opengis.metadata.distribution.Distributor
+MD_ExtendedElementInformation=org.opengis.metadata.ExtendedElementInformation
+MD_FeatureCatalogueDescription=org.opengis.metadata.content.FeatureCatalogueDescription
+MD_FeatureTypeList=org.opengis.metadata.FeatureTypeList
+MD_Format=org.opengis.metadata.distribution.Format
+MD_GeometricObjectTypeCode=org.opengis.metadata.spatial.GeometricObjectType
+MD_GeometricObjects=org.opengis.metadata.spatial.GeometricObjects
+MD_Georectified=org.opengis.metadata.spatial.Georectified
+MD_Georeferenceable=org.opengis.metadata.spatial.Georeferenceable
+MD_GridSpatialRepresentation=org.opengis.metadata.spatial.GridSpatialRepresentation
+MD_Identification=org.opengis.metadata.identification.Identification
+MD_Identifier=org.opengis.metadata.Identifier
+MD_ImageDescription=org.opengis.metadata.content.ImageDescription
+MD_ImagingConditionCode=org.opengis.metadata.content.ImagingCondition
+MD_KeywordTypeCode=org.opengis.metadata.identification.KeywordType
+MD_Keywords=org.opengis.metadata.identification.Keywords
+MD_LegalConstraints=org.opengis.metadata.constraint.LegalConstraints
+MD_MaintenanceFrequencyCode=org.opengis.metadata.maintenance.MaintenanceFrequency
+MD_MaintenanceInformation=org.opengis.metadata.maintenance.MaintenanceInformation
+MD_Medium=org.opengis.metadata.distribution.Medium
+MD_MediumFormatCode=org.opengis.metadata.distribution.MediumFormat
+MD_MediumNameCode=org.opengis.metadata.distribution.MediumName
+MD_Metadata=org.opengis.metadata.Metadata
+MD_MetadataExtensionInformation=org.opengis.metadata.MetadataExtensionInformation
+MD_ObligationCode=org.opengis.metadata.Obligation
+MD_PixelOrientationCode=org.opengis.metadata.spatial.PixelOrientation
+MD_PortrayalCatalogueReference=org.opengis.metadata.PortrayalCatalogueReference
+MD_ProgressCode=org.opengis.metadata.identification.Progress
+MD_RangeDimension=org.opengis.metadata.content.RangeDimension
+MD_RepresentativeFraction=org.opengis.metadata.identification.RepresentativeFraction
+MD_Resolution=org.opengis.metadata.identification.Resolution
+MD_RestrictionCode=org.opengis.metadata.constraint.Restriction
+MD_ScopeCode=org.opengis.metadata.maintenance.ScopeCode
+MD_ScopeDescription=org.opengis.metadata.maintenance.ScopeDescription
+MD_SecurityConstraints=org.opengis.metadata.constraint.SecurityConstraints
+MD_SpatialRepresentation=org.opengis.metadata.spatial.SpatialRepresentation
+MD_SpatialRepresentationTypeCode=org.opengis.metadata.spatial.SpatialRepresentationType
+MD_StandardOrderProcess=org.opengis.metadata.distribution.StandardOrderProcess
+MD_TopicCategoryCode=org.opengis.metadata.identification.TopicCategory
+MD_TopologyLevelCode=org.opengis.metadata.spatial.TopologyLevel
+MD_Usage=org.opengis.metadata.identification.Usage
+MD_VectorSpatialRepresentation=org.opengis.metadata.spatial.VectorSpatialRepresentation
+MI_AcquisitionInformation=org.opengis.metadata.acquisition.AcquisitionInformation
+MI_Band=org.opengis.metadata.content.Band
+MI_BandDefinition=org.opengis.metadata.content.BandDefinition
+MI_ContextCode=org.opengis.metadata.acquisition.Context
+MI_CoverageDescription=org.opengis.metadata.content.CoverageDescription
+MI_EnvironmentalRecord=org.opengis.metadata.acquisition.EnvironmentalRecord
+MI_Event=org.opengis.metadata.acquisition.Event
+MI_GCP=org.opengis.metadata.spatial.GCP
+MI_GCPCollection=org.opengis.metadata.spatial.GCPCollection
+MI_GeolocationInformation=org.opengis.metadata.spatial.GeolocationInformation
+MI_GeometryTypeCode=org.opengis.metadata.acquisition.GeometryType
+MI_Georectified=org.opengis.metadata.spatial.Georectified
+MI_Georeferenceable=org.opengis.metadata.spatial.Georeferenceable
+MI_ImageDescription=org.opengis.metadata.content.ImageDescription
+MI_Instrument=org.opengis.metadata.acquisition.Instrument
+MI_Metadata=org.opengis.metadata.Metadata
+MI_Objective=org.opengis.metadata.acquisition.Objective
+MI_ObjectiveTypeCode=org.opengis.metadata.acquisition.ObjectiveType
+MI_Operation=org.opengis.metadata.acquisition.Operation
+MI_OperationTypeCode=org.opengis.metadata.acquisition.OperationType
+MI_Plan=org.opengis.metadata.acquisition.Plan
+MI_Platform=org.opengis.metadata.acquisition.Platform
+MI_PlatformPass=org.opengis.metadata.acquisition.PlatformPass
+MI_PolarizationOrientationCode=org.opengis.metadata.content.PolarizationOrientation
+MI_PriorityCode=org.opengis.metadata.acquisition.Priority
+MI_RangeElementDescription=org.opengis.metadata.content.RangeElementDescription
+MI_RequestedDate=org.opengis.metadata.acquisition.RequestedDate
+MI_Requirement=org.opengis.metadata.acquisition.Requirement
+MI_SequenceCode=org.opengis.metadata.acquisition.Sequence
+MI_TransferFunctionTypeCode=org.opengis.metadata.content.TransferFunctionType
+MI_TriggerCode=org.opengis.metadata.acquisition.Trigger
+QE_CoverageResult=org.opengis.metadata.quality.CoverageResult
+QE_Usability=org.opengis.metadata.quality.Usability
+RS_Identifier=org.opengis.referencing.ReferenceIdentifier
+RS_ReferenceSystem=org.opengis.referencing.ReferenceSystem
+SC_CRS=org.opengis.referencing.crs.CoordinateReferenceSystem
+SC_CompoundCRS=org.opengis.referencing.crs.CompoundCRS
+SC_DerivedCRS=org.opengis.referencing.crs.DerivedCRS
+SC_EngineeringCRS=org.opengis.referencing.crs.EngineeringCRS
+SC_GeneralDerivedCRS=org.opengis.referencing.crs.GeneralDerivedCRS
+SC_GeocentricCRS=org.opengis.referencing.crs.GeocentricCRS
+SC_GeodeticCRS=org.opengis.referencing.crs.GeodeticCRS
+SC_GeographicCRS=org.opengis.referencing.crs.GeographicCRS
+SC_ImageCRS=org.opengis.referencing.crs.ImageCRS
+SC_ProjectedCRS=org.opengis.referencing.crs.ProjectedCRS
+SC_SingleCRS=org.opengis.referencing.crs.SingleCRS
+SC_TemporalCRS=org.opengis.referencing.crs.TemporalCRS
+SC_VerticalCRS=org.opengis.referencing.crs.VerticalCRS
+SV_ServiceIdentification=org.opengis.metadata.identification.ServiceIdentification
+
+#
+# Additional types not yet defined in GeoAPI.
+#
+CI_Party=org.apache.sis.metadata.iso.citation.AbstractParty
+CI_Individual=org.apache.sis.metadata.iso.citation.DefaultIndividual
+CI_Organisation=org.apache.sis.metadata.iso.citation.DefaultOrganisation
+CI_Responsibility=org.apache.sis.metadata.iso.citation.DefaultResponsibility
+CI_TelephoneTypeCode=org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList
+MD_AssociatedResource=org.apache.sis.metadata.iso.identification.DefaultAssociatedResource
+MD_AttributeGroup=org.apache.sis.metadata.iso.content.DefaultAttributeGroup
+MD_FeatureTypeInfo=org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo
+MD_Releasability=org.apache.sis.metadata.iso.constraint.DefaultReleasability
+MD_SampleDimension=org.apache.sis.metadata.iso.content.DefaultSampleDimension
+MD_MetadataScope=org.apache.sis.metadata.iso.DefaultMetadataScope
+SV_CoupledResource=org.apache.sis.metadata.iso.identification.DefaultCoupledResource
+SV_OperationChainMetadata=org.apache.sis.metadata.iso.identification.DefaultOperationChainMetadata
+SV_OperationMetadata=org.apache.sis.metadata.iso.identification.DefaultOperationMetadata
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/LegacyCodes.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/LegacyCodes.java
index 63bb8bc..9820b69 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/LegacyCodes.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/LegacyCodes.java
@@ -21,13 +21,8 @@
import java.util.Locale;
import org.apache.sis.util.collection.Containers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Properties;
-import java.io.InputStream;
-import java.io.IOException;
-import org.opengis.metadata.Metadata;
-import org.apache.sis.xml.bind.Context;
-import org.apache.sis.util.logging.Logging;
+// Specific to the main branch:
+import org.opengis.metadata.identification.CharacterSet;
/**
@@ -49,19 +44,16 @@
*/
static final Map<String,String> IANA_TO_LEGACY, LEGACY_TO_IANA;
static {
- final Properties codes = new Properties();
- try (InputStream in = Metadata.class.getResourceAsStream("2003/charset-codes.properties")) {
- codes.load(in);
- } catch (IOException e) {
- Logging.unexpectedException(Context.LOGGER, ValueConverter.class, "toCharset[Code]", e);
- }
- final int capacity = Containers.hashMapCapacity(codes.size());
+ final CharacterSet[] codes = CharacterSet.values();
+ final int capacity = Containers.hashMapCapacity(codes.length);
IANA_TO_LEGACY = new HashMap<>(capacity);
LEGACY_TO_IANA = new HashMap<>(capacity);
- for (final Map.Entry<Object,Object> entry : codes.entrySet()) {
- final String legacy = ((String) entry.getKey()).intern();
- final String name = ((String) entry.getValue()).intern();
- IANA_TO_LEGACY.put(name .toUpperCase(Locale.US), legacy); // IANA names are restricted to US-ASCII.
+ for (final CharacterSet code : codes) {
+ final String legacy = code.identifier().intern();
+ final String[] names = code.names();
+ String name = names[names.length - 1];
+ if (name.equals("ebcdic")) name = "EBCDIC"; // Missing IANA name in GeoAPI CharacterSet.
+ IANA_TO_LEGACY.put(name .toUpperCase(Locale.US), legacy); // IANA names are restricted to US-ASCII.
LEGACY_TO_IANA.put(legacy.toLowerCase(Locale.US), name);
IANA_TO_LEGACY.put(name, legacy);
LEGACY_TO_IANA.put(legacy, name);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/TransformedEvent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/TransformedEvent.java
index 414e092..3cb10b0 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/TransformedEvent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/TransformedEvent.java
@@ -126,7 +126,7 @@
/**
* Wrapper over a namespace emitted during the reading or writing of an XML document.
* This wrapper is used for changing the namespace URI. The wrapped {@link #event}
- * should be a {@link Namespace}, but this class accepts also the {@link Attribute}
+ * should be a {@link Namespace}, but this class accepts also the {@code Attribute}
* super-type for allowing the {@link Type} attribute to create synthetic namespaces.
*/
static final class NS extends TransformedEvent<Attribute> implements Namespace {
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/IdentifierMapEntry.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/IdentifierMapEntry.java
index 7997e62..f566d79 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/IdentifierMapEntry.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/IdentifierMapEntry.java
@@ -21,6 +21,9 @@
import org.opengis.metadata.citation.Citation;
import org.apache.sis.metadata.iso.citation.Citations;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* An entry in {@link org.apache.sis.xml.IdentifierMap}. This class implements both the {@link AbstractMap.Entry}
@@ -29,7 +32,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class IdentifierMapEntry extends AbstractMap.SimpleEntry<Citation,String> implements Identifier {
+final class IdentifierMapEntry extends AbstractMap.SimpleEntry<Citation,String> implements ReferenceIdentifier {
/**
* For cross-version compatibility.
*/
@@ -69,15 +72,26 @@
}
/**
+ * Returns {@code null} since this class does not hold version information.
+ *
+ * @return {@code null}.
+ */
+ @Override
+ public String getVersion() {
+ return null;
+ }
+
+ /**
* Same as the above, but as an immutable entry. We use this implementation when the
* entry has been created on-the-fly at iteration time rather than being stored in the
* identifier collection.
*/
- static final class Immutable extends AbstractMap.SimpleImmutableEntry<Citation,String> implements Identifier {
+ static final class Immutable extends AbstractMap.SimpleImmutableEntry<Citation,String> implements ReferenceIdentifier {
private static final long serialVersionUID = -6857931598565368465L;
Immutable(Citation authority, String code) {super(authority, code);}
@Override public Citation getAuthority() {return getKey();}
@Override public String getCode() {return getValue();}
@Override public String getCodeSpace() {return Citations.toCodeSpace(getAuthority());}
+ @Override public String getVersion() {return null;}
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/SpecializedIdentifier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/SpecializedIdentifier.java
index b1f6810..ca2e078 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/SpecializedIdentifier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/SpecializedIdentifier.java
@@ -31,8 +31,8 @@
import org.apache.sis.util.privy.CloneAccess;
import org.apache.sis.metadata.iso.citation.Citations;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -44,7 +44,7 @@
*
* @param <T> the value type, typically {@link XLink}, {@link UUID} or {@link String}.
*/
-public final class SpecializedIdentifier<T> implements Identifier, CloneAccess, Serializable {
+public final class SpecializedIdentifier<T> implements ReferenceIdentifier, CloneAccess, Serializable {
/**
* For cross-version compatibility.
*/
@@ -95,7 +95,7 @@
*
* @see IdentifierMapAdapter#put(Citation, String)
*/
- static Identifier parse(final Citation authority, final String code) {
+ static ReferenceIdentifier parse(final Citation authority, final String code) {
if (authority instanceof NonMarshalledAuthority) {
final int ordinal = ((NonMarshalledAuthority) authority).ordinal;
switch (ordinal) {
@@ -196,6 +196,16 @@
}
/**
+ * Returns {@code null} since this class does not hold version information.
+ *
+ * @return {@code null}.
+ */
+ @Override
+ public String getVersion() {
+ return null;
+ }
+
+ /**
* Returns a hash code value for this identifier.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/CodeListUID.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/CodeListUID.java
index e99dd9c..d75499f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/CodeListUID.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/CodeListUID.java
@@ -26,9 +26,9 @@
import org.apache.sis.xml.bind.Context;
import static org.apache.sis.metadata.privy.ImplementationHelper.ISO_NAMESPACE;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-import org.opengis.annotation.ResourceBundles;
+// Specific to the main branch:
+import java.util.ResourceBundle;
+import org.apache.sis.util.privy.CodeLists;
/**
@@ -226,7 +226,7 @@
* @param context the current (un)marshalling context, or {@code null} if none.
* @param code the code list to wrap.
*/
- public CodeListUID(final Context context, final ControlledVocabulary code) {
+ public CodeListUID(final Context context, final CodeList<?> code) {
final String classID = Types.getListName(code);
final String fieldID = Types.getCodeName(code);
codeList = schema(context, classID);
@@ -241,7 +241,8 @@
if (locale != null) {
final String key = classID + '.' + fieldID;
try {
- value = ResourceBundles.codeLists(locale).getString(key);
+ value = ResourceBundle.getBundle(CodeLists.RESOURCES,
+ locale, CodeList.class.getClassLoader()).getString(key);
} catch (MissingResourceException e) {
Context.warningOccured(context, CodeListAdapter.class, "marshal", e, false);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/EnumAdapter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/EnumAdapter.java
index 60fd69a..7e46230 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/EnumAdapter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/cat/EnumAdapter.java
@@ -18,10 +18,6 @@
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-import org.apache.sis.util.iso.Types;
-
/**
* An adapter for {@link Enum}, in order to implement the ISO 19115-3 standard.
@@ -83,7 +79,7 @@
* @param e the enumeration constant.
* @return the text to write in the XML element.
*/
- protected static String value(final ControlledVocabulary e) {
- return Types.getCodeName(e);
+ protected static String value(final Enum<?> e) {
+ return e.name();
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_CharacterString.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_CharacterString.java
index a6c39e4..019130b 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_CharacterString.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_CharacterString.java
@@ -42,9 +42,6 @@
import org.apache.sis.util.resources.Messages;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-
/**
* JAXB wrapper for string value in a {@code <gco:CharacterString>}, {@code <gcx:Anchor>},
@@ -261,7 +258,7 @@
if (type != ENUM) {
return null;
}
- final ControlledVocabulary code = Types.forCodeTitle(text);
+ final CodeList<?> code = Types.forCodeTitle(text);
final String name = Types.getListName(code);
/*
* The namespace has have various value like CIT, SRV, MDQ, MRI, MSR, LAN, etc.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
index 4cd2880..cae2ac6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
@@ -26,8 +26,8 @@
import org.apache.sis.temporal.TemporalObjects;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriod.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriod.java
index e1ce2c7..317af71 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriod.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriod.java
@@ -24,8 +24,8 @@
import org.apache.sis.util.privy.Strings;
import static org.apache.sis.xml.privy.LegacyNamespaces.VERSION_3_0;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Period;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Period;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
index 5b51345..921666d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlTransient;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.Instant;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Party.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Party.java
index f63c67e..a9052e5 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Party.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Party.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.citation.AbstractParty;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class CI_Party extends PropertyType<CI_Party, Party> {
+public final class CI_Party extends PropertyType<CI_Party, AbstractParty> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code Party.class}
*/
@Override
- protected Class<Party> getBoundType() {
- return Party.class;
+ protected Class<AbstractParty> getBoundType() {
+ return AbstractParty.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private CI_Party(final Party value) {
+ private CI_Party(final AbstractParty value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected CI_Party wrap(final Party value) {
+ protected CI_Party wrap(final AbstractParty value) {
return new CI_Party(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public AbstractParty getElement() {
- return AbstractParty.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Responsibility.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Responsibility.java
index 62a41dc..a84f944 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Responsibility.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/CI_Responsibility.java
@@ -23,9 +23,6 @@
import org.apache.sis.xml.bind.FilterByVersion;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -34,7 +31,7 @@
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
*/
-public final class CI_Responsibility extends PropertyType<CI_Responsibility, Responsibility> {
+public final class CI_Responsibility extends PropertyType<CI_Responsibility, DefaultResponsibility> {
/**
* Empty constructor for JAXB only.
*/
@@ -42,21 +39,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code Responsibility.class}
*/
@Override
- protected Class<Responsibility> getBoundType() {
- return Responsibility.class;
+ protected Class<DefaultResponsibility> getBoundType() {
+ return DefaultResponsibility.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private CI_Responsibility(final Responsibility value) {
+ private CI_Responsibility(final DefaultResponsibility value) {
super(value);
}
@@ -68,7 +63,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected CI_Responsibility wrap(final Responsibility value) {
+ protected CI_Responsibility wrap(final DefaultResponsibility value) {
return new CI_Responsibility(value);
}
@@ -87,9 +82,13 @@
// Need to build new DefaultResponsibility object here — simply casting doesn't work.
return new DefaultResponsibility(metadata);
}
- return DefaultResponsibility.castOrCopy(metadata);
+ return metadata;
} else if (FilterByVersion.LEGACY_METADATA.accept()) {
- return DefaultResponsibleParty.castOrCopy(metadata);
+ if (metadata instanceof DefaultResponsibleParty) {
+ return metadata;
+ } else {
+ return new DefaultResponsibleParty(metadata);
+ }
} else {
return null;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_BasicMeasure.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_BasicMeasure.java
index 866e3b9..ce7eaff 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_BasicMeasure.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_BasicMeasure.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultBasicMeasure;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.BasicMeasure;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQM_BasicMeasure extends PropertyType<DQM_BasicMeasure, BasicMeasure> {
+public final class DQM_BasicMeasure extends PropertyType<DQM_BasicMeasure, DefaultBasicMeasure> {
/**
* Empty constructor for JAXB only.
*/
@@ -42,17 +39,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code BasicMeasure.class}
+ * @return {@code DefaultBasicMeasure.class}
*/
@Override
- protected Class<BasicMeasure> getBoundType() {
- return BasicMeasure.class;
+ protected Class<DefaultBasicMeasure> getBoundType() {
+ return DefaultBasicMeasure.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQM_BasicMeasure(final BasicMeasure metadata) {
+ private DQM_BasicMeasure(final DefaultBasicMeasure metadata) {
super(metadata);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected DQM_BasicMeasure wrap(final BasicMeasure metadata) {
+ protected DQM_BasicMeasure wrap(final DefaultBasicMeasure metadata) {
return new DQM_BasicMeasure(metadata);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public DefaultBasicMeasure getElement() {
- return DefaultBasicMeasure.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Description.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Description.java
index 12c5a93..f4fb3ca 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Description.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Description.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultMeasureDescription;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Description;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQM_Description extends PropertyType<DQM_Description, Description> {
+public final class DQM_Description extends PropertyType<DQM_Description, DefaultMeasureDescription> {
/**
* Empty constructor for JAXB only.
*/
@@ -42,17 +39,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code Description.class}
+ * @return {@code DefaultMeasureDescription.class}
*/
@Override
- protected Class<Description> getBoundType() {
- return Description.class;
+ protected Class<DefaultMeasureDescription> getBoundType() {
+ return DefaultMeasureDescription.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQM_Description(final Description metadata) {
+ private DQM_Description(final DefaultMeasureDescription metadata) {
super(metadata);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected DQM_Description wrap(final Description metadata) {
+ protected DQM_Description wrap(final DefaultMeasureDescription metadata) {
return new DQM_Description(metadata);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public DefaultMeasureDescription getElement() {
- return DefaultMeasureDescription.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Measure.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Measure.java
index 7a3487e..9c67e78 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Measure.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_Measure.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultQualityMeasure;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.Measure;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQM_Measure extends PropertyType<DQM_Measure, Measure> {
+public final class DQM_Measure extends PropertyType<DQM_Measure, DefaultQualityMeasure> {
/**
* Empty constructor for JAXB only.
*/
@@ -42,17 +39,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code Measure.class}
+ * @return {@code DefaultQualityMeasure.class}
*/
@Override
- protected Class<Measure> getBoundType() {
- return Measure.class;
+ protected Class<DefaultQualityMeasure> getBoundType() {
+ return DefaultQualityMeasure.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQM_Measure(final Measure metadata) {
+ private DQM_Measure(final DefaultQualityMeasure metadata) {
super(metadata);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected DQM_Measure wrap(final Measure metadata) {
+ protected DQM_Measure wrap(final DefaultQualityMeasure metadata) {
return new DQM_Measure(metadata);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public DefaultQualityMeasure getElement() {
- return DefaultQualityMeasure.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_SourceReference.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_SourceReference.java
index 524692c..479f457 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_SourceReference.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQM_SourceReference.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultSourceReference;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.SourceReference;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQM_SourceReference extends PropertyType<DQM_SourceReference, SourceReference> {
+public final class DQM_SourceReference extends PropertyType<DQM_SourceReference, DefaultSourceReference> {
/**
* Empty constructor for JAXB only.
*/
@@ -42,17 +39,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code SourceReference.class}
+ * @return {@code DefaultSourceReference.class}
*/
@Override
- protected Class<SourceReference> getBoundType() {
- return SourceReference.class;
+ protected Class<DefaultSourceReference> getBoundType() {
+ return DefaultSourceReference.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQM_SourceReference(final SourceReference metadata) {
+ private DQM_SourceReference(final DefaultSourceReference metadata) {
super(metadata);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected DQM_SourceReference wrap(final SourceReference metadata) {
+ protected DQM_SourceReference wrap(final DefaultSourceReference metadata) {
return new DQM_SourceReference(metadata);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public DefaultSourceReference getElement() {
- return DefaultSourceReference.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_EvaluationMethod.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_EvaluationMethod.java
index 2a034e0..f7401b2 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_EvaluationMethod.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_EvaluationMethod.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultEvaluationMethod;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.EvaluationMethod;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -34,7 +31,7 @@
* @author Alexis Gaillard (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQ_EvaluationMethod extends PropertyType<DQ_EvaluationMethod, EvaluationMethod> {
+public final class DQ_EvaluationMethod extends PropertyType<DQ_EvaluationMethod, DefaultEvaluationMethod> {
/**
* Empty constructor for JAXB only.
*/
@@ -46,17 +43,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code EvaluationMethod.class}
+ * @return {@code DefaultEvaluationMethod.class}
*/
@Override
- protected Class<EvaluationMethod> getBoundType() {
- return EvaluationMethod.class;
+ protected Class<DefaultEvaluationMethod> getBoundType() {
+ return DefaultEvaluationMethod.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQ_EvaluationMethod(final EvaluationMethod metadata) {
+ private DQ_EvaluationMethod(final DefaultEvaluationMethod metadata) {
super(metadata);
}
@@ -69,7 +66,7 @@
* or {@code null} if marshalling a too old version of the standard.
*/
@Override
- protected DQ_EvaluationMethod wrap(final EvaluationMethod metadata) {
+ protected DQ_EvaluationMethod wrap(final DefaultEvaluationMethod metadata) {
return accept2014() ? new DQ_EvaluationMethod(metadata) : null;
}
@@ -82,7 +79,7 @@
*/
@XmlElementRef
public DefaultEvaluationMethod getElement() {
- return DefaultEvaluationMethod.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_MeasureReference.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_MeasureReference.java
index 7d5696a..f753921 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_MeasureReference.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_MeasureReference.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultMeasureReference;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.MeasureReference;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -34,7 +31,7 @@
* @author Alexis Gaillard (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DQ_MeasureReference extends PropertyType<DQ_MeasureReference, MeasureReference> {
+public final class DQ_MeasureReference extends PropertyType<DQ_MeasureReference, DefaultMeasureReference> {
/**
* Empty constructor for JAXB only.
*/
@@ -46,17 +43,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code MeasureReference.class}
+ * @return {@code DefaultMeasureReference.class}
*/
@Override
- protected Class<MeasureReference> getBoundType() {
- return MeasureReference.class;
+ protected Class<DefaultMeasureReference> getBoundType() {
+ return DefaultMeasureReference.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQ_MeasureReference(final MeasureReference metadata) {
+ private DQ_MeasureReference(final DefaultMeasureReference metadata) {
super(metadata);
}
@@ -69,7 +66,7 @@
* or {@code null} if marshalling a too old version of the standard.
*/
@Override
- protected DQ_MeasureReference wrap(final MeasureReference metadata) {
+ protected DQ_MeasureReference wrap(final DefaultMeasureReference metadata) {
return accept2014() ? new DQ_MeasureReference(metadata) : null;
}
@@ -82,7 +79,7 @@
*/
@XmlElementRef
public DefaultMeasureReference getElement() {
- return DefaultMeasureReference.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_StandaloneQualityReportInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_StandaloneQualityReportInformation.java
index ebab033..9f70e15 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_StandaloneQualityReportInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/DQ_StandaloneQualityReportInformation.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.quality.DefaultEvaluationReportInformation;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.quality.StandaloneQualityReportInformation;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -35,7 +32,7 @@
* @author Martin Desruisseaux (Geomatys)
*/
public final class DQ_StandaloneQualityReportInformation extends
- PropertyType<DQ_StandaloneQualityReportInformation, StandaloneQualityReportInformation>
+ PropertyType<DQ_StandaloneQualityReportInformation, DefaultEvaluationReportInformation>
{
/**
* Empty constructor for JAXB only.
@@ -48,17 +45,17 @@
* This method is indirectly invoked by the private constructor
* below, so it shall not depend on the state of this object.
*
- * @return {@code StandaloneQualityReportInformation.class}
+ * @return {@code DefaultEvaluationReportInformation.class}
*/
@Override
- protected Class<StandaloneQualityReportInformation> getBoundType() {
- return StandaloneQualityReportInformation.class;
+ protected Class<DefaultEvaluationReportInformation> getBoundType() {
+ return DefaultEvaluationReportInformation.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private DQ_StandaloneQualityReportInformation(final StandaloneQualityReportInformation metadata) {
+ private DQ_StandaloneQualityReportInformation(final DefaultEvaluationReportInformation metadata) {
super(metadata);
}
@@ -71,7 +68,7 @@
* or {@code null} if marshalling a too old version of the standard.
*/
@Override
- protected DQ_StandaloneQualityReportInformation wrap(final StandaloneQualityReportInformation metadata) {
+ protected DQ_StandaloneQualityReportInformation wrap(final DefaultEvaluationReportInformation metadata) {
return accept2014() ? new DQ_StandaloneQualityReportInformation(metadata) : null;
}
@@ -84,7 +81,7 @@
*/
@XmlElementRef
public DefaultEvaluationReportInformation getElement() {
- return DefaultEvaluationReportInformation.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AssociatedResource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AssociatedResource.java
deleted file mode 100644
index 21dbd12..0000000
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AssociatedResource.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.xml.bind.metadata;
-
-import jakarta.xml.bind.annotation.XmlElementRef;
-import org.opengis.metadata.identification.AssociatedResource;
-import org.apache.sis.metadata.iso.identification.DefaultAssociatedResource;
-import org.apache.sis.xml.bind.gco.PropertyType;
-
-
-/**
- * JAXB adapter mapping implementing class to the GeoAPI interface. See
- * package documentation for more information about JAXB and interface.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class MD_AssociatedResource extends PropertyType<MD_AssociatedResource, AssociatedResource> {
- /**
- * Empty constructor for JAXB only.
- */
- public MD_AssociatedResource() {
- }
-
- /**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
- *
- * @return {@code AssociatedResource.class}
- */
- @Override
- protected Class<AssociatedResource> getBoundType() {
- return AssociatedResource.class;
- }
-
- /**
- * Constructor for the {@link #wrap} method only.
- */
- private MD_AssociatedResource(final AssociatedResource value) {
- super(value);
- }
-
- /**
- * Invoked by {@link PropertyType} at marshalling time for wrapping the given metadata value
- * in a {@code <mri:MD_AssociatedResource>} XML element.
- *
- * @param value the metadata element to marshal.
- * @return a {@code PropertyType} wrapping the given the metadata element.
- */
- @Override
- protected MD_AssociatedResource wrap(final AssociatedResource value) {
- return new MD_AssociatedResource(value);
- }
-
- /**
- * Invoked by JAXB at marshalling time for getting the actual metadata to write
- * inside the {@code <mri:MD_AssociatedResource>} XML element.
- * This is the value or a copy of the value given in argument to the {@code wrap} method.
- *
- * @return the metadata to be marshalled.
- */
- @XmlElementRef
- public DefaultAssociatedResource getElement() {
- return DefaultAssociatedResource.castOrCopy(metadata);
- }
-
- /**
- * Invoked by JAXB at unmarshalling time for storing the result temporarily.
- *
- * @param value the unmarshalled metadata.
- */
- public void setElement(final DefaultAssociatedResource value) {
- metadata = value;
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AttributeGroup.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AttributeGroup.java
index 4961bc7..cd61533 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AttributeGroup.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_AttributeGroup.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.content.DefaultAttributeGroup;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.AttributeGroup;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class MD_AttributeGroup extends PropertyType<MD_AttributeGroup, AttributeGroup> {
+public final class MD_AttributeGroup extends PropertyType<MD_AttributeGroup, DefaultAttributeGroup> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code AttributeGroup.class}
*/
@Override
- protected Class<AttributeGroup> getBoundType() {
- return AttributeGroup.class;
+ protected Class<DefaultAttributeGroup> getBoundType() {
+ return DefaultAttributeGroup.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private MD_AttributeGroup(final AttributeGroup value) {
+ private MD_AttributeGroup(final DefaultAttributeGroup value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected MD_AttributeGroup wrap(final AttributeGroup value) {
+ protected MD_AttributeGroup wrap(final DefaultAttributeGroup value) {
return new MD_AttributeGroup(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public DefaultAttributeGroup getElement() {
- return DefaultAttributeGroup.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_FeatureTypeInfo.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_FeatureTypeInfo.java
index 30fd3ca..6bfe798 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_FeatureTypeInfo.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_FeatureTypeInfo.java
@@ -20,9 +20,6 @@
import org.apache.sis.xml.bind.gco.PropertyType;
import org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.FeatureTypeInfo;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Cullen Rombach (Image Matters)
*/
-public final class MD_FeatureTypeInfo extends PropertyType<MD_FeatureTypeInfo, FeatureTypeInfo> {
+public final class MD_FeatureTypeInfo extends PropertyType<MD_FeatureTypeInfo, DefaultFeatureTypeInfo> {
/**
* Empty constructor for JAXB only.
*/
@@ -45,14 +42,14 @@
* @return {@code FeatureTypeInfo.class}
*/
@Override
- protected Class<FeatureTypeInfo> getBoundType() {
- return FeatureTypeInfo.class;
+ protected Class<DefaultFeatureTypeInfo> getBoundType() {
+ return DefaultFeatureTypeInfo.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private MD_FeatureTypeInfo(final FeatureTypeInfo value) {
+ private MD_FeatureTypeInfo(final DefaultFeatureTypeInfo value) {
super(value);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected MD_FeatureTypeInfo wrap(final FeatureTypeInfo value) {
+ protected MD_FeatureTypeInfo wrap(final DefaultFeatureTypeInfo value) {
return new MD_FeatureTypeInfo(value);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public DefaultFeatureTypeInfo getElement() {
- return DefaultFeatureTypeInfo.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Identifier.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Identifier.java
index 53bf9a4..30ce411 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Identifier.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Identifier.java
@@ -23,6 +23,9 @@
import org.apache.sis.xml.bind.gco.PropertyType;
import org.apache.sis.xml.bind.metadata.replace.RS_Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -78,14 +81,15 @@
*/
@XmlElementRef
public final DefaultIdentifier getElement() {
- if (FilterByVersion.LEGACY_METADATA.accept() && metadata != null) {
+ if (FilterByVersion.LEGACY_METADATA.accept() && metadata instanceof ReferenceIdentifier) {
/*
* In legacy specification, "code space" and "version" were not defined in <gmd:MD_Identifier> but were
* defined in <gmd:RS_Identifier> subclass. In newer specification there is no longer such special case.
* Note that "description" did not existed anywhere in legacy specification.
*/
- if (metadata.getCodeSpace() != null || metadata.getVersion() != null) {
- return RS_Identifier.wrap(metadata);
+ final ReferenceIdentifier id = (ReferenceIdentifier) metadata;
+ if (id.getCodeSpace() != null || id.getVersion() != null) {
+ return RS_Identifier.wrap(id);
}
}
return DefaultIdentifier.castOrCopy(metadata);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_KeywordClass.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_KeywordClass.java
index 3d61223..dec9b56 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_KeywordClass.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_KeywordClass.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.identification.DefaultKeywordClass;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.KeywordClass;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public class MD_KeywordClass extends PropertyType<MD_KeywordClass, KeywordClass> {
+public class MD_KeywordClass extends PropertyType<MD_KeywordClass, DefaultKeywordClass> {
/**
* Empty constructor for JAXB only.
*/
@@ -45,14 +42,14 @@
* @return {@code KeywordClass.class}
*/
@Override
- protected final Class<KeywordClass> getBoundType() {
- return KeywordClass.class;
+ protected final Class<DefaultKeywordClass> getBoundType() {
+ return DefaultKeywordClass.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private MD_KeywordClass(final KeywordClass value) {
+ private MD_KeywordClass(final DefaultKeywordClass value) {
super(value);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected MD_KeywordClass wrap(final KeywordClass value) {
+ protected MD_KeywordClass wrap(final DefaultKeywordClass value) {
return new MD_KeywordClass(value);
}
@@ -77,7 +74,7 @@
*/
@XmlElementRef
public final DefaultKeywordClass getElement() {
- return DefaultKeywordClass.castOrCopy(metadata);
+ return metadata;
}
/**
@@ -103,7 +100,7 @@
*
* @return a non-null value only if marshalling ISO 19115-3 or newer.
*/
- @Override protected MD_KeywordClass wrap(final KeywordClass value) {
+ @Override protected MD_KeywordClass wrap(final DefaultKeywordClass value) {
return accept2014() ? super.wrap(value) : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_MetadataScope.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_MetadataScope.java
index 8d678b2..b37bbcf 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_MetadataScope.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_MetadataScope.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.DefaultMetadataScope;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class MD_MetadataScope extends PropertyType<MD_MetadataScope, MetadataScope> {
+public final class MD_MetadataScope extends PropertyType<MD_MetadataScope, DefaultMetadataScope> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code MetadataScope.class}
*/
@Override
- protected Class<MetadataScope> getBoundType() {
- return MetadataScope.class;
+ protected Class<DefaultMetadataScope> getBoundType() {
+ return DefaultMetadataScope.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private MD_MetadataScope(final MetadataScope value) {
+ private MD_MetadataScope(final DefaultMetadataScope value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected MD_MetadataScope wrap(final MetadataScope value) {
+ protected MD_MetadataScope wrap(final DefaultMetadataScope value) {
return new MD_MetadataScope(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public DefaultMetadataScope getElement() {
- return DefaultMetadataScope.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Releasability.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Releasability.java
index d68610b..7b065fd 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Releasability.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Releasability.java
@@ -20,9 +20,6 @@
import org.apache.sis.xml.bind.gco.PropertyType;
import org.apache.sis.metadata.iso.constraint.DefaultReleasability;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.constraint.Releasability;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface.
@@ -31,7 +28,7 @@
* @author Cullen Rombach (Image Matters)
* @author Martin Desruisseaux (Geomatys)
*/
-public class MD_Releasability extends PropertyType<MD_Releasability, Releasability> {
+public class MD_Releasability extends PropertyType<MD_Releasability, DefaultReleasability> {
/**
* Empty constructor for JAXB only.
*/
@@ -46,14 +43,14 @@
* @return {@code Releasability.class}
*/
@Override
- protected final Class<Releasability> getBoundType() {
- return Releasability.class;
+ protected final Class<DefaultReleasability> getBoundType() {
+ return DefaultReleasability.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private MD_Releasability(final Releasability value) {
+ private MD_Releasability(final DefaultReleasability value) {
super(value);
}
@@ -65,7 +62,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected MD_Releasability wrap(final Releasability value) {
+ protected MD_Releasability wrap(final DefaultReleasability value) {
return new MD_Releasability(value);
}
@@ -78,7 +75,7 @@
*/
@XmlElementRef
public final DefaultReleasability getElement() {
- return DefaultReleasability.castOrCopy(metadata);
+ return metadata;
}
/**
@@ -104,7 +101,7 @@
*
* @return a non-null value only if marshalling ISO 19115-3 or newer.
*/
- @Override protected MD_Releasability wrap(final Releasability value) {
+ @Override protected MD_Releasability wrap(final DefaultReleasability value) {
return accept2014() ? super.wrap(value) : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Scope.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Scope.java
index de496bb..e19489d 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Scope.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/MD_Scope.java
@@ -23,8 +23,8 @@
// Specific to the main and geoapi-3.1 branches:
import java.net.URISyntaxException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
/**
@@ -104,7 +104,7 @@
/** Converts an adapter read from an XML stream. */
@Override public Scope unmarshal(final MD_Scope value) throws URISyntaxException {
- return org.apache.sis.metadata.iso.quality.DefaultScope.castOrCopy(super.unmarshal(value));
+ return DefaultScope.castOrCopy(super.unmarshal(value));
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_CoupledResource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_CoupledResource.java
index 54cf07e..801dd30 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_CoupledResource.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_CoupledResource.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.identification.DefaultCoupledResource;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.CoupledResource;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class SV_CoupledResource extends PropertyType<SV_CoupledResource, CoupledResource> {
+public final class SV_CoupledResource extends PropertyType<SV_CoupledResource, DefaultCoupledResource> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code CoupledResource.class}
*/
@Override
- protected Class<CoupledResource> getBoundType() {
- return CoupledResource.class;
+ protected Class<DefaultCoupledResource> getBoundType() {
+ return DefaultCoupledResource.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private SV_CoupledResource(final CoupledResource value) {
+ private SV_CoupledResource(final DefaultCoupledResource value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected SV_CoupledResource wrap(final CoupledResource value) {
+ protected SV_CoupledResource wrap(final DefaultCoupledResource value) {
return new SV_CoupledResource(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public DefaultCoupledResource getElement() {
- return DefaultCoupledResource.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationChainMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationChainMetadata.java
index 165f949..f355b60 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationChainMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationChainMetadata.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.identification.DefaultOperationChainMetadata;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.OperationChainMetadata;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class SV_OperationChainMetadata extends PropertyType<SV_OperationChainMetadata, OperationChainMetadata> {
+public final class SV_OperationChainMetadata extends PropertyType<SV_OperationChainMetadata, DefaultOperationChainMetadata> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code OperationChainMetadata.class}
*/
@Override
- protected Class<OperationChainMetadata> getBoundType() {
- return OperationChainMetadata.class;
+ protected Class<DefaultOperationChainMetadata> getBoundType() {
+ return DefaultOperationChainMetadata.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private SV_OperationChainMetadata(final OperationChainMetadata value) {
+ private SV_OperationChainMetadata(final DefaultOperationChainMetadata value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected SV_OperationChainMetadata wrap(final OperationChainMetadata value) {
+ protected SV_OperationChainMetadata wrap(final DefaultOperationChainMetadata value) {
return new SV_OperationChainMetadata(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public DefaultOperationChainMetadata getElement() {
- return DefaultOperationChainMetadata.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationMetadata.java
index 0a5369a..3e16a40 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/SV_OperationMetadata.java
@@ -20,9 +20,6 @@
import org.apache.sis.metadata.iso.identification.DefaultOperationMetadata;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.OperationMetadata;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public class SV_OperationMetadata extends PropertyType<SV_OperationMetadata, OperationMetadata> {
+public class SV_OperationMetadata extends PropertyType<SV_OperationMetadata, DefaultOperationMetadata> {
/**
* Empty constructor for JAXB only.
*/
@@ -38,21 +35,19 @@
}
/**
- * Returns the GeoAPI interface which is bound by this adapter.
- * This method is indirectly invoked by the private constructor
- * below, so it shall not depend on the state of this object.
+ * Returns the type which is bound by this adapter.
*
* @return {@code OperationMetadata.class}
*/
@Override
- protected final Class<OperationMetadata> getBoundType() {
- return OperationMetadata.class;
+ protected final Class<DefaultOperationMetadata> getBoundType() {
+ return DefaultOperationMetadata.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private SV_OperationMetadata(final OperationMetadata value) {
+ private SV_OperationMetadata(final DefaultOperationMetadata value) {
super(value);
}
@@ -64,7 +59,7 @@
* @return a {@code PropertyType} wrapping the given the metadata element.
*/
@Override
- protected SV_OperationMetadata wrap(final OperationMetadata value) {
+ protected SV_OperationMetadata wrap(final DefaultOperationMetadata value) {
return new SV_OperationMetadata(value);
}
@@ -77,7 +72,7 @@
*/
@XmlElementRef
public final DefaultOperationMetadata getElement() {
- return DefaultOperationMetadata.castOrCopy(metadata);
+ return metadata;
}
/**
@@ -103,7 +98,7 @@
*
* @return a non-null value only if marshalling ISO 19115-3 or newer.
*/
- @Override protected SV_OperationMetadata wrap(final OperationMetadata value) {
+ @Override protected SV_OperationMetadata wrap(final DefaultOperationMetadata value) {
return accept2014() ? super.wrap(value) : null;
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/CI_TelephoneTypeCode.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/CI_TelephoneTypeCode.java
index 082ec07..10fd655 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/CI_TelephoneTypeCode.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/CI_TelephoneTypeCode.java
@@ -20,20 +20,20 @@
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.bind.cat.CodeListUID;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.TelephoneType;
-import org.apache.sis.xml.bind.cat.CodeListAdapter;
+// Specific to the main branch:
+import org.apache.sis.xml.bind.FilterByVersion;
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeListAdapter;
/**
- * JAXB adapter for {@link TelephoneType}
+ * JAXB adapter for {@code TelephoneType}
* in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
* See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
*
* @author Cullen Rombach (Image Matters)
* @author Martin Desruisseaux (Geomatys)
*/
-public class CI_TelephoneTypeCode extends CodeListAdapter<CI_TelephoneTypeCode, TelephoneType> {
+public class CI_TelephoneTypeCode extends UnsupportedCodeListAdapter<CI_TelephoneTypeCode> {
/**
* Empty constructor for JAXB only.
*/
@@ -63,8 +63,8 @@
* @return the code list class.
*/
@Override
- protected final Class<TelephoneType> getCodeListClass() {
- return TelephoneType.class;
+ protected String getCodeListName() {
+ return "CI_TelephoneTypeCode";
}
/**
@@ -102,7 +102,7 @@
* @return a non-null value only if marshalling ISO 19115-3 or newer.
*/
@Override protected CI_TelephoneTypeCode wrap(final CodeListUID value) {
- return accept2014() ? super.wrap(value) : null;
+ return FilterByVersion.CURRENT_METADATA.accept() ? super.wrap(value) : null;
}
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DCPList.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DCPList.java
index eb10e90..8e20939 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DCPList.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DCPList.java
@@ -20,19 +20,18 @@
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.bind.cat.CodeListUID;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.DistributedComputingPlatform;
-import org.apache.sis.xml.bind.cat.CodeListAdapter;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeListAdapter;
/**
- * JAXB adapter for {@link DistributedComputingPlatform}
+ * JAXB adapter for {@code DistributedComputingPlatform}
* in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
* See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class DCPList extends CodeListAdapter<DCPList, DistributedComputingPlatform> {
+public final class DCPList extends UnsupportedCodeListAdapter<DCPList> {
/**
* Empty constructor for JAXB only.
*/
@@ -62,8 +61,29 @@
* @return the code list class.
*/
@Override
- protected Class<DistributedComputingPlatform> getCodeListClass() {
- return DistributedComputingPlatform.class;
+ protected String getCodeListName() {
+ return "DCPList";
+ }
+
+ /**
+ * Converts the given Java constant name to something hopefully close to the UML identifier,
+ * or close to the textual value to put in the XML.
+ *
+ * @param name The Java constant name (e.g. {@code WEB_SERVICES}).
+ * @param buffer An initially empty buffer to use for creating the identifier.
+ * @param isValue {@code false} for the {@code codeListValue} attribute, or {@code true} for the XML value.
+ * @return The identifier (e.g. {@code "WebServices"} or {@code "Web services"}).
+ */
+ @Override
+ protected String toIdentifier(final String name, final StringBuilder buffer, final boolean isValue) {
+ if (name.startsWith("WEB_")) {
+ super.toIdentifier(name, buffer, isValue);
+ buffer.setCharAt(0, 'W');
+ return buffer.toString();
+ } else {
+ // Other names are abbreviations (e.g. XML, SQL, FTP, etc.), so return unchanged.
+ return name;
+ }
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DQM_ValueStructure.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DQM_ValueStructure.java
deleted file mode 100644
index b378970..0000000
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/DQM_ValueStructure.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.xml.bind.metadata.code;
-
-import jakarta.xml.bind.annotation.XmlElement;
-import org.opengis.metadata.quality.ValueStructure;
-import org.apache.sis.xml.Namespaces;
-import org.apache.sis.xml.bind.cat.CodeListAdapter;
-import org.apache.sis.xml.bind.cat.CodeListUID;
-
-
-/**
- * JAXB adapter for {@link ValueStructure}
- * in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
- * See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class DQM_ValueStructure extends CodeListAdapter<DQM_ValueStructure, ValueStructure> {
- /**
- * Empty constructor for JAXB only.
- */
- public DQM_ValueStructure() {
- }
-
- /**
- * Creates a new adapter for the given value.
- */
- private DQM_ValueStructure(final CodeListUID value) {
- super(value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the wrapper for the code list value.
- */
- @Override
- protected DQM_ValueStructure wrap(final CodeListUID value) {
- return new DQM_ValueStructure(value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the code list class.
- */
- @Override
- protected Class<ValueStructure> getCodeListClass() {
- return ValueStructure.class;
- }
-
- /**
- * Invoked by JAXB on marshalling.
- *
- * @return the value to be marshalled.
- */
- @Override
- @XmlElement(name = "DQM_ValueStructure", namespace = Namespaces.DQM)
- public CodeListUID getElement() {
- return identifier;
- }
-
- /**
- * Invoked by JAXB on unmarshalling.
- *
- * @param value the unmarshalled value.
- */
- public void setElement(final CodeListUID value) {
- identifier = value;
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_CharacterSetCode.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_CharacterSetCode.java
index 16d16f6..9a7f67e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_CharacterSetCode.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_CharacterSetCode.java
@@ -26,6 +26,9 @@
import org.apache.sis.xml.bind.Context;
import org.apache.sis.xml.bind.cat.CodeListUID;
+// Specific to the main branch:
+import org.opengis.metadata.identification.CharacterSet;
+
/**
* JAXB adapter for {@link Charset}
@@ -102,4 +105,25 @@
public void setElement(final CodeListUID value) {
identifier = value;
}
+
+ /**
+ * Converts the given Java Character Set to {@code CharacterSet}.
+ *
+ * @param cs the character set, or {@code null}.
+ * @return a code list for the given character set, or {@code null} if the given {@code cs} was null.
+ */
+ public static CharacterSet fromCharset(final Charset cs) {
+ if (cs == null) {
+ return null;
+ }
+ final String name = cs.name();
+ for (final CharacterSet candidate : CharacterSet.values()) {
+ for (final String n : candidate.names()) {
+ if (name.equals(n)) {
+ return candidate;
+ }
+ }
+ }
+ return CharacterSet.valueOf(name);
+ }
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_ReferenceSystemTypeCode.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_ReferenceSystemTypeCode.java
deleted file mode 100644
index afc1148..0000000
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_ReferenceSystemTypeCode.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.xml.bind.metadata.code;
-
-import jakarta.xml.bind.annotation.XmlElement;
-import org.opengis.referencing.ReferenceSystemType;
-import org.apache.sis.xml.Namespaces;
-import org.apache.sis.xml.bind.cat.CodeListAdapter;
-import org.apache.sis.xml.bind.cat.CodeListUID;
-
-
-/**
- * JAXB adapter for {@link ReferenceSystemTypeCode}
- * in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
- * See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class MD_ReferenceSystemTypeCode extends CodeListAdapter<MD_ReferenceSystemTypeCode, ReferenceSystemType> {
- /**
- * Empty constructor for JAXB only.
- */
- public MD_ReferenceSystemTypeCode() {
- }
-
- /**
- * Creates a new adapter for the given value.
- */
- private MD_ReferenceSystemTypeCode(final CodeListUID value) {
- super(value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the wrapper for the code list value.
- */
- @Override
- protected MD_ReferenceSystemTypeCode wrap(final CodeListUID value) {
- return new MD_ReferenceSystemTypeCode(value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the code list class.
- */
- @Override
- protected Class<ReferenceSystemType> getCodeListClass() {
- return ReferenceSystemType.class;
- }
-
- /**
- * Invoked by JAXB on marshalling.
- *
- * @return the value to be marshalled.
- */
- @Override
- @XmlElement(name = "MD_ReferenceSystemTypeCode", namespace = Namespaces.MSR)
- public CodeListUID getElement() {
- return identifier;
- }
-
- /**
- * Invoked by JAXB on unmarshalling.
- *
- * @param value the unmarshalled value.
- */
- public void setElement(final CodeListUID value) {
- identifier = value;
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_RestrictionCode.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_RestrictionCode.java
index 635475e..557795f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_RestrictionCode.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/MD_RestrictionCode.java
@@ -91,8 +91,8 @@
* @param value the unmarshalled value.
*/
public void setElement(final CodeListUID value) {
- if (value != null && "license".equalsIgnoreCase(value.codeListValue)) {
- value.codeListValue = "licence"; // For matching current spelling (ISO 19115-3:2016).
+ if (value != null && "licence".equalsIgnoreCase(value.codeListValue)) {
+ value.codeListValue = "license"; // For matching legacy spelling (ISO 19139:2007).
}
identifier = value;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_CouplingType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_CouplingType.java
index 18ae9dd..33fa687 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_CouplingType.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_CouplingType.java
@@ -20,19 +20,18 @@
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.bind.cat.CodeListUID;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.CouplingType;
-import org.apache.sis.xml.bind.cat.CodeListAdapter;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeListAdapter;
/**
- * JAXB adapter for {@link CouplingType}
+ * JAXB adapter for {@code CouplingType}
* in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
* See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class SV_CouplingType extends CodeListAdapter<SV_CouplingType, CouplingType> {
+public final class SV_CouplingType extends UnsupportedCodeListAdapter<SV_CouplingType> {
/**
* Empty constructor for JAXB only.
*/
@@ -62,8 +61,8 @@
* @return the code list class.
*/
@Override
- protected Class<CouplingType> getCodeListClass() {
- return CouplingType.class;
+ protected String getCodeListName() {
+ return "SV_CouplingType";
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_ParameterDirection.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_ParameterDirection.java
deleted file mode 100644
index 1da66b1..0000000
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/code/SV_ParameterDirection.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.xml.bind.metadata.code;
-
-import jakarta.xml.bind.annotation.XmlElement;
-import org.opengis.parameter.ParameterDirection;
-import org.apache.sis.xml.Namespaces;
-import org.apache.sis.xml.bind.cat.EnumAdapter;
-
-
-/**
- * JAXB adapter for {@link ParameterDirection}
- * in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
- * See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class SV_ParameterDirection extends EnumAdapter<SV_ParameterDirection, ParameterDirection> {
- /**
- * The enumeration value.
- */
- @XmlElement(name = "SV_ParameterDirection", namespace = Namespaces.SRV)
- public String value;
-
- /**
- * Empty constructor for JAXB only.
- */
- public SV_ParameterDirection() {
- }
-
- /**
- * Returns the wrapped value.
- *
- * @param wrapper the wrapper.
- * @return the wrapped value.
- */
- @Override
- public final ParameterDirection unmarshal(final SV_ParameterDirection wrapper) {
- return ParameterDirection.valueOf(name(wrapper.value));
- }
-
- /**
- * Wraps the given value.
- *
- * @param e the value to wrap.
- * @return the wrapped value.
- */
- @Override
- public final SV_ParameterDirection marshal(final ParameterDirection e) {
- if (e == null) {
- return null;
- }
- final SV_ParameterDirection wrapper = new SV_ParameterDirection();
- wrapper.value = value(e);
- return wrapper;
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/Parameter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/Parameter.java
index bc9760a..c8f349f 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/Parameter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/Parameter.java
@@ -25,8 +25,9 @@
import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.util.ComparisonMode;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.apache.sis.util.Utilities.deepEquals;
+// Specific to the main branch:
+import java.util.Set;
+import javax.measure.Unit;
/**
@@ -84,10 +85,8 @@
*
* @return the type name of value component(s) in this parameter, or {@code null} if unknown.
*/
- @Override
public TypeName getValueType() {
- final ParameterDescriptor<T> p = descriptor;
- return (p != null) ? p.getValueType() : null;
+ return ReferencingServices.getInstance().getValueType(descriptor);
}
/**
@@ -123,8 +122,18 @@
return p.createValue();
}
+ /**
+ * Optional properties.
+ * @return {@code null}.
+ */
+ @Override public Set<T> getValidValues() {return null;} // Really null, not an empty set. See method contract.
+ @Override public Comparable<T> getMinimumValue() {return null;}
+ @Override public Comparable<T> getMaximumValue() {return null;}
+ @Override public T getDefaultValue() {return null;}
+ @Override public Unit<?> getUnit() {return null;}
+
/*
- * Do not override getValidValues(), getMinimumValue(), getMaximumValue(), getDefaultValue() or getUnit()
+ * Do not redirect getValidValues(), getMinimumValue(), getMaximumValue(), getDefaultValue() or getUnit()
* in order to keep property values stable before and after the `descriptor` field has been initialized.
* The `equals(Object)` method assumes that all those methods return null.
*/
@@ -153,14 +162,11 @@
return Objects.equals(toString(getName()), toString(that.getName()));
// super.equals(…) already compared `getName()` in other modes.
}
- return deepEquals(that.getValueType(), getValueType(), mode) &&
- deepEquals(that.getDescription(), getDescription(), mode) &&
- that.getDirection() == getDirection() &&
- that.getMinimumOccurs() == getMinimumOccurs() &&
- that.getMaximumOccurs() == getMaximumOccurs() &&
- that.getValidValues() == null &&
- that.getMinimumValue() == null &&
- that.getMaximumValue() == null;
+ return that.getMinimumOccurs() == getMinimumOccurs() &&
+ that.getMaximumOccurs() == getMaximumOccurs() &&
+ that.getValidValues() == null &&
+ that.getMinimumValue() == null &&
+ that.getMaximumValue() == null;
}
}
return false;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/QualityParameter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/QualityParameter.java
index 9f92939..feb608a 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/QualityParameter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/QualityParameter.java
@@ -36,11 +36,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import org.opengis.coverage.Coverage;
-import org.opengis.metadata.quality.Description;
-import org.opengis.metadata.quality.ValueStructure;
+// Specific to the main branch:
+import org.apache.sis.metadata.privy.ReferencingServices;
/**
@@ -68,8 +65,7 @@
"code",
"definition",
"description",
- "valueType",
- "valueStructure"
+ "valueType"
})
@XmlRootElement(name = "DQM_Parameter", namespace = Namespaces.DQM)
public final class QualityParameter extends Parameter {
@@ -88,7 +84,7 @@
/**
* Definition of the data quality parameter.
- * Stored in {@link Identifier#getDescription()}.
+ * Stored in {@link ReferenceIdentifier#getDescription()}.
*
* @see #getName()
*/
@@ -100,8 +96,7 @@
* Description of the data quality parameter.
*/
@XmlElement
- @SuppressWarnings("serial") // Most Apache SIS implementations are serializable.
- public Description description;
+ public DefaultMeasureDescription description;
/**
* Value type of the data quality parameter (shall be one of the data types defined in ISO/TS 19103:2005).
@@ -115,14 +110,6 @@
public TypeName valueType;
/**
- * Structure of the data quality parameter.
- *
- * @see #getValueClass()
- */
- @XmlElement
- public ValueStructure valueStructure;
-
- /**
* Creates an initially empty parameter.
* This constructor is needed by JAXB at unmarshalling time.
*/
@@ -139,13 +126,8 @@
final Identifier id = parameter.getName();
if (id != null) {
code = id.getCode();
- definition = id.getDescription();
}
- parameter.getDescription().ifPresent((text) -> {
- description = new DefaultMeasureDescription(text);
- });
- valueType = parameter.getValueType();
- valueStructure = ValueStructure.valueOf(parameter.getValueClass()).orElse(null);
+ valueType = ReferencingServices.getInstance().getValueType(parameter);
}
/**
@@ -161,6 +143,9 @@
return new QualityParameter(parameter);
}
+ @Override public int getMinimumOccurs() {return 0;}
+ @Override public int getMaximumOccurs() {return 1;}
+
/**
* Returns the name as an {@code Identifier}, which is the type requested by ISO 19111.
* Note that this is different than the type requested by ISO 19157, which is {@link String}.
@@ -179,18 +164,6 @@
}
/**
- * Returns a narrative explanation of the role of the parameter.
- *
- * @return a narrative explanation of the role of the parameter.
- */
- @Override
- public Optional<InternationalString> getDescription() {
- @SuppressWarnings("LocalVariableHidesMemberVariable")
- final Description description = this.description;
- return Optional.ofNullable((description != null) ? description.getTextDescription() : null);
- }
-
- /**
* Infers the value class from the type name.
* This method is the reason why we cannot parameterize this {@code QualityParameter} class
* (see <cite>Note about raw-type usage</cite> in class javadoc), because there is no way we
@@ -202,8 +175,7 @@
public Class<?> getValueClass() {
Class<?> type = super.getValueClass();
if (type == null) {
- final ValueStructure s = valueStructure;
- type = (s != null) ? s.toJavaType().orElse(null) : Names.toClass(valueType);
+ type = Names.toClass(valueType);
}
return type;
}
@@ -230,9 +202,6 @@
* <li>Otherwise the given class is used as if it was already a component type (i.e. a singleton item).</li>
* </ul>
*
- * This method is used for mapping {@link Class} to ({@link ValueStructure}, {@link TypeName}) pair.
- * The other member of the pair is given by {@link ValueStructure#valueOf(Class)}.
- *
* @todo {@code Coverage} case needs to be added. It would be handle like {@link Matrix}.
*
* @param valueClass the type of values for which to infer a {@link TypeName} instance.
@@ -243,7 +212,7 @@
valueClass = valueClass.getComponentType();
} else if (Iterable.class.isAssignableFrom(valueClass) || Map.class.isAssignableFrom(valueClass)) {
valueClass = Classes.boundOfParameterizedDeclaration(valueClass);
- } else if (Matrix.class.isAssignableFrom(valueClass) || Coverage.class.isAssignableFrom(valueClass)) {
+ } else if (Matrix.class.isAssignableFrom(valueClass)) {
valueClass = Double.class;
}
return Names.createTypeName(valueClass);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ReferenceSystemMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ReferenceSystemMetadata.java
index 570aadf..885397c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ReferenceSystemMetadata.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ReferenceSystemMetadata.java
@@ -30,10 +30,6 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ReferenceSystemType;
-import org.apache.sis.util.collection.Containers;
-
/**
* An implementation of {@link ReferenceSystem} marshalled as specified in ISO 19115.
@@ -46,6 +42,9 @@
* ├─mrs:referenceSystemIdentifier : mcc:MD_Identifier
* └─mrs:referenceSystemType : mrs:MD_ReferenceSystemTypeCode</pre>
*
+ * The {@code referenceSystemType} attribute is missing. It is present in GeoAPI 3.1 only.
+ * See <a href="https://issues.apache.org/jira/browse/SIS-470">SIS-470</a>.
+ *
* <p>Note that this implementation is very simple and serves no other purpose than being
* a container for XML parsing or formatting. For real referencing service, consider using
* {@link org.apache.sis.referencing.AbstractReferenceSystem} subclasses instead.</p>
@@ -58,8 +57,7 @@
* @see <a href="https://issues.apache.org/jira/browse/SIS-431">SIS-431</a>
*/
@XmlType(name = "MD_ReferenceSystem_Type", namespace = Namespaces.MRS, propOrder = {
- "name",
- "referenceSystemType"
+ "name"
})
@XmlRootElement(name = "MD_ReferenceSystem", namespace = Namespaces.MRS)
public class ReferenceSystemMetadata extends SimpleIdentifiedObject implements ReferenceSystem {
@@ -74,13 +72,6 @@
private boolean isLegacyMetadata;
/**
- * The type of the reference system, or {@code null} if unknown.
- * This type is inferred from the interfaces implemented by the CRS.
- */
- @XmlElement(name = "referenceSystemType")
- public ReferenceSystemType referenceSystemType;
-
- /**
* Creates a reference system without identifier.
* This constructor is mainly for JAXB.
*/
@@ -94,7 +85,6 @@
*/
public ReferenceSystemMetadata(final ReferenceSystem crs) {
super(crs);
- referenceSystemType = crs.getReferenceSystemType().orElse(null);
}
/**
@@ -151,13 +141,11 @@
public boolean equals(final Object object, final ComparisonMode mode) {
if (super.equals(object, mode) && (object instanceof ReferenceSystem)) {
final var that = (ReferenceSystem) object;
- if (that.getReferenceSystemType().orElse(null) == referenceSystemType) {
- if (mode.isIgnoringMetadata()) {
- // Compare the name because it was ignored by super.equals(…) in "ignore metadata" mode.
- return Utilities.deepEquals(getName(), that.getName(), mode);
- }
- return Containers.isNullOrEmpty(that.getDomains());
+ if (mode.isIgnoringMetadata()) {
+ // Compare the name because it was ignored by super.equals(…) in "ignore metadata" mode.
+ return Utilities.deepEquals(getName(), that.getName(), mode);
}
+ return that.getDomainOfValidity() == null && that.getScope() == null;
}
return false;
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/SensorType.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/SensorType.java
index 2c96b8d..7a50418 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/SensorType.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/SensorType.java
@@ -20,6 +20,10 @@
import org.opengis.annotation.Specification;
import org.opengis.util.CodeList;
+// Specific to the main branch:
+import java.util.List;
+import java.util.ArrayList;
+
/**
* The code list for {@code <gmi:MI_SensorTypeCode>}.
@@ -35,34 +39,59 @@
*/
private static final long serialVersionUID = 3510875680392393838L;
- /*
- * We need to construct values with `valueOf(String)` instead of the constructor
- * because this package is not exported to GeoAPI. See `CodeList` class javadoc.
+ /**
+ * List of all enumerations of this type.
+ * Must be declared before any enum declaration.
*/
+ private static final List<SensorType> VALUES = new ArrayList<>();
/**
* The sensor is a radiometer.
*/
- public static final SensorType RADIOMETER = valueOf("RADIOMETER");
+ public static final SensorType RADIOMETER = new SensorType("RADIOMETER");
/**
- * Constructs an element of the given name.
+ * Constructs an element of the given name. The new element is
+ * automatically added to the list returned by {@link #values()}.
*
* @param name the name of the new element.
* This name must not be in use by another element of this type.
*/
private SensorType(final String name) {
- super(name);
+ super(name, VALUES);
+ }
+
+ /**
+ * Returns the list of {@code SensorType}s.
+ *
+ * @return the list of codes declared in the current JVM.
+ */
+ public static SensorType[] values() {
+ synchronized (VALUES) {
+ return VALUES.toArray(SensorType[]::new);
+ }
+ }
+
+ /**
+ * Disables the search for UML identifiers because we do not export this package to GeoAPI.
+ *
+ * @return {@code null}.
+ */
+ @Override
+ public String identifier() {
+ return null;
}
/**
* Returns the list of codes of the same kind as this code list element.
+ * Invoking this method is equivalent to invoking {@link #values()}, except that
+ * this method can be invoked on an instance of the parent {@code CodeList} class.
*
* @return all code {@linkplain #values() values} for this code list.
*/
@Override
public SensorType[] family() {
- return values(SensorType.class);
+ return values();
}
/**
@@ -72,6 +101,6 @@
* @return a code matching the given name.
*/
public static SensorType valueOf(String code) {
- return valueOf(SensorType.class, code, SensorType::new).get();
+ return valueOf(SensorType.class, code);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ServiceParameter.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ServiceParameter.java
index 8621ef0..2802356 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ServiceParameter.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/ServiceParameter.java
@@ -38,9 +38,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.parameter.ParameterDirection;
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.apache.sis.metadata.privy.ReferencingServices;
/**
@@ -68,7 +67,6 @@
@XmlType(name = "SV_Parameter_Type", namespace = Namespaces.SRV, propOrder = {
"memberName", // The ISO 19115-3:2016 way to marshal name.
"legacyName", // Legacy ISO 19139:2007 way to marshal name.
- "direction",
"description",
"optionality",
"optionalityLabel", // Legacy ISO 19139:2007 way to marshal optionality.
@@ -108,14 +106,6 @@
public MemberName memberName;
/**
- * Indication if the parameter is an input to the service, an output or both.
- *
- * @see #getDirection()
- */
- @XmlElement(required = true)
- public ParameterDirection direction;
-
- /**
* A narrative explanation of the role of the parameter.
*
* @see #getDescription()
@@ -163,8 +153,6 @@
private ServiceParameter(final ParameterDescriptor<?> parameter) {
super(parameter);
memberName = getMemberName(parameter);
- direction = parameter.getDirection();
- description = parameter.getDescription().orElse(null);
optionality = parameter.getMinimumOccurs() > 0;
repeatability = parameter.getMaximumOccurs() > 1;
}
@@ -192,7 +180,7 @@
* <li>Otherwise this method searches for the first {@linkplain ParameterDescriptor#getAlias() alias}
* which is an instance of {@code MemberName}. If found, that alias is returned.</li>
* <li>If no alias is found, then this method tries to build a member name from the primary name and the
- * {@linkplain ParameterDescriptor#getValueType() value type} (if available) or the
+ * {@linkplain org.apache.sis.parameter.DefaultParameterDescriptor#getValueType() value type} (if available) or the
* {@linkplain ParameterDescriptor#getValueClass() value class}.</li>
* </ul>
*
@@ -205,7 +193,7 @@
*/
public static MemberName getMemberName(final ParameterDescriptor<?> parameter) {
if (parameter != null) {
- final Identifier id = parameter.getName();
+ final ReferenceIdentifier id = parameter.getName();
if (id instanceof MemberName) {
return (MemberName) id;
}
@@ -218,7 +206,7 @@
final String code = id.getCode();
if (code != null) {
final String namespace = id.getCodeSpace();
- final TypeName type = parameter.getValueType();
+ final TypeName type = ReferencingServices.getInstance().getValueType(parameter);
if (type != null) {
return Names.createMemberName(namespace, null, code, type);
} else {
@@ -327,21 +315,10 @@
}
/**
- * Returns an indication if the parameter is an input to the service, an output or both.
- *
- * @return indication if the parameter is an input or output to the service, or {@code null} if unspecified.
- */
- @Override
- public ParameterDirection getDirection() {
- return direction;
- }
-
- /**
* Returns a narrative explanation of the role of the parameter.
*
* @return a narrative explanation of the role of the parameter.
*/
- @Override
public Optional<InternationalString> getDescription() {
return Optional.ofNullable(description);
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/package-info.java
index a796576..28732fa 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/metadata/replace/package-info.java
@@ -44,9 +44,6 @@
@XmlJavaTypeAdapter(GO_Boolean.class),
@XmlJavaTypeAdapter(MD_Identifier.class),
@XmlJavaTypeAdapter(DQM_Description.class),
- @XmlJavaTypeAdapter(DQM_ValueStructure.class),
- @XmlJavaTypeAdapter(SV_ParameterDirection.class),
- @XmlJavaTypeAdapter(MD_ReferenceSystemTypeCode.class),
// Java types, primitive types and basic OGC types handling
@XmlJavaTypeAdapter(StringAdapter.class),
@@ -67,8 +64,3 @@
import org.apache.sis.xml.bind.metadata.MD_Identifier;
import org.apache.sis.xml.bind.metadata.DQM_Description;
import org.apache.sis.xml.bind.gco.*;
-
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.xml.bind.metadata.code.MD_ReferenceSystemTypeCode;
-import org.apache.sis.xml.bind.metadata.code.SV_ParameterDirection;
-import org.apache.sis.xml.bind.metadata.code.DQM_ValueStructure;
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java
index 7ac728f..d84214c 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java
@@ -34,10 +34,13 @@
import org.apache.sis.xml.test.DocumentComparator;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
-import org.opengis.metadata.maintenance.Scope;
-import org.opengis.metadata.content.FeatureTypeInfo;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
+import org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription;
+import org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo;
+import org.apache.sis.metadata.iso.lineage.DefaultSource;
+import org.apache.sis.metadata.iso.maintenance.DefaultScope;
/**
@@ -78,7 +81,7 @@
*/
public static void assertPartyNameEquals(final String expected, final Citation citation, final String message) {
assertNotNull(citation, message);
- final Responsibility r = getSingleton(citation.getCitedResponsibleParties());
+ final DefaultResponsibility r = (DefaultResponsibility) getSingleton(citation.getCitedResponsibleParties());
final InternationalString name = getSingleton(r.getParties()).getName();
assertNotNull(name, message);
assertEquals(expected, name.toString(Locale.US), message);
@@ -93,7 +96,7 @@
* @param catalog the content info to validate.
*/
public static void assertContentInfoEquals(final String name, final Integer count, final FeatureCatalogueDescription catalog) {
- final FeatureTypeInfo info = getSingleton(catalog.getFeatureTypeInfo());
+ final DefaultFeatureTypeInfo info = getSingleton(((DefaultFeatureCatalogueDescription) catalog).getFeatureTypeInfo());
assertEquals(name, String.valueOf(info.getFeatureTypeName()), "metadata.contentInfo.featureType");
assertEquals(count, info.getFeatureInstanceCount(), "metadata.contentInfo.featureInstanceCount");
}
@@ -108,7 +111,7 @@
*/
public static void assertFeatureSourceEquals(final String name, final String[] features, final Source source) {
assertEquals(name, String.valueOf(source.getSourceCitation().getTitle()), "metadata.lineage.source.sourceCitation.title");
- final Scope scope = source.getScope();
+ final DefaultScope scope = (DefaultScope) ((DefaultSource) source).getScope();
assertNotNull(scope, "metadata.lineage.source.scope");
assertEquals(ScopeCode.FEATURE_TYPE, scope.getLevel(), "metadata.lineage.source.scope.level");
final var actual = getSingleton(scope.getLevelDescription()).getFeatures().toArray(CharSequence[]::new);
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/HashCodeTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/HashCodeTest.java
index 36e066e..37b4374 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/HashCodeTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/HashCodeTest.java
@@ -39,9 +39,6 @@
import org.opengis.metadata.citation.ResponsibleParty;
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Individual;
-
/**
* Tests the {@link HashCode} class. This is also used as a relatively simple {@link MetadataVisitor} test.
@@ -97,7 +94,7 @@
/*
* Individual hash code is the sum of all its properties, none of them being a collection.
*/
- int expected = Individual.class.hashCode() + person.hashCode();
+ int expected = DefaultIndividual.class.hashCode() + person.hashCode();
assertEquals(Integer.valueOf(expected), hash(party));
/*
* The +31 below come from java.util.List contract, since above Individual is a list member.
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataCopierTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataCopierTest.java
index e0609fc..2384d25 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataCopierTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataCopierTest.java
@@ -113,7 +113,7 @@
final DefaultMetadata original = new DefaultMetadata();
original.getLocalesAndCharsets().put(Locale.FRENCH, StandardCharsets.UTF_8);
original.getLocalesAndCharsets().put(Locale.JAPANESE, StandardCharsets.UTF_16);
- final Metadata copy = copier.copy(Metadata.class, original);
+ final DefaultMetadata copy = (DefaultMetadata) copier.copy(Metadata.class, original);
final Map<Locale,Charset> lc = copy.getLocalesAndCharsets();
assertEquals(StandardCharsets.UTF_8, lc.get(Locale.FRENCH));
assertEquals(StandardCharsets.UTF_16, lc.get(Locale.JAPANESE));
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataStandardTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataStandardTest.java
index e21fdbb..f584fb9 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataStandardTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/MetadataStandardTest.java
@@ -42,10 +42,6 @@
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.List;
-import org.opengis.coverage.grid.RectifiedGrid;
-
/**
* Tests the {@link MetadataStandard} class.
@@ -93,7 +89,7 @@
assertFalse(isMetadata(IdentifiedObject.class));
assertFalse(isMetadata(SimpleIdentifiedObject.class));
assertFalse(isMetadata(GeographicCRS.class));
- assertFalse(isMetadata(RectifiedGrid.class));
+// assertFalse(isMetadata(RectifiedGrid.class));
assertFalse(isMetadata(Double.class));
assertFalse(isMetadata(Double.TYPE));
@@ -104,7 +100,7 @@
assertTrue (isMetadata(IdentifiedObject.class));
assertTrue (isMetadata(SimpleIdentifiedObject.class));
assertTrue (isMetadata(GeographicCRS.class));
- assertFalse(isMetadata(RectifiedGrid.class));
+// assertFalse(isMetadata(RectifiedGrid.class));
standard = MetadataStandard.ISO_19123;
assertFalse(isMetadata(String.class));
@@ -113,7 +109,7 @@
assertTrue (isMetadata(IdentifiedObject.class)); // Dependency
assertTrue (isMetadata(SimpleIdentifiedObject.class)); // Dependency
assertTrue (isMetadata(GeographicCRS.class)); // Dependency
- assertTrue (isMetadata(RectifiedGrid.class));
+// assertTrue (isMetadata(RectifiedGrid.class));
}
/**
@@ -312,38 +308,6 @@
}
/**
- * Tests the {@link MetadataStandard#ISO_19123} constant. Getters shall
- * be accessible even if there is no implementation on the module path.
- */
- @Test
- public void testWithoutImplementation() {
- standard = MetadataStandard.ISO_19123;
- assertFalse(isMetadata(String.class));
- assertTrue (isMetadata(Citation.class)); // Transitive dependency
- assertTrue (isMetadata(DefaultCitation.class)); // Transitive dependency
- assertTrue (isMetadata(RectifiedGrid.class));
- /*
- * Ensure that the getters have been found.
- */
- final Map<String,String> names = standard.asNameMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
- assertFalse(names.isEmpty(), "Getters should have been found even if there is no implementation.");
- assertEquals("dimension", names.get("dimension"));
- assertEquals("cells", names.get("cell"));
- /*
- * Ensure that the type are recognized, especially RectifiedGrid.getOffsetVectors()
- * which is of type List<double[]>.
- */
- Map<String,Class<?>> types;
- types = standard.asTypeMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.PROPERTY_TYPE);
- assertEquals(Integer.TYPE, types.get("dimension"));
- assertEquals(List.class, types.get("offsetVectors"));
-
- types = standard.asTypeMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
- assertEquals(Integer.class, types.get("dimension"));
- assertEquals(double[].class, types.get("offsetVectors"));
- }
-
- /**
* Tests serialization of predefined constants.
*/
@Test
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java
index 5ce9295..a413ae7 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java
@@ -68,11 +68,10 @@
import org.opengis.metadata.citation.ResponsibleParty;
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.AttributeGroup;
-import org.opengis.referencing.ReferenceSystemType;
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.content.DefaultAttributeGroup;
+import org.apache.sis.metadata.iso.identification.AbstractIdentification;
+import org.apache.sis.metadata.iso.identification.DefaultAssociatedResource;
/**
@@ -193,8 +192,8 @@
// Citation.class, "getCollectiveTitle", "collectiveTitle", "collectiveTitle", "Collective title", InternationalString.class, -- deprecated as of ISO 19115:2014
Citation.class, "getISBN", "ISBN", "ISBN", "ISBN", String.class,
Citation.class, "getISSN", "ISSN", "ISSN", "ISSN", String.class,
- Citation.class, "getOnlineResources", "onlineResources", "onlineResource", "Online resources", OnlineResource[].class,
- Citation.class, "getGraphics", "graphics", "graphic", "Graphics", BrowseGraphic[].class);
+ DefaultCitation.class, "getOnlineResources", "onlineResources", "onlineResource", "Online resources", OnlineResource[].class,
+ DefaultCitation.class, "getGraphics", "graphics", "graphic", "Graphics", BrowseGraphic[].class);
}
/**
@@ -216,29 +215,28 @@
Identification.class, "getCredits", "credits", "credit", "Credits", String[].class,
Identification.class, "getStatus", "status", "status", "Status", Progress[].class,
Identification.class, "getPointOfContacts", "pointOfContacts", "pointOfContact", "Point of contacts", ResponsibleParty[].class,
- Identification.class, "getSpatialRepresentationTypes", "spatialRepresentationTypes", "spatialRepresentationType", "Spatial representation types", SpatialRepresentationType[].class,
- Identification.class, "getSpatialResolutions", "spatialResolutions", "spatialResolution", "Spatial resolutions", Resolution[].class,
- Identification.class, "getTemporalResolutions", "temporalResolutions", "temporalResolution", "Temporal resolutions", TemporalAmount[].class,
- Identification.class, "getTopicCategories", "topicCategories", "topicCategory", "Topic categories", TopicCategory[].class,
- Identification.class, "getExtents", "extents", "extent", "Extents", Extent[].class,
- Identification.class, "getAdditionalDocumentations", "additionalDocumentations", "additionalDocumentation", "Additional documentations", Citation[].class,
- Identification.class, "getProcessingLevel", "processingLevel", "processingLevel", "Processing level", Identifier.class,
+ DataIdentification.class, "getSpatialRepresentationTypes", "spatialRepresentationTypes", "spatialRepresentationType", "Spatial representation types", SpatialRepresentationType[].class,
+ DataIdentification.class, "getSpatialResolutions", "spatialResolutions", "spatialResolution", "Spatial resolutions", Resolution[].class,
+ AbstractIdentification.class, "getTemporalResolutions", "temporalResolutions", "temporalResolution", "Temporal resolutions", TemporalAmount[].class,
+ DataIdentification.class, "getTopicCategories", "topicCategories", "topicCategory", "Topic categories", TopicCategory[].class,
+ DataIdentification.class, "getExtents", "extents", "extent", "Extents", Extent[].class,
+ AbstractIdentification.class, "getAdditionalDocumentations", "additionalDocumentations", "additionalDocumentation", "Additional documentations", Citation[].class,
+ AbstractIdentification.class, "getProcessingLevel", "processingLevel", "processingLevel", "Processing level", Identifier.class,
Identification.class, "getResourceMaintenances", "resourceMaintenances", "resourceMaintenance", "Resource maintenances", MaintenanceInformation[].class,
Identification.class, "getGraphicOverviews", "graphicOverviews", "graphicOverview", "Graphic overviews", BrowseGraphic[].class,
Identification.class, "getResourceFormats", "resourceFormats", "resourceFormat", "Resource formats", Format[].class,
Identification.class, "getDescriptiveKeywords", "descriptiveKeywords", "descriptiveKeywords", "Descriptive keywords", Keywords[].class,
Identification.class, "getResourceSpecificUsages", "resourceSpecificUsages", "resourceSpecificUsage", "Resource specific usages", Usage[].class,
Identification.class, "getResourceConstraints", "resourceConstraints", "resourceConstraints", "Resource constraints", Constraints[].class,
- Identification.class, "getAssociatedResources", "associatedResources", "associatedResource", "Associated resources", AssociatedResource[].class,
+ AbstractIdentification.class, "getAssociatedResources", "associatedResources", "associatedResource", "Associated resources", DefaultAssociatedResource[].class,
DataIdentification.class, "getEnvironmentDescription", "environmentDescription", "environmentDescription", "Environment description", InternationalString.class,
DataIdentification.class, "getSupplementalInformation", "supplementalInformation", "supplementalInformation", "Supplemental information", InternationalString.class,
- DataIdentification.class, "getLocalesAndCharsets", "localesAndCharsets", "defaultLocale+otherLocale", "Locales and charsets", Map.class);
+ DefaultDataIdentification.class, "getLocalesAndCharsets", "localesAndCharsets", "defaultLocale+otherLocale", "Locales and charsets", Map.class);
}
/**
* Tests the constructor with a method which override another method with covariant return type.
- * This test may need to be updated if a future GeoAPI release modifies the {@link GeographicCRS}
- * interface or one of its parent interfaces.
+ * This test may need to be updated if a future GeoAPI release modifies the {@link GeographicCRS} interface.
*/
@Test
public void testConstructorWithCovariantReturnType() {
@@ -246,13 +244,12 @@
//……Declaring type……………………………Method……………………………………………………JavaBeans……………………………………UML identifier………………………Sentence…………………………………………Type…………………………………………………………
GeographicCRS.class, "getCoordinateSystem", "coordinateSystem", "coordinateSystem", "Coordinate system", EllipsoidalCS.class, // Covariant return type
GeodeticCRS.class, "getDatum", "datum", "datum", "Datum", GeodeticDatum.class, // Covariant return type
- GeodeticCRS.class, "getDatumEnsemble", "datumEnsemble", "datumEnsemble", "Datum ensemble", DatumEnsemble.class, // Covariant return type
IdentifiedObject.class, "getName", "name", "name", "Name", ReferenceIdentifier.class,
IdentifiedObject.class, "getAlias", "alias", "alias", "Alias", GenericName[].class,
IdentifiedObject.class, "getIdentifiers", "identifiers", "identifier", "Identifiers", ReferenceIdentifier[].class,
- IdentifiedObject.class, "getDomains", "domains", "ObjectUsage.domain", "Domains", ObjectDomain[].class,
- IdentifiedObject.class, "getRemarks", "remarks", "remarks", "Remarks", InternationalString.class,
- ReferenceSystem.class, "getReferenceSystemType", "referenceSystemType", "referenceSystemType", "Reference system type", ReferenceSystemType.class);
+ ReferenceSystem.class, "getScope", "scope", "SC_CRS.scope", "Scope", InternationalString.class,
+ ReferenceSystem.class, "getDomainOfValidity", "domainOfValidity", "domainOfValidity", "Domain of validity", Extent.class,
+ IdentifiedObject.class, "getRemarks", "remarks", "remarks", "Remarks", InternationalString.class);
}
/**
@@ -380,7 +377,7 @@
/*
* Compares with the non-deprecated property.
*/
- final Collection<AttributeGroup> groups = instance.getAttributeGroups();
+ final Collection<DefaultAttributeGroup> groups = instance.getAttributeGroups();
assertSame(groups, accessor.get(indexOfReplacement, instance));
assertEquals(CoverageContentType.IMAGE, getSingleton(getSingleton(groups).getContentTypes()));
/*
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyConsistencyCheck.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyConsistencyCheck.java
index 5ce77cd..55f5504 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyConsistencyCheck.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyConsistencyCheck.java
@@ -34,9 +34,6 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.xml.test.AnnotationConsistencyCheck;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-
/**
* Base class for tests done on metadata objects using reflection. This base class tests JAXB annotations
@@ -131,11 +128,11 @@
if (Date.class.isAssignableFrom(type)) {
return new Date(random.nextInt() * 1000L);
}
- if (ControlledVocabulary.class.isAssignableFrom(type)) try {
+ if (CodeList.class.isAssignableFrom(type)) try {
if (type == CodeList.class) {
return null;
}
- final ControlledVocabulary[] codes = (ControlledVocabulary[]) type.getMethod("values", (Class[]) null).invoke(null, (Object[]) null);
+ final CodeList<?>[] codes = (CodeList<?>[]) type.getMethod("values", (Class[]) null).invoke(null, (Object[]) null);
return codes[random.nextInt(codes.length)];
} catch (ReflectiveOperationException e) {
fail(e.toString());
@@ -190,7 +187,7 @@
public void testPropertyValues() {
random = TestUtilities.createRandomNumberGenerator();
for (final Class<?> type : types) {
- if (!ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (!CodeList.class.isAssignableFrom(type)) {
final Class<?> impl = getImplementation(type);
if (impl != null) {
assertTrue(type.isAssignableFrom(impl), "Not an implementation of expected interface.");
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeChildrenTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeChildrenTest.java
index 57af6b7..d0c956e 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeChildrenTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeChildrenTest.java
@@ -37,6 +37,9 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
+// Specific to the main branch:
+import java.util.Date;
+
/**
* Tests the {@link TreeNodeChildren} class.
@@ -180,7 +183,7 @@
"Some title",
"First alternate title",
"Some edition",
- "PresentationForm.MAP_DIGITAL",
+ "PresentationForm[MAP_DIGITAL]",
"Some other details"
};
assertEquals(-1, children.titleProperty);
@@ -202,8 +205,8 @@
"First alternate title",
"Second alternate title",
"Some edition",
- "PresentationForm.MAP_DIGITAL",
- "PresentationForm.MAP_HARDCOPY",
+ "PresentationForm[MAP_DIGITAL]",
+ "PresentationForm[MAP_HARDCOPY]",
"Some other details"
};
assertEquals(-1, children.titleProperty);
@@ -231,7 +234,7 @@
final TreeNodeChildren children = (TreeNodeChildren) node.getChildren();
final String[] expected = {
// The "Date" node should be omitted because merged with the parent "Date" node.
- "DateType.CREATION"
+ "DateType[CREATION]"
};
assertEquals(0, children.titleProperty);
assertFalse (children.isEmpty());
@@ -257,9 +260,9 @@
"Second alternate title",
"Third alternate title", // After addition
"New edition", // After "addition" (actually change).
- "PresentationForm.IMAGE_DIGITAL", // After addition
- "PresentationForm.MAP_DIGITAL",
- "PresentationForm.MAP_HARDCOPY",
+ "PresentationForm[IMAGE_DIGITAL]", // After addition
+ "PresentationForm[MAP_DIGITAL]",
+ "PresentationForm[MAP_HARDCOPY]",
"Some other details"
};
toAdd.setValue(TableColumn.IDENTIFIER, "edition");
@@ -355,8 +358,8 @@
null, // edition date
null, // identifiers (collection)
null, // cited responsibly parties (collection)
- "PresentationForm.MAP_DIGITAL",
- "PresentationForm.MAP_HARDCOPY",
+ "PresentationForm[MAP_DIGITAL]",
+ "PresentationForm[MAP_HARDCOPY]",
null, // series
"Some other details",
// null, // collective title -- deprecated as of ISO 19115:2014.
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeTest.java
index 5e97e57..4d8bb5d 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeNodeTest.java
@@ -45,9 +45,6 @@
import org.opengis.metadata.citation.ResponsibleParty;
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-
/**
* Tests the {@link TreeNode} class.
@@ -194,8 +191,8 @@
private void assertCitationContentEquals(final int offset, final TableColumn<?> column, final Object... expected) {
if (valuePolicy == ValueExistencePolicy.COMPACT) {
assertEquals(19, expected.length);
- System.arraycopy(expected, 11+offset, expected, 10+offset, 8-offset); // Compact the "Individual" element.
- System.arraycopy(expected, 7+offset, expected, 6+offset, 11-offset); // Compact the "Organisation" element.
+ System.arraycopy(expected, 12+offset, expected, 11+offset, 7-offset); // Compact the "Individual" element.
+ System.arraycopy(expected, 8+offset, expected, 7+offset, 10-offset); // Compact the "Organisation" element.
System.arraycopy(expected, 1+offset, expected, offset, 16-offset); // Compact the "Title" element.
Arrays.fill(expected, 16, 19, null);
}
@@ -214,16 +211,16 @@
"Alternate title (2 of 2)",
"Edition",
"Cited responsible party (1 of 2)",
- "Organisation",
- "Name", // In COMPACT mode, this value is associated to "Organisation" node.
"Role",
+ "Party",
+ "Name", // In COMPACT mode, this value is associated to "Organisation" node.
"Cited responsible party (2 of 2)",
- "Individual",
+ "Role",
+ "Party",
"Name", // In COMPACT mode, this value is associated to "Individual" node.
"Contact info",
"Address",
"Electronic mail address",
- "Role",
"Presentation form (1 of 2)",
"Presentation form (2 of 2)",
"Other citation details");
@@ -244,16 +241,16 @@
"alternateTitle",
"edition",
"citedResponsibleParty",
+ "role",
"party",
"name", // In COMPACT mode, this value is associated to "party" node.
- "role",
"citedResponsibleParty",
+ "role",
"party",
"name", // In COMPACT mode, this value is associated to "party" node.
"contactInfo",
"address",
"electronicMailAddress",
- "role",
"presentationForm",
"presentationForm",
"otherCitationDetails");
@@ -274,16 +271,16 @@
ONE, // alternateTitle
null, // edition
ZERO, // citedResponsibleParty
+ null, // role
ZERO, // party (organisation)
null, // name — in COMPACT mode, this value is associated to "party" node.
- null, // role
ONE, // citedResponsibleParty
+ null, // role
ZERO, // party (individual)
null, // name — in COMPACT mode, this value is associated to "party" node.
ZERO, // contactInfo
ZERO, // address
ZERO, // electronicMailAddress
- null, // role
ZERO, // presentationForm
ONE, // presentationForm
null); // otherCitationDetails
@@ -301,16 +298,16 @@
InternationalString.class,
InternationalString.class,
ResponsibleParty.class,
- Party.class, // In COMPACT mode, value with be the one of "name" node instead.
- InternationalString.class, // Name
Role.class,
+ AbstractParty.class, // In COMPACT mode, value with be the one of "name" node instead.
+ InternationalString.class, // Name
ResponsibleParty.class,
- Party.class, // In COMPACT mode, value with be the one of "name" node instead.
+ Role.class,
+ AbstractParty.class, // In COMPACT mode, value with be the one of "name" node instead.
InternationalString.class, // Name
Contact.class,
Address.class,
String.class,
- Role.class,
PresentationForm.class,
PresentationForm.class,
InternationalString.class);
@@ -328,16 +325,16 @@
"Second alternate title",
"Some edition",
null, // ResponsibleParty
+ Role.DISTRIBUTOR,
null, // Party (organisation)
"Some organisation",
- Role.DISTRIBUTOR,
null, // ResponsibleParty
+ Role.POINT_OF_CONTACT,
null, // Party (individual)
"Some person of contact",
null, // Contact
null, // Address
"Some email",
- Role.POINT_OF_CONTACT,
PresentationForm.MAP_DIGITAL,
PresentationForm.MAP_HARDCOPY,
"Some other details");
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableFormatTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableFormatTest.java
index 3a76924..0e50bed 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableFormatTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableFormatTest.java
@@ -84,9 +84,10 @@
"Citation……………………………………………………………………………… Undercurrent\n" +
" ├─Alternate title………………………………………………… Andākarento\n" +
" ├─Cited responsible party (1 of 2)\n" +
- " │ ├─Individual…………………………………………………… Testsuya Toyoda\n" +
- " │ └─Role…………………………………………………………………… Author\n" +
+ " │ ├─Role…………………………………………………………………… Author\n" +
+ " │ └─Party………………………………………………………………… Testsuya Toyoda\n" +
" ├─Cited responsible party (2 of 2)\n" +
+ " │ ├─Role…………………………………………………………………… EDITOR\n" +
" │ ├─Extent……………………………………………………………… World\n" +
" │ │ └─Geographic element\n" +
" │ │ ├─West bound longitude…… 180°W\n" +
@@ -94,8 +95,7 @@
" │ │ ├─South bound latitude…… 90°S\n" +
" │ │ ├─North bound latitude…… 90°N\n" +
" │ │ └─Extent type code……………… True\n" +
- " │ ├─Organisation……………………………………………… Kōdansha\n" +
- " │ └─Role…………………………………………………………………… Editor\n" +
+ " │ └─Party………………………………………………………………… Kōdansha\n" +
" ├─Presentation form (1 of 2)…………………… Document digital\n" +
" ├─Presentation form (2 of 2)…………………… Document hardcopy\n" +
" └─ISBN……………………………………………………………………………… 9782505004509\n", text);
@@ -164,7 +164,7 @@
citation.setPresentationForms(List.of(
PresentationForm.IMAGE_DIGITAL,
- PresentationForm.valueOf("AUDIO_DIGITAL"), // Existing form
+ PresentationForm.valueOf("TABLE_DIGITAL"), // Existing form
PresentationForm.valueOf("test"))); // Custom form
final String text = format.format(citation.asTreeTable());
@@ -174,7 +174,7 @@
" ├─Alternate title (2 of 3)………… Orange\n" +
" ├─Alternate title (3 of 3)………… Kiwi\n" +
" ├─Presentation form (1 of 3)…… Image digital\n" +
- " ├─Presentation form (2 of 3)…… Audio digital\n" +
+ " ├─Presentation form (2 of 3)…… Table digital\n" +
" └─Presentation form (3 of 3)…… Test\n",
text);
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableViewTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableViewTest.java
index 8b3e026..ddacace 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableViewTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/TreeTableViewTest.java
@@ -70,14 +70,14 @@
" ├─Alternate title (2 of 2)…………………………………………… Second alternate title\n" +
" ├─Edition………………………………………………………………………………………… Some edition\n" +
" ├─Cited responsible party (1 of 2)\n" +
- " │ ├─Organisation………………………………………………………………… Some organisation\n" +
- " │ └─Role……………………………………………………………………………………… Distributor\n" +
+ " │ ├─Role……………………………………………………………………………………… Distributor\n" +
+ " │ └─Party…………………………………………………………………………………… Some organisation\n" +
" ├─Cited responsible party (2 of 2)\n" +
- " │ ├─Individual……………………………………………………………………… Some person of contact\n" +
- " │ │ └─Contact info\n" +
- " │ │ └─Address\n" +
- " │ │ └─Electronic mail address…… Some email\n" +
- " │ └─Role……………………………………………………………………………………… Point of contact\n" +
+ " │ ├─Role……………………………………………………………………………………… Point of contact\n" +
+ " │ └─Party…………………………………………………………………………………… Some person of contact\n" +
+ " │ └─Contact info\n" +
+ " │ └─Address\n" +
+ " │ └─Electronic mail address…… Some email\n" +
" ├─Presentation form (1 of 2)……………………………………… Map digital\n" +
" ├─Presentation form (2 of 2)……………………………………… Map hardcopy\n" +
" └─Other citation details………………………………………………… Some other details\n";
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/AllMetadataTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/AllMetadataTest.java
index db175ce..b977e2a 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/AllMetadataTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/AllMetadataTest.java
@@ -24,9 +24,8 @@
// Test dependencies
import org.junit.jupiter.api.Test;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.annotation.Stereotype;
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -41,14 +40,12 @@
@SuppressWarnings("deprecation")
public AllMetadataTest() {
super(MetadataStandard.ISO_19115,
- org.opengis.annotation.Obligation.class,
org.opengis.metadata.ApplicationSchemaInformation.class,
org.opengis.metadata.Datatype.class,
org.opengis.metadata.ExtendedElementInformation.class,
org.opengis.metadata.Identifier.class,
org.opengis.metadata.Metadata.class,
org.opengis.metadata.MetadataExtensionInformation.class,
- org.opengis.metadata.MetadataScope.class,
org.opengis.metadata.PortrayalCatalogueReference.class,
org.opengis.metadata.acquisition.AcquisitionInformation.class,
org.opengis.metadata.acquisition.Context.class,
@@ -75,9 +72,7 @@
org.opengis.metadata.citation.DateType.class,
org.opengis.metadata.citation.OnLineFunction.class,
org.opengis.metadata.citation.OnlineResource.class,
- org.opengis.metadata.citation.Party.class,
org.opengis.metadata.citation.PresentationForm.class,
- org.opengis.metadata.citation.Responsibility.class,
org.opengis.metadata.citation.ResponsibleParty.class,
org.opengis.metadata.citation.Role.class,
org.opengis.metadata.citation.Series.class,
@@ -87,7 +82,6 @@
org.opengis.metadata.constraint.LegalConstraints.class,
org.opengis.metadata.constraint.Restriction.class,
org.opengis.metadata.constraint.SecurityConstraints.class,
- org.opengis.metadata.content.AttributeGroup.class,
org.opengis.metadata.content.Band.class,
org.opengis.metadata.content.BandDefinition.class,
org.opengis.metadata.content.ContentInformation.class,
@@ -99,7 +93,6 @@
org.opengis.metadata.content.PolarizationOrientation.class,
org.opengis.metadata.content.RangeDimension.class,
org.opengis.metadata.content.RangeElementDescription.class,
- org.opengis.metadata.content.SampleDimension.class,
org.opengis.metadata.content.TransferFunctionType.class,
org.opengis.metadata.distribution.DataFile.class,
org.opengis.metadata.distribution.DigitalTransferOptions.class,
@@ -119,20 +112,15 @@
org.opengis.metadata.extent.TemporalExtent.class,
org.opengis.metadata.extent.VerticalExtent.class,
org.opengis.metadata.identification.AggregateInformation.class,
- org.opengis.metadata.identification.AssociatedResource.class,
org.opengis.metadata.identification.AssociationType.class,
org.opengis.metadata.identification.BrowseGraphic.class,
org.opengis.metadata.identification.CharacterSet.class,
- org.opengis.metadata.identification.CoupledResource.class,
org.opengis.metadata.identification.DataIdentification.class,
org.opengis.metadata.identification.Identification.class,
org.opengis.metadata.identification.InitiativeType.class,
org.opengis.metadata.identification.Keywords.class,
- org.opengis.metadata.identification.KeywordClass.class,
org.opengis.metadata.identification.KeywordType.class,
org.opengis.metadata.identification.Progress.class,
- org.opengis.metadata.identification.OperationChainMetadata.class,
- org.opengis.metadata.identification.OperationMetadata.class,
org.opengis.metadata.identification.RepresentativeFraction.class,
org.opengis.metadata.identification.Resolution.class,
org.opengis.metadata.identification.ServiceIdentification.class,
@@ -147,57 +135,36 @@
org.opengis.metadata.lineage.Source.class,
org.opengis.metadata.maintenance.MaintenanceFrequency.class,
org.opengis.metadata.maintenance.MaintenanceInformation.class,
- org.opengis.metadata.maintenance.Scope.class,
org.opengis.metadata.maintenance.ScopeCode.class,
org.opengis.metadata.maintenance.ScopeDescription.class,
org.opengis.metadata.quality.AbsoluteExternalPositionalAccuracy.class,
org.opengis.metadata.quality.AccuracyOfATimeMeasurement.class,
- org.opengis.metadata.quality.AggregationDerivation.class,
- org.opengis.metadata.quality.BasicMeasure.class,
org.opengis.metadata.quality.Completeness.class,
org.opengis.metadata.quality.CompletenessCommission.class,
org.opengis.metadata.quality.CompletenessOmission.class,
org.opengis.metadata.quality.ConceptualConsistency.class,
- org.opengis.metadata.quality.Confidence.class,
org.opengis.metadata.quality.ConformanceResult.class,
org.opengis.metadata.quality.CoverageResult.class,
- org.opengis.metadata.quality.DataEvaluation.class,
org.opengis.metadata.quality.DataQuality.class,
-// org.opengis.metadata.quality.Description.class, // Pending ISO 19157:2022 renaming.
- org.opengis.metadata.quality.DescriptiveResult.class,
org.opengis.metadata.quality.DomainConsistency.class,
org.opengis.metadata.quality.Element.class,
- org.opengis.metadata.quality.EvaluationMethod.class,
org.opengis.metadata.quality.EvaluationMethodType.class,
org.opengis.metadata.quality.FormatConsistency.class,
- org.opengis.metadata.quality.FullInspection.class,
org.opengis.metadata.quality.GriddedDataPositionalAccuracy.class,
- org.opengis.metadata.quality.Homogeneity.class,
- org.opengis.metadata.quality.IndirectEvaluation.class,
org.opengis.metadata.quality.LogicalConsistency.class,
-// org.opengis.metadata.quality.Measure.class, // Pending ISO 19157:2022 renaming.
- org.opengis.metadata.quality.MeasureReference.class,
- org.opengis.metadata.quality.Metaquality.class,
org.opengis.metadata.quality.NonQuantitativeAttributeAccuracy.class,
- org.opengis.metadata.quality.NonQuantitativeAttributeCorrectness.class,
org.opengis.metadata.quality.PositionalAccuracy.class,
org.opengis.metadata.quality.QuantitativeAttributeAccuracy.class,
org.opengis.metadata.quality.QuantitativeResult.class,
org.opengis.metadata.quality.RelativeInternalPositionalAccuracy.class,
- org.opengis.metadata.quality.Representativity.class,
org.opengis.metadata.quality.Result.class,
- org.opengis.metadata.quality.SampleBasedInspection.class,
- org.opengis.metadata.quality.SourceReference.class,
-// org.opengis.metadata.quality.StandaloneQualityReportInformation.class, // Pending ISO 19157:2022 renaming.
org.opengis.metadata.quality.TemporalAccuracy.class,
org.opengis.metadata.quality.TemporalConsistency.class,
- org.opengis.metadata.quality.TemporalQuality.class,
org.opengis.metadata.quality.TemporalValidity.class,
org.opengis.metadata.quality.ThematicAccuracy.class,
org.opengis.metadata.quality.ThematicClassificationCorrectness.class,
org.opengis.metadata.quality.TopologicalConsistency.class,
org.opengis.metadata.quality.Usability.class,
- org.opengis.metadata.quality.ValueStructure.class,
org.opengis.metadata.spatial.CellGeometry.class,
org.opengis.metadata.spatial.Dimension.class,
org.opengis.metadata.spatial.DimensionNameType.class,
@@ -237,10 +204,13 @@
* Returns the name of the XML root element for an interface described by the given UML.
* This method does the generic work described in super-class, then applies special rules
* specific to the metadata package.
+ *
+ * @deprecated the complete function is available only on development branch because it depends on GeoAPI 3.1.
*/
@Override
- protected String getExpectedXmlRootElementName(final Stereotype stereotype, final UML uml) {
- String name = super.getExpectedXmlRootElementName(stereotype, uml);
+ @Deprecated
+ protected String getExpectedXmlRootElementName(final UML uml) {
+ String name = super.getExpectedXmlRootElementName(uml);
if (name.equals("DQ_CoverageResult")) name = "QE_CoverageResult";
return name;
}
@@ -249,10 +219,13 @@
* Returns the name of the XML type for an interface described by the given UML.
* This method does the generic work described in super-class, then applies special rules
* specific to the metadata package.
+ *
+ * @deprecated the complete function is available only on development branch because it depends on GeoAPI 3.1.
*/
@Override
- protected String getExpectedXmlTypeName(final Stereotype stereotype, final UML uml) {
- String name = super.getExpectedXmlTypeName(stereotype, uml);
+ @Deprecated
+ protected String getExpectedXmlTypeName(final UML uml) {
+ String name = super.getExpectedXmlTypeName(uml);
if (name.equals("DQ_CoverageResult_Type")) name = "QE_CoverageResult_Type";
return name;
}
@@ -274,9 +247,13 @@
*/
return null;
}
+ String identifier = type.getAnnotation(UML.class).identifier();
+ if (identifier.equals("MI_PolarizationOrientationCode")) {
+ identifier = "MI_PolarisationOrientationCode";
+ // https://issues.apache.org/jira/browse/SIS-398
+ }
final String classname = "org.apache.sis.xml.bind.metadata." +
- (ControlledVocabulary.class.isAssignableFrom(type) ? "code." : "") +
- type.getAnnotation(UML.class).identifier();
+ (CodeList.class.isAssignableFrom(type) ? "code." : "") + identifier;
final Class<?> wrapper = Class.forName(classname);
Class<?>[] expectedFinalClasses = wrapper.getClasses(); // "Since2014" internal class.
if (expectedFinalClasses.length == 0) {
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/CustomMetadataTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/CustomMetadataTest.java
index 449673a..3847257 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/CustomMetadataTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/CustomMetadataTest.java
@@ -40,6 +40,13 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.xml.test.TestCase;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.metadata.constraint.Constraints;
+import org.opengis.metadata.distribution.Format;
+import org.opengis.metadata.maintenance.MaintenanceInformation;
+import org.opengis.metadata.spatial.SpatialRepresentationType;
+
/**
* Tests XML marshalling of custom implementation of metadata interfaces. The custom implementations
@@ -109,9 +116,25 @@
return factory.createInternationalString(names);
}
- @Override public Citation getCitation() {return null;}
- @Override public Collection<TopicCategory> getTopicCategories() {return null;}
- @Override public Collection<Extent> getExtents() {return null;}
+ @Override public InternationalString getSupplementalInformation() {return null;}
+ @Override public Citation getCitation() {return null;}
+ @Override public InternationalString getPurpose() {return null;}
+ @Override public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {return null;}
+ @Override public Collection<Resolution> getSpatialResolutions() {return null;}
+ @Override public Collection<Locale> getLanguages() {return null;}
+ @Override public Collection<CharacterSet> getCharacterSets() {return null;}
+ @Override public Collection<TopicCategory> getTopicCategories() {return null;}
+ @Override public Collection<Extent> getExtents() {return null;}
+ @Override public Collection<String> getCredits() {return null;}
+ @Override public Collection<Progress> getStatus() {return null;}
+ @Override public Collection<ResponsibleParty> getPointOfContacts() {return null;}
+ @Override public Collection<MaintenanceInformation> getResourceMaintenances() {return null;}
+ @Override public Collection<BrowseGraphic> getGraphicOverviews() {return null;}
+ @Override public Collection<Format> getResourceFormats() {return null;}
+ @Override public Collection<Keywords> getDescriptiveKeywords() {return null;}
+ @Override public Collection<Usage> getResourceSpecificUsages() {return null;}
+ @Override public Collection<Constraints> getResourceConstraints() {return null;}
+@Deprecated @Override public Collection<AggregateInformation> getAggregationInfo() {return null;}
};
final DefaultMetadata data = new DefaultMetadata();
data.setIdentificationInfo(Set.of(identification));
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java
index 0366df6..d983e58 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java
@@ -40,9 +40,6 @@
import static org.apache.sis.test.TestUtilities.getSingleton;
import static org.apache.sis.metadata.Assertions.assertTitleEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
-
/**
* Tests {@link DefaultMetadata}, without Coordinate Reference System (CRS) information.
@@ -186,9 +183,9 @@
/*
* The above deprecated methods shall have created MetadataScope object. Verify that.
*/
- final Collection<MetadataScope> scopes = metadata.getMetadataScopes();
- final Iterator<MetadataScope> it = scopes.iterator();
- MetadataScope scope = it.next();
+ final Collection<DefaultMetadataScope> scopes = metadata.getMetadataScopes();
+ final Iterator<DefaultMetadataScope> it = scopes.iterator();
+ DefaultMetadataScope scope = it.next();
assertEquals("Bridges", scope.getName().toString());
assertEquals(ScopeCode.FEATURE_TYPE, scope.getResourceScope());
scope = it.next();
@@ -232,7 +229,7 @@
*/
Date creation = date("2014-10-07 00:00:00");
final var dates = new DefaultCitationDate[] {
- new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.LAST_UPDATE),
+ new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.valueOf("LAST_UPDATE")),
new DefaultCitationDate(creation, DateType.CREATION)
};
metadata.setDateInfo(Arrays.asList(dates));
@@ -281,7 +278,5 @@
final var metadata = new DefaultMetadata();
metadata.setDataSetUri("file:/tmp/myfile.txt");
assertEquals("file:/tmp/myfile.txt", metadata.getDataSetUri());
- assertEquals("file:/tmp/myfile.txt", getSingleton(getSingleton(metadata.getIdentificationInfo())
- .getCitation().getOnlineResources()).getLinkage().toString());
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/api-changes.properties b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/api-changes.properties
index a1687d2..ae642b7 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/api-changes.properties
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/api-changes.properties
@@ -22,3 +22,36 @@
# with the changes in the international standard. The UML identifiers of added methods are "number"
# and "numberType" respectively.
#
+org.opengis.metadata.citation.Citation=-getCollectiveTitle +getGraphics:graphic +getOnlineResources:onlineResource
+org.opengis.metadata.citation.Contact=-getAddress +getAddresses:address +getContactType:contactType -getOnlineResource +getOnlineResources:onlineResource -getPhone +getPhones:phone
+org.opengis.metadata.citation.OnlineResource=+getProtocolRequest:protocolRequest
+org.opengis.metadata.citation.ResponsibleParty=-getContactInfo -getIndividualName -getOrganisationName -getPositionName
+org.opengis.metadata.citation.Telephone=-getFacsimiles +getNumber:number +getNumberType:numberType -getVoices
+org.opengis.metadata.constraint.Constraints=+getConstraintApplicationScope:constraintApplicationScope +getGraphics:graphic +getReferences:reference +getReleasability:releasability +getResponsibleParties:responsibleParty
+org.opengis.metadata.content.Band=+getBoundMax:boundMax +getBoundMin:boundMin +getBoundUnits:boundUnits
+org.opengis.metadata.content.CoverageDescription=+getAttributeGroups:attributeGroup -getContentType -getDimensions +getProcessingLevelCode:processingLevelCode
+org.opengis.metadata.content.FeatureCatalogueDescription=+getFeatureTypeInfo:featureTypes -getFeatureTypes -getLanguages +getLocalesAndCharsets:locale
+org.opengis.metadata.content.RangeDimension=+getDescription:description -getDescriptor +getNames:name
+org.opengis.metadata.distribution.DigitalTransferOptions=+getDistributionFormats:distributionFormat -getOffLine +getOffLines:offLine +getTransferFrequency:transferFrequency
+org.opengis.metadata.distribution.Distribution=+getDescription:description
+org.opengis.metadata.distribution.Format=+getFormatSpecificationCitation:formatSpecificationCitation +getMedia:medium -getName -getSpecification -getVersion
+org.opengis.metadata.distribution.Medium=-getDensities +getDensity:density +getIdentifier:identifier
+org.opengis.metadata.distribution.StandardOrderProcess=+getOrderOptionsType:orderOptionsType +getOrderOptions:orderOptions
+org.opengis.metadata.ExtendedElementInformation=-getDomainCode +getRationale:rationale -getRationales -getShortName
+org.opengis.metadata.extent.SpatialTemporalExtent=+getVerticalExtent:verticalExtent
+org.opengis.metadata.identification.AggregateInformation=-getAggregateDataSetIdentifier -getAggregateDataSetName +getMetadataReference:metadataReference +getName:name
+org.opengis.metadata.identification.BrowseGraphic=+getImageConstraints:imageContraints +getLinkages:linkage
+org.opengis.metadata.identification.DataIdentification=-getCharacterSets -getLanguages +getLocalesAndCharsets:defaultLocale+otherLocale
+org.opengis.metadata.identification.Identification=+getAdditionalDocumentations:additionalDocumentation -getAggregationInfo +getAssociatedResources:associatedResource +getExtents:extent +getProcessingLevel:processingLevel +getSpatialRepresentationTypes:spatialRepresentationType +getSpatialResolutions:spatialResolution ~+getTemporalResolutions:temporalResolution +getTopicCategories:topicCategory
+org.opengis.metadata.identification.Keywords=+getKeywordClass:keywordClass
+org.opengis.metadata.identification.Resolution=+getAngularDistance:angularDistance +getLevelOfDetail:levelOfDetail +getVertical:vertical
+org.opengis.metadata.identification.ServiceIdentification=+getAccessProperties:accessProperties +getContainsChain:containsChain +getContainsOperations:containsOperations +getCoupledResources:coupledResource +getCouplingType:couplingType +getOperatedDatasets:operatedDataset +getOperatesOn:operatesOn +getProfiles:profile +getServiceStandards:serviceStandard +getServiceType:serviceType +getServiceTypeVersions:serviceTypeVersion
+org.opengis.metadata.identification.Usage=+getAdditionalDocumentation:additionalDocumentation +getIdentifiedIssues:identifiedIssues +getResponses:response
+org.opengis.metadata.Identifier=+getCodeSpace:codeSpace +getDescription:description +getVersion:version
+org.opengis.metadata.lineage.Lineage=+getAdditionalDocumentation:additionalDocumentation +getScope:scope
+org.opengis.metadata.lineage.ProcessStep=-getDate +getReferences:reference +getScope:scope
+org.opengis.metadata.lineage.Source=-getScaleDenominator +getScope:scope -getSourceExtents +getSourceMetadata:sourceMetadata +getSourceSpatialResolution:sourceSpatialResolution
+org.opengis.metadata.maintenance.MaintenanceInformation=-getDateOfNextUpdate +getMaintenanceDates:maintenanceDate +getMaintenanceScopes:maintenanceScope -getUpdateScopeDescriptions -getUpdateScopes
+org.opengis.metadata.Metadata=+getAlternativeMetadataReferences:alternativeMetadataReference -getCharacterSet -getCharacterSets -getDataSetUri -getDateStamp +getDateInfo:dateInfo -getFileIdentifier -getHierarchyLevelNames -getHierarchyLevels -getLanguage -getLanguages -getLocales +getLocalesAndCharsets:defaultLocale+otherLocale +getMetadataIdentifier:metadataIdentifier +getMetadataLinkages:metadataLinkage +getMetadataProfiles:metadataProfile +getMetadataScopes:metadataScope -getMetadataStandardName -getMetadataStandardVersion +getMetadataStandards:metadataStandard -getParentIdentifier +getParentMetadata:parentMetadata +getResourceLineages:resourceLineage
+org.opengis.metadata.quality.Scope=-getExtent +getExtents:extent
+org.opengis.metadata.spatial.Dimension=+getDimensionDescription:dimensionDescription +getDimensionTitle:dimensionTitle
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java
index 1e15401..2fad300 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java
@@ -40,6 +40,9 @@
import static org.apache.sis.metadata.Assertions.assertTitleEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Tests {@link Citations}.
@@ -122,20 +125,20 @@
*/
@Test
public void testGetIdentifier() {
- assertEquals("Apache:SIS", getIdentifier(SIS));
+ assertEquals("SIS", getIdentifier(SIS));
assertEquals("OGC", getIdentifier(OGC));
assertEquals("IOGP", getIdentifier(IOGP));
assertEquals("EPSG", getIdentifier(EPSG));
- assertEquals("ESRI:ArcGIS", getIdentifier(ESRI));
+ assertEquals("ArcGIS", getIdentifier(ESRI));
assertEquals("NetCDF", getIdentifier(NETCDF));
assertEquals("GeoTIFF", getIdentifier(GEOTIFF));
assertEquals("ISBN", getIdentifier(ISBN));
assertEquals("ISSN", getIdentifier(ISSN));
- assertEquals("OSGeo:PROJ", getIdentifier(PROJ4)); // Not a valid Unicode identifier.
- assertEquals("IHO:S-57", getIdentifier(S57)); // Not a valid Unicode identifier.
- assertEquals("ISO:19115-1", getIdentifier(ISO_19115.get(0))); // The ':' separator is not usual in ISO references
- assertEquals("ISO:19115-2", getIdentifier(ISO_19115.get(1))); // and could be changed in future SIS versions.
- assertEquals("OGC:WMS", getIdentifier(WMS));
+ assertEquals("PROJ", getIdentifier(PROJ4)); // Not a valid Unicode identifier.
+ assertEquals("S-57", getIdentifier(S57)); // Not a valid Unicode identifier.
+ assertEquals("19115-1", getIdentifier(ISO_19115.get(0))); // The ':' separator is not usual in ISO references
+ assertEquals("19115-2", getIdentifier(ISO_19115.get(1))); // and could be changed in future SIS versions.
+ assertEquals("WMS", getIdentifier(WMS));
}
/**
@@ -219,6 +222,7 @@
* Tests {@code getCitedResponsibleParties()} on some {@code Citation} constants.
*/
@Test
+ @org.junit.jupiter.api.Disabled("Requires GeoAPI 3.1.")
public void testGetCitedResponsibleParty() {
assertEquals("Open Geospatial Consortium", getCitedResponsibleParty(OGC));
assertEquals("International Organization for Standardization", getCitedResponsibleParty(ISO_19115.get(0)));
@@ -231,7 +235,7 @@
* Returns the responsible party for the given constant.
*/
private static String getCitedResponsibleParty(final Citation citation) {
- return getSingleton(getSingleton(citation.getCitedResponsibleParties()).getParties()).getName().toString(Locale.US);
+ return getSingleton(citation.getCitedResponsibleParties()).getOrganisationName().toString(Locale.US);
}
/**
@@ -245,7 +249,7 @@
public void testEPSG() {
final Identifier identifier = getSingleton(EPSG.getIdentifiers());
assertEquals("EPSG", toCodeSpace(EPSG));
- assertEquals("IOGP", identifier.getCodeSpace());
+// assertEquals("IOGP", identifier.getCodeSpace());
assertEquals("EPSG", identifier.getCode());
}
@@ -281,17 +285,24 @@
*/
@Test
public void testIdentifierMatches() {
- final var ogc = new DefaultIdentifier("OGC", "06-042", null);
- final var iso = new DefaultIdentifier("ISO", "19128", null);
+ final var ogc = new Id("OGC", "06-042");
+ final var iso = new Id("ISO", "19128");
final var citation = new DefaultCitation("Web Map Server");
citation.setIdentifiers(List.of(ogc, iso, new DefaultIdentifier("Foo", "06-042", null)));
assertTrue (/* With full identifier */ Citations.identifierMatches(citation, ogc, ogc.getCode()));
assertTrue (/* With full identifier */ Citations.identifierMatches(citation, iso, iso.getCode()));
- assertFalse(/* With wrong code */ Citations.identifierMatches(citation, new DefaultIdentifier("ISO", "19115", null), "19115"));
- assertFalse(/* With wrong codespace */ Citations.identifierMatches(citation, new DefaultIdentifier("Foo", "19128", null), "19128"));
+ assertFalse(/* With wrong code */ Citations.identifierMatches(citation, new Id("ISO", "19115"), "19115"));
+ assertFalse(/* With wrong codespace */ Citations.identifierMatches(citation, new Id("Foo", "19128"), "19128"));
assertFalse(/* With wrong code */ Citations.identifierMatches(citation, "Foo"));
assertTrue (/* Without identifier */ Citations.identifierMatches(citation, "19128"));
assertTrue (/* With parsing */ Citations.identifierMatches(citation, "ISO:19128"));
assertFalse(/* With wrong codespace */ Citations.identifierMatches(citation, "Foo:19128"));
}
+
+ @SuppressWarnings("serial")
+ private static final class Id extends DefaultIdentifier implements ReferenceIdentifier {
+ Id(String codeSpace, String code) {
+ super(codeSpace, code, null);
+ }
+ }
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
index 55e52af..7c97bc9 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
@@ -26,8 +26,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.time.temporal.Temporal;
+// Specific to the main branch:
+import java.util.Date;
/**
@@ -48,13 +48,12 @@
@Test
public void testCopyConstructor() {
final var original = new CitationDate() {
- @Override public Temporal getReferenceDate() {return Instant.ofEpochMilli(1305716658508L);}
+ @Override public Date getDate() {return new Date(1305716658508L);}
@Override public DateType getDateType() {return DateType.CREATION;}
};
final var copy = new DefaultCitationDate(original);
assertEquals(Instant.ofEpochMilli(1305716658508L), copy.getReferenceDate());
assertEquals(DateType.CREATION, copy.getDateType());
- assertTrue (copy.equals(original, ComparisonMode.DEBUG));
assertFalse(copy.equals(original, ComparisonMode.STRICT)); // Opportunist test.
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
index 4626a23..d19cdd1 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
@@ -52,10 +52,9 @@
import static org.apache.sis.test.TestUtilities.getSingleton;
import static org.apache.sis.metadata.Assertions.assertTitleEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.CitationDate;
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.util.CodeList;
/**
@@ -102,7 +101,7 @@
final DefaultResponsibleParty author = new DefaultResponsibleParty(Role.AUTHOR);
author.setParties(Set.of(new DefaultIndividual("Testsuya Toyoda", null, null)));
- final DefaultResponsibleParty editor = new DefaultResponsibleParty(Role.EDITOR);
+ final DefaultResponsibleParty editor = new DefaultResponsibleParty(Role.valueOf("EDITOR"));
editor.setParties(Set.of(new DefaultOrganisation("Kōdansha", null, null, null)));
editor.setExtents(Set.of(Extents.WORLD));
@@ -198,12 +197,12 @@
/*
* Verify the author metadata.
*/
- final Responsibility re = CollectionsExt.first(original.getCitedResponsibleParties());
- final Responsibility ra = CollectionsExt.first(clone .getCitedResponsibleParties());
+ final ResponsibleParty re = CollectionsExt.first(original.getCitedResponsibleParties());
+ final ResponsibleParty ra = CollectionsExt.first(clone .getCitedResponsibleParties());
assertNotSame(re, ra);
assertSame(re.getRole(), ra.getRole());
- assertSame(getSingleton(re.getParties()).getName(),
- getSingleton(ra.getParties()).getName());
+ assertSame(re.getIndividualName(),
+ ra.getIndividualName());
}
/**
@@ -255,12 +254,12 @@
contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "ip-protocol");
final var c = new DefaultCitation("Fight against poverty");
final var r1 = new DefaultResponsibleParty(Role.ORIGINATOR);
- final var r2 = new DefaultResponsibleParty(Role.FUNDER);
+ final var r2 = new DefaultResponsibleParty(Role.valueOf("funder"));
r1.setParties(Set.of(new DefaultIndividual("Maid Marian", null, contact)));
r2.setParties(Set.of(new DefaultIndividual("Robin Hood", null, contact)));
c.setCitedResponsibleParties(List.of(r1, r2));
- c.getDates().add(new DefaultCitationDate(OffsetDateTime.of(2015, 10, 17, 2, 0, 0, 0, ZoneOffset.ofHours(2)), DateType.ADOPTED));
- c.getPresentationForms().add(PresentationForm.PHYSICAL_OBJECT);
+ c.getDates().add(new DefaultCitationDate(OffsetDateTime.of(2015, 10, 17, 2, 0, 0, 0, ZoneOffset.ofHours(2)), DateType.valueOf("adopted")));
+ c.getPresentationForms().add(PresentationForm.valueOf("physicalObject"));
/*
* Check that XML file built by the marshaller is the same as the example file.
*/
@@ -307,33 +306,43 @@
public static void verifyUnmarshalledCitation(final Citation c) {
assertTitleEquals("Fight against poverty", c, "citation");
- final CitationDate date = getSingleton(c.getDates());
+ final var date = (DefaultCitationDate) getSingleton(c.getDates());
assertEquals(date.getReferenceDate(), OffsetDateTime.of(2015, 10, 17, 2, 0, 0, 0, ZoneOffset.ofHours(2)));
- assertEquals(DateType.ADOPTED, date.getDateType());
- assertEquals(PresentationForm.PHYSICAL_OBJECT, getSingleton(c.getPresentationForms()));
+ assertEqualsIgnoreCase(DateType.valueOf("adopted"), date.getDateType());
+ assertEqualsIgnoreCase(PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms()));
- final Iterator<? extends Responsibility> it = c.getCitedResponsibleParties().iterator();
+ final Iterator<? extends ResponsibleParty> it = c.getCitedResponsibleParties().iterator();
final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next());
assertEquals("Send carrier pigeon.", String.valueOf(contact.getContactInstructions()));
- final OnlineResource resource = getSingleton(contact.getOnlineResources());
+ final OnlineResource resource = contact.getOnlineResource();
assertEquals("IP over Avian Carriers", String.valueOf(resource.getName()));
assertEquals("High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription()));
assertEquals("https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage()));
assertEquals(OnLineFunction.OFFLINE_ACCESS, resource.getFunction());
// Thanks to xlink:href, the Contact shall be the same instance as above.
- assertSame(contact, assertResponsibilityEquals(Role.FUNDER, "Robin Hood", it.next()));
+ assertSame(contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next()));
assertFalse(it.hasNext());
}
/**
* Asserts that the given responsibility has the expected properties, then returns its contact info.
*/
- private static Contact assertResponsibilityEquals(final Role role, final String name, final Responsibility actual) {
- assertEquals(role, actual.getRole());
- final Party p = getSingleton(actual.getParties());
+ private static Contact assertResponsibilityEquals(final Role role, final String name, final ResponsibleParty actual) {
+ assertEqualsIgnoreCase(role, actual.getRole());
+ final AbstractParty p = getSingleton(((DefaultResponsibleParty) actual).getParties());
assertEquals(name, String.valueOf(p.getName()));
return getSingleton(p.getContactInfo());
}
+
+ /**
+ * Asserts that two codes are equal, ignoring case and underscore. This method is used for comparing instances
+ * created by {@code valueOf(String)}, because it is difficult to guarantee that they have the expected case.
+ * It depends on the test order execution, because other tests create the same codes with different cases.
+ */
+ private static void assertEqualsIgnoreCase(CodeList<?> expected, CodeList<?> actual) {
+ assertEquals(expected.getClass(), actual.getClass());
+ assertTrue(expected.name().equalsIgnoreCase(actual.name().replace("_", "")));
+ }
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultContactTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultContactTest.java
index a358d61..8458e8b 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultContactTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultContactTest.java
@@ -28,8 +28,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.xml.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.TelephoneType;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -87,10 +87,10 @@
@SuppressWarnings("deprecation")
public void testSetPhones() {
init();
- final DefaultTelephone tel1 = new DefaultTelephone("00.01", TelephoneType.SMS);
- final DefaultTelephone tel2 = new DefaultTelephone("00.02", TelephoneType.VOICE);
- final DefaultTelephone tel3 = new DefaultTelephone("00.03", TelephoneType.FACSIMILE);
- final DefaultTelephone tel4 = new DefaultTelephone("00.04", TelephoneType.VOICE);
+ final DefaultTelephone tel1 = new DefaultTelephone("00.01", UnsupportedCodeList.valueOf("SMS"));
+ final DefaultTelephone tel2 = new DefaultTelephone("00.02", UnsupportedCodeList.VOICE);
+ final DefaultTelephone tel3 = new DefaultTelephone("00.03", UnsupportedCodeList.FACSIMILE);
+ final DefaultTelephone tel4 = new DefaultTelephone("00.04", UnsupportedCodeList.VOICE);
final DefaultTelephone[] tels = new DefaultTelephone[] {tel1, tel2, tel3, tel4};
final DefaultContact contact = new DefaultContact();
contact.setPhones(List.of(tel1, tel2, tel3, tel4));
@@ -101,7 +101,7 @@
*/
assertSame(tel2, contact.getPhone()); // Shall ignore the TelephoneType.SMS.
assertEquals("IgnoredPropertyAssociatedTo_1", resourceKey);
- assertArrayEquals(new String[] {"TelephoneType.SMS"}, parameters);
+ assertArrayEquals(new String[] {"SMS"}, parameters);
verifyLegacyLists(tels);
}
@@ -157,8 +157,6 @@
final Telephone view;
if (hideSIS) {
view = new Telephone() {
- @Override public String getNumber() {return tel.getNumber();}
- @Override public TelephoneType getNumberType() {return tel.getNumberType();}
@Override public Collection<String> getVoices() {return tel.getVoices();}
@Override public Collection<String> getFacsimiles() {return tel.getFacsimiles();}
};
@@ -173,9 +171,9 @@
contact.setPhone(view);
verifyLegacyLists(view);
assertArrayEquals(new DefaultTelephone[] {
- new DefaultTelephone("00.02", TelephoneType.VOICE),
- new DefaultTelephone("00.04", TelephoneType.VOICE),
- new DefaultTelephone("00.03", TelephoneType.FACSIMILE)
+ new DefaultTelephone("00.02", UnsupportedCodeList.VOICE),
+ new DefaultTelephone("00.04", UnsupportedCodeList.VOICE),
+ new DefaultTelephone("00.03", UnsupportedCodeList.FACSIMILE)
}, contact.getPhones().toArray());
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java
index 198f133..7023efc 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java
@@ -61,7 +61,7 @@
" <gco:CharacterString>An author</gco:CharacterString>\n" +
" </gmd:individualName>\n" +
" <gmd:role>\n" +
- " <gmd:CI_RoleCode codeList=\"http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode\" codeListValue=\"author\" codeSpace=\"eng\">Author</gmd:CI_RoleCode>\n" +
+ " <gmd:CI_RoleCode codeList=\"http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode\" codeListValue=\"author\">Author</gmd:CI_RoleCode>\n" +
" </gmd:role>\n" +
" </gmd:CI_ResponsibleParty>\n" +
" </gmd:citedResponsibleParty>\n" +
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
index ecd7f42..a39979e 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
@@ -71,7 +71,7 @@
}
/**
- * Tests (un)marshalling of a XML fragment containing the {@link Restriction#LICENCE} code.
+ * Tests (un)marshalling of a XML fragment containing the {@link Restriction#LICENSE} code.
* The spelling changed between ISO 19115:2003 and 19115:2014, from "license" to "licence".
* We need to ensure that XML marshalling use the old spelling, until the XML schema is updated.
*
@@ -84,16 +84,15 @@
" <mco:useConstraints>\n" +
" <mco:MD_RestrictionCode"
+ " codeList=\"" + ISO_NAMESPACE + "19115/resources/Codelist/cat/codelists.xml#MD_RestrictionCode\""
- + " codeListValue=\"licence\""
- + " codeSpace=\"eng\">Licence</mco:MD_RestrictionCode>\n" +
+ + " codeListValue=\"licence\">License</mco:MD_RestrictionCode>\n" +
" </mco:useConstraints>\n" +
"</mco:MD_LegalConstraints>\n";
final DefaultLegalConstraints c = new DefaultLegalConstraints();
- c.setUseConstraints(Set.of(Restriction.LICENCE));
+ c.setUseConstraints(Set.of(Restriction.LICENSE));
assertXmlEquals(xml, marshal(c), "xmlns:*");
DefaultLegalConstraints actual = unmarshal(DefaultLegalConstraints.class, xml);
- assertSame(Restriction.LICENCE, getSingleton(actual.getUseConstraints()));
+ assertSame(Restriction.LICENSE, getSingleton(actual.getUseConstraints()));
assertEquals(c, actual);
/*
* Above code tested ISO 19115-3 (un)marshalling. Code below test legacy ISO 19139:2007 (un)marshalling.
@@ -104,14 +103,13 @@
" <gmd:useConstraints>\n" +
" <gmd:MD_RestrictionCode"
+ " codeList=\"http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode\""
- + " codeListValue=\"license\"" // Note the "s" - from old ISO 19115:2013 spelling.
- + " codeSpace=\"eng\">Licence</gmd:MD_RestrictionCode>\n" + // Note the "c" - this one come from resource file.
+ + " codeListValue=\"license\">License</gmd:MD_RestrictionCode>\n" +
" </gmd:useConstraints>\n" +
"</gmd:MD_LegalConstraints>\n";
assertXmlEquals(xml, marshal(c, VERSION_2007), "xmlns:*");
actual = unmarshal(DefaultLegalConstraints.class, xml);
- assertSame(Restriction.LICENCE, getSingleton(actual.getUseConstraints()));
+ assertSame(Restriction.LICENSE, getSingleton(actual.getUseConstraints()));
assertEquals(c, actual);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/content/DefaultBandTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/content/DefaultBandTest.java
index 2191387..77d37d1 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/content/DefaultBandTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/content/DefaultBandTest.java
@@ -49,7 +49,7 @@
+ " </mrc:nominalSpatialResolution>\n"
+ " <mrc:detectedPolarisation>\n"
+ " <mrc:MI_PolarisationOrientationCode " // Spell with "s" in 2014 schema.
- + "codeList=\"" + ISO_NAMESPACE + "19115/resources/Codelist/cat/codelists.xml#MI_PolarisationOrientationCode\" codeListValue=\"vertical\">"
+ + "codeList=\"" + ISO_NAMESPACE + "19115/resources/Codelist/cat/codelists.xml#MI_PolarizationOrientationCode\" codeListValue=\"vertical\">"
+ "Vertical"
+ "</mrc:MI_PolarisationOrientationCode>\n"
+ " </mrc:detectedPolarisation>\n"
@@ -67,7 +67,7 @@
+ " </gmi:nominalSpatialResolution>\n"
+ " <gmi:detectedPolarisation>\n"
+ " <gmi:MI_PolarizationOrientationCode " // Spell with "z" in 2003 schema.
- + "codeList=\"http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MI_PolarisationOrientationCode\" codeListValue=\"vertical\">" +
+ + "codeList=\"http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MI_PolarizationOrientationCode\" codeListValue=\"vertical\">" +
"Vertical"
+ "</gmi:MI_PolarizationOrientationCode>\n"
+ " </gmi:detectedPolarisation>\n"
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/extent/ExtentsTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/extent/ExtentsTest.java
index 93928b1..708ee86 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/extent/ExtentsTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/extent/ExtentsTest.java
@@ -38,8 +38,8 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.mock.VerticalCRSMock;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
/**
@@ -85,7 +85,7 @@
Unit<?> unit = null;
for (final DefaultVerticalExtent e : extents) {
unit = e.getVerticalCRS().getCoordinateSystem().getAxis(0).getUnit();
- if (e.getVerticalCRS().getDatum().getRealizationMethod().orElse(null) == RealizationMethod.GEOID) break;
+ if (e.getVerticalCRS().getDatum().getVerticalDatumType() == VerticalDatumType.GEOIDAL) break;
}
final UnitConverter c = unit.getConverterToAny(Units.METRE);
/*
@@ -200,14 +200,14 @@
public static void testCentroid() {
final DefaultGeographicBoundingBox bbox = new DefaultGeographicBoundingBox(140, 160, 30, 50);
DirectPosition pos = Extents.centroid(bbox);
- assertEquals(150, pos.getCoordinate(0), "longitude");
- assertEquals( 40, pos.getCoordinate(1), "latitude");
+ assertEquals(150, pos.getOrdinate(0), "longitude");
+ assertEquals( 40, pos.getOrdinate(1), "latitude");
/*
* Test crossing anti-meridian.
*/
bbox.setEastBoundLongitude(-160);
pos = Extents.centroid(bbox);
- assertEquals(170, pos.getCoordinate(0), "longitude");
- assertEquals( 40, pos.getCoordinate(1), "latitude");
+ assertEquals(170, pos.getOrdinate(0), "longitude");
+ assertEquals( 40, pos.getOrdinate(1), "latitude");
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java
index 9f5fe35..a43a174 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java
@@ -30,9 +30,8 @@
import org.apache.sis.xml.bind.metadata.replace.ServiceParameterTest;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.OperationMetadata;
-import org.opengis.metadata.identification.DistributedComputingPlatform;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -51,7 +50,9 @@
* Creates the resource to use for testing purpose.
*/
static DefaultCoupledResource create(final NameFactory factory) {
- final var operation = new DefaultOperationMetadata("Get Map", DistributedComputingPlatform.WEB_SERVICES, null);
+ final var operation = new DefaultOperationMetadata();
+ operation.setOperationName("Get Map");
+ operation.setDistributedComputingPlatforms(Set.of(UnsupportedCodeList.valueOf("WEB_SERVICES")));
operation.setParameters(Set.of((ParameterDescriptor<?>) ServiceParameterTest.create()));
operation.setConnectPoints(Set.of(NilReason.MISSING.createNilObject(OnlineResource.class)));
@@ -67,7 +68,7 @@
@Test
public void testOperationNameResolve() {
final DefaultCoupledResource resource = create(DefaultNameFactory.provider());
- final OperationMetadata operation = resource.getOperation();
+ final DefaultOperationMetadata operation = resource.getOperation();
/*
* Test OperationName replacement when the name matches.
*/
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
index b460ced..334470c 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
@@ -32,13 +32,8 @@
import static org.apache.sis.metadata.Assertions.assertTitleEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.parameter.ParameterDirection;
-import org.opengis.metadata.identification.CouplingType;
-import org.opengis.metadata.identification.CoupledResource;
-import org.opengis.metadata.identification.OperationMetadata;
-import org.opengis.metadata.identification.ServiceIdentification;
-import org.opengis.metadata.identification.DistributedComputingPlatform;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -77,7 +72,7 @@
"A dummy service for testing purpose."); // abstract
id.setServiceTypeVersions(Set.of("1.0"));
id.setCoupledResources(Set.of(resource));
- id.setCouplingType(CouplingType.LOOSE);
+ id.setCouplingType(UnsupportedCodeList.valueOf("LOOSE"));
id.setContainsOperations(Set.of(resource.getOperation()));
return id;
}
@@ -86,28 +81,27 @@
* Compare values of the given service identifications against the value expected for the
* instance created by {@link #create()} method.
*/
- private static void verify(final ServiceIdentification id) {
+ private static void verify(final DefaultServiceIdentification id) {
assertEquals("1.0", getSingleton(id.getServiceTypeVersions()));
assertEquals("Web Map Server", String.valueOf(id.getServiceType()));
assertEquals("A dummy service for testing purpose.", String.valueOf(id.getAbstract()));
assertEquals(NilReason.MISSING, NilReason.forObject(id.getCitation()));
- assertEquals(CouplingType.LOOSE, id.getCouplingType());
+ assertEquals(UnsupportedCodeList.valueOf("loose"), id.getCouplingType());
- final CoupledResource resource = getSingleton(id.getCoupledResources());
+ final DefaultCoupledResource resource = getSingleton(id.getCoupledResources());
// assertEquals("scopedName", "mySpace:ABC-123", …) skipped because not present in new ISO 19115-3:2016.
// assertEquals("resourceReference", "WMS specification", …) skipped because not present in legacy ISO 19139:2007.
- final OperationMetadata op = resource.getOperation();
+ final DefaultOperationMetadata op = resource.getOperation();
assertNotNull(op);
assertEquals("Get Map", op.getOperationName());
- assertEquals(DistributedComputingPlatform.WEB_SERVICES, getSingleton(op.getDistributedComputingPlatforms()));
+ assertEquals(UnsupportedCodeList.valueOf("WEB_SERVICES"), getSingleton(op.getDistributedComputingPlatforms()));
assertEquals(NilReason.MISSING, NilReason.forObject(getSingleton(op.getConnectPoints())));
final ParameterDescriptor<?> param = getSingleton(op.getParameters());
assertEquals("My service parameter", String.valueOf(param.getName()));
assertEquals(0, param.getMinimumOccurs());
assertEquals(1, param.getMaximumOccurs());
- assertEquals(ParameterDirection.IN, param.getDirection());
}
/**
@@ -117,9 +111,9 @@
*/
@Test
public void testUnmarshal() throws JAXBException {
- final ServiceIdentification id = unmarshalFile(ServiceIdentification.class, openTestFile(Format.XML2016));
+ final DefaultServiceIdentification id = unmarshalFile(DefaultServiceIdentification.class, openTestFile(Format.XML2016));
verify(id);
- final CoupledResource resource = getSingleton(id.getCoupledResources());
+ final DefaultCoupledResource resource = getSingleton(id.getCoupledResources());
assertTitleEquals("WMS specification", getSingleton(resource.getResourceReferences()), "resourceReference");
}
@@ -130,9 +124,9 @@
*/
@Test
public void testUnmarshalLegacy() throws JAXBException {
- final ServiceIdentification id = unmarshalFile(ServiceIdentification.class, openTestFile(Format.XML2007));
+ final DefaultServiceIdentification id = unmarshalFile(DefaultServiceIdentification.class, openTestFile(Format.XML2007));
verify(id);
- final CoupledResource resource = getSingleton(id.getCoupledResources());
+ final DefaultCoupledResource resource = getSingleton(id.getCoupledResources());
assertEquals("mySpace:ABC-123", String.valueOf(resource.getScopedName()));
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
index 84cc4bf..171f41c 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
@@ -148,8 +148,8 @@
final QuantitativeResult pResult = (QuantitativeResult) TestUtilities.getSingleton(programmatic.getResults());
final RecordType uType = uResult.getValueType();
final RecordType pType = pResult.getValueType();
- final Map<MemberName,Type> uFields = uType.getFieldTypes();
- final Map<MemberName,Type> pFields = pType.getFieldTypes();
+ final Map<MemberName,Type> uFields = uType.getMemberTypes();
+ final Map<MemberName,Type> pFields = pType.getMemberTypes();
final Iterator<MemberName> uIter = uFields.keySet().iterator();
final Iterator<MemberName> pIter = pFields.keySet().iterator();
assertEquals(uFields.size(), pFields.size());
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
index 0ce6406..85f7db7 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
@@ -25,8 +25,8 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.maintenance.Scope;
+// Specific to the main branch:
+import org.opengis.metadata.quality.Scope;
/**
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/IdentifiersTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/IdentifiersTest.java
index 0a2c00c..2fe41a3 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/IdentifiersTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/IdentifiersTest.java
@@ -28,6 +28,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Tests {@link Identifiers}.
@@ -54,8 +57,15 @@
/**
* Creates an identifier with a code space.
*/
- private static Identifier identifier(final String codeSpace, final String code) {
- return new DefaultIdentifier(codeSpace, code, null);
+ private static ReferenceIdentifier identifier(final String codeSpace, final String code) {
+ return new Id(codeSpace, code);
+ }
+
+ @SuppressWarnings("serial")
+ private static final class Id extends DefaultIdentifier implements ReferenceIdentifier {
+ Id(String codeSpace, String code) {
+ super(codeSpace, code, null);
+ }
}
/**
@@ -63,8 +73,8 @@
*/
@Test
public void testHasCommonIdentifier() {
- final List<Identifier> id1 = new ArrayList<>(3);
- final List<Identifier> id2 = new ArrayList<>(2);
+ final List<ReferenceIdentifier> id1 = new ArrayList<>(3);
+ final List<ReferenceIdentifier> id2 = new ArrayList<>(2);
assertNull(Identifiers.hasCommonIdentifier(id1, id2));
/*
* Add codes for two Operation Methods which are implemented in Apache SIS by the same class:
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/MergerTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/MergerTest.java
index 9320f39..80c3a43 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/MergerTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/privy/MergerTest.java
@@ -40,9 +40,6 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSetEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.CoverageDescription;
-
/**
* Tests the {@link Merger} class.
@@ -117,7 +114,7 @@
final Iterator<ContentInformation> it = target.getContentInfo().iterator();
final ImageDescription image = (ImageDescription) it.next();
final FeatureCatalogueDescription features = (FeatureCatalogueDescription) it.next();
- final CoverageDescription coverage = (CoverageDescription) it.next();
+ final DefaultCoverageDescription coverage = (DefaultCoverageDescription) it.next();
assertFalse(it.hasNext());
assertEquals(ImagingCondition.CLOUD, image .getImagingCondition());
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
index 6ff30f8..4936361 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
@@ -30,9 +30,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
/**
@@ -122,22 +121,22 @@
assertNull(actualID, name);
} else if (actualID != null) {
assertEquals(expectedID.getCode(), actualID.getCode(), name);
- assertEquals(expectedID.getCodeSpace(), actualID.getCodeSpace(), name);
- assertEquals(expectedID.getVersion(), actualID.getVersion(), name);
+// assertEquals(expectedID.getCodeSpace(), actualID.getCodeSpace(), name);
+// assertEquals(expectedID.getVersion(), actualID.getVersion(), name);
}
/*
* The fallback may not declare all responsible parties.
* If it declares a party, the name and role shall be equal.
*/
- final Responsibility expectedResp = first(fromDB.getCitedResponsibleParties());
- final Responsibility actualResp = first(fromFB.getCitedResponsibleParties());
+ final ResponsibleParty expectedResp = first(fromDB.getCitedResponsibleParties());
+ final ResponsibleParty actualResp = first(fromFB.getCitedResponsibleParties());
if (expectedResp == null) {
assertNull(actualResp, name);
} else if (actualResp != null) {
assertEquals(expectedResp.getRole(), actualResp.getRole(), name);
- final Party expectedParty = first(expectedResp.getParties());
- final Party actualParty = first(actualResp.getParties());
- assertEquals(expectedParty.getName(), actualParty.getName(), name);
+// final Party expectedParty = first(expectedResp.getParties());
+// final Party actualParty = first(actualResp.getParties());
+// assertEquals(expectedParty.getName(), actualParty.getName(), name);
}
assertEquals(first(fromDB.getPresentationForms()),
first(fromFB.getPresentationForms()), name);
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
index dd4ad99..8a6e143 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
@@ -34,9 +34,6 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.test.TestStep;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.apache.sis.test.TestUtilities.getSingleton;
-
/**
* Tests {@link MetadataSource}.
@@ -116,10 +113,8 @@
* @param title the expected format title.
*/
private static void verify(final Format format, final String abbreviation, final String title) {
- final Citation spec = format.getFormatSpecificationCitation();
- assertNotNull(spec, "formatSpecificationCitation");
- assertEquals(abbreviation, String.valueOf(getSingleton(spec.getAlternateTitles())), "abbreviation");
- assertEquals(title, String.valueOf(spec.getTitle()), "title");
+ assertEquals(abbreviation, String.valueOf(format.getName()), "abbreviation");
+ assertEquals(title, String.valueOf(format.getSpecification()), "title");
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
index b92e56f..d05dda5 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
@@ -34,11 +34,8 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Contact;
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
-import org.apache.sis.util.privy.URLs;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
/**
@@ -86,6 +83,7 @@
*/
@Test
@ResourceLock(TestDatabase.POSTGRESQL)
+ @org.junit.jupiter.api.Disabled("Requires GeoAPI 3.1.")
public void testPostgreSQL() throws Exception {
try (final TestDatabase db = TestDatabase.createOnPostgreSQL("MetadataWriter", true)) {
source = new MetadataWriter(MetadataStandard.ISO_19115, db.source, "MetadataWriter", null);
@@ -122,7 +120,7 @@
assertEquals("EPSG", source.search(HardCodedCitations.EPSG));
assertEquals("SIS", source.search(HardCodedCitations.SIS));
assertNull ( source.search(HardCodedCitations.ISO_19111));
- assertEquals("{rp}EPSG", source.search(TestUtilities.getSingleton(
+ assertEquals("EPSG", source.search(TestUtilities.getSingleton(
HardCodedCitations.EPSG.getCitedResponsibleParties())));
}
@@ -154,21 +152,13 @@
/*
* Ask for dependencies that are known to exist.
*/
- final Responsibility responsible = TestUtilities.getSingleton(c.getCitedResponsibleParties());
+ final ResponsibleParty responsible = TestUtilities.getSingleton(c.getCitedResponsibleParties());
assertEquals(Role.PRINCIPAL_INVESTIGATOR, responsible.getRole());
- final Party party = TestUtilities.getSingleton(responsible.getParties());
- assertEquals("International Association of Oil & Gas Producers", party.getName().toString());
- final Contact contact = TestUtilities.getSingleton(party.getContactInfo());
- /*
- * Invoke the deprecated `getOnlineResource()` method (singular form) before the non-deprecated
- * `getOnlineResources()` (plural form) replacement. They shall give the same result no matter
- * which form were stored in the database.
- */
- @SuppressWarnings("deprecation")
- final OnlineResource resource = contact.getOnlineResource();
- assertSame(resource, TestUtilities.getSingleton(contact.getOnlineResources()));
- assertEquals(URLs.EPSG, resource.getLinkage().toString());
+ assertEquals("International Association of Oil & Gas Producers", responsible.getOrganisationName().toString());
+
+ OnlineResource resource = responsible.getContactInfo().getOnlineResource();
+ assertEquals("https://epsg.org/", resource.getLinkage().toString());
assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
/*
* Ask columns that are known to not exist.
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2007/ServiceIdentification.xml b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2007/ServiceIdentification.xml
index 172a10d..a06c614 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2007/ServiceIdentification.xml
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2007/ServiceIdentification.xml
@@ -76,9 +76,6 @@
</gco:TypeName>
</gco:attributeType>
</srv:name>
- <srv:direction>
- <srv:SV_ParameterDirection>in</srv:SV_ParameterDirection>
- </srv:direction>
<srv:optionality>
<gco:CharacterString>Optional</gco:CharacterString>
</srv:optionality>
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2016/ServiceIdentification.xml b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2016/ServiceIdentification.xml
index ce54e7b..35b359f 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2016/ServiceIdentification.xml
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/2016/ServiceIdentification.xml
@@ -41,7 +41,7 @@
</srv:serviceTypeVersion>
<srv:couplingType>
- <srv:SV_CouplingType codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#SV_CouplingType" codeListValue="loose" codeSpace="eng">Loose</srv:SV_CouplingType>
+ <srv:SV_CouplingType codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#SV_CouplingType" codeListValue="loose">Loose</srv:SV_CouplingType>
</srv:couplingType>
<srv:coupledResource>
@@ -62,7 +62,7 @@
<gco:CharacterString>Get Map</gco:CharacterString>
</srv:operationName>
<srv:distributedComputingPlatform>
- <srv:DCPList codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DCPList" codeListValue="WebServices" codeSpace="eng">Web services</srv:DCPList>
+ <srv:DCPList codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DCPList" codeListValue="WebServices">Web services</srv:DCPList>
</srv:distributedComputingPlatform>
<srv:connectPoint gco:nilReason="missing"/>
<srv:parameter>
@@ -81,9 +81,6 @@
</gco:attributeType>
</gco:MemberName>
</srv:name>
- <srv:direction>
- <srv:SV_ParameterDirection>in</srv:SV_ParameterDirection>
- </srv:direction>
<srv:optionality>
<gco:Boolean>true</gco:Boolean>
</srv:optionality>
@@ -103,7 +100,7 @@
<gco:CharacterString>Get Map</gco:CharacterString>
</srv:operationName>
<srv:distributedComputingPlatform>
- <srv:DCPList codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DCPList" codeListValue="WebServices" codeSpace="eng">Web services</srv:DCPList>
+ <srv:DCPList codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DCPList" codeListValue="WebServices">Web services</srv:DCPList>
</srv:distributedComputingPlatform>
<srv:connectPoint gco:nilReason="missing"/>
<srv:parameter>
@@ -122,9 +119,6 @@
</gco:attributeType>
</gco:MemberName>
</srv:name>
- <srv:direction>
- <srv:SV_ParameterDirection>in</srv:SV_ParameterDirection>
- </srv:direction>
<srv:optionality>
<gco:Boolean>true</gco:Boolean>
</srv:optionality>
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
deleted file mode 100644
index ae14e73..0000000
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.metadata.xml;
-
-import java.nio.file.Path;
-import java.nio.file.Files;
-import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.system.DataDirectory;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assumptions.*;
-import org.apache.sis.test.TestCase;
-import org.apache.sis.test.ProjectDirectories;
-import org.apache.sis.xml.test.SchemaCompliance;
-
-
-/**
- * Tests conformance of JAXB annotations with XML schemas if those schemas are available.
- * This tests requires the {@code $SIS_DATA/Schemas/iso/19115/-3} directory to exists.
- * Those files must be installed manually; they are not distributed with Apache SIS for licensing reasons.
- * Content can be downloaded as ZIP files from <a href="https://schemas.isotc211.org/19115/">ISO portal</a>.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class SchemaComplianceTest extends TestCase {
- /**
- * Creates a new test case.
- */
- public SchemaComplianceTest() {
- }
-
- /**
- * Verifies compliance with metadata schemas.
- *
- * @throws Exception if an error occurred while checking the schema.
- *
- * @see <a href="https://schemas.isotc211.org/19115/">ISO schemas for metadata</a>
- */
- @Test
- public void verifyMetadata() throws Exception {
- Path directory = DataDirectory.SCHEMAS.getDirectory();
- assumeTrue(directory != null, "Schema directory is not specified.");
- directory = directory.resolve("iso");
- assumeTrue(Files.isDirectory(directory.resolve("19115")));
- /*
- * Locate the root of metadata class directory. In a Maven build:
- * "core/sis-metadata/target/classes/org/apache/sis/metadata/iso"
- */
- final ProjectDirectories dir = new ProjectDirectories(ISOMetadata.class);
- final SchemaCompliance checker = new SchemaCompliance(dir.classesRootDirectory, directory);
- checker.loadDefaultSchemas();
- checker.verify(dir.classesPackageDirectory);
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultInstantTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultInstantTest.java
index 9767aca..955a151 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultInstantTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultInstantTest.java
@@ -30,10 +30,10 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.IndeterminateValue;
-import org.opengis.temporal.IndeterminatePositionException;
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import java.time.DateTimeException;
+import org.apache.sis.pending.geoapi.temporal.IndeterminateValue;
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -139,7 +139,7 @@
* @param c the comparison to perform.
*/
private static void assertIndeterminate(final Executable c) {
- assertNotNull(assertThrows(IndeterminatePositionException.class, c).getMessage());
+ assertNotNull(assertThrows(DateTimeException.class, c).getMessage());
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultPeriodTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultPeriodTest.java
index a51a608..b519510 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultPeriodTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/temporal/DefaultPeriodTest.java
@@ -26,8 +26,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.TemporalOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.temporal.TemporalOperatorName;
/**
@@ -122,7 +122,8 @@
* @param other the period against which {@code self} is compared.
*/
private static void assertRelativePositionEquals(TemporalOperatorName expected,
- org.opengis.temporal.Period self, org.opengis.temporal.Period other)
+ org.apache.sis.pending.geoapi.temporal.Period self,
+ org.apache.sis.pending.geoapi.temporal.Period other)
{
assertEquals(expected, self.findRelativePosition(other));
assertEquals(expected.reversed().orElseThrow(), other.findRelativePosition(self));
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/CoordinateSystemAxisMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/CoordinateSystemAxisMock.java
index 9c28157..8b06962 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/CoordinateSystemAxisMock.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/CoordinateSystemAxisMock.java
@@ -61,6 +61,8 @@
@Override public int getDimension() {return 1;}
@Override public CoordinateSystemAxis getAxis(int dimension) {return this;}
@Override public AxisDirection getDirection() {return null;}
+ @Override public double getMinimumValue() {return Double.NEGATIVE_INFINITY;}
+ @Override public double getMaximumValue() {return Double.POSITIVE_INFINITY;}
@Override public RangeMeaning getRangeMeaning() {return RangeMeaning.EXACT;}
@Override public Unit<?> getUnit() {return null;}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/GeographicCRSMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/GeographicCRSMock.java
index 7a3e43e..c2a0594 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/GeographicCRSMock.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/GeographicCRSMock.java
@@ -29,11 +29,11 @@
@XmlType(name = "GeodeticCRSType", propOrder = {
"coordinateSystem",
"datum",
- "datumEnsemble",
"name",
"alias",
"identifiers",
- "domains",
+ "scope",
+ "domainOfValidity",
"remarks"
})
public abstract class GeographicCRSMock implements GeographicCRS {
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/IdentifiedObjectMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/IdentifiedObjectMock.java
index 9721162..ed3bdd8 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/IdentifiedObjectMock.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/IdentifiedObjectMock.java
@@ -31,6 +31,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
+// Specific to the main branch:
+import java.util.Set;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Citation;
+
/**
* A dummy implementation of {@link IdentifiedObject} with minimal XML (un)marshalling capability.
@@ -124,6 +129,26 @@
}
/**
+ * Returns the namespace version ({@code null} for now).
+ *
+ * @return the namespace version.
+ */
+ @Override
+ public final String getVersion() {
+ return null;
+ }
+
+ /**
+ * Returns the authority that define the object ({@code null} for now).
+ *
+ * @return the defining authority.
+ */
+ @Override
+ public final Citation getAuthority() {
+ return null;
+ }
+
+ /**
* Returns {@link #alias} in an unmodifiable collection, or an empty collection if the alias is null.
*
* @return {@link #alias} singleton or an empty collection.
@@ -134,6 +159,37 @@
}
/**
+ * Returns the identifiers (currently null).
+ *
+ * @return the identifiers of this object.
+ */
+ @Override
+ public final Set<ReferenceIdentifier> getIdentifiers() {
+ return null;
+ }
+
+ /**
+ * Returns the remarks (currently null).
+ *
+ * @return the remarks associated to this object.
+ */
+ @Override
+ public final InternationalString getRemarks() {
+ return null;
+ }
+
+ /**
+ * Returns the WKT representation (currently none).
+ *
+ * @return the WKT representation of this object.
+ * @throws UnsupportedOperationException if there is no WKT representation.
+ */
+ @Override
+ public final String toWKT() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Returns a string representation for debugging purpose.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/MetadataMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/MetadataMock.java
index b6584fe..345856d 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/MetadataMock.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/MetadataMock.java
@@ -16,9 +16,9 @@
*/
package org.apache.sis.test.mock;
+import java.util.Locale;
import java.util.Set;
import java.util.Collection;
-import java.util.Locale;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -27,11 +27,6 @@
import org.apache.sis.xml.bind.lan.LocaleAdapter;
import org.apache.sis.metadata.simple.SimpleMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Map;
-import java.util.Collections;
-import java.nio.charset.Charset;
-
/**
* A dummy implementation of {@link org.opengis.metadata.Metadata} with minimal XML (un)marshalling capability.
@@ -69,22 +64,11 @@
}
/**
- * Returns {@link #language} in a singleton map or an empty map.
- *
- * @return {@link #language}
- */
- @Override
- public Map<Locale,Charset> getLocalesAndCharsets() {
- return (language != null) ? Collections.singletonMap(language, null) : Collections.emptyMap();
- }
-
- /**
* Returns {@link #language} in a singleton set or an empty set.
*
* @return {@link #language}
*/
@Override
- @Deprecated
public Collection<Locale> getLanguages() {
return (language != null) ? Set.of(language) : Set.of();
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java
index 2ad61c5..e2bf9fc 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java
@@ -29,9 +29,9 @@
import org.opengis.metadata.extent.Extent;
import org.opengis.util.InternationalString;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import java.util.Date;
+import org.opengis.referencing.datum.VerticalDatumType;
/**
@@ -39,7 +39,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-@SuppressWarnings({"serial", "deprecation"})
+@SuppressWarnings("serial")
public final class VerticalCRSMock extends IdentifiedObjectMock
implements VerticalCRS, VerticalDatum, VerticalCS, CoordinateSystemAxis
{
@@ -47,36 +47,36 @@
* Height in metres.
*/
public static final VerticalCRS HEIGHT = new VerticalCRSMock("Height",
- RealizationMethod.GEOID, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.METRE, true);
+ VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.METRE, true);
/**
* Height in feet.
*/
public static final VerticalCRS HEIGHT_ft = new VerticalCRSMock("Height",
- RealizationMethod.GEOID, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.FOOT, true);
+ VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.FOOT, true);
/**
* Height estimated from hPa.
*/
public static final VerticalCRS BAROMETRIC_HEIGHT = new VerticalCRSMock("Barometric height",
- RealizationMethod.LEVELLING, 0, Double.POSITIVE_INFINITY, Units.HECTOPASCAL, true);
+ VerticalDatumType.BAROMETRIC, 0, Double.POSITIVE_INFINITY, Units.HECTOPASCAL, true);
/**
* Depth in metres.
*/
public static final VerticalCRS DEPTH = new VerticalCRSMock("Depth",
- RealizationMethod.TIDAL, 0, Double.POSITIVE_INFINITY, Units.METRE, false);
+ VerticalDatumType.DEPTH, 0, Double.POSITIVE_INFINITY, Units.METRE, false);
/**
* Depth as a fraction of the sea floor depth at the location of the point for which the depth is evaluated.
*/
public static final VerticalCRS SIGMA_LEVEL = new VerticalCRSMock("Sigma level",
- null, 0, 1, Units.UNITY, false);
+ VerticalDatumType.OTHER_SURFACE, 0, 1, Units.UNITY, false);
/**
- * The realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified.
+ * The datum type (geoidal, barometric, etc.).
*/
- private final RealizationMethod method;
+ private final VerticalDatumType type;
/**
* The minimum and maximum values.
@@ -97,17 +97,16 @@
* Creates a new vertical CRS for the given name.
*
* @param name the CRS, CS, datum and axis name.
- * @param method the realization method (geoid, tidal, <i>etc.</i>).
* @param minimumValue the minium value.
* @param maximumValue the maximum value.
* @param unit the unit of measurement.
* @param up {@code true} if the axis direction is up, or {@code false} if down.
*/
- private VerticalCRSMock(final String name, final RealizationMethod method,
+ private VerticalCRSMock(final String name, VerticalDatumType type,
final double minimumValue, final double maximumValue, final Unit<?> unit, final boolean up)
{
super(name);
- this.method = method;
+ this.type = type;
this.minimumValue = minimumValue;
this.maximumValue = maximumValue;
this.unit = unit;
@@ -124,8 +123,10 @@
@Override public String getAbbreviation() {return up ? "h" : "d";}
@Override public InternationalString getScope() {return null;}
+ @Override public InternationalString getAnchorPoint() {return null;}
+ @Override public Date getRealizationEpoch() {return null;}
@Override public Extent getDomainOfValidity() {return null;}
- @Override public Optional<RealizationMethod> getRealizationMethod() {return Optional.ofNullable(method);}
+ @Override public VerticalDatumType getVerticalDatumType() {return type;}
@Override public VerticalDatum getDatum() {return this;}
@Override public VerticalCS getCoordinateSystem() {return this;}
@Override public int getDimension() {return 1;}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/DefaultRecordSchemaTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
index 0a61396..966e38c 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
@@ -45,7 +45,7 @@
* Tests {@link DefaultRecordSchema#createRecordType(CharSequence, Map)}.
*/
@Test
- @SuppressWarnings({"deprecation", "removal"})
+ @SuppressWarnings("removal")
public void testCreateRecordType() {
final var schema = new DefaultRecordSchema(null, null, "MySchema");
final var fields = new LinkedHashMap<CharSequence,Class<?>>(8);
@@ -60,7 +60,7 @@
assertSame(schema, recordType.getContainer());
assertEquals(Names.createTypeName("MySchema", ":", "MyRecordType"), recordType.getTypeName());
int count = 0;
- for (final Map.Entry<MemberName,Type> entry : recordType.getFieldTypes().entrySet()) {
+ for (final Map.Entry<MemberName,Type> entry : recordType.getMemberTypes().entrySet()) {
final String expectedName;
final String expectedType;
final Class<?> expectedClass;
@@ -106,7 +106,7 @@
final var copy = new DefaultRecordType(
recordType.getTypeName(),
recordType.getContainer(),
- recordType.getFieldTypes());
+ recordType.getMemberTypes());
assertEquals(recordType, copy);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypeNamesTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypeNamesTest.java
index 47be06b..7420eb3 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypeNamesTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypeNamesTest.java
@@ -58,7 +58,7 @@
final DefaultNameFactory factory = DefaultNameFactory.provider();
final TypeName type = factory.toTypeName(valueClass);
assertNotNull(type, name);
- assertSame (valueClass, type.toJavaType().get(), name);
+ assertSame (valueClass, ((DefaultTypeName) type).toJavaType().get(), name);
assertEquals (namespace, type.scope().name().toString(), name);
assertEquals (name, type.toString(), name);
assertEquals (valueClass, TypeNames.toClass(namespace, name), name);
@@ -111,7 +111,7 @@
public void testMetadataClasses() throws ClassNotFoundException {
verifyLookup(OGC, "Geometry", Geometry.class);
verifyLookup(OGC, "MD_Metadata", Metadata.class);
- verifyLookup(OGC, "CRS", CoordinateReferenceSystem.class);
+ verifyLookup(OGC, "SC_CRS", CoordinateReferenceSystem.class);
}
/**
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
index a59e6e0..fea409d 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
@@ -38,9 +38,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.constraint.Restriction;
-import org.opengis.parameter.ParameterDirection;
+// Specific to the main branch:
+import org.opengis.referencing.datum.PixelInCell;
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
/**
@@ -98,9 +98,9 @@
*/
@Test
public void testGetStandardName() {
- assertEquals("CI_Citation", Types.getStandardName(Citation .class));
- assertEquals("Datum", Types.getStandardName(Datum .class));
- assertEquals("AxisDirection", Types.getStandardName(AxisDirection.class));
+ assertEquals("CI_Citation", Types.getStandardName(Citation .class));
+ assertEquals("CD_Datum", Types.getStandardName(Datum .class));
+ assertEquals("CS_AxisDirection", Types.getStandardName(AxisDirection.class));
}
/**
@@ -109,16 +109,16 @@
@Test
public void testForStandardName() {
assertEquals(Citation .class, Types.forStandardName("CI_Citation"));
- assertEquals(Datum .class, Types.forStandardName("Datum"));
+ assertEquals(Datum .class, Types.forStandardName("CD_Datum"));
assertEquals(Citation .class, Types.forStandardName("CI_Citation")); // Value should be cached.
assertEquals(Citation .class, Types.forStandardName("Citation"));
- assertEquals(AxisDirection.class, Types.forStandardName("AxisDirection"));
+ assertEquals(AxisDirection.class, Types.forStandardName("CS_AxisDirection"));
assertNull ( Types.forStandardName("MD_Dummy"));
}
/**
* Tests the {@link Types#forEnumName(Class, String)} method with an enumeration from the JDK.
- * Such enumerations do not implement the {@link org.opengis.util.ControlledVocabulary} interface.
+ * Such enumerations do not implement the {@code org.opengis.util.ControlledVocabulary} interface.
*/
@Test
public void testForStandardEnumName() {
@@ -130,19 +130,6 @@
}
/**
- * Tests the {@link Types#forEnumName(Class, String)} method with an enumeration from GeoAPI.
- * Such enumerations implement the {@link org.opengis.util.ControlledVocabulary} interface.
- */
- @Test
- public void testForGeoapiEnumName() {
- assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "IN_OUT"));
- assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "INOUT"));
- assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "in out"));
- assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "in/out"));
- assertNull(Types.forEnumName(ParameterDirection.class, "out/in"));
- }
-
- /**
* Tests the {@link Types#forCodeName(Class, String, boolean)} method.
*/
@Test
@@ -153,8 +140,10 @@
assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "semi-darkness", null));
assertNull(Types.forCodeName(ImagingCondition.class, "darkness", null));
- assertSame(Restriction.LICENCE, Types.forCodeName(Restriction.class, "licence", null));
- assertSame(Restriction.LICENCE, Types.forCodeName(Restriction.class, "license", null));
+ assertSame(PixelInCell.CELL_CORNER, Types.forCodeName(PixelInCell.class, "cell corner", null));
+ assertSame(PixelInCell.CELL_CORNER, Types.forCodeName(PixelInCell.class, "cellCorner", null));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell center", null));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCenter", null));
}
/**
@@ -183,7 +172,7 @@
}
/**
- * Tests the {@link Types#getDescription(ControlledVocabulary)} method.
+ * Tests the {@code Types.getDescription(ControlledVocabulary)} method.
*/
@Test
public void testGetCodeDescription() {
@@ -192,34 +181,32 @@
description.toString(Locale.ROOT));
assertEquals("Online instructions for transferring data from one storage device or system to another.",
description.toString(Locale.ENGLISH));
- assertEquals("Transfert de la ressource d’un système à un autre.",
+ assertEquals("Transfert de la ressource d'un système à un autre.",
description.toString(Locale.FRENCH));
}
/**
- * Tests the examples given in {@link Types#getListName(ControlledVocabulary)} javadoc.
+ * Tests the examples given in {@code Types.getListName(ControlledVocabulary)} javadoc.
*/
@Test
public void testGetListName() {
- assertEquals("SV_ParameterDirection", Types.getListName(ParameterDirection.IN_OUT));
- assertEquals("AxisDirection", Types.getListName(AxisDirection .NORTH));
+ assertEquals("CS_AxisDirection", Types.getListName(AxisDirection .NORTH));
assertEquals("CI_OnLineFunctionCode", Types.getListName(OnLineFunction .DOWNLOAD));
assertEquals("MD_ImagingConditionCode", Types.getListName(ImagingCondition .BLURRED_IMAGE));
}
/**
- * Tests the examples given in {@link Types#getCodeName(ControlledVocabulary)} javadoc.
+ * Tests the examples given in {@code Types.getCodeName(ControlledVocabulary)} javadoc.
*/
@Test
public void testGetCodeName() {
- assertEquals("in/out", Types.getCodeName(ParameterDirection.IN_OUT));
assertEquals("north", Types.getCodeName(AxisDirection .NORTH));
assertEquals("download", Types.getCodeName(OnLineFunction .DOWNLOAD));
assertEquals("blurredImage", Types.getCodeName(ImagingCondition .BLURRED_IMAGE));
}
/**
- * Tests the examples given in {@link Types#getCodeLabel(ControlledVocabulary)} javadoc.
+ * Tests the examples given in {@code Types.getCodeLabel(ControlledVocabulary)} javadoc.
*/
@Test
public void testGetCodeLabel() {
@@ -229,7 +216,7 @@
}
/**
- * Tests {@link Types#getCodeTitle(ControlledVocabulary)}.
+ * Tests {@code Types.getCodeTitle(ControlledVocabulary)}.
* Also opportunistically tests {@link Types#forCodeTitle(CharSequence)}.
*/
@Test
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/CharSequenceSubstitutionTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/CharSequenceSubstitutionTest.java
index a77ca6c..887eb34 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/CharSequenceSubstitutionTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/CharSequenceSubstitutionTest.java
@@ -33,8 +33,9 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
/**
@@ -77,7 +78,7 @@
"</gmd:MD_ReferenceSystem>";
final ReferenceSystemMetadata md = unmarshal(ReferenceSystemMetadata.class, expected);
- final Identifier id = md.getName();
+ final ReferenceIdentifier id = md.getName();
assertEquals("L101", id.getCodeSpace(), "codespace");
assertEquals("EPSG:4326", id.getCode(), "code");
}
@@ -103,7 +104,7 @@
" </mcc:codeSpace>\n" +
"</mcc:MD_Identifier>";
- final Identifier id = unmarshal(Identifier.class, expected);
+ final DefaultIdentifier id = unmarshal(DefaultIdentifier.class, expected);
assertEquals("L101", id.getCodeSpace(), "codespace");
assertEquals("EPSG:4326", id.getCode(), "code");
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/NilReasonTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/NilReasonTest.java
index 6ad32a7..21bf2f2 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/NilReasonTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/NilReasonTest.java
@@ -29,8 +29,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
/**
@@ -221,7 +221,7 @@
assertTrue (c.equals(e2, ComparisonMode.DEBUG));
// Following object should alway be different because it does not implement the same interface.
- final Responsibility r1 = NilReason.TEMPLATE.createNilObject(Responsibility.class);
+ final ResponsibleParty r1 = NilReason.TEMPLATE.createNilObject(ResponsibleParty.class);
assertFalse(c.equals(r1, ComparisonMode.STRICT));
assertFalse(c.equals(r1, ComparisonMode.BY_CONTRACT));
assertFalse(c.equals(r1, ComparisonMode.IGNORE_METADATA));
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/ReferenceResolverTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/ReferenceResolverTest.java
index 8fa5713..b1f8bd1 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/ReferenceResolverTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/ReferenceResolverTest.java
@@ -56,11 +56,11 @@
/*
* The fragment should reference the exact same object as the one in the citation.
*/
- final var parent = getSingleton(citation.getCitedResponsibleParties().iterator().next().getParties());
- final var reusing = getSingleton(getSingleton(data.getPointOfContacts()).getParties());
- assertEquals("Little John", reusing.getName().toString());
- assertSame(getSingleton(parent .getContactInfo()),
- getSingleton(reusing.getContactInfo()));
+ final var parent = citation.getCitedResponsibleParties().iterator().next();
+ final var reusing = getSingleton(data.getPointOfContacts());
+ assertEquals("Little John", reusing.getIndividualName());
+ assertSame(parent .getContactInfo(),
+ reusing.getContactInfo());
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/RenameListGenerator.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/RenameListGenerator.java
deleted file mode 100644
index f5327f5..0000000
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/RenameListGenerator.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.xml;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Files;
-import java.nio.file.DirectoryStream;
-import java.nio.file.DirectoryIteratorException;
-import java.lang.reflect.Method;
-import jakarta.xml.bind.annotation.XmlSchema;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlRootElement;
-import org.opengis.geoapi.schema.SchemaException;
-import org.apache.sis.xml.privy.LegacyNamespaces;
-
-
-/**
- * Creates a file in the {@value TransformingReader#FILENAME} format.
- * {@code RenameListGenerator} can be executed if ISO 19115 standards have changed.
- * The format is described in the {@code readme.html} page in source code directory.
- * Output format contains namespaces first, then classes, then properties. Example:
- *
- * <pre class="text">
- * http://standards.iso.org/iso/19115/-3/cit/1.0
- * CI_Address
- * administrativeArea
- * city
- * CI_Citation
- * citedResponsibleParty</pre>
- *
- * This class can be used as a starting point for generating a new file from scratch.
- * It should not be used for updating the existing file (unless a lot of things have changed)
- * because some of {@value TransformingReader#FILENAME} content have been edited by hand.
- * In particular:
- *
- * <ul>
- * <li>Current implementation lists all classes, including classes that should
- * not be listed because they did not existed in previous standard.</li>
- * <li>Current implementation repeats properties inherited from parent classes.
- * It does not use the "<var>Child</var> : <var>Parent</var>" syntax.</li>
- * </ul>
- *
- * For generating a new file:
- *
- * {@snippet lang="java" :
- * public static void main(String[] args) throws Exception {
- * RenameListGenerator gen = new RenameListGenerator(Path.of("/home/user/project/build/classes"));
- * gen.add(Path.of("org/apache/sis/metadata/iso"));
- * try (final BufferedWriter out = Files.newBufferedWriter(Path.of("MyOutputFile.lst"))) {
- * gen.print(out);
- * }
- * }
- * }
- */
-public final class RenameListGenerator {
- /**
- * Properties in those namespaces do not have older namespaces to map from.
- */
- private static final Set<String> LEGACY_NAMESPACES = Set.of(
- LegacyNamespaces.GMD,
- LegacyNamespaces.GMI,
- LegacyNamespaces.SRV);
-
- /**
- * The {@value} string used in JAXB annotations for default names or namespaces.
- */
- private static final String DEFAULT = "##default";
-
- /**
- * Root directory from which to search for classes.
- */
- private final Path classRootDirectory;
-
- /**
- * The content to write. Keys in the first (outer) map are namespaces. Keys in the enclosed maps
- * are class names. Keys in the enclosed set are property names.
- */
- private final Map<String, Map<String, Set<String>>> content;
-
- /**
- * Creates a new {@value TransformingReader#FILENAME} generator for classes under the given directory.
- * The given directory shall be the root of {@code "*.class"} files.
- *
- * @param classRootDirectory the root of compiled class files.
- */
- public RenameListGenerator(final Path classRootDirectory) {
- this.classRootDirectory = classRootDirectory;
- content = new TreeMap<>();
- }
-
- /**
- * Gets the namespaces, types and properties for all class files in the given directory and sub-directories.
- * Those information are memorized for future listing with {@link #print(Appendable)}.
- *
- * @param directory the directory to scan for classes, relative to class root directory.
- * @throws IOException if an error occurred while reading files or schemas.
- * @throws ClassNotFoundException if an error occurred while loading a {@code "*.class"} file.
- * @throws SchemaException if two properties have the same name in the same class and namespace.
- */
- public void add(final Path directory) throws IOException, ClassNotFoundException, SchemaException {
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(classRootDirectory.resolve(directory))) {
- for (Path path : stream) {
- final String filename = path.getFileName().toString();
- if (!filename.startsWith(".")) {
- if (Files.isDirectory(path)) {
- add(path);
- } else if (filename.endsWith(".class")) {
- path = classRootDirectory.relativize(path);
- String classname = path.toString();
- classname = classname.substring(0, classname.length() - 6).replace('/', '.');
- add(Class.forName(classname));
- }
- }
- }
- } catch (DirectoryIteratorException e) {
- throw e.getCause();
- }
- }
-
- /**
- * Gets the namespaces, types and properties for the given class.
- * Properties defined in super-classes will be copied as if they were declared in-line.
- * Those information are memorized for future listing with {@link #print(Appendable)}.
- *
- * @throws SchemaException if two properties have the same name in the same class and namespace.
- */
- private void add(Class<?> classe) throws SchemaException {
- XmlRootElement root = classe.getDeclaredAnnotation(XmlRootElement.class);
- if (root != null) {
- /*
- * Add the following entry:
- *
- * http://a.namespace
- * PX_AClass
- * …
- *
- * Then list all properties below "PX_AClass". Note that the namespace may change because properties
- * may be declared in different namespaces, but the class name stay the same. If the same properties
- * are inherited by many classes, they will be repeated in each subclass.
- */
- final String topLevelTypeName = root.name();
- String classNS = namespace(classe, root.namespace());
- for (;; classNS = namespace(classe, root.namespace())) {
- for (final Method method : classe.getDeclaredMethods()) {
- if (!method.isBridge()) {
- final XmlElement xe = method.getDeclaredAnnotation(XmlElement.class);
- if (xe != null) {
- String namespace = xe.namespace();
- if (namespace.equals(DEFAULT)) {
- namespace = classNS;
- }
- add(namespace, topLevelTypeName, xe.name());
- }
- }
- }
- classe = classe.getSuperclass();
- root = classe.getDeclaredAnnotation(XmlRootElement.class);
- if (root == null) break;
- }
- } else {
- /*
- * In Apache SIS implementation, classes without JAXB annotation except on a single method are
- * code lists or enumerations. Those classes have exactly one method annotated with @XmlElement,
- * and that method actually gives a type, not a property (because of the way OGC/ISO wrap every
- * properties in a type).
- */
- XmlElement singleton = null;
- for (final Method method : classe.getDeclaredMethods()) {
- final XmlElement xe = method.getDeclaredAnnotation(XmlElement.class);
- if (xe != null) {
- if (singleton != null) return;
- singleton = xe;
- }
- }
- }
- }
-
- /**
- * Returns the namespace declared on {@link XmlSchema} annotation.
- * May be the namespace inherited from the package.
- */
- private static String namespace(final Class<?> classe, String classNS) {
- if (classNS.equals(DEFAULT)) {
- classNS = classe.getPackage().getDeclaredAnnotation(XmlSchema.class).namespace();
- }
- return classNS;
- }
-
- /**
- * Adds a property in the given class in the given namespace.
- */
- private void add(final String namespace, final String typeName, final String property) throws SchemaException {
- if (!LEGACY_NAMESPACES.contains(namespace)) {
- if (!content.computeIfAbsent(namespace, (k) -> new TreeMap<>())
- .computeIfAbsent(typeName, (k) -> new TreeSet<>())
- .add(property))
- {
- if (typeName.equals("Integer")) return; // Exception because of GO_Integer and GO_Integer64.
- throw new SchemaException(String.format("Duplicated property %s.%s in:%n%s", typeName, property, namespace));
- }
- }
- }
-
- /**
- * Prints the {@value TransformingReader#FILENAME} file.
- *
- * @param out where to print the content.
- * @throws IOException if an error occurred while printing the content.
- */
- public void print(final Appendable out) throws IOException {
- for (final Map.Entry<String, Map<String, Set<String>>> e : content.entrySet()) {
- out.append(e.getKey()).append('\n'); // Namespace
- for (final Map.Entry<String, Set<String>> c : e.getValue().entrySet()) {
- out.append(' ').append(c.getKey()).append('\n'); // Class
- for (final String p : c.getValue()) {
- out.append(" ").append(p).append('\n'); // Property
- }
- }
- }
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/cat/CodeListMarshallingTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/cat/CodeListMarshallingTest.java
index 3f3fb32..2a3c383 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/cat/CodeListMarshallingTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/cat/CodeListMarshallingTest.java
@@ -37,8 +37,8 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
/**
@@ -107,7 +107,7 @@
@Test
public void testDefaultURL() throws JAXBException {
final String expected = getResponsiblePartyXML(CodeListUID.METADATA_ROOT_LEGACY);
- final Responsibility rp = unmarshal(Responsibility.class, expected);
+ final ResponsibleParty rp = unmarshal(ResponsibleParty.class, expected);
assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
/*
* Use the convenience method in order to avoid the effort of creating
@@ -127,7 +127,7 @@
@Test
public void testLegacyISO_URL() throws JAXBException {
final String expected = getResponsiblePartyXML("http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/");
- final Responsibility rp = unmarshal(Responsibility.class, expected);
+ final ResponsibleParty rp = unmarshal(ResponsibleParty.class, expected);
assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
final MarshallerPool pool = getMarshallerPool();
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/lan/LanguageCodeTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/lan/LanguageCodeTest.java
index a5737d9..7249e95 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/lan/LanguageCodeTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/lan/LanguageCodeTest.java
@@ -37,9 +37,6 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.apache.sis.test.TestUtilities.getSingleton;
-
/**
* Tests the XML marshalling of {@code Locale} when used for a language.
@@ -154,7 +151,7 @@
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final String xml = getMetadataXML(LANGUAGE_CODE);
final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
- assertEquals(Locale.JAPANESE, getSingleton(metadata.getLocalesAndCharsets().keySet()));
+ assertEquals(Locale.JAPANESE, metadata.getLanguage());
}
/**
@@ -176,7 +173,7 @@
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final String xml = getMetadataXML(LANGUAGE_CODE_WITHOUT_ATTRIBUTE);
final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
- assertEquals(Locale.JAPANESE, getSingleton(metadata.getLocalesAndCharsets().keySet()));
+ assertEquals(Locale.JAPANESE, metadata.getLanguage());
pool.recycle(unmarshaller);
}
@@ -218,7 +215,7 @@
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final String xml = getMetadataXML(CHARACTER_STRING);
final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
- assertEquals(Locale.JAPANESE, getSingleton(metadata.getLocalesAndCharsets().keySet()));
+ assertEquals(Locale.JAPANESE, metadata.getLanguage());
pool.recycle(unmarshaller);
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/QualityParameterTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/QualityParameterTest.java
index 6ea99d0..59d36ec 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/QualityParameterTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/QualityParameterTest.java
@@ -28,10 +28,8 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.operation.Matrix;
-import org.opengis.metadata.quality.ValueStructure;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -53,11 +51,10 @@
*/
public static QualityParameter create() {
final QualityParameter param = new QualityParameter();
- param.code = "some parameter";
- param.definition = new SimpleInternationalString("a definition");
- param.description = new DefaultMeasureDescription("a description");
- param.valueStructure = ValueStructure.MATRIX;
- param.valueType = Names.createTypeName(Integer.class);
+ param.code = "some parameter";
+ param.definition = new SimpleInternationalString("a definition");
+ param.description = new DefaultMeasureDescription("a description");
+ param.valueType = Names.createTypeName(Integer.class);
return param;
}
@@ -67,11 +64,9 @@
@Test
public void testGetName() {
final QualityParameter param = create();
- final Identifier name = param.getName();
+ final ReferenceIdentifier name = param.getName();
assertNull (name.getCodeSpace());
assertEquals("some parameter", name.getCode());
- assertEquals("a definition", name.getDescription().toString());
- assertEquals("a description", param.getDescription().orElseThrow().toString());
}
/**
@@ -80,7 +75,6 @@
@Test
public void testGetValueType() {
final QualityParameter param = create();
- assertEquals(Matrix.class, param.getValueClass());
assertEquals("OGC:Integer", param.getValueType().toFullyQualifiedName().toString());
}
@@ -115,10 +109,6 @@
" </gco:aName>\n" +
" </gco:TypeName>\n" +
" </dqm:valueType>\n" +
- " <dqm:valueStructure>\n" +
- " <dqm:DQM_ValueStructure codeList=\"http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DQM_ValueStructure\""
- + " codeListValue=\"matrix\">Matrix</dqm:DQM_ValueStructure>\n" +
- " </dqm:valueStructure>\n" +
"</dqm:DQM_Parameter>\n", xml, "xmlns:*");
}
}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/ServiceParameterTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/ServiceParameterTest.java
index 4d67ae3..c4eb58a 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/ServiceParameterTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/metadata/replace/ServiceParameterTest.java
@@ -27,9 +27,8 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.parameter.ParameterDirection;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -56,7 +55,6 @@
param.memberName = name;
param.optionality = true;
param.repeatability = false;
- param.direction = ParameterDirection.IN;
return param;
}
@@ -66,7 +64,7 @@
@Test
public void testGetName() {
final ServiceParameter param = create();
- final Identifier name = param.getName();
+ final ReferenceIdentifier name = param.getName();
assertEquals("TestSpace", name.getCodeSpace());
assertEquals("My service parameter", name.getCode());
assertEquals("TestSpace:My service parameter", name.toString());
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/AnnotationConsistencyCheck.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/AnnotationConsistencyCheck.java
index 4c11f61..3e481db 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/AnnotationConsistencyCheck.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/AnnotationConsistencyCheck.java
@@ -46,11 +46,6 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCaseWithLogs;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.annotation.Classifier;
-import org.opengis.annotation.Stereotype;
-import org.opengis.util.ControlledVocabulary;
-
/**
* Verifies consistency between {@link UML}, {@link XmlElement} and other annotations.
@@ -72,7 +67,6 @@
* </ul>
*
* This class does not verify JAXB annotations against a XSD file.
- * For such verification, see {@link SchemaCompliance}.
*
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
@@ -229,13 +223,12 @@
* <p>The default implementation recognizes the
* {@linkplain Specification#ISO_19115 ISO 19115},
* {@linkplain Specification#ISO_19115_2 ISO 19115-2},
- * {@linkplain Specification#ISO_19115_3 ISO 19115-3},
* {@linkplain Specification#ISO_19139 ISO 19139} and
* {@linkplain Specification#ISO_19108 ISO 19108} specifications,
* with a hard-coded list of exceptions to the general rule.
* Subclasses shall override this method if they need to support more namespaces.</p>
*
- * <p>Note that a more complete verification is done by {@link SchemaCompliance}.
+ * <p>Note that a more complete verification is done by {@code SchemaCompliance}.
* But the test done in this {@link AnnotationConsistencyCheck} class can be run without network access.</p>
*
* <p>The prefix for the given namespace will be fetched by
@@ -245,8 +238,10 @@
* @param uml the UML associated to the class or the method.
* @return the expected namespace.
* @throws IllegalArgumentException if the given UML is unknown to this method.
+ *
+ * @deprecated the complete function is available only on development branch because it depends on GeoAPI 3.1.
*/
- @SuppressWarnings("deprecation")
+ @Deprecated
protected String getExpectedNamespaceStart(final Class<?> impl, final UML uml) {
final String identifier = uml.identifier();
switch (identifier) {
@@ -255,13 +250,11 @@
case "SV_OperationChainMetadata":
case "SV_ServiceIdentification": { // Historical reasons (other standard integrated into ISO 19115)
assertEquals(Specification.ISO_19115, uml.specification(), "Unexpected @Specification value.");
- assertEquals((short) 0, uml.version(), "Specification version should be latest ISO 19115.");
return Namespaces.SRV;
}
case "DQ_TemporalAccuracy": // Renamed DQ_TemporalQuality
case "DQ_NonQuantitativeAttributeAccuracy": { // Renamed DQ_NonQuantitativeAttributeCorrectness
assertEquals(Specification.ISO_19115, uml.specification(), "Unexpected @Specification value.");
- assertEquals((short) 2003, uml.version(), "Specification version should be legacy ISO 19115.");
return LegacyNamespaces.GMD;
}
case "role": {
@@ -307,27 +300,32 @@
}
}
if (identifier.startsWith("DQ_")) {
- assertEquals(Specification.ISO_19157, uml.specification(), "Unexpected @Specification value.");
- assertEquals((short) 0, uml.version(), "Specification version should be ISO 19157.");
+ assertEquals(Specification.ISO_19115, uml.specification(), "Unexpected @Specification value.");
return Namespaces.MDQ;
}
if (identifier.startsWith("DQM_")) {
- assertEquals(Specification.ISO_19157, uml.specification(), "Unexpected @Specification value.");
- assertEquals((short) 0, uml.version(), "Specification version should be ISO 19157.");
return Namespaces.DQM;
}
if (identifier.startsWith("QE_")) {
assertEquals(Specification.ISO_19115_2, uml.specification(), "Unexpected @Specification value.");
- assertEquals((short) 2009, uml.version(), "Specification version should be legacy ISO 19115-2.");
- return LegacyNamespaces.GMI;
+ switch (/*uml.version()*/ 0) {
+ case 0: return Namespaces.MDQ;
+ case 2009: return LegacyNamespaces.GMI;
+ default: fail("Unexpected version number in " + uml);
+ }
+ }
+ if (org.opengis.metadata.quality.DataQuality.class.isAssignableFrom(impl) || // For properties in those types.
+ org.opengis.metadata.quality.Element.class.isAssignableFrom(impl) ||
+ org.opengis.metadata.quality.Result.class.isAssignableFrom(impl))
+ {
+ return Namespaces.MDQ;
}
/*
* General cases (after we processed all the special cases)
* based on which standard defines the type or property.
*/
- final short version = uml.version();
final Specification specification = uml.specification();
- if (version != 0 && version < specification.defaultVersion()) {
+ if (/*uml.version()*/ 0 != 0) {
switch (specification) {
case ISO_19115: return LegacyNamespaces.GMD;
case ISO_19115_2: return LegacyNamespaces.GMI;
@@ -335,15 +333,9 @@
}
switch (specification) {
case ISO_19115:
- case ISO_19115_2:
- case ISO_19115_3: return CodeListUID.METADATA_ROOT;
+ case ISO_19115_2: return CodeListUID.METADATA_ROOT;
case ISO_19139: return LegacyNamespaces.GMX;
case ISO_19108: return LegacyNamespaces.GMD;
- case ISO_19157: {
- // Case for a method. By contrast, above `identifier.startsWith(…)` checks were for types.
- final UML parent = TestUtilities.getSingleton(impl.getInterfaces()).getAnnotation(UML.class);
- return parent.identifier().startsWith("DQM_") ? Namespaces.DQM : Namespaces.MDQ;
- }
default: throw new IllegalArgumentException(uml.toString());
}
}
@@ -355,18 +347,17 @@
* and unconditionally with {@code "_Type"} appended.
* Subclasses shall override this method when mismatches are known to exist between the UML and XML type names.
*
- * @param stereotype the stereotype of the interface, or {@code null} if none.
- * @param uml the UML of the interface for which to get the corresponding XML type name.
+ * @param uml the UML of the interface for which to get the corresponding XML type name.
* @return the name of the XML type for the given element, or {@code null} if none.
*
* @see #testImplementationAnnotations()
+ *
+ * @deprecated the complete function is available only on development branch because it depends on GeoAPI 3.1.
*/
- protected String getExpectedXmlTypeName(final Stereotype stereotype, final UML uml) {
+ @Deprecated
+ protected String getExpectedXmlTypeName(final UML uml) {
final String rootName = uml.identifier();
final StringBuilder buffer = new StringBuilder(rootName.length() + 13);
- if (stereotype == Stereotype.ABSTRACT) {
- buffer.append("Abstract");
- }
return buffer.append(rootName).append("_Type").toString();
}
@@ -375,16 +366,19 @@
* The default implementation returns {@link UML#identifier()}, possibly with {@code "Abstract"} prepended.
* Subclasses shall override this method when mismatches are known to exist between the UML and XML element names.
*
- * @param stereotype the stereotype of the interface, or {@code null} if none.
- * @param uml the UML of the interface for which to get the corresponding XML root element name.
+ * @param uml the UML of the interface for which to get the corresponding XML root element name.
* @return the name of the XML root element for the given UML.
*
* @see #testImplementationAnnotations()
+ *
+ * @deprecated the complete function is available only on development branch because it depends on GeoAPI 3.1.
*/
- protected String getExpectedXmlRootElementName(final Stereotype stereotype, final UML uml) {
+ @Deprecated
+ protected String getExpectedXmlRootElementName(final UML uml) {
String name = uml.identifier();
- if (stereotype == Stereotype.ABSTRACT) {
- name = "Abstract".concat(name);
+ switch (name) {
+ // This case can be removed if https://issues.apache.org/jira/browse/SIS-398 is fixed.
+ case "MI_PolarizationOrientationCode": name = "MI_PolarisationOrientationCode"; break;
}
return name;
}
@@ -406,6 +400,12 @@
protected String getExpectedXmlElementName(final Class<?> enclosing, final UML uml) {
String name = firstIdentifier(uml);
switch (name) {
+ case "stepDateTime": {
+ if (org.opengis.metadata.lineage.ProcessStep.class.isAssignableFrom(enclosing)) {
+ name = "dateTime";
+ }
+ break;
+ }
case "satisfiedPlan": {
if (org.opengis.metadata.acquisition.Requirement.class.isAssignableFrom(enclosing)) {
name = "satisifiedPlan"; // Misspelling in ISO 19115-3:2016
@@ -418,6 +418,24 @@
}
break;
}
+ case "detectedPolarization": {
+ if (org.opengis.metadata.content.Band.class.isAssignableFrom(enclosing)) {
+ name = "detectedPolarisation"; // Spelling change in XSD files
+ }
+ break;
+ }
+ case "transmittedPolarization": {
+ if (org.opengis.metadata.content.Band.class.isAssignableFrom(enclosing)) {
+ name = "transmittedPolarisation"; // Spelling change in XSD files
+ }
+ break;
+ }
+ case "featureType": {
+ if (org.opengis.metadata.distribution.DataFile.class.isAssignableFrom(enclosing)) {
+ name = "featureTypes"; // Spelling change in XSD files
+ }
+ break;
+ }
case "valueType": {
if (org.opengis.metadata.quality.Result.class.isAssignableFrom(enclosing)) {
return "valueRecordType";
@@ -583,7 +601,7 @@
case "getNominalSpatialResolution":
case "getTransferFunctionType": {
final Class<?> dc = method.getDeclaringClass();
- return org.opengis.metadata.content.SampleDimension.class.isAssignableFrom(dc)
+ return org.apache.sis.metadata.iso.content.DefaultSampleDimension.class.isAssignableFrom(dc)
&& !org.opengis.metadata.content.Band.class.isAssignableFrom(dc);
}
/*
@@ -591,7 +609,7 @@
* We do not duplicate the Java methods only for that.
*/
case "getDerivedElements": {
- return org.opengis.metadata.quality.Metaquality.class.isAssignableFrom(method.getDeclaringClass());
+ return true;
}
/*
* Property which exists in a deprecated and a non-deprecated version,
@@ -643,7 +661,7 @@
testingClass = type.getCanonicalName();
UML uml = type.getAnnotation(UML.class);
assertNotNull(uml, "Missing @UML annotation.");
- if (!ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (!CodeList.class.isAssignableFrom(type)) {
for (final Method method : type.getDeclaredMethods()) {
if (isPublic(method)) {
testingMethod = method.getName();
@@ -673,7 +691,7 @@
public void testPackageAnnotations() {
final Set<Package> packages = new HashSet<>();
for (final Class<?> type : types) {
- if (!ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (!CodeList.class.isAssignableFrom(type)) {
testingClass = type.getCanonicalName();
final Class<?> impl = getImplementation(type);
if (impl != null) {
@@ -714,7 +732,7 @@
@Test
public void testImplementationAnnotations() {
for (final Class<?> type : types) {
- if (ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (CodeList.class.isAssignableFrom(type)) {
// Skip code lists, since they are not the purpose of this test.
continue;
}
@@ -737,14 +755,7 @@
final XmlRootElement root = impl.getAnnotation(XmlRootElement.class);
assertNotNull(root, "Missing @XmlRootElement annotation.");
final UML uml = type.getAnnotation(UML.class);
- Stereotype stereotype = null;
- if (uml != null) {
- final Classifier c = type.getAnnotation(Classifier.class);
- if (c != null) {
- stereotype = c.value();
- }
- assertEquals(getExpectedXmlRootElementName(stereotype, uml), root.name(), "Wrong @XmlRootElement.name().");
- }
+ // More tests on development branch (removed on trunk because test depends on GeoAPI 3.1)
/*
* Check that the namespace is the expected one (according subclass)
* and is not redundant with the package @XmlSchema annotation.
@@ -755,11 +766,7 @@
*/
final XmlType xmlType = impl.getAnnotation(XmlType.class);
assertNotNull(xmlType, "Missing @XmlType annotation.");
- String expected = getExpectedXmlTypeName(stereotype, uml);
- if (expected == null) {
- expected = DEFAULT;
- }
- assertEquals(expected, xmlType.name(), "Wrong @XmlType.name().");
+ // More tests on development branch (removed on trunk because test depends on GeoAPI 3.1)
}
loggings.assertNoUnexpectedLog();
}
@@ -777,7 +784,7 @@
@Test
public void testMethodAnnotations() {
for (final Class<?> type : types) {
- if (ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (CodeList.class.isAssignableFrom(type)) {
// Skip code lists, since they are not the purpose of this test.
continue;
}
@@ -851,9 +858,7 @@
*/
if (uml != null) {
assertEquals(getExpectedXmlElementName(type, uml), element.name(), "Wrong @XmlElement.name().");
- if (!method.isAnnotationPresent(Deprecated.class) && uml.version() == 0) {
- assertEquals(uml.obligation() == Obligation.MANDATORY, element.required(), "Wrong @XmlElement.required().");
- }
+ // More tests on development branch (removed on trunk because test depends on GeoAPI 3.1)
}
/*
* Check that the namespace is the expected one (according subclass)
@@ -941,10 +946,10 @@
assertFalse(wrapper.isInherited, "Expected @XmlElementRef.");
final UML uml = type.getAnnotation(UML.class);
if (uml != null) { // `assertNotNull` is `testInterfaceAnnotations()` job.
- assertEquals(getExpectedXmlRootElementName(null, uml), element.name(), "Wrong @XmlElement.");
+ assertEquals(getExpectedXmlRootElementName(uml), element.name(), "Wrong @XmlElement.");
}
final String namespace = assertExpectedNamespace(element.namespace(), wrapper.type, uml);
- if (!ControlledVocabulary.class.isAssignableFrom(type)) {
+ if (!CodeList.class.isAssignableFrom(type)) {
final String expected = getNamespace(getImplementation(type));
if (expected != null) { // `assertNotNull` is `testImplementationAnnotations()` job.
assertEquals(expected, namespace, "Inconsistent @XmlRootElement namespace.");
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/PackageVerifier.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/PackageVerifier.java
deleted file mode 100644
index 62c8d3b..0000000
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/PackageVerifier.java
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * 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.xml.test;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.Collection;
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.ParameterizedType;
-import javax.xml.parsers.ParserConfigurationException;
-import jakarta.xml.bind.annotation.XmlNs;
-import jakarta.xml.bind.annotation.XmlType;
-import jakarta.xml.bind.annotation.XmlSchema;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlRootElement;
-import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
-import org.xml.sax.SAXException;
-import org.opengis.util.CodeList;
-import org.opengis.annotation.UML;
-import org.opengis.geoapi.schema.SchemaException;
-import org.opengis.geoapi.schema.SchemaInformation;
-import static org.opengis.geoapi.schema.SchemaInformation.ROOT_NAMESPACE;
-import static org.opengis.geoapi.schema.SchemaInformation.SCHEMA_ROOT_URL;
-import org.apache.sis.util.Classes;
-import org.apache.sis.system.Modules;
-import org.apache.sis.xml.Namespaces;
-import org.apache.sis.xml.privy.LegacyNamespaces;
-
-// Test dependencies
-import static org.apache.sis.test.TestCase.PENDING_FUTURE_SIS_VERSION;
-
-
-/**
- * Verifies JAXB annotations in a single package. A new instance of this class is created by
- * {@link SchemaCompliance#verify(java.nio.file.Path)} for each Java package to be verified.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-final class PackageVerifier {
- /**
- * Sentinel value used in {@link #LEGACY_NAMESPACES} for meaning "all properties in that namespace".
- */
- @SuppressWarnings("unchecked")
- private static final Set<String> ALL = InfiniteSet.INSTANCE;
-
- /**
- * Classes or properties having a JAXB annotation in this namespace should be deprecated.
- * Deprecated namespaces are enumerated as keys. If the associated value is {@link #ALL},
- * the whole namespace is deprecated. If the value is not ALL, then only the enumerated
- * properties are deprecated.
- *
- * <p>Non-ALL values are rare. They happen in a few cases where a property is legacy despite its namespace.
- * Those "properties" are errors in the legacy ISO 19139:2007 schema; they were types without their property
- * wrappers. For example, in {@code SV_CoupledResource}, {@code <gco:ScopedName>} was marshalled without its
- * {@code <srv:scopedName>} wrapper — note the upper and lower-case "s". Because {@code ScopedName} is a type,
- * we had to keep the namespace declared in {@link org.apache.sis.util.iso.DefaultScopedName}
- * (the replacement is performed by {@code org.apache.sis.xml.TransformingWriter}).</p>
- */
- private static final Map<String, Set<String>> LEGACY_NAMESPACES = Map.of(
- LegacyNamespaces.GMD, ALL,
- LegacyNamespaces.GMI, ALL,
- LegacyNamespaces.GMX, ALL,
- LegacyNamespaces.SRV, ALL,
- Namespaces.GCO, Set.of("ScopedName")); // Not to be confused with standard <srv:scopedName>
-
- /**
- * Types declared in JAXB annotations to be considered as equivalent to types in XML schemas.
- */
- private static final Map<String,String> TYPE_EQUIVALENCES = Map.of(
- "PT_FreeText", "CharacterString",
- "Abstract_Citation", "CI_Citation",
- "AbstractCI_Party", "CI_Party",
- "Abstract_Responsibility", "CI_Responsibility",
- "Abstract_Extent", "EX_Extent");
-
- /**
- * XML elements that are not yet in the XML schema used by this verifier.
- * They are XML elements added by corrigendum applied on abstract models,
- * but not yet (at the time of writing this test) propagated in the XML schema.
- */
- private static final Map<Class<?>, String> PENDING_XML_ELEMENTS = Map.of(
- org.apache.sis.metadata.iso.citation.AbstractParty.class, "partyIdentifier",
- org.apache.sis.metadata.iso.content.DefaultSampleDimension.class, "rangeElementDescription",
- org.apache.sis.metadata.iso.spatial.AbstractSpatialRepresentation.class, "scope");
-
- /**
- * The schemas to compare with the JAXB annotations.
- * Additional schemas will be loaded as needed.
- */
- private final SchemaCompliance schemas;
-
- /**
- * The package name, for reporting error.
- */
- private final String packageName;
-
- /**
- * The default namespace to use if a class does not define explicitly a namespace.
- */
- private final String packageNS;
-
- /**
- * The namespace of the class under examination.
- * This field must be updated for every class found in a package.
- */
- private String classNS;
-
- /**
- * The class under examination, used in error messages.
- * This field must be updated for every class found in a package.
- */
- private Class<?> currentClass;
-
- /**
- * Whether the class under examination is defined in a legacy namespace.
- * In such case, some checks may be skipped because we didn't loaded schemas for legacy properties.
- */
- private boolean isDeprecatedClass;
-
- /**
- * The schema definition for the class under examination.
- *
- * @see SchemaCompliance#getTypeDefinition(String)
- */
- private Map<String, SchemaCompliance.Element> properties;
-
- /**
- * Whether a namespace is actually used of not.
- * We use this map for identifying unnecessary prefix declarations.
- */
- private final Map<String,Boolean> namespaceIsUsed;
-
- /**
- * Whether adapters declared in {@code package-info.java} are used or not.
- */
- private final Map<Class<?>,Boolean> adapterIsUsed;
-
- /**
- * Creates a new verifier for the given package.
- */
- PackageVerifier(final SchemaCompliance schemas, final Package pkg)
- throws IOException, ParserConfigurationException, SAXException, SchemaException
- {
- this.schemas = schemas;
- namespaceIsUsed = new HashMap<>();
- adapterIsUsed = new HashMap<>();
- String name = "?", namespace = "";
- if (pkg != null) {
- name = pkg.getName();
- final XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
- if (schema != null) {
- namespace = schema.namespace();
- String location = schema.location();
- if (!XmlSchema.NO_LOCATION.equals(location)) {
- String expected = location;
- if (expected.startsWith(SCHEMA_ROOT_URL)) {
- expected = ROOT_NAMESPACE + expected.substring(SCHEMA_ROOT_URL.length());
- }
- if (!expected.startsWith(schema.namespace())) {
- throw new SchemaException("XML schema location inconsistent with namespace in package " + name);
- }
- schemas.loadSchema(location);
- }
- for (final XmlNs xmlns : schema.xmlns()) {
- final String pr = xmlns.prefix();
- final String ns = xmlns.namespaceURI();
- final String cr = schemas.allXmlNS.put(pr, ns);
- if (cr != null && !cr.equals(ns)) {
- throw new SchemaException(String.format("Prefix \"%s\" associated to two different namespaces:%n%s%n%s", pr, cr, ns));
- }
- if (namespaceIsUsed.put(ns, Boolean.FALSE) != null) {
- throw new SchemaException(String.format("Duplicated namespace in package %s:%n%s", name, ns));
- }
- }
- }
- /*
- * Lists the type of all values for which an adapter is declared in package-info.
- * If the type is not explicitly declared, then it is inferred from class signature.
- */
- final XmlJavaTypeAdapters adapters = pkg.getAnnotation(XmlJavaTypeAdapters.class);
- if (adapters != null) {
- for (final XmlJavaTypeAdapter adapter : adapters.value()) {
- Class<?> propertyType = adapter.type();
- if (propertyType == XmlJavaTypeAdapter.DEFAULT.class) {
- for (Class<?> adapterClass = adapter.value(); ; adapterClass = adapterClass.getSuperclass()) {
- final Type adapterType = adapterClass.getGenericSuperclass();
- if (adapterType == null) {
- throw new SchemaException(String.format(
- "Cannot infer type for %s adapter.", adapter.value().getName()));
- }
- if (adapterType instanceof ParameterizedType p1) {
- final Type[] parameters = p1.getActualTypeArguments();
- if (parameters.length == 2) {
- Type typeInAPI = parameters[1];
- if (typeInAPI instanceof ParameterizedType p2) {
- typeInAPI = p2.getRawType();
- }
- if (typeInAPI instanceof Class<?> pc) {
- propertyType = pc;
- break;
- }
- }
- }
- }
- }
- if (adapterIsUsed.put((Class<?>) propertyType, Boolean.FALSE) != null) {
- throw new SchemaException(String.format(
- "More than one adapter for %s in package %s", propertyType, name));
- }
- }
- }
- }
- packageName = name;
- packageNS = namespace;
- }
-
- /**
- * Verifies {@code @XmlType} and {@code @XmlRootElement} on the class. This method verifies naming convention
- * (type name should be same as root element name with {@value SchemaCompliance#TYPE_SUFFIX} suffix appended),
- * ensures that the name exists in the schema, and checks the namespace.
- *
- * @param type the class on which to verify annotations.
- */
- final void verify(final Class<?> type)
- throws IOException, ParserConfigurationException, SAXException, SchemaException
- {
- /*
- * Reinitialize fields to be updated for each class.
- */
- classNS = null;
- currentClass = type;
- isDeprecatedClass = false;
- properties = Map.of();
-
- final XmlType xmlType = type.getDeclaredAnnotation(XmlType.class);
- final XmlRootElement xmlRoot = type.getDeclaredAnnotation(XmlRootElement.class);
- XmlElement codeList = null;
- /*
- * Get the type name and namespace from the @XmlType or @XmlRootElement annotations.
- * If both of them are present, verify that they are consistent (same namespace and
- * same name with "_Type" suffix in @XmlType). If the type name is not declared, we
- * assume that it is the same as the class name (this is what Apache SIS 1.0 does
- * in its org.apache.sis.xml.bind.metadata.code package for CodeList adapters).
- */
- final String isoName; // ISO class name (not the same as Java class name).
- if (xmlRoot != null) {
- classNS = xmlRoot.namespace();
- isoName = xmlRoot.name();
- if (xmlType != null) {
- if (!classNS.equals(xmlType.namespace())) {
- throw new SchemaException(errorInClassMember(null)
- .append("Mismatched namespace in @XmlType and @XmlRootElement.").toString());
- }
- SchemaCompliance.verifyNamingConvention(type.getName(), isoName, xmlType.name(), SchemaCompliance.TYPE_SUFFIX);
- }
- } else if (xmlType != null) {
- classNS = xmlType.namespace();
- final String name = xmlType.name();
- isoName = SchemaCompliance.trim(name, SchemaCompliance.TYPE_SUFFIX);
- } else {
- /*
- * If there is neither @XmlRootElement or @XmlType annotation, it may be a code list as implemented
- * in the org.apache.sis.xml.bind.metadata.code package. Those adapters have a single @XmlElement which
- * is to be interpreted as if it was the actual type.
- */
- for (final Method method : type.getDeclaredMethods()) {
- final XmlElement e = method.getDeclaredAnnotation(XmlElement.class);
- if (e != null) {
- if (codeList != null) return;
- codeList = e;
- }
- }
- if (codeList == null) return;
- classNS = codeList.namespace();
- isoName = codeList.name();
- }
- /*
- * Verify that the namespace declared on the class is not redundant with the namespace
- * declared in the package. Actually redundant namespaces are not wrong, but we try to
- * reduce code size.
- */
- if (classNS.equals(AnnotationConsistencyCheck.DEFAULT)) {
- classNS = packageNS;
- } else if (classNS.equals(packageNS)) {
- throw new SchemaException(errorInClassMember(null)
- .append("Redundant namespace declaration: ").append(classNS).toString());
- }
- /*
- * Verify that the namespace has a prefix associated to it in the package-info file.
- */
- if (namespaceIsUsed.put(classNS, Boolean.TRUE) == null) {
- throw new SchemaException(errorInClassMember(null)
- .append("No prefix in package-info for ").append(classNS).toString());
- }
- /*
- * Properties in the legacy GMD or GMI namespaces may be deprecated, depending if a replacement
- * is already available or not. However, properties in other namespaces should not be deprecated.
- * Some validations of deprecated properties are skipped because we didn't loaded their schema.
- */
- isDeprecatedClass = (LEGACY_NAMESPACES.get(classNS) == ALL);
- if (!isDeprecatedClass) {
- if (type.isAnnotationPresent(Deprecated.class)) {
- throw new SchemaException(errorInClassMember(null)
- .append("Unexpected @Deprecated annotation.").toString());
- }
- /*
- * Verify that class name exists, then verify its namespace (associated to the null key by convention).
- */
- properties = schemas.getTypeDefinition(isoName);
- if (properties == null) {
- throw new SchemaException(errorInClassMember(null)
- .append("Unknown name declared in @XmlRootElement: ").append(isoName).toString());
- }
- final String expectedNS = properties.get(null).namespace;
- if (!classNS.equals(expectedNS)) {
- throw new SchemaException(errorInClassMember(null)
- .append(isoName).append(" shall be associated to namespace ").append(expectedNS).toString());
- }
- if (codeList != null) return; // If the class was a code list, we are done.
- }
- /*
- * At this point the classNS, className, isDeprecatedClass and properties field have been set.
- * We can now loop over the XML elements, which may be on fields or on methods (public or private).
- */
- for (final Field field : type.getDeclaredFields()) {
- Class<?> valueType = field.getType();
- final boolean isCollection = Collection.class.isAssignableFrom(valueType);
- if (isCollection) {
- valueType = Classes.boundOfParameterizedProperty(field);
- }
- verify(field, field.getName(), valueType, isCollection);
- }
- for (final Method method : type.getDeclaredMethods()) {
- Class<?> valueType = method.getReturnType();
- final boolean isCollection = Collection.class.isAssignableFrom(valueType);
- if (isCollection || Classes.isParameterizedProperty(valueType)) {
- valueType = Classes.boundOfParameterizedProperty(method);
- }
- verify(method, method.getName(), valueType, isCollection);
- }
- }
-
- /**
- * Validate a field or a method against the expected schema.
- *
- * @param property the field or method to validate.
- * @param javaName the field name or method name in Java code.
- * @param valueType the field type or the method return type, or element type in case of collection.
- * @param isCollection whether the given value type is the element type of a collection.
- */
- private void verify(final AnnotatedElement property, final String javaName,
- final Class<?> valueType, final boolean isCollection) throws SchemaException
- {
- final XmlElement element = property.getDeclaredAnnotation(XmlElement.class);
- if (element == null) {
- return; // No @XmlElement annotation - skip this property.
- }
- String name = element.name();
- if (name.equals(AnnotationConsistencyCheck.DEFAULT)) {
- name = javaName;
- }
- String ns = element.namespace();
- if (ns.equals(AnnotationConsistencyCheck.DEFAULT)) {
- ns = classNS;
- }
- if (namespaceIsUsed.put(ns, Boolean.TRUE) == null) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Missing @XmlNs for namespace ").append(ns).toString());
- }
- /*
- * Remember that we need an adapter for this property, unless the method or field defines its own adapter.
- * In theory we do not need to report missing adapter since JAXB performs its own check, but we do anyway
- * because JAXB has default adapters for String, Double, Boolean, Date, etc. which do not match the way
- * OGC/ISO marshal those elements.
- */
- if (!property.isAnnotationPresent(XmlJavaTypeAdapter.class) && valueType != null) {
- /*
- * Internal classes in Apache SIS "jaxb" subpackages can be marshalled directly.
- * Apache SIS classes defined in other packages may be code lists, which still need adapters.
- */
- if (!valueType.getName().startsWith(Modules.CLASSNAME_PREFIX) || CodeList.class.isAssignableFrom(valueType)) {
- Class<?> c = valueType;
- while (adapterIsUsed.replace(c, Boolean.TRUE) == null) {
- final Class<?> parent = c.getSuperclass();
- if (parent != null) {
- c = parent;
- } else {
- final Class<?>[] p = c.getInterfaces();
- if (p.length == 0) {
- if (valueType == org.opengis.metadata.Obligation.class) {
- break;
- }
- throw new SchemaException(errorInClassMember(javaName)
- .append("Missing @XmlJavaTypeAdapter for ").append(valueType).toString());
- }
- c = p[0]; // Take only the first interface, which should be the "main" parent.
- }
- }
- }
- }
- /*
- * We do not verify fully the properties in legacy namespaces because we didn't loaded their schemas.
- * However, we verify at least that those properties are not declared as required.
- */
- if (LEGACY_NAMESPACES.getOrDefault(ns, Set.of()).contains(name)) {
- if (!isDeprecatedClass && element.required()) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Legacy property should not be required.").toString());
- }
- } else {
- /*
- * Property in non-legacy namespaces should not be deprecated. Verify also their namespace
- * and whether the property is required or optional, and whether it should be a collection.
- */
- if (property.isAnnotationPresent(Deprecated.class)) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Unexpected deprecation status.").toString());
- }
- final SchemaCompliance.Element info = properties.get(name);
- if (info == null) {
- if (name.equals(PENDING_XML_ELEMENTS.get(currentClass))) {
- return;
- }
- throw new SchemaException(errorInClassMember(javaName)
- .append("Unexpected XML element: ").append(name).toString());
- }
- if (info.namespace != null && !ns.equals(info.namespace)) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Declared namespace: ").append(ns).append(System.lineSeparator())
- .append("Expected namespace: ").append(info.namespace).toString());
- }
- if (element.required() != info.isRequired) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Expected @XmlElement(required = ").append(info.isRequired).append(')').toString());
- }
- /*
- * Following is a continuation of our check for multiplicity, but also the beginning of the check
- * for return value type. The return type should be an interface with a UML annotation; we check
- * that this annotation contains the name of the expected type.
- */
- if (isCollection) {
- if (!info.isCollection) {
- if (PENDING_FUTURE_SIS_VERSION) // Temporarily disabled because require GeoAPI modifications.
- throw new SchemaException(errorInClassMember(javaName).append("Value should be a singleton.").toString());
- }
- } else if (info.isCollection) {
- if (PENDING_FUTURE_SIS_VERSION) // Temporarily disabled because require GeoAPI modifications.
- throw new SchemaException(errorInClassMember(javaName).append("Value should be a collection.").toString());
- }
- if (valueType != null) {
- final UML valueUML = valueType.getAnnotation(UML.class);
- if (valueUML != null) {
- String expected = info.typeName;
- String actual = valueUML.identifier();
- expected = TYPE_EQUIVALENCES.getOrDefault(expected, expected);
- actual = TYPE_EQUIVALENCES.getOrDefault(actual, actual);
- if (!expected.equals(actual)) {
- if (PENDING_FUTURE_SIS_VERSION) // Temporarily disabled because require GeoAPI modifications.
- throw new SchemaException(errorInClassMember(javaName)
- .append("Declared value type: ").append(actual).append(System.lineSeparator())
- .append("Expected value type: ").append(expected).toString());
- }
- }
- }
- /*
- * Verify if we have a @XmlNs for the type of the value. This is probably not required, but we
- * do that as a safety. A common namespace added by this check is Metadata Common Classes (MCC).
- */
- final Map<String, SchemaCompliance.Element> valueInfo = schemas.getTypeDefinition(info.typeName);
- if (valueInfo != null) {
- final SchemaInformation.Element typeAndNS = valueInfo.get(null);
- if (typeAndNS != null) {
- final String valueNS = typeAndNS.namespace;
- if (namespaceIsUsed.put(valueNS, Boolean.TRUE) == null) {
- throw new SchemaException(errorInClassMember(javaName)
- .append("Missing @XmlNs for property value namespace: ").append(valueNS).toString());
- }
- }
- }
- }
- }
-
- /**
- * Returns a message beginning with "Error in …", to be completed by the caller.
- * This is a helper method for exception messages.
- *
- * @param name the property name, or {@code null} if none.
- */
- private StringBuilder errorInClassMember(final String name) {
- final StringBuilder builder = new StringBuilder(80).append("Error in ");
- if (isDeprecatedClass) {
- builder.append("legacy ");
- }
- builder.append(currentClass.getCanonicalName());
- if (name != null) {
- builder.append('.').append(name);
- }
- return builder.append(':').append(System.lineSeparator());
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/SchemaCompliance.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/SchemaCompliance.java
deleted file mode 100644
index af1dcc8..0000000
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/SchemaCompliance.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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.xml.test;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Files;
-import java.nio.file.DirectoryStream;
-import java.nio.file.DirectoryIteratorException;
-import java.util.Map;
-import java.util.HashMap;
-import javax.xml.parsers.ParserConfigurationException;
-import jakarta.xml.bind.annotation.XmlNs;
-import jakarta.xml.bind.annotation.XmlElement;
-import org.xml.sax.SAXException;
-import org.opengis.geoapi.schema.Departures;
-import org.opengis.geoapi.schema.DocumentationStyle;
-import org.opengis.geoapi.schema.SchemaInformation;
-import org.opengis.geoapi.schema.SchemaException;
-import org.apache.sis.util.StringBuilders;
-
-
-/**
- * Compares JAXB annotations against the ISO 19115 schemas. This test requires a connection to
- * <a href="https://schemas.isotc211.org/19115/">https://schemas.isotc211.org/19115/</a>.
- * All classes in a given directory are scanned.
- *
- * <h2>Limitations</h2>
- * Current implementation ignores the XML prefix (e.g. {@code "cit:"} in {@code "cit:CI_Citation"}).
- * We assume that there is no name collision, especially given that {@code "CI_"} prefix in front of
- * most OGC/ISO class names have the effect of a namespace. If a collision nevertheless happen, then
- * an exception will be thrown.
- *
- * <p>Current implementation assumes that XML element name, type name, property name and property type
- * name follow some naming convention. For example, type names are suffixed with {@code "_Type"} in OGC
- * schemas, while property type names are suffixed with {@code "_PropertyType"}. This class throws an
- * exception if a type does not follow the expected naming convention. This requirement makes
- * implementation easier, by reducing the number of {@link Map}s that we need to manage.</p>
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class SchemaCompliance extends SchemaInformation {
- /**
- * The prefix of XML type names for properties. In ISO/OGC schemas, this prefix does not appear
- * in the definition of class types but may appear in the definition of property types.
- */
- private static final String ABSTRACT_PREFIX = "Abstract_";
-
- /**
- * The suffix of XML type names for classes.
- * This is used by convention in OGC/ISO standards (but not necessarily in other XSD).
- */
- static final String TYPE_SUFFIX = "_Type";
-
- /**
- * Separator between XML prefix and the actual name.
- */
- private static final char PREFIX_SEPARATOR = ':';
-
- /**
- * Root directory from which to search for classes.
- */
- private final Path classRootDirectory;
-
- /**
- * The namespaces associated to prefixes, as declared by JAXB {@link XmlNs} annotations.
- * Used for verifying that no prefix is defined twice for different namespaces.
- *
- * <p>This field is not really related to schema loading process. But we keep it in this class for
- * {@link PackageVerifier} convenience, as a way to share a single map for all verifier instances.</p>
- */
- final Map<String,String> allXmlNS;
-
- /**
- * Creates a new verifier for classes under the given directory. The given directory shall be the
- * root of {@code "*.class"} files. For example if the {@code mypackage.MyClass} class is compiled
- * in the {@code "MyProject/target/classes/mypackage/MyClass.class"} file, then the root directory
- * shall be {@code "MyProject/target/classes/"}.
- *
- * @param classRootDirectory the root of compiled class files.
- * @param schemaRootDirectory if the computer contains a local copy of ISO schemas, path to that directory.
- * Otherwise {@code null}. This is only for making tests faster.
- */
- public SchemaCompliance(final Path classRootDirectory, final Path schemaRootDirectory) {
- super(schemaRootDirectory, new Departures(), DocumentationStyle.NONE);
- this.classRootDirectory = classRootDirectory;
- allXmlNS = new HashMap<>();
- }
-
- /**
- * Verifies {@link XmlElement} annotations on all {@code *.class} files in the given directory and sub-directories.
- * The given directory must be a sub-directory of the root directory given at construction time.
- * This method will invoke itself for scanning sub-directories.
- *
- * @param directory the directory to scan for classes, relative to class root directory.
- * @throws IOException if an error occurred while reading files or schemas.
- * @throws ClassNotFoundException if an error occurred while loading a {@code "*.class"} file.
- * @throws ParserConfigurationException if {@link javax.xml.parsers.DocumentBuilder} cannot be created.
- * @throws SAXException if an error occurred while parsing the XSD file.
- * @throws SchemaException if a XSD file does not comply with our assumptions,
- * or a JAXB annotation failed a compliance check.
- */
- public void verify(final Path directory)
- throws IOException, ClassNotFoundException, ParserConfigurationException, SAXException, SchemaException
- {
- PackageVerifier verifier = null;
- final StringBuilder buffer = new StringBuilder();
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(classRootDirectory.resolve(directory))) {
- for (Path path : stream) {
- final String filename = path.getFileName().toString();
- if (!filename.startsWith(".")) {
- if (Files.isDirectory(path)) {
- verify(path);
- } else if (filename.endsWith(".class")) {
- path = classRootDirectory.relativize(path);
- buffer.setLength(0);
- buffer.append(path.toString()).setLength(buffer.length() - 6); // Remove ".class" suffix.
- StringBuilders.replace(buffer, File.separatorChar, '.');
- final Class<?> c = Class.forName(buffer.toString());
- if (verifier == null) {
- verifier = new PackageVerifier(this, c.getPackage());
- }
- verifier.verify(c);
- }
- }
- }
- } catch (DirectoryIteratorException e) {
- throw e.getCause();
- }
- }
-
- /**
- * Verifies that the relationship between the name of the given entity and its type are consistent with
- * OGC/ISO conventions. This method ignores the prefix (e.g. {@code "mdb:"} in {@code "mdb:MD_Metadata"}).
- *
- * @param enclosing schema or other container where the error happened.
- * @param name the class or property name. Example: {@code "MD_Metadata"}, {@code "citation"}.
- * @param type the type of the above named object. Example: {@code "MD_Metadata_Type"}, {@code "CI_Citation_PropertyType"}.
- * @param suffix the expected suffix at the end of {@code type}.
- * @throws SchemaException if the given {@code name} and {@code type} are not compliant with expected convention.
- */
- static void verifyNamingConvention(final String enclosing,
- final String name, final String type, final String suffix) throws SchemaException
- {
- if (type.endsWith(suffix)) {
- int nameStart = name.indexOf(PREFIX_SEPARATOR) + 1; // Skip "mdb:" or similar prefix.
- int typeStart = type.indexOf(PREFIX_SEPARATOR) + 1;
- if (name.startsWith(ABSTRACT_PREFIX, nameStart)) nameStart += ABSTRACT_PREFIX.length();
- if (type.startsWith(ABSTRACT_PREFIX, typeStart)) typeStart += ABSTRACT_PREFIX.length();
- final int length = name.length() - nameStart;
- if (type.length() - typeStart - suffix.length() == length &&
- type.regionMatches(typeStart, name, nameStart, length))
- {
- return;
- }
- }
- throw new SchemaException(String.format("Error in %s:%n" +
- "The type name should be the name with \"%s\" suffix, but found name=\"%s\" and type=\"%s\">.",
- enclosing, suffix, name, type));
- }
-
- /**
- * Removes leading and trailing spaces if any, then the prefix and the suffix in the given name.
- * The prefix is anything before the first {@value #PREFIX_SEPARATOR} character.
- * The suffix must be the given string, otherwise an exception is thrown.
- *
- * @param name the name from which to remove prefix and suffix.
- * @param suffix the suffix to remove.
- * @return the given name without prefix and suffix.
- * @throws SchemaException if the given name does not end with the given suffix.
- */
- static String trim(String name, final String suffix) throws SchemaException {
- name = name.trim();
- if (name.endsWith(suffix)) {
- return name.substring(name.indexOf(PREFIX_SEPARATOR) + 1, name.length() - suffix.length());
- }
- throw new SchemaException(String.format("Expected a name ending with \"%s\" but got \"%s\".", suffix, name));
- }
-}
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/package-info.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/package-info.java
index 5406add..b9bb88c 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/package-info.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/package-info.java
@@ -18,7 +18,6 @@
/**
* Utility methods for testing XML files or JAXB annotations.
* {@link org.apache.sis.xml.test.AnnotationConsistencyCheck} and
- * {@link org.apache.sis.xml.test.SchemaCompliance} verifies JAXB annotations.
* {@link org.apache.sis.xml.test.DocumentComparator} compares an actual XML document with the expected one.
*
* <p>Objects defined in this package are only for SIS testing purpose any many change
diff --git a/endorsed/src/org.apache.sis.openoffice/bundle/README.md b/endorsed/src/org.apache.sis.openoffice/bundle/README.md
index e21a698..84cd4dc 100644
--- a/endorsed/src/org.apache.sis.openoffice/bundle/README.md
+++ b/endorsed/src/org.apache.sis.openoffice/bundle/README.md
@@ -83,7 +83,7 @@
```
cd target
-unopkg add apache-sis-1.x-SNAPSHOT.oxt --log-file log.txt
+unopkg add apache-sis-1.5-SNAPSHOT.oxt --log-file log.txt
scalc -env:RTL_LOGFILE=log.txt
```
diff --git a/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/ReferencingFunctions.java b/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/ReferencingFunctions.java
index 3883c2d..c6a2624 100644
--- a/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/ReferencingFunctions.java
+++ b/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/ReferencingFunctions.java
@@ -42,8 +42,9 @@
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.base.CodeType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.apache.sis.referencing.DefaultObjectDomain;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -106,7 +107,6 @@
* @throws FactoryException if an error occurred while creating the object.
* @throws DataStoreException if an error occurred while reading a data file.
*/
- @SuppressWarnings("removal")
private IdentifiedObject getIdentifiedObject(final String codeOrPath, CodeType type)
throws FactoryException, DataStoreException
{
@@ -175,7 +175,7 @@
return object.getName().getCode();
}
// In Apache SIS implementation, `getDescriptionText(…)` returns the identified object name.
- name = CRS.getAuthorityFactory(null).getDescriptionText(IdentifiedObject.class, codeOrPath).orElse(null);
+ name = CRS.getAuthorityFactory(null).getDescriptionText(codeOrPath);
} catch (Exception exception) {
return getLocalizedMessage(exception);
}
@@ -193,7 +193,7 @@
final Object value;
try {
final IdentifiedObject object = getIdentifiedObject(codeOrPath, null);
- for (final ObjectDomain domain : object.getDomains()) {
+ for (final DefaultObjectDomain domain : Legacy.getDomains(object)) {
InternationalString scope = domain.getScope();
if (scope != null) {
return scope.toString(getJavaLocale());
@@ -215,7 +215,7 @@
public String getDomainOfValidity(final String codeOrPath) {
try {
final IdentifiedObject object = getIdentifiedObject(codeOrPath, null);
- for (final ObjectDomain domain : object.getDomains()) {
+ for (final DefaultObjectDomain domain : Legacy.getDomains(object)) {
final Extent extent = domain.getDomainOfValidity();
if (extent != null) {
final InternationalString description = extent.getDescription();
@@ -250,7 +250,7 @@
area = handler.peek();
if (area == null) try {
final IdentifiedObject object = getIdentifiedObject(codeOrPath, null);
- for (final ObjectDomain domain : object.getDomains()) {
+ for (final DefaultObjectDomain domain : Legacy.getDomains(object)) {
area = Extents.getGeographicBoundingBox(domain.getDomainOfValidity());
if (area != null) {
break;
diff --git a/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/Transformer.java b/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/Transformer.java
index 410e140..89ee4d8 100644
--- a/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/Transformer.java
+++ b/endorsed/src/org.apache.sis.openoffice/main/org/apache/sis/openoffice/Transformer.java
@@ -161,7 +161,7 @@
sourcePt.coordinates[i] = (i < coords.length) ? coords[i] : 0;
}
try {
- result[j] = mt.transform(sourcePt, targetPt).getCoordinates();
+ result[j] = mt.transform(sourcePt, targetPt).getCoordinate();
} catch (TransformException exception) {
/*
* The coordinate operation failed for this particular point. But maybe it will
@@ -200,8 +200,8 @@
}
final GeneralEnvelope result = Envelopes.transform(operation, new GeneralEnvelope(min, max));
return new double[][] {
- result.getLowerCorner().getCoordinates(),
- result.getUpperCorner().getCoordinates()
+ result.getLowerCorner().getCoordinate(),
+ result.getUpperCorner().getCoordinate()
};
}
}
diff --git a/endorsed/src/org.apache.sis.portrayal/main/module-info.java b/endorsed/src/org.apache.sis.portrayal/main/module-info.java
index af2abe2..6be2cb7 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/module-info.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/module-info.java
@@ -33,9 +33,6 @@
exports org.apache.sis.map.coverage to
org.apache.sis.gui; // In the "optional" sub-project.
- exports org.apache.sis.style.se1 to
- org.apache.sis.portrayal.map; // In the "incubator" sub-project.
-
/*
* Allow JAXB to use reflection for marshalling and
* unmarshalling Apache SIS objects in XML documents.
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
index 7dd2344..848942f 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
@@ -59,9 +59,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.geometry.MismatchedReferenceSystemException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.coverage.CannotEvaluateException;
/**
@@ -572,7 +572,7 @@
*/
oldObjectiveToDisplay = getObjectiveToDisplay();
final WraparoundApplicator wp = new WraparoundApplicator(null, objectivePOI, oldValue.getCoordinateSystem());
- final MathTransform change = orthogonalTangent(wp.forDomainOfUse(newToOld), anchor.getCoordinates());
+ final MathTransform change = orthogonalTangent(wp.forDomainOfUse(newToOld), anchor.getCoordinate());
final MathTransform result = MathTransforms.concatenate(change, oldObjectiveToDisplay);
/*
* The result is the new `objectiveToTransform` such as the display is unchanged around POI.
@@ -739,7 +739,7 @@
return;
}
}
- throw new org.opengis.geometry.MismatchedDimensionException(errors().getString(
+ throw new MismatchedDimensionException(errors().getString(
Errors.Keys.MismatchedDimension_3, OBJECTIVE_TO_DISPLAY_PROPERTY, expected, actual));
}
@@ -911,7 +911,7 @@
* May be {@code null} if the point of interest is unknown.
*/
final double[] getObjectivePOI() {
- return (objectivePOI != null) ? objectivePOI.getCoordinates() : null;
+ return (objectivePOI != null) ? objectivePOI.getCoordinate() : null;
}
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/CanvasExtent.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/CanvasExtent.java
index f753c77..2ecf9e7 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/CanvasExtent.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/CanvasExtent.java
@@ -108,7 +108,7 @@
}
final double[] c = new double[agmDim];
for (int i = poi.getDimension(); --i >= 0;) {
- c[i] = poi.getCoordinate(i);
+ c[i] = poi.getOrdinate(i);
}
return new CanvasExtent(axisTypes, lower, upper, c);
}
@@ -197,7 +197,7 @@
while (supplementalDimensions != 0) {
final int n = Long.numberOfTrailingZeros(supplementalDimensions);
gridToCRS.setElement(j, j, Double.NaN);
- gridToCRS.setElement(j++, agmDim, pointOfInterest.getCoordinate(n));
+ gridToCRS.setElement(j++, agmDim, pointOfInterest.getOrdinate(n));
supplementalDimensions &= ~(1L << n);
}
return MathTransforms.linear(gridToCRS);
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AbstractStyle.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AbstractStyle.java
index 39f0e39..263294c 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AbstractStyle.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AbstractStyle.java
@@ -27,14 +27,15 @@
import jakarta.xml.bind.annotation.XmlAttribute;
import org.opengis.util.GenericName;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.ResourceId;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
/**
* Defines the styling that is to be applied on data of some arbitrary type.
* The type of data is specified by the {@code <R>} parameterized type and depends on the concrete subclass.
- * The two main types are {@link org.opengis.feature.Feature} and {@link org.apache.sis.coverage.BandedCoverage}.
+ * The two main types are {@link org.apache.sis.feature.AbstractFeature}
+ * and {@link org.apache.sis.coverage.BandedCoverage}.
*
* <!-- Following list of authors contains credits to OGC GeoAPI 2 contributors. -->
* @author Johann Sorel (Geomatys)
@@ -92,7 +93,7 @@
* @see #getFeatureInstanceIDs()
* @see #setFeatureInstanceIDs(ResourceId)
*/
- protected ResourceId<? super R> featureInstanceIDs;
+ protected Filter<? super R> featureInstanceIDs;
/**
* Name of the feature type that this style is meant to act upon, or {@code null} if none.
@@ -236,7 +237,7 @@
*
* @return identification of the feature instances.
*/
- public Optional<ResourceId<? super R>> getFeatureInstanceIDs() {
+ public Optional<Filter<? super R>> getFeatureInstanceIDs() {
return Optional.ofNullable(featureInstanceIDs);
}
@@ -246,7 +247,7 @@
*
* @param value new identification of feature instances, or {@code null} if none.
*/
- public void setFeatureInstanceIDs(final ResourceId<? super R> value) {
+ public void setFeatureInstanceIDs(final Filter<? super R> value) {
featureInstanceIDs = value;
}
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AnchorPoint.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AnchorPoint.java
index f894f27..b89f88a 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AnchorPoint.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/AnchorPoint.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ContrastEnhancement.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ContrastEnhancement.java
index 794f189..25cced3 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ContrastEnhancement.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ContrastEnhancement.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Displacement.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Displacement.java
index 119c8ff..5b32357 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Displacement.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Displacement.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ExpressionAdapter.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ExpressionAdapter.java
index 2dd08f7..f2a3b93 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ExpressionAdapter.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ExpressionAdapter.java
@@ -18,8 +18,8 @@
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/FeatureTypeStyle.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/FeatureTypeStyle.java
index 34c96f2..2c9c7a3 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/FeatureTypeStyle.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/FeatureTypeStyle.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlRootElement;
import org.apache.sis.filter.DefaultFilterFactory;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -34,11 +34,11 @@
*/
@XmlType(name = "FeatureTypeStyleType")
@XmlRootElement(name = "FeatureTypeStyle")
-public class FeatureTypeStyle extends AbstractStyle<Feature> {
+public class FeatureTypeStyle extends AbstractStyle<AbstractFeature> {
/**
* The default style factory for features.
*/
- public static final StyleFactory<Feature> FACTORY =
+ public static final StyleFactory<AbstractFeature> FACTORY =
new StyleFactory<>(DefaultFilterFactory.forFeatures());
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Fill.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Fill.java
index a1a69ba..967ab34 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Fill.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Fill.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Font.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Font.java
index fd5adf9..e822c15 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Font.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Font.java
@@ -21,8 +21,8 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Graphic.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Graphic.java
index 339ceb3..51d08f2 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Graphic.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Graphic.java
@@ -23,8 +23,8 @@
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/GraphicStroke.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/GraphicStroke.java
index 89e698f..9152165 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/GraphicStroke.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/GraphicStroke.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Halo.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Halo.java
index e99788d..7dd1bdd 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Halo.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Halo.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LinePlacement.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LinePlacement.java
index ef57751..0a52d58 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LinePlacement.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LinePlacement.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LineSymbolizer.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LineSymbolizer.java
index 71481e4..a742bb5 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LineSymbolizer.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/LineSymbolizer.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Mark.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Mark.java
index bf70e3a..fbea3f9 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Mark.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Mark.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PointPlacement.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PointPlacement.java
index ffa53f5..f233a0d 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PointPlacement.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PointPlacement.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PolygonSymbolizer.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PolygonSymbolizer.java
index 038221d..cf88922 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PolygonSymbolizer.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/PolygonSymbolizer.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/RasterSymbolizer.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/RasterSymbolizer.java
index 79d1d2f..442ac82 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/RasterSymbolizer.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/RasterSymbolizer.java
@@ -21,8 +21,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Rule.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Rule.java
index 6abb5ab..4224b6a 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Rule.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Rule.java
@@ -28,8 +28,8 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/SelectedChannel.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/SelectedChannel.java
index efeab4a..fae15f2 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/SelectedChannel.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/SelectedChannel.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ShadedRelief.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ShadedRelief.java
index c33153b..e5bafab 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ShadedRelief.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/ShadedRelief.java
@@ -20,8 +20,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Stroke.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Stroke.java
index be3ac3c..b364d35 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Stroke.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Stroke.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleElement.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleElement.java
index cb20c18..72ce62a 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleElement.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleElement.java
@@ -22,9 +22,8 @@
import jakarta.xml.bind.annotation.XmlTransient;
import org.opengis.util.InternationalString;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -86,7 +85,7 @@
* @param value the value for which to return a literal, or {@code null} if none.
* @return literal for the given value, or {@code null} if the given value was null.
*/
- public final <E> Literal<R,E> literal(final E value) {
+ public final <E> Expression<R,E> literal(final E value) {
return (value == null) ? null : factory.filterFactory.literal(value);
}
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleFactory.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleFactory.java
index 90e2f83..40b2e80 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleFactory.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/StyleFactory.java
@@ -22,17 +22,17 @@
import org.apache.sis.feature.privy.AttributeConvention;
import org.apache.sis.metadata.iso.citation.DefaultOnlineResource;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Literal;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.filter.DefaultFilterFactory;
/**
* Factory of style elements.
* Style factory uses a {@link FilterFactory} instance that depends on the type of data to be styled.
* That type of data is specified by the parameterized type {@code <R>}.
- * The two main types are {@link org.opengis.feature.Feature} and {@link org.apache.sis.coverage.BandedCoverage}.
+ * The two main types are {@link org.apache.sis.feature.AbstractFeature}
+ * and {@link org.apache.sis.coverage.BandedCoverage}.
*
* @author Martin Desruisseaux (Geomatys)
*
@@ -42,7 +42,7 @@
/**
* The factory to use for creating expressions.
*/
- final FilterFactory<R,?,?> filterFactory;
+ final DefaultFilterFactory<R,?,?> filterFactory;
/**
* Literal commonly used as a default value.
@@ -50,12 +50,12 @@
* @see StyleElement#defaultToTrue(Expression)
* @see StyleElement#defaultToFalse(Expression)
*/
- final Literal<R,Boolean> enabled, disabled;
+ final Expression<R,Boolean> enabled, disabled;
/**
* Literal commonly used as a default value.
*/
- final Literal<R,Integer> zeroAsInt;
+ final Expression<R,Integer> zeroAsInt;
/**
* Literal commonly used as a default value.
@@ -64,23 +64,23 @@
* @see StyleElement#defaultToHalf(Expression)
* @see StyleElement#defaultToOne(Expression)
*/
- final Literal<R,Double> zero, half, one, six, ten;
+ final Expression<R,Double> zero, half, one, six, ten;
/**
* Default factor for shaded relief.
* This is an arbitrary suggested but not standardized by OGC 05-077r4.
*/
- final Literal<R,Double> relief;
+ final Expression<R,Double> relief;
/**
* Literal commonly used as a default value.
*/
- final Literal<R,String> normal, square, bevel;
+ final Expression<R,String> normal, square, bevel;
/**
* Literal for a predefined color which can be used as fill color.
*/
- final Literal<R,Color> black, gray, white;
+ final Expression<R,Color> black, gray, white;
/**
* An expression for fetching the default geometry.
@@ -88,14 +88,14 @@
* @todo According SE specification, the default expression in the context of some symbolizers should
* fetch all geometries, not only a default one. The default seems to depend on the symbolizer type.
*/
- final ValueReference<R,?> defaultGeometry;
+ final Expression<R,?> defaultGeometry;
/**
* Creates a new style factory.
*
* @param filterFactory the factory to use for creating expressions.
*/
- public StyleFactory(final FilterFactory<R,?,?> filterFactory) {
+ public StyleFactory(final DefaultFilterFactory<R,?,?> filterFactory) {
this.filterFactory = Objects.requireNonNull(filterFactory);
enabled = filterFactory.literal(Boolean.TRUE);
disabled = filterFactory.literal(Boolean.FALSE);
@@ -126,21 +126,21 @@
*/
@SuppressWarnings("unchecked")
StyleFactory(final StyleFactory<?> source) {
- enabled = (Literal<R,Boolean>) source.enabled;
- disabled = (Literal<R,Boolean>) source.disabled;
- zeroAsInt = (Literal<R,Integer>) source.zeroAsInt;
- zero = (Literal<R,Double>) source.zero;
- half = (Literal<R,Double>) source.half;
- one = (Literal<R,Double>) source.one;
- six = (Literal<R,Double>) source.six;
- ten = (Literal<R,Double>) source.ten;
- relief = (Literal<R,Double>) source.relief;
- normal = (Literal<R,String>) source.normal;
- square = (Literal<R,String>) source.square;
- bevel = (Literal<R,String>) source.bevel;
- black = (Literal<R,Color>) source.black;
- gray = (Literal<R,Color>) source.gray;
- white = (Literal<R,Color>) source.white;
+ enabled = (Expression<R,Boolean>) source.enabled;
+ disabled = (Expression<R,Boolean>) source.disabled;
+ zeroAsInt = (Expression<R,Integer>) source.zeroAsInt;
+ zero = (Expression<R,Double>) source.zero;
+ half = (Expression<R,Double>) source.half;
+ one = (Expression<R,Double>) source.one;
+ six = (Expression<R,Double>) source.six;
+ ten = (Expression<R,Double>) source.ten;
+ relief = (Expression<R,Double>) source.relief;
+ normal = (Expression<R,String>) source.normal;
+ square = (Expression<R,String>) source.square;
+ bevel = (Expression<R,String>) source.bevel;
+ black = (Expression<R,Color>) source.black;
+ gray = (Expression<R,Color>) source.gray;
+ white = (Expression<R,Color>) source.white;
filterFactory = null; // TODO: FilterFactory for coverage is not yet available.
defaultGeometry = null; // Idem.
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Symbolizer.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Symbolizer.java
index 297a78d..8f379f5 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Symbolizer.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Symbolizer.java
@@ -28,9 +28,8 @@
import org.apache.sis.measure.Units;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
@@ -224,7 +223,6 @@
/**
* Returns the expression used for fetching the geometry to draw.
- * This expression is often a {@link ValueReference}.
* The value in the referenced feature property should be a geometry
* from a {@linkplain org.apache.sis.setup.GeometryLibrary supported library},
* expect in the particular case of {@link RasterSymbolizer} where the value
@@ -240,7 +238,7 @@
/**
* Sets the expression used for fetching the geometry to draw.
* If this method is never invoked, then the default value is
- * a {@link ValueReference} fetching {@code "sis:geometry"}.
+ * a {@code ValueReference} fetching {@code "sis:geometry"}.
*
* @todo The default expression may change in a future version.
* According SE specification, the default should fetch all geometries.
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/TextSymbolizer.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/TextSymbolizer.java
index fdba948..968c590 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/TextSymbolizer.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/TextSymbolizer.java
@@ -22,8 +22,8 @@
import jakarta.xml.bind.annotation.XmlElementRef;
import jakarta.xml.bind.annotation.XmlRootElement;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Translucent.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Translucent.java
index f1f39f4..15735aa 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Translucent.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/style/se1/Translucent.java
@@ -16,8 +16,8 @@
*/
package org.apache.sis.style.se1;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java
index c2f7916..0a2369f 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java
@@ -20,8 +20,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -44,7 +44,7 @@
final var cdt = factory.createHalo();
// Check default
- Fill<Feature> value = cdt.getFill();
+ Fill<AbstractFeature> value = cdt.getFill();
assertEquals(factory.white, value.getColor());
assertLiteralEquals(1.0, value.getOpacity());
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java
index 3a0fa5a..4744252 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java
@@ -22,8 +22,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -46,7 +46,7 @@
final var cdt = factory.createLineSymbolizer();
// Check default
- Stroke<Feature> value = cdt.getStroke();
+ Stroke<AbstractFeature> value = cdt.getStroke();
assertLiteralEquals(Color.BLACK, value.getColor());
// Check get/set
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java
index 7997c48..089dffc 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java
@@ -20,8 +20,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -44,7 +44,7 @@
final var cdt = factory.createPointPlacement();
// Check default
- AnchorPoint<Feature> value = cdt.getAnchorPoint();
+ AnchorPoint<AbstractFeature> value = cdt.getAnchorPoint();
assertLiteralEquals(0.5, value.getAnchorPointX());
assertLiteralEquals(0.5, value.getAnchorPointY());
@@ -62,7 +62,7 @@
final var cdt = factory.createPointPlacement();
// Check default
- Displacement<Feature> value = cdt.getDisplacement();
+ Displacement<AbstractFeature> value = cdt.getDisplacement();
assertLiteralEquals(0.0, value.getDisplacementX());
assertLiteralEquals(0.0, value.getDisplacementY());
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java
index fbc3768..364e47a 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java
@@ -20,8 +20,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -44,7 +44,7 @@
final var cdt = factory.createPointSymbolizer();
// Check default
- Graphic<Feature> value = cdt.getGraphic();
+ Graphic<AbstractFeature> value = cdt.getGraphic();
assertLiteralEquals(1.0, value.getOpacity());
// Check get/set
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java
index bfae6de..6fa6f68 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java
@@ -22,8 +22,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -64,7 +64,7 @@
final var cdt = factory.createPolygonSymbolizer();
// Check default
- Fill<Feature> value = cdt.getFill().orElseThrow();
+ Fill<AbstractFeature> value = cdt.getFill().orElseThrow();
assertLiteralEquals(Color.GRAY, value.getColor());
// Check get/set
@@ -82,7 +82,7 @@
final var cdt = factory.createPolygonSymbolizer();
// Check default
- Displacement<Feature> value = cdt.getDisplacement();
+ Displacement<AbstractFeature> value = cdt.getDisplacement();
assertLiteralEquals(0.0, value.getDisplacementX());
assertLiteralEquals(0.0, value.getDisplacementY());
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java
index 9977611..5a7a2a5 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java
@@ -23,8 +23,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.Filter;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java
index 2654290..a8113c4 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java
@@ -24,10 +24,10 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
+// Specific to the main branch:
+import org.apache.sis.filter.Expression;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.Literal;
/**
@@ -39,7 +39,7 @@
/**
* The factory to use for creating style elements.
*/
- final StyleFactory<Feature> factory;
+ final StyleFactory<AbstractFeature> factory;
/**
* Creates a new test case.
@@ -55,14 +55,14 @@
* @param value the value for which to return a literal.
* @return literal for the given value.
*/
- final <E> Literal<Feature,E> literal(final E value) {
+ final <E> Expression<AbstractFeature,E> literal(final E value) {
return factory.filterFactory.literal(value);
}
/**
* Creates a dummy description with arbitrary title and abstract.
*/
- final Description<Feature> anyDescription() {
+ final Description<AbstractFeature> anyDescription() {
final var value = factory.createDescription();
value.setTitle(new SimpleInternationalString("A random title"));
value.setAbstract(new SimpleInternationalString("A random abstract"));
@@ -73,7 +73,7 @@
* Returns an expression with a random color.
* The color is {@link #ANY_COLOR}.
*/
- final Expression<Feature,Color> anyColor() {
+ final Expression<AbstractFeature,Color> anyColor() {
return literal(ANY_COLOR);
}
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java
index 0f9f913..90f8f3b 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java
@@ -22,8 +22,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
diff --git a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java
index 3d9c451..ddfa426 100644
--- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java
+++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java
@@ -20,8 +20,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -78,7 +78,7 @@
final var cdt = factory.createTextSymbolizer();
// Check default
- LabelPlacement<Feature> value = cdt.getLabelPlacement();
+ LabelPlacement<AbstractFeature> value = cdt.getLabelPlacement();
assertNotNull(value);
// Check get/set
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocation.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocation.java
index 7f225d0..59a73d2 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocation.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocation.java
@@ -28,10 +28,8 @@
import org.apache.sis.geometry.Envelope2D;
import org.apache.sis.geometry.GeneralDirectPosition;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
@@ -67,7 +65,7 @@
*
* @since 0.8
*/
-public abstract class AbstractLocation implements Location {
+public abstract class AbstractLocation {
/**
* The description of the nature of this geographic identifier, or {@code null} if unspecified.
*
@@ -76,7 +74,7 @@
*
* @see #getLocationType()
*/
- private LocationType type;
+ private AbstractLocationType type;
/**
* The geographic identifier, or {@code null} if unspecified.
@@ -89,10 +87,24 @@
* Creates a new location for the given geographic identifier.
* This constructor accepts {@code null} arguments, but this is not recommended.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of {@code type} argument may be generalized to the
+ * {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param type the description of the nature of this geographic identifier.
* @param identifier the geographic identifier to be returned by {@link #getGeographicIdentifier()}.
*/
- protected AbstractLocation(final LocationType type, final CharSequence identifier) {
+ protected AbstractLocation(final ModifiableLocationType type, final CharSequence identifier) {
+ this.type = type;
+ this.identifier = identifier;
+ }
+
+ /**
+ * Temporary workaround for the lack of {@code LocationType} interface and {@code AbstractLocationType}
+ * being package-private. We do not want to expose {@code AbstractLocationType} in public API for now.
+ */
+ AbstractLocation(final AbstractLocationType type, final CharSequence identifier) {
this.type = type;
this.identifier = identifier;
}
@@ -115,7 +127,7 @@
* for example “Paris, Texas”.
*
* <h4>Examples</h4>
- * If {@link LocationType#getIdentifications()} contain “name”, then geographic identifiers may be country
+ * If {@code LocationType.getIdentifications()} contain “name”, then geographic identifiers may be country
* names like “Japan” or “France”, or places like “Eiffel Tower”. If location type identifications contain
* “code”, then geographic identifiers may be “SW1P 3AD” postcode.
*
@@ -123,7 +135,6 @@
*
* @see ModifiableLocationType#getIdentifications()
*/
- @Override
public InternationalString getGeographicIdentifier() {
return Types.toInternationalString(identifier);
}
@@ -134,7 +145,6 @@
*
* @return other identifier(s) for the location instance, or an empty collection if none.
*/
- @Override
public Collection<? extends InternationalString> getAlternativeGeographicIdentifiers() {
return Collections.emptySet();
}
@@ -145,7 +155,6 @@
*
* @return date of creation of this version of the location instance, or {@code null} if none.
*/
- @Override
public TemporalExtent getTemporalExtent() {
return null;
}
@@ -161,7 +170,6 @@
* @see org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox
* @see org.apache.sis.metadata.iso.extent.DefaultBoundingPolygon
*/
- @Override
public GeographicExtent getGeographicExtent() {
return null;
}
@@ -175,7 +183,6 @@
*
* @return envelope that encompass the location, or {@code null} if none.
*/
- @Override
public Envelope getEnvelope() {
final GeographicExtent extent = getGeographicExtent();
return (extent instanceof GeographicBoundingBox) ? new Envelope2D((GeographicBoundingBox) extent) : null;
@@ -189,7 +196,6 @@
*
* @return coordinates of a representative point for the location instance, or {@code null} if none.
*/
- @Override
public DirectPosition getPosition() {
final Envelope envelope = getEnvelope();
if (envelope == null) {
@@ -207,10 +213,24 @@
/**
* Returns a description of the nature of this geographic identifier.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized to the
+ * {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.
+ * If applied, this method will be made non-final.</div>
+ *
* @return the nature of the identifier and its associated geographic location.
*/
- @Override
- public LocationType getLocationType() {
+ public final ModifiableLocationType getLocationType() {
+ return ModifiableLocationTypeAdapter.copy(type);
+ }
+
+ /**
+ * Workaround for the lack of {@code LocationType} interface in GeoAPI 3.0.
+ * This workaround will be removed in a future SIS version if the location
+ * type interface is introduced in a future GeoAPI version.
+ */
+ final AbstractLocationType type() {
return type;
}
@@ -218,14 +238,17 @@
* Returns the organization responsible for defining the characteristics of the location instance.
* The default implementation returns the {@linkplain ModifiableLocationType#getOwner() owner}.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized to the
+ * {@code org.opengis.metadata.citation.Party} interface. This change is pending
+ * GeoAPI revision for upgrade from ISO 19115:2003 to ISO 19115:2014.</div>
+ *
* @return organization responsible for defining the characteristics of the location instance, or {@code null}.
*
* @see ModifiableLocationType#getOwner()
* @see ReferencingByIdentifiers#getOverallOwner()
*/
- @Override
- public Party getAdministrator() {
- final LocationType type = getLocationType();
+ public AbstractParty getAdministrator() {
return (type != null) ? type.getOwner() : null;
}
@@ -233,12 +256,16 @@
* Returns location instances of a different location type, for which this location instance is a sub-division.
* The default implementation returns an empty list.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of collection elements may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return parent locations, or an empty collection if none.
*
* @see ModifiableLocationType#getParents()
*/
- @Override
- public Collection<? extends Location> getParents() {
+ public Collection<? extends AbstractLocation> getParents() {
return Collections.emptyList();
}
@@ -246,12 +273,16 @@
* Returns location instances of a different location type which subdivides this location instance.
* The default implementation returns an empty list.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of collection elements may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return child locations, or an empty collection if none.
*
* @see ModifiableLocationType#getChildren()
*/
- @Override
- public Collection<? extends Location> getChildren() {
+ public Collection<? extends AbstractLocation> getChildren() {
return Collections.emptyList();
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
index 0af8af3..f73721e 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
@@ -30,9 +30,11 @@
import org.apache.sis.util.collection.TableColumn;
import org.apache.sis.util.collection.TreeTable;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.LocationType;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+// Specific to the main branch:
+import java.util.Collection;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.extent.GeographicExtent;
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
@@ -41,7 +43,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-abstract class AbstractLocationType implements LocationType, LenientComparable {
+abstract class AbstractLocationType implements LenientComparable {
/**
* For sub-class constructors.
*/
@@ -62,11 +64,11 @@
* @param types the location types for which to take a snapshot.
* @return unmodifiable copies of the given location types.
*/
- public static List<LocationType> snapshot(final ReferenceSystemUsingIdentifiers rs, final LocationType... types) {
+ public static List<AbstractLocationType> snapshot(final ReferencingByIdentifiers rs, final AbstractLocationType... types) {
ArgumentChecks.ensureNonNull("types", types);
- final List<LocationType> snapshot = FinalLocationType.snapshot(Arrays.asList(types), rs, new IdentityHashMap<>());
- final Map<LocationType,Boolean> parents = new IdentityHashMap<>();
- for (final LocationType type : snapshot) {
+ final List<AbstractLocationType> snapshot = FinalLocationType.snapshot(Arrays.asList(types), rs, new IdentityHashMap<>());
+ final Map<AbstractLocationType,Boolean> parents = new IdentityHashMap<>();
+ for (final AbstractLocationType type : snapshot) {
checkForCycles(type, parents);
}
return snapshot;
@@ -77,11 +79,11 @@
*
* @throws IllegalArgumentException if an infinite recursion is detected.
*/
- private static void checkForCycles(final LocationType type, final Map<LocationType,Boolean> parents) {
+ private static void checkForCycles(final AbstractLocationType type, final Map<AbstractLocationType,Boolean> parents) {
if (parents.put(type, Boolean.TRUE) != null) {
throw new IllegalArgumentException(Resources.format(Resources.Keys.LocationTypeCycle_1, type.getName()));
}
- for (final LocationType child : type.getChildren()) {
+ for (final AbstractLocationType child : type.getChildren()) {
checkForCycles(child, parents);
}
parents.remove(type);
@@ -98,6 +100,54 @@
}
/**
+ * Name of the location type.
+ */
+ public abstract InternationalString getName();
+
+ /**
+ * Property used as the defining characteristic of the location type.
+ */
+ public abstract InternationalString getTheme();
+
+ /**
+ * Method(s) of uniquely identifying location instances.
+ */
+ public abstract Collection<? extends InternationalString> getIdentifications();
+
+ /**
+ * The way in which location instances are defined.
+ */
+ public abstract InternationalString getDefinition();
+
+ /**
+ * Geographic area within which the location type occurs.
+ */
+ public abstract GeographicExtent getTerritoryOfUse();
+
+ /**
+ * The reference system that comprises this location type.
+ */
+ public abstract ReferencingByIdentifiers getReferenceSystem();
+
+ /**
+ * Name of organization or class of organization able to create and destroy location instances.
+ */
+ public abstract AbstractParty getOwner();
+
+ /**
+ * Parent location types (location types of which this location type is a sub-division).
+ * A location type can have more than one possible parent. For example the parent of a
+ * location type named <cite>“street”</cite> could be <cite>“locality”</cite>, <cite>“town”</cite>
+ * or <cite>“administrative area”</cite>.
+ */
+ public abstract Collection<? extends AbstractLocationType> getParents();
+
+ /**
+ * Child location types (location types which sub-divides this location type).
+ */
+ public abstract Collection<? extends AbstractLocationType> getChildren();
+
+ /**
* Compares this location type with the specified object for equality.
* This method compares the value of {@link #getName()} and {@link #getChildren()} in all modes.
* At the opposite, values of {@link #getParents()} and {@link #getReferenceSystem()} are never
@@ -126,8 +176,8 @@
// Fall through
}
case BY_CONTRACT: {
- if (!(object instanceof LocationType)) break;
- final LocationType that = (LocationType) object;
+ if (!(object instanceof AbstractLocationType)) break;
+ final AbstractLocationType that = (AbstractLocationType) object;
// Do not compare the ReferenceSystem as it may cause an infinite recursion.
if (!Utilities.deepEquals(getTheme(), that.getTheme(), mode) ||
!Utilities.deepEquals(getIdentifications(), that.getIdentifications(), mode) ||
@@ -140,8 +190,8 @@
// Fall through
}
default: {
- if (!(object instanceof LocationType)) break;
- final LocationType that = (LocationType) object;
+ if (!(object instanceof AbstractLocationType)) break;
+ final AbstractLocationType that = (AbstractLocationType) object;
if (Objects.equals(getName(), that.getName())) {
/*
* To be safe, we should apply some check against infinite recursion here.
@@ -183,7 +233,7 @@
@Override
public int hashCode() {
int code = Objects.hashCode(getName());
- for (final LocationType child : getChildren()) {
+ for (final AbstractLocationType child : getChildren()) {
// Take only children name without recursion over their own children.
code = code*31 + Objects.hashCode(child.getName());
}
@@ -218,10 +268,10 @@
* on the assumption that subclasses verified this constraint by calls
* to {@link #checkForCycles()}.
*/
- private static void format(final LocationType type, final TreeTable.Node node) {
+ private static void format(final AbstractLocationType type, final TreeTable.Node node) {
node.setValue(TableColumn.NAME, type.getName());
node.setValue(TableColumn.VALUE_AS_TEXT, type.getDefinition());
- for (final LocationType child : type.getChildren()) {
+ for (final AbstractLocationType child : type.getChildren()) {
format(child, node.newChild());
}
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/FinalLocationType.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/FinalLocationType.java
index 887b045..cf97b3a 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/FinalLocationType.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/FinalLocationType.java
@@ -29,15 +29,12 @@
import org.apache.sis.metadata.ModifiableMetadata;
import org.apache.sis.metadata.MetadataCopier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.referencing.gazetteer.LocationType;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
- * Unmodifiable description of a location created as a snapshot of another {@link LocationType} instance
+ * Unmodifiable description of a location created as a snapshot of another {@code LocationType} instance
* at {@link ReferencingByIdentifiers} construction time. This instance will be set a different reference
* system than the original location type.
*
@@ -77,8 +74,7 @@
/**
* The reference system that comprises this location type.
*/
- @SuppressWarnings("serial") // Most Apache SIS implementations are serializable.
- private final ReferenceSystemUsingIdentifiers referenceSystem;
+ private final ReferencingByIdentifiers referenceSystem;
/**
* Geographic area within which the location type occurs.
@@ -89,22 +85,21 @@
/**
* Name of organization or class of organization able to create and destroy location instances.
*/
- @SuppressWarnings("serial") // Most Apache SIS implementations are serializable.
- private final Party owner;
+ private final AbstractParty owner;
/**
* Parent location types (location types of which this location type is a sub-division).
* This list is unmodifiable.
*/
@SuppressWarnings("serial")
- private final List<LocationType> parents;
+ private final List<AbstractLocationType> parents;
/**
* Child location types (location types which sub-divides this location type).
* This list is unmodifiable.
*/
@SuppressWarnings("serial")
- final List<LocationType> children;
+ final List<AbstractLocationType> children;
/**
* Creates a copy of the given location type with the reference system set to the given value.
@@ -114,8 +109,8 @@
* @param existing other {@code FinalLocationType} instances created before this one.
*/
@SuppressWarnings("LocalVariableHidesMemberVariable")
- private FinalLocationType(final LocationType source, final ReferenceSystemUsingIdentifiers rs,
- final Map<LocationType, FinalLocationType> existing)
+ private FinalLocationType(final AbstractLocationType source, final ReferencingByIdentifiers rs,
+ final Map<AbstractLocationType, FinalLocationType> existing)
{
/*
* Put 'this' in the map at the beginning in case the parents and children contain cyclic references.
@@ -133,7 +128,7 @@
*/
InternationalString theme;
GeographicExtent territoryOfUse;
- Party owner;
+ AbstractParty owner;
/*
* Copy the value from the source location type, make them unmodifiable,
* fallback on the ReferenceSystemUsingIdentifiers if necessary.
@@ -142,8 +137,8 @@
theme = source.getTheme();
identifications = snapshot(source.getIdentifications());
definition = source.getDefinition();
- territoryOfUse = unmodifiable(GeographicExtent.class, source.getTerritoryOfUse());
- owner = unmodifiable(Party.class, source.getOwner());
+ territoryOfUse = (GeographicExtent) unmodifiable(source.getTerritoryOfUse());
+ owner = (AbstractParty) unmodifiable(source.getOwner());
parents = snapshot(source.getParents(), rs, existing);
children = snapshot(source.getChildren(), rs, existing);
referenceSystem = rs;
@@ -151,11 +146,9 @@
if (theme == null) theme = rs.getTheme();
if (owner == null) owner = rs.getOverallOwner();
if (territoryOfUse == null) {
- for (ObjectDomain domain : rs.getDomains()) {
- Extent domainOfValidity = domain.getDomainOfValidity();
- if (domainOfValidity instanceof GeographicExtent) {
- territoryOfUse = (GeographicExtent) domainOfValidity;
- }
+ final Extent domainOfValidity = rs.getDomainOfValidity();
+ if (domainOfValidity instanceof GeographicExtent) {
+ territoryOfUse = (GeographicExtent) domainOfValidity;
}
}
}
@@ -172,12 +165,12 @@
* @param rs the reference system to assign to the new location types.
* @param existing an initially empty identity hash map for internal usage by this method.
*/
- static List<LocationType> snapshot(final Collection<? extends LocationType> types,
- final ReferenceSystemUsingIdentifiers rs, final Map<LocationType, FinalLocationType> existing)
+ static List<AbstractLocationType> snapshot(final Collection<? extends AbstractLocationType> types,
+ final ReferencingByIdentifiers rs, final Map<AbstractLocationType, FinalLocationType> existing)
{
- final LocationType[] array = types.toArray(LocationType[]::new);
+ final AbstractLocationType[] array = types.toArray(AbstractLocationType[]::new);
for (int i=0; i < array.length; i++) {
- final LocationType source = array[i];
+ final AbstractLocationType source = array[i];
ArgumentChecks.ensureNonNullElement("types", i, source);
FinalLocationType copy = existing.get(source);
if (copy == null) {
@@ -211,14 +204,12 @@
/**
* Returns an unmodifiable copy of the given metadata, if necessary and possible.
*
- * @param <T> compile-time value of the {@code type} argument.
- * @param type the interface of the metadata object to eventually copy.
* @param metadata the metadata object to eventually copy, or {@code null}.
* @return an unmodifiable copy of the given metadata object, or {@code null} if the given argument is {@code null}.
*/
- private static <T> T unmodifiable(final Class<T> type, T metadata) {
+ private static Object unmodifiable(Object metadata) {
if (metadata instanceof ModifiableMetadata) {
- metadata = MetadataCopier.forModifiable(((ModifiableMetadata) metadata).getStandard()).copy(type, metadata);
+ metadata = MetadataCopier.forModifiable(((ModifiableMetadata) metadata).getStandard()).copy(metadata);
if (metadata instanceof ModifiableMetadata) {
((ModifiableMetadata) metadata).transitionTo(ModifiableMetadata.State.FINAL);
}
@@ -301,7 +292,7 @@
* @return the reference system that comprises this location type.
*/
@Override
- public ReferenceSystemUsingIdentifiers getReferenceSystem() {
+ public ReferencingByIdentifiers getReferenceSystem() {
return referenceSystem;
}
@@ -311,7 +302,7 @@
* @return organization or class of organization able to create and destroy location instances.
*/
@Override
- public Party getOwner() {
+ public AbstractParty getOwner() {
return owner;
}
@@ -324,7 +315,7 @@
*/
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Because unmodifiable
- public Collection<LocationType> getParents() {
+ public Collection<AbstractLocationType> getParents() {
return parents;
}
@@ -335,7 +326,7 @@
*/
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Because unmodifiable
- public Collection<LocationType> getChildren() {
+ public Collection<AbstractLocationType> getChildren() {
return children;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
index 512e608..6502420 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
@@ -45,10 +45,6 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.pending.jdk.JDK18;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
-
/**
* Geographic coordinates represented as <i>geohashes</i> strings.
@@ -199,10 +195,10 @@
* ("Relax constraint on placement of this()/super() call in constructors").
*/
@Workaround(library="JDK", version="1.8")
- private static LocationType[] types() {
+ private static ModifiableLocationType[] types() {
final ModifiableLocationType gzd = new ModifiableLocationType(IDENTIFIER);
gzd.addIdentification(Vocabulary.formatInternational(Vocabulary.Keys.Code));
- return new LocationType[] {gzd};
+ return new ModifiableLocationType[] {gzd};
}
/**
@@ -321,7 +317,7 @@
final int lonNumBits = latNumBits + (length & 1); // Longitude has 1 more bit when length is odd.
if (position != null) try {
position = toGeographic(position);
- double φ = Math.toRadians(position.getCoordinate(1));
+ double φ = Math.toRadians(position.getOrdinate(1));
double a = Math.PI/2 * Formulas.geocentricRadius(ellipsoid, φ); // Arc length of 90° using radius at φ.
double b = Math.cos(φ) * (2*a) / (1 << lonNumBits); // Precision along longitude axis.
a /= (1 << latNumBits); // Precision along latitude axis.
@@ -357,7 +353,7 @@
p = unit.getConverterToAny(ellipsoid.getAxisUnit()).convert(p);
if (position != null) try {
position = toGeographic(position);
- double φ = Math.toRadians(position.getCoordinate(1));
+ double φ = Math.toRadians(position.getOrdinate(1));
numLat = Math.PI/2 * Formulas.geocentricRadius(ellipsoid, φ) / p;
numLon = Math.cos(φ) * (2*numLat);
} catch (FactoryException | TransformException e) {
@@ -472,7 +468,7 @@
} catch (FactoryException e) {
throw new GazetteerException(e.getLocalizedMessage(), e);
}
- return encode(position.getCoordinate(1), position.getCoordinate(0));
+ return encode(position.getOrdinate(1), position.getOrdinate(0));
}
/**
@@ -500,7 +496,7 @@
throw new GazetteerException(e.getLocalizedMessage(), e);
}
setPrecision(precision, position);
- return encode(position.getCoordinate(1), position.getCoordinate(0));
+ return encode(position.getOrdinate(1), position.getOrdinate(0));
}
/**
@@ -525,12 +521,17 @@
* Decodes the given geohash into a latitude and a longitude.
* The axis order depends on the coordinate reference system of the enclosing {@link GeohashReferenceSystem}.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param geohash geohash string to decode.
* @return a new geographic coordinate for the given geohash.
* @throws TransformException if an error occurred while parsing the given string.
*/
@Override
- public Location decode(final CharSequence geohash) throws TransformException {
+ public AbstractLocation decode(final CharSequence geohash) throws TransformException {
ArgumentChecks.ensureNonEmpty("geohash", geohash);
return new Decoder(geohash, coordinates);
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/LocationFormat.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/LocationFormat.java
index 8b41065..2ab2989 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/LocationFormat.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/LocationFormat.java
@@ -58,14 +58,12 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Vocabulary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
- * Formats {@link Location} instances in a tabular format.
+ * Formats {@code Location} instances in a tabular format.
* This format assumes a monospaced font and an encoding supporting drawing box characters (e.g. UTF-8).
*
* <h2>Example</h2>
@@ -95,7 +93,7 @@
* @version 0.8
* @since 0.8
*/
-public class LocationFormat extends TabularFormat<Location> {
+public class LocationFormat extends TabularFormat<AbstractLocation> {
/**
* For cross-version compatibility.
*/
@@ -136,8 +134,8 @@
* @return the type of values formatted by this {@code Format} instance.
*/
@Override
- public Class<Location> getValueType() {
- return Location.class;
+ public Class<AbstractLocation> getValueType() {
+ return AbstractLocation.class;
}
/**
@@ -187,13 +185,18 @@
/**
* Writes a textual representation of the given location in the given stream or buffer.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of {@code location} parameter may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param location the location to format.
* @param toAppendTo where to format the location.
* @throws IOException if an error occurred while writing to the given appendable.
*/
@Override
@SuppressWarnings("fallthrough")
- public void format(final Location location, final Appendable toAppendTo) throws IOException {
+ public void format(final AbstractLocation location, final Appendable toAppendTo) throws IOException {
ArgumentChecks.ensureNonNull("location", location);
final Locale locale = getLocale(Locale.Category.DISPLAY);
final Vocabulary vocabulary = Vocabulary.forLocale(locale);
@@ -203,7 +206,7 @@
* Location type.
*/
table.appendHorizontalSeparator();
- final LocationType type = location.getLocationType();
+ final AbstractLocationType type = location.type();
if (type != null) {
append(table, vocabulary, Vocabulary.Keys.LocationType, toString(type.getName(), locale));
}
@@ -334,8 +337,8 @@
dimension = 1;
break;
case 4: dimension = 1; // Fall through
- case 1: if (geopos != null) g = geopos .getCoordinate(dimension);
- if (position != null) p = position.getCoordinate(dimension);
+ case 1: if (geopos != null) g = geopos .getOrdinate(dimension);
+ if (position != null) p = position.getOrdinate(dimension);
rounding = RoundingMode.HALF_EVEN;
break;
}
@@ -404,7 +407,7 @@
/*
* Organization responsible for defining the characteristics of the location instance.
*/
- final Party administrator = location.getAdministrator();
+ final AbstractParty administrator = location.getAdministrator();
if (administrator != null) {
append(table, vocabulary, Vocabulary.Keys.Administrator, toString(administrator.getName(), locale));
}
@@ -418,7 +421,7 @@
/**
* Creates the format to use for formatting a latitude, longitude or projected coordinate.
- * This method is invoked by {@link #format(Location, Appendable)} when first needed.
+ * This method is invoked by {@code format(Location, Appendable)} when first needed.
*
* @param valueType {@code Angle.class}. {@code Number.class} or {@code Unit.class}.
* @return a new {@link AngleFormat}, {@link NumberFormat} or {@link UnitFormat} instance
@@ -471,7 +474,7 @@
* @throws ParseException if an error occurred while parsing the location.
*/
@Override
- public Location parse(CharSequence text, ParsePosition pos) throws ParseException {
+ public AbstractLocation parse(CharSequence text, ParsePosition pos) throws ParseException {
throw new ParseException(Errors.format(Errors.Keys.UnsupportedOperation_1, "parse"), pos.getIndex());
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
index 24bacf8..42446d3 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
@@ -76,13 +76,8 @@
import org.apache.sis.measure.Quantities;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
-import org.apache.sis.metadata.sql.MetadataSource;
-import org.apache.sis.metadata.sql.MetadataStoreException;
-import org.apache.sis.util.logging.Logging;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
@@ -295,15 +290,8 @@
*/
@Workaround(library="JDK", version="1.8")
private static Map<String,?> properties() {
- Party party;
- try {
- party = MetadataSource.getProvided().lookup(Party.class, "{org}NATO");
- } catch (MetadataStoreException e) {
- party = null;
- Logging.unexpectedException(LOGGER, MilitaryGridReferenceSystem.class, "<init>", e);
- }
- NamedIdentifier name = new NamedIdentifier(null, "NATO", Resources.formatInternational(Resources.Keys.MGRS), null, null);
- return properties(name, IDENTIFIER, party);
+ AbstractParty party = new AbstractParty("North Atlantic Treaty Organization", null);
+ return properties(new NamedIdentifier(null, "NATO", Resources.formatInternational(Resources.Keys.MGRS), null, null), IDENTIFIER, party);
}
/**
@@ -311,7 +299,7 @@
* ("Relax constraint on placement of this()/super() call in constructors").
*/
@Workaround(library="JDK", version="1.8")
- private static LocationType[] types() {
+ private static ModifiableLocationType[] types() {
final ModifiableLocationType gzd = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.GridZoneDesignator));
final ModifiableLocationType square = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.SquareIdentifier100));
final ModifiableLocationType coord = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.GridCoordinates));
@@ -319,7 +307,7 @@
coord .addIdentification(Vocabulary.formatInternational(Vocabulary.Keys.Coordinate));
square.addParent(gzd);
coord .addParent(square);
- return new LocationType[] {gzd};
+ return new ModifiableLocationType[] {gzd};
}
/**
@@ -337,7 +325,7 @@
south ? TransverseMercator.Zoner.SOUTH_BOUNDS
: TransverseMercator.Zoner.NORTH_BOUNDS, 0);
double northing = datum.universal(position.x * 1.01, position.y).getConversionFromBase()
- .getMathTransform().transform(position, position).getCoordinate(1);
+ .getMathTransform().transform(position, position).getOrdinate(1);
if (south) {
northing = 2*PolarStereographicA.UPS_SHIFT - northing;
}
@@ -771,12 +759,17 @@
* Decodes the given MGRS reference into a position and an envelope.
* The Coordinate Reference System (CRS) associated to the returned position depends on the given reference.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param reference MGRS string to decode.
* @return a new position with the longitude at coordinate 0 and latitude at coordinate 1.
* @throws TransformException if an error occurred while parsing the given string.
*/
@Override
- public Location decode(final CharSequence reference) throws TransformException {
+ public AbstractLocation decode(final CharSequence reference) throws TransformException {
ArgumentChecks.ensureNonEmpty("reference", reference);
return new Decoder(this, reference);
}
@@ -854,8 +847,8 @@
* Use of lower and upper corners below are not the same as calls to Envelope.getMinimum(0)
* or Envelope.getMaximum(0) if the envelope crosses the anti-meridian.
*/
- zoneStart = ZONER.zone(0, geographicArea.getLowerCorner().getCoordinate(0)) - 1; // Inclusive.
- zoneEnd = ZONER.zone(0, geographicArea.getUpperCorner().getCoordinate(0)); // Exclusive.
+ zoneStart = ZONER.zone(0, geographicArea.getLowerCorner().getOrdinate(0)) - 1; // Inclusive.
+ zoneEnd = ZONER.zone(0, geographicArea.getUpperCorner().getOrdinate(0)); // Exclusive.
if (zoneEnd < zoneStart) {
zoneEnd += zoneCount; // Envelope crosses the anti-meridian.
}
@@ -1352,8 +1345,8 @@
int y = gridY;
if (x < xCenter) x += step - 1;
if (downward) y += step - 1;
- normalized.setCoordinate(0, x);
- normalized.setCoordinate(1, y);
+ normalized.setOrdinate(0, x);
+ normalized.setOrdinate(1, y);
String ref = encoder.encode(this, normalized, false, separator, digits, 0);
if (ref != null) {
/*
@@ -1365,7 +1358,7 @@
latitudeBand = encoder.latitudeBand;
if (latitudeBand != previous && previous != 0) {
pending = ref;
- normalized.setCoordinate(1, y + (downward ? +1 : -1));
+ normalized.setOrdinate(1, y + (downward ? +1 : -1));
ref = encoder.encode(this, normalized, false, separator, digits, 0);
if (ref == null || encoder.latitudeBand == previous) {
ref = pending; // No result or same result as previous iteration - cancel.
@@ -1595,7 +1588,7 @@
owner.normalized = position = toNormalized.transform(position, owner.normalized);
}
owner.geographic = position = toGeographic.transform(position, owner.geographic);
- return position.getCoordinate(0);
+ return position.getOrdinate(0);
}
/**
@@ -1619,8 +1612,8 @@
}
final DirectPosition geographic = toGeographic.transform(position, owner.geographic);
owner.geographic = geographic; // For reuse in next method calls.
- final double λ = geographic.getCoordinate(1);
- final double φ = geographic.getCoordinate(0);
+ final double λ = geographic.getOrdinate(1);
+ final double φ = geographic.getOrdinate(0);
final boolean isUTM = φ >= TransverseMercator.Zoner.SOUTH_BOUNDS &&
φ < TransverseMercator.Zoner.NORTH_BOUNDS;
final int zone = isUTM ? ZONER.zone(φ, λ) : POLE;
@@ -1643,7 +1636,7 @@
toActualZone = CRS.findOperation(datum.geographic(), datum.universal(φ, λ), null).getMathTransform();
actualZone = signedZone;
}
- geographic.setCoordinate(1, Longitude.normalize(λ));
+ geographic.setOrdinate(1, Longitude.normalize(λ));
owner.normalized = position = toActualZone.transform(geographic, owner.normalized);
}
/*
@@ -1674,8 +1667,8 @@
* 100 kilometres square identification.
*/
if (digits >= 0) {
- final double x = position.getCoordinate(0);
- final double y = position.getCoordinate(1);
+ final double x = position.getOrdinate(0);
+ final double y = position.getOrdinate(1);
final double cx = Math.floor(x / GRID_SQUARE_SIZE);
final double cy = Math.floor(y / GRID_SQUARE_SIZE);
int col = (int) cx;
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
index 5b6e5bd..264603c 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
@@ -32,9 +32,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
@@ -141,7 +140,7 @@
/**
* Name of organization or class of organization able to create and destroy location instances.
*/
- private Party owner;
+ private AbstractParty owner;
/**
* Parent location types (location types of which this location type is a sub-division).
@@ -350,6 +349,11 @@
* If no organization has been explicitly set, then this method inherits the value from
* the parents providing that all parents specify the same organization.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized to the
+ * {@code org.opengis.metadata.citation.Party} interface. This change is pending
+ * GeoAPI revision for upgrade from ISO 19115:2003 to ISO 19115:2014.</div>
+ *
* @return organization or class of organization able to create and destroy location instances,
* or {@code null} if no value has been defined or can be inherited.
*
@@ -357,7 +361,7 @@
* @see ReferencingByIdentifiers#getOverallOwner()
*/
@Override
- public Party getOwner() {
+ public AbstractParty getOwner() {
return (owner != null) ? owner : inherit(ModifiableLocationType::getOwner);
}
@@ -366,9 +370,14 @@
* The given value is typically an instance of {@link DefaultOrganisation}.
* For an alternative where only the organization name is specified, see {@link #setOwner(CharSequence)}.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the argument type may be generalized to the
+ * {@code org.opengis.metadata.citation.Party} interface. This change is pending
+ * GeoAPI revision for upgrade from ISO 19115:2003 to ISO 19115:2014.</div>
+ *
* @param value the new owner.
*/
- public void setOwner(final Party value) {
+ public void setOwner(final AbstractParty value) {
owner = value;
}
@@ -471,12 +480,17 @@
* the reference system is always null. The reference system is defined when the location types are
* given to the {@link ReferencingByIdentifiers} constructor for example.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized to the
+ * {@code org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return {@code null}.
*
* @see ReferencingByIdentifiers#getLocationTypes()
*/
@Override
- public ReferenceSystemUsingIdentifiers getReferenceSystem() {
+ public ReferencingByIdentifiers getReferenceSystem() {
return null;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationTypeAdapter.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationTypeAdapter.java
new file mode 100644
index 0000000..b265215
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ModifiableLocationTypeAdapter.java
@@ -0,0 +1,101 @@
+/*
+ * 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.referencing.gazetteer;
+
+import java.util.List;
+import java.util.Map;
+import java.util.IdentityHashMap;
+import org.opengis.util.InternationalString;
+import org.apache.sis.util.privy.UnmodifiableArrayList;
+
+
+/**
+ * Workaround for the lack of {@code LocationType} interface in GeoAPI 3.0.
+ * This workaround will be removed if a future GeoAPI version publish that interface,
+ * or if {@link AbstractLocationType} is made public.
+ */
+final class ModifiableLocationTypeAdapter extends ModifiableLocationType {
+ /**
+ * The reference system of the original type.
+ * This is the only information not stored in {@link ModifiableLocationType}.
+ */
+ private final ReferencingByIdentifiers referenceSystem;
+
+ /**
+ * Copies all information from the given type.
+ */
+ private ModifiableLocationTypeAdapter(final AbstractLocationType type,
+ final Map<AbstractLocationType,ModifiableLocationTypeAdapter> previous)
+ {
+ super(type.getName());
+ setTheme(type.getTheme());
+ setDefinition(type.getDefinition());
+ setTerritoryOfUse(type.getTerritoryOfUse());
+ setOwner(type.getOwner());
+ for (final InternationalString s : type.getIdentifications()) {
+ addIdentification(s);
+ }
+ referenceSystem = type.getReferenceSystem();
+ for (final AbstractLocationType c : type.getChildren()) {
+ ModifiableLocationTypeAdapter p = previous.get(c);
+ if (p == null) {
+ p = new ModifiableLocationTypeAdapter(c, previous);
+ previous.put(c, p);
+ }
+ p.addParent(this);
+ }
+ }
+
+ /**
+ * Returns type type as-is if it is already an instance of {@code ModifiableLocationType},
+ * or returns a copy otherwise.
+ */
+ static ModifiableLocationType copy(final AbstractLocationType type) {
+ if (type instanceof ModifiableLocationType) {
+ return (ModifiableLocationType) type;
+ } else {
+ return new ModifiableLocationTypeAdapter(type,
+ new IdentityHashMap<AbstractLocationType,ModifiableLocationTypeAdapter>());
+ }
+ }
+
+ /**
+ * Copies a list of location types.
+ */
+ static List<ModifiableLocationType> copy(final List<? extends AbstractLocationType> types) {
+ final Map<AbstractLocationType,ModifiableLocationTypeAdapter> previous = new IdentityHashMap<>();
+ final ModifiableLocationType[] nt = new ModifiableLocationType[types.size()];
+ for (int i=0; i<nt.length; i++) {
+ final AbstractLocationType c = types.get(i);
+ ModifiableLocationTypeAdapter p = previous.get(c);
+ if (p == null) {
+ p = new ModifiableLocationTypeAdapter(c, previous);
+ previous.put(c, p);
+ }
+ nt[i] = p;
+ }
+ return UnmodifiableArrayList.wrap(nt);
+ }
+
+ /**
+ * Returns the reference system of the type given to the constructor.
+ */
+ @Override
+ public ReferencingByIdentifiers getReferenceSystem() {
+ return referenceSystem;
+ }
+}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
index 9c48b39..80e6326 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
@@ -45,12 +45,8 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.resources.Vocabulary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.metadata.citation.Party;
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.AbstractParty;
/**
@@ -72,7 +68,25 @@
* @since 0.8
*/
@XmlTransient
-public abstract class ReferencingByIdentifiers extends AbstractReferenceSystem implements ReferenceSystemUsingIdentifiers {
+public abstract class ReferencingByIdentifiers extends AbstractReferenceSystem {
+ /**
+ * Key for the <code>{@value}</code> property to be given to the
+ * object factory {@code createFoo(…)} methods.
+ * This is used for setting the value to be returned by {@link #getTheme()}.
+ *
+ * @see #getTheme()
+ */
+ public static final String THEME_KEY = "theme";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the
+ * object factory {@code createFoo(…)} methods.
+ * This is used for setting the value to be returned by {@link #getOverallOwner()}.
+ *
+ * @see #getOverallOwner()
+ */
+ public static final String OVERALL_OWNER_KEY = "overallOwner";
+
/**
* Serial number for inter-operability with different versions.
*/
@@ -96,8 +110,7 @@
*
* @see #getOverallOwner()
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final Party overallOwner;
+ private final AbstractParty overallOwner;
/**
* Description of location type(s) in the spatial reference system.
@@ -105,8 +118,8 @@
*
* @see #getLocationTypes()
*/
- @SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final List<LocationType> locationTypes;
+ @SuppressWarnings("serial")
+ final List<AbstractLocationType> locationTypes;
/**
* Creates a reference system from the given properties.
@@ -121,12 +134,12 @@
* <th>Value type</th>
* <th>Returned by</th>
* </tr><tr>
- * <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#THEME_KEY}</td>
+ * <td>"theme"</td>
* <td>{@link String} or {@link InternationalString}</td>
* <td>{@link #getTheme()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#OVERALL_OWNER_KEY}</td>
- * <td>{@link Party}</td>
+ * <td>"overallOwner"</td>
+ * <td>{@code Party}</td>
* <td>{@link #getOverallOwner()}</td>
* </tr><tr>
* <th colspan="3" class="hsep">Defined in parent class (reminder)</th>
@@ -147,28 +160,33 @@
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#SCOPE_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td>
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getScope()}</td>
* </tr>
* </table>
*
- * This constructor copies the given {@link LocationType} instances as per
- * {@link ModifiableLocationType#snapshot(ReferenceSystemUsingIdentifiers, LocationType...)}.
+ * This constructor copies the given {@code LocationType} instances as per
+ * {@code ModifiableLocationType.snapshot(ReferenceSystemUsingIdentifiers, LocationType...)}.
* Changes in the given location types after construction will not affect this {@code ReferencingByIdentifiers}.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * In a future SIS version, the type of array elements may be generalized to the
+ * {@code org.opengis.referencing.gazetteer.LocationType} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param properties the properties to be given to the reference system.
* @param types description of location type(s) in the spatial reference system.
*/
@SuppressWarnings("this-escape")
- public ReferencingByIdentifiers(final Map<String,?> properties, final LocationType... types) {
+ public ReferencingByIdentifiers(final Map<String,?> properties, final ModifiableLocationType... types) {
super(properties);
theme = Types.toInternationalString(properties, THEME_KEY);
- overallOwner = Containers.property(properties, OVERALL_OWNER_KEY, Party.class);
+ overallOwner = Containers.property(properties, OVERALL_OWNER_KEY, AbstractParty.class);
/*
* Having the 'this' reference escaped in object construction should not be an issue here because
* we invoke package-private method in such a way that if an exception is thrown, the whole tree
@@ -185,27 +203,15 @@
* @param id an identifier for the reference system. Use SIS namespace until we find an authority for them.
* @param party the overall owner, or {@code null} if none.
*/
- static Map<String,Object> properties(final Object name, final String id, final Party party) {
+ static Map<String,Object> properties(final Object name, final String id, final AbstractParty party) {
final Map<String,Object> properties = new HashMap<>(8);
properties.put(NAME_KEY, name);
properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.SIS, Constants.SIS, id));
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, Extents.WORLD);
+ properties.put(DOMAIN_OF_VALIDITY_KEY, Extents.WORLD);
properties.put(THEME_KEY, Vocabulary.formatInternational(Vocabulary.Keys.Mapping));
properties.put(OVERALL_OWNER_KEY, party);
return properties;
}
-
- /**
- * Returns the GeoAPI interface implemented by this class.
- * The default implementation returns {@code ReferenceSystemUsingIdentifiers.class}.
- *
- * @return the GeoAPI interface implemented by this class.
- */
- @Override
- public Class<? extends ReferenceSystemUsingIdentifiers> getInterface() {
- return ReferenceSystemUsingIdentifiers.class;
- }
-
/**
* Property used to characterize the spatial reference system.
*
@@ -213,7 +219,6 @@
*
* @see ModifiableLocationType#getTheme()
*/
- @Override
public InternationalString getTheme() {
return theme;
}
@@ -221,13 +226,17 @@
/**
* Authority with overall responsibility for the spatial reference system.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized to the
+ * {@code org.opengis.metadata.citation.Party} interface. This change is pending
+ * GeoAPI revision for upgrade from ISO 19115:2003 to ISO 19115:2014.</div>
+ *
* @return authority with overall responsibility for the spatial reference system.
*
* @see ModifiableLocationType#getOwner()
* @see AbstractLocation#getAdministrator()
*/
- @Override
- public Party getOverallOwner() {
+ public AbstractParty getOverallOwner() {
return overallOwner;
}
@@ -235,20 +244,24 @@
* Description of location type(s) in the spatial reference system.
* The collection returned by this method is unmodifiable.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of elements type may be generalized to the
+ * {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return description of location type(s) in the spatial reference system.
*
* @see ModifiableLocationType#getReferenceSystem()
*/
- @Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Because the collection is unmodifiable.
- public List<? extends LocationType> getLocationTypes() {
- return locationTypes;
+ public List<? extends ModifiableLocationType> getLocationTypes() {
+ return ModifiableLocationTypeAdapter.copy(locationTypes);
}
/**
* Returns the first location type.
*/
- final LocationType rootType() {
+ final AbstractLocationType rootType() {
return locationTypes.get(0);
}
@@ -351,11 +364,16 @@
* Decodes the given identifier into a latitude and a longitude.
* The axis order depends on the coordinate reference system of the enclosing {@link ReferencingByIdentifiers}.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * in a future SIS version, the type of returned element may be generalized
+ * to the {@code org.opengis.referencing.gazetteer.Location} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @param identifier identifier string to decode.
* @return a new geographic coordinate for the given identifier.
* @throws TransformException if an error occurred while parsing the given string.
*/
- public abstract Location decode(CharSequence identifier) throws TransformException;
+ public abstract AbstractLocation decode(CharSequence identifier) throws TransformException;
/**
* Logs a warning for a recoverable error while transforming a position. This is used for implementations
@@ -397,7 +415,7 @@
locationTypes.equals(that.locationTypes);
}
case BY_CONTRACT: {
- final ReferenceSystemUsingIdentifiers that = (ReferenceSystemUsingIdentifiers) object;
+ final ReferencingByIdentifiers that = (ReferencingByIdentifiers) object;
if (!Utilities.deepEquals(getTheme(), that.getTheme(), mode) ||
!Utilities.deepEquals(getOverallOwner(), that.getOverallOwner(), mode))
{
@@ -407,8 +425,8 @@
}
default: {
// Theme and owner are metadata, so they can be ignored.
- final ReferenceSystemUsingIdentifiers that = (ReferenceSystemUsingIdentifiers) object;
- return Utilities.deepEquals(getLocationTypes(), that.getLocationTypes(), mode);
+ final ReferencingByIdentifiers that = (ReferencingByIdentifiers) object;
+ return Utilities.deepEquals(locationTypes, that.locationTypes, mode);
}
}
}
@@ -446,7 +464,7 @@
formatter.newLine();
formatter.append(new SubElement("Owner", overallOwner.getName()));
}
- for (final LocationType type : locationTypes) {
+ for (final AbstractLocationType type : locationTypes) {
formatter.newLine();
formatter.append(new SubElement("LocationType", type.getName()));
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/SimpleLocation.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/SimpleLocation.java
index 932739f..4672c25 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/SimpleLocation.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/SimpleLocation.java
@@ -27,9 +27,6 @@
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.LocationType;
-
/**
* A location described by an unmodifiable direct position that defines the centroid of an envelope.
@@ -89,7 +86,7 @@
* @param type the description of the nature of this geographic identifier.
* @param identifier the geographic identifier to be returned by {@link #getGeographicIdentifier()}.
*/
- SimpleLocation(final LocationType type, final CharSequence identifier) {
+ SimpleLocation(final AbstractLocationType type, final CharSequence identifier) {
super(type, identifier);
}
@@ -121,6 +118,16 @@
}
/**
+ * Returns this direct position.
+ *
+ * @return {@code this}.
+ */
+ @Override
+ public final DirectPosition getDirectPosition() {
+ return this;
+ }
+
+ /**
* Returns the coordinate reference system the envelope and the position.
* Default implementation returns {@link CommonCRS#defaultGeographic()}.
* Subclasses must override this method if they use another CRS.
@@ -142,15 +149,15 @@
* Returns the coordinates of the centroid.
*/
@Override
- public final double[] getCoordinates() {
- return new double[] {getCoordinate(0), getCoordinate(1)};
+ public final double[] getCoordinate() {
+ return new double[] {getOrdinate(0), getOrdinate(1)};
}
/**
* Returns the centroid coordinate value for the specified dimension.
*/
@Override
- public final double getCoordinate(final int dimension) {
+ public final double getOrdinate(final int dimension) {
return getMedian(dimension);
}
@@ -229,7 +236,7 @@
* Do not allow modification of the direct position.
*/
@Override
- public final void setCoordinate(int dimension, double value) {
+ public final void setOrdinate(int dimension, double value) {
throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, DirectPosition.class));
}
@@ -326,7 +333,7 @@
* @param type the description of the nature of this geographic identifier.
* @param identifier the geographic identifier to be returned by {@link #getGeographicIdentifier()}.
*/
- Projected(final LocationType type, final CharSequence identifier) {
+ Projected(final AbstractLocationType type, final CharSequence identifier) {
super(type, identifier);
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/GeohashReferenceSystemTest.java b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/GeohashReferenceSystemTest.java
index 596fce1..e22fd23 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/GeohashReferenceSystemTest.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/GeohashReferenceSystemTest.java
@@ -33,10 +33,6 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
-
/**
* Tests methods from the {@link GeohashReferenceSystem} class.
@@ -253,10 +249,10 @@
*/
private void testDecode(final GeohashReferenceSystem.Coder coder, final int λi, final int φi) throws TransformException {
for (final Place place : PLACES) {
- final Location location = coder.decode(place.geohash);
+ final AbstractLocation location = coder.decode(place.geohash);
final DirectPosition result = location.getPosition();
- assertEquals(place.longitude, result.getCoordinate(λi), TOLERANCE, place.name);
- assertEquals(place.latitude, result.getCoordinate(φi), TOLERANCE, place.name);
+ assertEquals(place.longitude, result.getOrdinate(λi), TOLERANCE, place.name);
+ assertEquals(place.latitude, result.getOrdinate(φi), TOLERANCE, place.name);
}
}
@@ -271,7 +267,7 @@
assertEquals("Mapping", rs.getTheme().toString(Locale.ENGLISH));
assertEquals("Cartographie", rs.getTheme().toString(Locale.FRENCH));
- final LocationType type = TestUtilities.getSingleton(rs.getLocationTypes());
+ final AbstractLocationType type = TestUtilities.getSingleton(rs.getLocationTypes());
assertEquals("Geohash", type.getName().toString(Locale.ENGLISH));
assertEquals(0, type.getParents().size());
assertEquals(0, type.getChildren().size());
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationTypeTest.java b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
index 107ac5a..e826e1a 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
@@ -27,9 +27,6 @@
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.LocationType;
-
/**
* Tests {@link AbstractLocationType}, {@link FinalLocationType} and {@link ModifiableLocationType}.
@@ -120,7 +117,7 @@
/**
* Verifies the value of a "administrative area" location type.
*/
- private static void verify(final LocationType[] type) {
+ private static void verify(final AbstractLocationType[] type) {
assertEquals(5, type.length);
verify(type[0], "administrative area",
"local administration",
@@ -152,8 +149,8 @@
/**
* Verifies the value of a location type created by or copied from {@link #create(boolean)}.
*/
- private static void verify(final LocationType type, final String name, final String theme, final String definition,
- final String identification, final String owner)
+ private static void verify(final AbstractLocationType type, final String name, final String theme,
+ final String definition, final String identification, final String owner)
{
assertEquals(name, String.valueOf(type.getName()));
assertEquals(theme, String.valueOf(type.getTheme()));
@@ -186,7 +183,7 @@
*/
@Test
public void testSnapshot() {
- verify(ModifiableLocationType.snapshot(null, create(true)).toArray(LocationType[]::new));
+ verify(ModifiableLocationType.snapshot(null, create(true)).toArray(AbstractLocationType[]::new));
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationViewer.java b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationViewer.java
index 211711b..a9bf548 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationViewer.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/LocationViewer.java
@@ -41,12 +41,9 @@
import org.apache.sis.geometry.Envelope2D;
import org.apache.sis.util.Debug;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.Location;
-
/**
- * A Swing panel drawing {@link Location} instances.
+ * A Swing panel drawing {@code Location} instances.
* This is used for debugging purpose only.
*
* @author Martin Desruisseaux (Geomatys)
@@ -212,7 +209,7 @@
* @throws FactoryException if a transformation to the display CRS cannot be obtained.
* @throws TransformException if an error occurred while transforming an envelope.
*/
- public void addLocation(final String label, final Location location) throws FactoryException, TransformException {
+ public void addLocation(final String label, final AbstractLocation location) throws FactoryException, TransformException {
final Envelope envelope = location.getEnvelope();
final MathTransform2D tr = (MathTransform2D) CRS.findOperation(
envelope.getCoordinateReferenceSystem(), displayCRS, null).getMathTransform();
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
index 03a81be..50b3000 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
@@ -47,10 +47,6 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.gazetteer.Location;
-import org.opengis.referencing.gazetteer.LocationType;
-
/**
* Tests {@link MilitaryGridReferenceSystem}.
@@ -73,15 +69,15 @@
assertEquals("Mapping", rs.getTheme().toString(Locale.ENGLISH));
assertEquals("Cartographie", rs.getTheme().toString(Locale.FRENCH));
- final LocationType gzd = TestUtilities.getSingleton(rs.getLocationTypes());
+ final AbstractLocationType gzd = TestUtilities.getSingleton(rs.getLocationTypes());
assertEquals("Grid zone designator", gzd.getName().toString(Locale.ENGLISH));
assertEquals(0, gzd.getParents().size());
- final LocationType sid = TestUtilities.getSingleton(gzd.getChildren());
+ final AbstractLocationType sid = TestUtilities.getSingleton(gzd.getChildren());
assertEquals("100 km square identifier", sid.getName().toString(Locale.ENGLISH));
assertSame(gzd, TestUtilities.getSingleton(sid.getParents()));
- final LocationType gc = TestUtilities.getSingleton(sid.getChildren());
+ final AbstractLocationType gc = TestUtilities.getSingleton(sid.getChildren());
assertEquals("Grid coordinate", gc.getName().toString(Locale.ENGLISH));
assertSame(sid, TestUtilities.getSingleton(gc.getParents()));
}
@@ -164,7 +160,7 @@
*/
geographic.x = φ;
geographic.y = isSouth ? zoneBorder : zoneCentre;
- final double ymin = projection.transform(geographic, projected).getCoordinate(1);
+ final double ymin = projection.transform(geographic, projected).getOrdinate(1);
/*
* Computes the largest possible northing value. This is not only the value of the next latitude band;
* we also need to interchange the "zone centre" and "zone border" logic described in previous comment.
@@ -172,7 +168,7 @@
*/
geographic.y = isSouth ? zoneCentre : zoneBorder;
geographic.x = MilitaryGridReferenceSystem.Decoder.upperBound(φ);
- final double ymax = projection.transform(geographic, projected).getCoordinate(1);
+ final double ymax = projection.transform(geographic, projected).getOrdinate(1);
/*
* Computes the value that we will encode in the MilitaryGridReferenceSystem.Decoder.ROW_RESOLVER table.
* The lowest 4 bits are the number of the row cycle (a cycle of 2000 km). The remaining bits tell which
@@ -216,7 +212,7 @@
private static DirectPosition decode(final MilitaryGridReferenceSystem.Coder coder, final String reference)
throws TransformException
{
- final Location loc = coder.decode(reference);
+ final AbstractLocation loc = coder.decode(reference);
final Envelope2D envelope = new Envelope2D(loc.getEnvelope());
final DirectPosition2D pos = new DirectPosition2D(loc.getPosition());
assertTrue(envelope.contains(pos), reference);
@@ -286,28 +282,28 @@
position = decode(coder, "32TNL8410239239");
assertSame(CommonCRS.WGS84.universal(41, 10), position.getCoordinateReferenceSystem());
- assertEquals( 584102.5, position.getCoordinate(0));
- assertEquals(4539239.5, position.getCoordinate(1));
+ assertEquals( 584102.5, position.getOrdinate(0));
+ assertEquals(4539239.5, position.getOrdinate(1));
position = decode(coder, "29XMM8446304963");
assertSame(CommonCRS.WGS84.universal(82, -10), position.getCoordinateReferenceSystem());
- assertEquals( 484463.5, position.getCoordinate(0));
- assertEquals(9104963.5, position.getCoordinate(1));
+ assertEquals( 484463.5, position.getOrdinate(0));
+ assertEquals(9104963.5, position.getOrdinate(1));
position = decode(coder, "32GNV8410260761");
assertSame(CommonCRS.WGS84.universal(-41, 10), position.getCoordinateReferenceSystem());
- assertEquals( 584102.5, position.getCoordinate(0));
- assertEquals(5460761.5, position.getCoordinate(1));
+ assertEquals( 584102.5, position.getOrdinate(0));
+ assertEquals(5460761.5, position.getOrdinate(1));
position = decode(coder, "33XVM2240708183");
assertSame(CommonCRS.WGS84.universal(82, 10), position.getCoordinateReferenceSystem());
- assertEquals( 422407.5, position.getCoordinate(0));
- assertEquals(9108183.5, position.getCoordinate(1));
+ assertEquals( 422407.5, position.getOrdinate(0));
+ assertEquals(9108183.5, position.getOrdinate(1));
position = decode(coder, "32FNL9360826322");
assertSame(CommonCRS.WGS84.universal(-49.4, 10.3), position.getCoordinateReferenceSystem());
- assertEquals( 593608.5, position.getCoordinate(0));
- assertEquals(4526322.5, position.getCoordinate(1));
+ assertEquals( 593608.5, position.getOrdinate(0));
+ assertEquals(4526322.5, position.getOrdinate(1));
}
/**
@@ -331,14 +327,14 @@
position = decode(coder, "19JBK"); // South hemisphere
crs = CommonCRS.WGS84.universal(-10, -69);
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 250000, position.getCoordinate(0), 1);
- assertEquals(6950000, position.getCoordinate(1));
+ assertEquals( 250000, position.getOrdinate(0), 1);
+ assertEquals(6950000, position.getOrdinate(1));
coder.setClipToValidArea(true);
position = decode(coder, "19JBK");
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 251256, position.getCoordinate(0), 1);
- assertEquals(6950000, position.getCoordinate(1));
+ assertEquals( 251256, position.getOrdinate(0), 1);
+ assertEquals(6950000, position.getOrdinate(1));
/*
* Easting range before clipping is [300000 … 400000] metres.
* The east bound become 343828 metres after clipping.
@@ -349,14 +345,14 @@
position = decode(coder, "1VCK"); // North of Norway latitude band
crs = CommonCRS.WGS84.universal(62, -180);
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 350000, position.getCoordinate(0), 1);
- assertEquals(6950000, position.getCoordinate(1));
+ assertEquals( 350000, position.getOrdinate(0), 1);
+ assertEquals(6950000, position.getOrdinate(1));
coder.setClipToValidArea(true);
position = decode(coder, "1VCK");
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 371914, position.getCoordinate(0), 1);
- assertEquals(6950000, position.getCoordinate(1));
+ assertEquals( 371914, position.getOrdinate(0), 1);
+ assertEquals(6950000, position.getOrdinate(1));
/*
* Northing value before clipping: 7350000
* Northing value after clipping: 7371306
@@ -365,14 +361,14 @@
position = decode(coder, "57KTP");
crs = CommonCRS.WGS84.universal(-24, 156);
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 250000, position.getCoordinate(0));
- assertEquals(7350000, position.getCoordinate(1), 1);
+ assertEquals( 250000, position.getOrdinate(0));
+ assertEquals(7350000, position.getOrdinate(1), 1);
coder.setClipToValidArea(true);
position = decode(coder, "57KTP");
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 250000, position.getCoordinate(0));
- assertEquals(7371306, position.getCoordinate(1), 1);
+ assertEquals( 250000, position.getOrdinate(0));
+ assertEquals(7371306, position.getOrdinate(1), 1);
/*
* Easting and northing values before clipping: 650000 6250000
* Easting and northing values after clipping: 643536 6253618
@@ -381,14 +377,14 @@
position = decode(coder, "56VPH");
crs = CommonCRS.WGS84.universal(55, 154);
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 650000, position.getCoordinate(0), 1);
- assertEquals(6250000, position.getCoordinate(1), 1);
+ assertEquals( 650000, position.getOrdinate(0), 1);
+ assertEquals(6250000, position.getOrdinate(1), 1);
coder.setClipToValidArea(true);
position = decode(coder, "56VPH");
assertSame(crs, position.getCoordinateReferenceSystem());
- assertEquals( 643536, position.getCoordinate(0), 1);
- assertEquals(6253618, position.getCoordinate(1), 1);
+ assertEquals( 643536, position.getOrdinate(0), 1);
+ assertEquals(6253618, position.getOrdinate(1), 1);
}
/**
@@ -443,35 +439,35 @@
*/
position = decode(coder, "BAN0001000010");
assertSame(CommonCRS.WGS84.universal(-90, 0), position.getCoordinateReferenceSystem());
- assertEquals(2000010.5, position.getCoordinate(0));
- assertEquals(2000010.5, position.getCoordinate(1));
+ assertEquals(2000010.5, position.getOrdinate(0));
+ assertEquals(2000010.5, position.getOrdinate(1));
position = decode(coder, "AZM9999099990");
assertSame(CommonCRS.WGS84.universal(-90, 0), position.getCoordinateReferenceSystem());
- assertEquals(1999990.5, position.getCoordinate(0));
- assertEquals(1999990.5, position.getCoordinate(1));
+ assertEquals(1999990.5, position.getOrdinate(0));
+ assertEquals(1999990.5, position.getOrdinate(1));
position = decode(coder, "BLJ0672702814");
assertSame(CommonCRS.WGS84.universal(-90, 0), position.getCoordinateReferenceSystem());
- assertEquals(2806727.5, position.getCoordinate(0));
- assertEquals(1602814.5, position.getCoordinate(1));
+ assertEquals(2806727.5, position.getOrdinate(0));
+ assertEquals(1602814.5, position.getOrdinate(1));
/*
* North case.
*/
position = decode(coder, "ZAH0001000010");
assertSame(CommonCRS.WGS84.universal(90, 0), position.getCoordinateReferenceSystem());
- assertEquals(2000010.5, position.getCoordinate(0));
- assertEquals(2000010.5, position.getCoordinate(1));
+ assertEquals(2000010.5, position.getOrdinate(0));
+ assertEquals(2000010.5, position.getOrdinate(1));
position = decode(coder, "YZG9999099990");
assertSame(CommonCRS.WGS84.universal(90, 0), position.getCoordinateReferenceSystem());
- assertEquals(1999990.5, position.getCoordinate(0));
- assertEquals(1999990.5, position.getCoordinate(1));
+ assertEquals(1999990.5, position.getOrdinate(0));
+ assertEquals(1999990.5, position.getOrdinate(1));
position = decode(coder, "YRK8672702814");
assertSame(CommonCRS.WGS84.universal(90, 0), position.getCoordinateReferenceSystem());
- assertEquals(1386727.5, position.getCoordinate(0));
- assertEquals(2202814.5, position.getCoordinate(1));
+ assertEquals(1386727.5, position.getOrdinate(0));
+ assertEquals(2202814.5, position.getOrdinate(1));
}
/**
@@ -569,28 +565,28 @@
position = decode(coder, "32TNL8410239239");
assertEquals(position, decode(coder, "32/T/NL/84102/39239"));
- assertEquals( 584102.5, position.getCoordinate(0));
- assertEquals(4539239.5, position.getCoordinate(1));
+ assertEquals( 584102.5, position.getOrdinate(0));
+ assertEquals(4539239.5, position.getOrdinate(1));
position = decode(coder, "32TNL8439");
assertEquals(position, decode(coder, "32/T/NL/84/39"));
- assertEquals( 584500.0, position.getCoordinate(0));
- assertEquals(4539500.0, position.getCoordinate(1));
+ assertEquals( 584500.0, position.getOrdinate(0));
+ assertEquals(4539500.0, position.getOrdinate(1));
position = decode(coder, "32TNL83");
assertEquals(position, decode(coder, "32/T/NL/8/3"));
- assertEquals( 585000.0, position.getCoordinate(0));
- assertEquals(4535000.0, position.getCoordinate(1));
+ assertEquals( 585000.0, position.getOrdinate(0));
+ assertEquals(4535000.0, position.getOrdinate(1));
position = decode(coder, "32TNL");
assertEquals(position, decode(coder, "32/T/NL"));
- assertEquals( 550000.0, position.getCoordinate(0));
- assertEquals(4550000.0, position.getCoordinate(1));
+ assertEquals( 550000.0, position.getOrdinate(0));
+ assertEquals(4550000.0, position.getOrdinate(1));
position = decode(coder, "32T");
assertEquals(position, decode(coder, "32/T"));
- assertEquals( 500000.0, position.getCoordinate(0));
- assertEquals(9000000.0, position.getCoordinate(1));
+ assertEquals( 500000.0, position.getOrdinate(0));
+ assertEquals(9000000.0, position.getOrdinate(1));
}
/**
@@ -635,7 +631,7 @@
final DirectPosition r = decode(coder, reference);
final ProjectedCRS crs = (ProjectedCRS) r.getCoordinateReferenceSystem();
assertSame(expected, crs.getConversionFromBase().getMathTransform().transform(position, expected));
- final double distance = expected.distance(r.getCoordinate(0), r.getCoordinate(1));
+ final double distance = expected.distance(r.getOrdinate(0), r.getOrdinate(1));
if (!(distance < 1.5)) { // Use '!' for catching NaN.
final String lineSeparator = System.lineSeparator();
fail("Consistency check failed for φ = " + position.x + " and λ = " + position.y + lineSeparator
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
index f7cc6fb..756f05d 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
@@ -27,9 +27,6 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* Tests {@link ReferencingByIdentifiers}.
@@ -54,7 +51,7 @@
assertNull(properties.put(ReferencingByIdentifiers.NAME_KEY, "UK property addressing"));
assertNull(properties.put(ReferencingByIdentifiers.THEME_KEY, "property"));
assertNull(properties.put(ReferencingByIdentifiers.OVERALL_OWNER_KEY, new DefaultOrganisation("Office for National Statistics", null, null, null)));
- assertNull(properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK", null, null, null)));
+ assertNull(properties.put(ReferencingByIdentifiers.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK", null, null, null)));
return new ReferencingByIdentifiers(properties, LocationTypeTest.create(inherit)) {
@Override public ReferencingByIdentifiers.Coder createCoder() {
throw new UnsupportedOperationException();
diff --git a/endorsed/src/org.apache.sis.referencing/main/module-info.java b/endorsed/src/org.apache.sis.referencing/main/module-info.java
index 74c62c3..e8d927d 100644
--- a/endorsed/src/org.apache.sis.referencing/main/module-info.java
+++ b/endorsed/src/org.apache.sis.referencing/main/module-info.java
@@ -33,9 +33,6 @@
provides org.apache.sis.metadata.sql.privy.Initializer
with org.apache.sis.referencing.internal.DatabaseListener;
- provides org.opengis.referencing.RegisterOperations
- with org.apache.sis.referencing.MultiRegisterOperations;
-
provides org.opengis.referencing.crs.CRSFactory
with org.apache.sis.referencing.factory.GeodeticObjectFactory;
@@ -178,7 +175,6 @@
exports org.apache.sis.referencing.privy to
org.apache.sis.referencing.gazetteer,
org.apache.sis.feature,
- org.apache.sis.geometry, // In the "incubator" sub-project.
org.apache.sis.storage,
org.apache.sis.storage.sql,
org.apache.sis.storage.netcdf,
@@ -204,6 +200,10 @@
org.glassfish.jaxb.core, // For access to various classes.
jakarta.xml.bind; // Seems ignored.
+ exports org.apache.sis.referencing.internal to // On main branch only, for transition from GeoAPI 3.0.
+ org.apache.sis.console,
+ org.apache.sis.openoffice;
+
/*
* Allow JAXB to use reflection for marshalling and
* unmarshalling Apache SIS objects in XML documents.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/AbstractCoordinateSet.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/AbstractCoordinateSet.java
index 212b77f..bea3303 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/AbstractCoordinateSet.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/AbstractCoordinateSet.java
@@ -20,51 +20,93 @@
import java.io.Serializable;
import org.apache.sis.referencing.IdentifiedObjects;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.CoordinateSet;
-import org.opengis.coordinate.CoordinateMetadata;
+// Specific to the main branch:
+import java.util.Iterator;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19111;
+import org.opengis.annotation.UML;
+import org.opengis.geometry.DirectPosition;
/**
* Skeletal implementation of a collection of coordinate tuples referenced to the same <abbr>CRS</abbr> and epoch.
* This implementation is serializable if the coordinate metadata given at construction time is also serializable.
*
+ * <h2>Future evolution</h2>
+ * This class is expected to implement a {@code CoordinateSet} interface after the next GeoAPI release.
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
* @since 1.5
*/
-public abstract class AbstractCoordinateSet implements CoordinateSet, Serializable {
+public abstract class AbstractCoordinateSet implements Iterable<DirectPosition>, Serializable {
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 3656426153519035462L;
+ private static final long serialVersionUID = 3656426153519035461L;
/**
* Coordinate reference system and epoch (if dynamic) of this coordinate set.
*/
- @SuppressWarnings("serial") // Apache SIS implementations of this interface are serializable.
- private final CoordinateMetadata metadata;
+ private final DefaultCoordinateMetadata metadata;
/**
* Creates a new set of coordinate tuples.
*
* @param metadata coordinate reference system and epoch (if dynamic) of this coordinate set.
*/
- protected AbstractCoordinateSet(final CoordinateMetadata metadata) {
+ protected AbstractCoordinateSet(final DefaultCoordinateMetadata metadata) {
this.metadata = Objects.requireNonNull(metadata);
}
/**
* Returns the coordinate metadata to which this coordinate set is referenced.
*
+ * <div class="warning"><b>Upcoming API change</b><br>
+ * {@code DefaultCoordinateMetadata} class may be replaced by {@code CoordinateMetadata} interface
+ * after upgrade to GeoAPI 3.1.
+ * </div>
+ *
* @return coordinate metadata to which this coordinate set is referenced.
*/
- @Override
- public CoordinateMetadata getCoordinateMetadata() {
+ public DefaultCoordinateMetadata getCoordinateMetadata() {
return metadata;
}
/**
+ * Returns the number of dimensions of coordinate tuples. This is determined by the
+ * {@linkplain DefaultCoordinateMetadata#getCoordinateReferenceSystem() coordinate reference system}.
+ *
+ * @return the number of dimensions of coordinate tuples.
+ */
+ public int getDimension() {
+ // All methods invoked below are for attributes declared as mandatory. Values shall not be null.
+ return getCoordinateMetadata().getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
+ }
+
+ /**
+ * Returns the positions described by coordinate tuples.
+ *
+ * @return position described by coordinate tuples.
+ */
+ @Override
+ @UML(identifier="coordinateTuple", obligation=MANDATORY, specification=ISO_19111)
+ public abstract Iterator<DirectPosition> iterator();
+
+ /**
+ * Returns a stream of coordinate tuples.
+ * Whether the stream is sequential or parallel is implementation dependent.
+ * The default implementation creates a sequential stream.
+ *
+ * @return a sequential or parallel stream of coordinate tuples.
+ */
+ public Stream<DirectPosition> stream() {
+ return StreamSupport.stream(spliterator(), false);
+ }
+
+ /**
* Returns a string representation of this coordinate set for debugging purposes.
* This string representation may change in any future version.
*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
index a5ee561..39a7426 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
@@ -33,9 +33,6 @@
import org.apache.sis.util.LenientComparable;
import org.apache.sis.util.Utilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.CoordinateMetadata;
-
/**
* Default implementation of metadata required to reference coordinates.
@@ -43,12 +40,15 @@
* This default implementation provides <i>Well-Known Text</i> support.
* It is immutable and serializable if the CRS and epoch are also serializable.
*
+ * <h2>Future evolution</h2>
+ * This class is expected to implement a {@code CoordinateMetadata} interface after the next GeoAPI release.
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
* @since 1.5
*/
public class DefaultCoordinateMetadata extends FormattableObject
- implements CoordinateMetadata, LenientComparable, Serializable
+ implements LenientComparable, Serializable
{
/**
* Serial number for inter-operability with different versions.
@@ -88,45 +88,11 @@
}
/**
- * Creates a new coordinate metadata with the same values as the specified one.
- * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
- * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
- *
- * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
- *
- * @param metadata the coordinate metadata to copy.
- *
- * @see #castOrCopy(CoordinateMetadata)
- */
- protected DefaultCoordinateMetadata(final CoordinateMetadata metadata) {
- this(metadata.getCoordinateReferenceSystem(), metadata.getCoordinateEpoch().orElse(null));
- }
-
- /**
- * Returns a SIS datum implementation with the same values as the given arbitrary implementation.
- * If the given object is {@code null}, then this method returns {@code null}.
- * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
- * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultCoordinateMetadata castOrCopy(final CoordinateMetadata object) {
- if (object == null || object instanceof DefaultCoordinateMetadata) {
- return (DefaultCoordinateMetadata) object;
- } else {
- return new DefaultCoordinateMetadata(object);
- }
- }
-
- /**
* Returns the <abbr>CRS</abbr> in which the coordinate tuples are given.
* Should never be null in principle, however this implementation does not enforce this restriction.
*
* @return the coordinate reference system (CRS) of coordinate tuples.
*/
- @Override
public CoordinateReferenceSystem getCoordinateReferenceSystem() {
return crs;
}
@@ -136,7 +102,6 @@
*
* @return epoch at which coordinate tuples are valid.
*/
- @Override
public Optional<Temporal> getCoordinateEpoch() {
return Optional.ofNullable(epoch);
}
@@ -182,10 +147,6 @@
final var other = (DefaultCoordinateMetadata) obj;
return crs.equals(other.crs) && Objects.equals(epoch, other.epoch);
}
- } else if (obj instanceof CoordinateMetadata) {
- final var other = (CoordinateMetadata) obj;
- return Utilities.deepEquals(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem(), mode)
- && Objects.equals(getCoordinateEpoch(), other.getCoordinateEpoch());
}
}
return false;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
index 4f4fdb5..8d53bf5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
@@ -25,8 +25,7 @@
import java.util.Arrays;
import java.util.Objects;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.CoordinateSystem;
@@ -87,6 +86,102 @@
}
/**
+ * Returns this direct position.
+ *
+ * @return {@code this}.
+ */
+ @Override
+ public final DirectPosition getDirectPosition() {
+ return this;
+ }
+
+ /**
+ * Returns the coordinate reference system in which the coordinate tuple is given.
+ * May be {@code null} if this particular {@code DirectPosition} is included in a larger object
+ * with such a reference to a {@linkplain CoordinateReferenceSystem coordinate reference system}.
+ *
+ * <p>The default implementation returns {@code null}.
+ * Subclasses should override this method if the CRS can be provided.</p>
+ *
+ * @return the coordinate reference system, or {@code null}.
+ */
+ @Override
+ public CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return null;
+ }
+
+ /**
+ * Returns a sequence of numbers that hold the coordinate of this position in its reference system.
+ *
+ * @return the coordinates.
+ *
+ * @deprecated Renamed {@link #getCoordinates()} for consistency with ISO 19111 terminology.
+ */
+ @Override
+ @Deprecated(since="1.5")
+ public double[] getCoordinate() {
+ return getCoordinates();
+ }
+
+ /**
+ * Returns a sequence of numbers that hold the coordinate of this position in its reference system.
+ *
+ * @return the coordinates.
+ */
+ public double[] getCoordinates() {
+ final double[] coordinates = new double[getDimension()];
+ for (int i=0; i<coordinates.length; i++) {
+ coordinates[i] = getCoordinate(i);
+ }
+ return coordinates;
+ }
+
+ /**
+ * Returns the coordinate at the specified dimension.
+ *
+ * @param dimension the dimension in the range 0 to {@linkplain #getDimension dimension}-1.
+ * @return the coordinate at the specified dimension.
+ * @throws IndexOutOfBoundsException if the given index is negative or is equal or greater
+ * than the {@linkplain #getDimension() number of dimensions}.
+ *
+ * @deprecated Renamed {@link #getCoordinate(int)} for consistency with ISO 19111 terminology.
+ */
+ @Deprecated(since="1.5")
+ public double getOrdinate(int dimension) throws IndexOutOfBoundsException {
+ return getCoordinate(dimension);
+ }
+
+ /**
+ * Returns the coordinate at the specified dimension.
+ *
+ * @param dimension the dimension in the range 0 to {@linkplain #getDimension dimension}-1.
+ * @return the coordinate at the specified dimension.
+ * @throws IndexOutOfBoundsException if the given index is negative or is equal or greater
+ * than the {@linkplain #getDimension() number of dimensions}.
+ *
+ * @since 1.5
+ */
+ public abstract double getCoordinate(int dimension) throws IndexOutOfBoundsException;
+
+ /**
+ * Sets the coordinate value along the specified dimension.
+ *
+ * @param dimension the dimension for the coordinate of interest.
+ * @param value the coordinate value of interest.
+ * @throws IndexOutOfBoundsException if the given index is negative or is equal or greater
+ * than the {@linkplain #getDimension() position dimension}.
+ * @throws UnsupportedOperationException if this direct position is immutable.
+ *
+ * @deprecated Renamed {@link #setCoordinate(int, double)} for consistency with ISO 19111 terminology.
+ */
+ @Deprecated(since="1.5")
+ public void setOrdinate(int dimension, double value)
+ throws IndexOutOfBoundsException, UnsupportedOperationException
+ {
+ setCoordinate(dimension, value);
+ }
+
+ /**
* Sets the coordinate value along the specified dimension.
*
* <p>The default implementation throws {@link UnsupportedOperationException}.
@@ -100,7 +195,6 @@
*
* @since 1.5
*/
- @Override
public void setCoordinate(int dimension, double value) {
throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1, getClass()));
}
@@ -111,15 +205,15 @@
*
* <p>If this position and the given position have a non-null CRS, then the default implementation
* requires the CRS to be {@linkplain Utilities#equalsIgnoreMetadata equals (ignoring metadata)},
- * otherwise a {@code MismatchedCoordinateMetadataException} is thrown. However, subclass may choose
+ * otherwise a {@code MismatchedReferenceSystemException} is thrown. However, subclass may choose
* to assign the CRS of this position to the CRS of the given position.</p>
*
* @param position the new position, or {@code null}.
* @throws MismatchedDimensionException if the given position doesn't have the expected dimension.
- * @throws MismatchedCoordinateMetadataException if the given position doesn't use the expected CRS.
+ * @throws MismatchedReferenceSystemException if the given position doesn't use the expected CRS.
*/
public void setLocation(final DirectPosition position)
- throws MismatchedDimensionException, MismatchedCoordinateMetadataException
+ throws MismatchedDimensionException, MismatchedReferenceSystemException
{
final int dimension = getDimension();
if (position != null) {
@@ -132,7 +226,7 @@
}
}
for (int i=0; i<dimension; i++) {
- setCoordinate(i, position.getCoordinate(i));
+ setCoordinate(i, position.getOrdinate(i));
}
} else {
for (int i=0; i<dimension; i++) {
@@ -262,7 +356,7 @@
char separator = '(';
for (int i=0; i<dimension; i++) {
buffer.append(separator);
- final double coordinate = position.getCoordinate(i);
+ final double coordinate = position.getOrdinate(i);
if (isSinglePrecision) {
buffer.append((float) coordinate);
} else {
@@ -414,7 +508,7 @@
final int dimension = getDimension();
if (dimension == that.getDimension()) {
for (int i=0; i<dimension; i++) {
- if (!Numerics.equals(getCoordinate(i), that.getCoordinate(i))) {
+ if (!Numerics.equals(getCoordinate(i), that.getOrdinate(i))) {
return false;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
index 46de65c..2319773 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
@@ -31,8 +31,7 @@
import jakarta.xml.bind.annotation.XmlTransient;
import org.opengis.geometry.Envelope;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.CoordinateSystem;
@@ -185,11 +184,11 @@
* @param lowerCorner the first position.
* @param upperCorner the second position.
* @return their common CRS, or {@code null} if none.
- * @throws MismatchedCoordinateMetadataException if the two positions don't use equal CRS.
+ * @throws MismatchedReferenceSystemException if the two positions don't use equal CRS.
*/
static CoordinateReferenceSystem getCommonCRS(final DirectPosition lowerCorner,
final DirectPosition upperCorner)
- throws MismatchedCoordinateMetadataException
+ throws MismatchedReferenceSystemException
{
final CoordinateReferenceSystem crs1 = lowerCorner.getCoordinateReferenceSystem();
final CoordinateReferenceSystem crs2 = upperCorner.getCoordinateReferenceSystem();
@@ -283,7 +282,7 @@
* The default implementation returns a view over the {@link #getLower(int)} method,
* so changes in this envelope will be immediately reflected in the returned direct position.
* If the particular case of the {@code GeneralEnvelope} subclass, the returned position
- * supports also {@linkplain DirectPosition#setCoordinate(int, double) write operations},
+ * supports also {@linkplain DirectPosition#setOrdinate(int, double) write operations},
* so changes in the position are reflected back in the envelope.
*
* <h4>Note on wraparound</h4>
@@ -311,7 +310,7 @@
* The default implementation returns a view over the {@link #getUpper(int)} method,
* so changes in this envelope will be immediately reflected in the returned direct position.
* If the particular case of the {@code GeneralEnvelope} subclass, the returned position
- * supports also {@linkplain DirectPosition#setCoordinate(int, double) write operations},
+ * supports also {@linkplain DirectPosition#setOrdinate(int, double) write operations},
* so changes in the position are reflected back in the envelope.
*
* <h4>Note on wraparound</h4>
@@ -787,7 +786,7 @@
ensureDimensionMatches("point", dimension, position);
assert assertEquals(getCoordinateReferenceSystem(), position.getCoordinateReferenceSystem()) : position;
for (int i=0; i<dimension; i++) {
- final double value = position.getCoordinate(i);
+ final double value = position.getOrdinate(i);
final double lower = getLower(i);
final double upper = getUpper(i);
final boolean c1 = (value >= lower);
@@ -870,8 +869,8 @@
for (int i=0; i<dimension; i++) {
final double lower0 = getLower(i);
final double upper0 = getUpper(i);
- final double lower1 = lowerCorner.getCoordinate(i);
- final double upper1 = upperCorner.getCoordinate(i);
+ final double lower1 = lowerCorner.getOrdinate(i);
+ final double upper1 = upperCorner.getOrdinate(i);
final boolean lowerCondition, upperCondition;
if (edgesInclusive) {
lowerCondition = (lower1 >= lower0);
@@ -1006,8 +1005,8 @@
for (int i=0; i<dimension; i++) {
final double lower0 = getLower(i);
final double upper0 = getUpper(i);
- final double lower1 = lowerCorner.getCoordinate(i);
- final double upper1 = upperCorner.getCoordinate(i);
+ final double lower1 = lowerCorner.getOrdinate(i);
+ final double upper1 = upperCorner.getOrdinate(i);
final boolean lowerCondition, upperCondition;
if (touch) {
lowerCondition = (lower1 <= upper0);
@@ -1061,7 +1060,7 @@
*/
static boolean hasNaN(final DirectPosition position) {
for (int i=position.getDimension(); --i>=0;) {
- if (Double.isNaN(position.getCoordinate(i))) {
+ if (Double.isNaN(position.getOrdinate(i))) {
return true;
}
}
@@ -1123,8 +1122,8 @@
ε *= span;
}
}
- if (!epsilonEqual(getLower(i), lowerCorner.getCoordinate(i), ε) ||
- !epsilonEqual(getUpper(i), upperCorner.getCoordinate(i), ε))
+ if (!epsilonEqual(getLower(i), lowerCorner.getOrdinate(i), ε) ||
+ !epsilonEqual(getUpper(i), upperCorner.getOrdinate(i), ε))
{
return false;
}
@@ -1248,7 +1247,7 @@
do { // Executed exactly twice.
for (int i=0; i<dimension; i++) {
buffer.append(i == 0 && !isUpper ? '(' : ' ');
- final double coordinate = (isUpper ? upperCorner : lowerCorner).getCoordinate(i);
+ final double coordinate = (isUpper ? upperCorner : lowerCorner).getOrdinate(i);
if (isSinglePrecision) {
buffer.append((float) coordinate);
} else {
@@ -1285,8 +1284,8 @@
@Override
protected String formatTo(final Formatter formatter) {
final Vector[] points = {
- Vector.create(getLowerCorner().getCoordinates()),
- Vector.create(getUpperCorner().getCoordinates())
+ Vector.create(getLowerCorner().getCoordinate()),
+ Vector.create(getUpperCorner().getCoordinate())
};
formatter.append(points, WKTUtilities.suggestFractionDigits(getCoordinateReferenceSystem(), points));
final int dimension = getDimension();
@@ -1300,7 +1299,7 @@
/**
* Base class for unmodifiable direct positions backed by the enclosing envelope.
- * Subclasses must override the {@link #getCoordinate(int)} method in order to delegate
+ * Subclasses must override the {@link #getOrdinate(int)} method in order to delegate
* the work to the appropriate {@link AbstractEnvelope} method.
*
* <p>Instance of this class are serializable if the enclosing envelope is serializable.</p>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ArrayEnvelope.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ArrayEnvelope.java
index b738116..e41f042 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ArrayEnvelope.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ArrayEnvelope.java
@@ -27,8 +27,7 @@
import java.io.Serializable;
import org.opengis.geometry.Envelope;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.referencing.cs.RangeMeaning;
import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -101,10 +100,10 @@
* @param lowerCorner the limits in the direction of decreasing coordinate values for each dimension.
* @param upperCorner the limits in the direction of increasing coordinate values for each dimension.
* @throws MismatchedDimensionException if the two positions do not have the same dimension.
- * @throws MismatchedCoordinateMetadataException if the CRS of the two position are not equal.
+ * @throws MismatchedReferenceSystemException if the CRS of the two position are not equal.
*/
public ArrayEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
- throws MismatchedDimensionException, MismatchedCoordinateMetadataException
+ throws MismatchedDimensionException, MismatchedReferenceSystemException
{
crs = getCommonCRS(lowerCorner, upperCorner); // This performs also an argument check.
final int dimension = lowerCorner.getDimension();
@@ -112,8 +111,8 @@
ensureSameDimension(dimension, upperCorner.getDimension());
coordinates = new double[dimension * 2];
for (int i=0; i<dimension; i++) {
- coordinates[i ] = lowerCorner.getCoordinate(i);
- coordinates[i + dimension] = upperCorner.getCoordinate(i);
+ coordinates[i ] = lowerCorner.getOrdinate(i);
+ coordinates[i + dimension] = upperCorner.getOrdinate(i);
}
verifyRanges(crs, coordinates);
}
@@ -170,8 +169,8 @@
final DirectPosition lowerCorner = envelope.getLowerCorner();
final DirectPosition upperCorner = envelope.getUpperCorner();
for (int i=0; i<dimension; i++) {
- coordinates[i] = lowerCorner.getCoordinate(i);
- coordinates[i+dimension] = upperCorner.getCoordinate(i);
+ coordinates[i] = lowerCorner.getOrdinate(i);
+ coordinates[i+dimension] = upperCorner.getOrdinate(i);
}
verifyRanges(crs, coordinates);
}
@@ -312,7 +311,7 @@
*/
static void ensureSameDimension(final int dim1, final int dim2) throws MismatchedDimensionException {
if (dim1 != dim2) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_2, dim1, dim2));
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/CoordinateFormat.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/CoordinateFormat.java
index 182ace9..e7a6e4b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/CoordinateFormat.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/CoordinateFormat.java
@@ -1462,7 +1462,7 @@
*/
final int dimension = position.getDimension();
for (int i=0; i < dimension; i++) {
- double value = position.getCoordinate(i);
+ double value = position.getOrdinate(i);
final Object valueObject;
final String unit, direction;
final Format f;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition1D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition1D.java
index 3dfdbfa..079e9de 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition1D.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition1D.java
@@ -26,7 +26,7 @@
import java.io.Serializable;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
@@ -212,7 +212,7 @@
public void setLocation(final DirectPosition position) throws MismatchedDimensionException {
ensureDimensionMatches("position", 1, position);
setCoordinateReferenceSystem(position.getCoordinateReferenceSystem());
- coordinate = position.getCoordinate(0);
+ coordinate = position.getOrdinate(0);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition2D.java
index b091bdf..93c57c1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition2D.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/DirectPosition2D.java
@@ -26,8 +26,8 @@
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -150,8 +150,8 @@
*/
public DirectPosition2D(final DirectPosition position) throws MismatchedDimensionException {
ensureDimensionMatches("position", 2, position);
- x = position.getCoordinate(0);
- y = position.getCoordinate(1);
+ x = position.getOrdinate(0);
+ y = position.getOrdinate(1);
crs = position.getCoordinateReferenceSystem();
}
@@ -183,6 +183,16 @@
}
/**
+ * Returns this direct position.
+ *
+ * @return {@code this}.
+ */
+ @Override
+ public final DirectPosition getDirectPosition() {
+ return this;
+ }
+
+ /**
* The length of coordinate sequence (the number of entries).
* This is always 2 for {@code DirectPosition2D} objects.
*
@@ -222,10 +232,24 @@
* This method is final for ensuring consistency with the {@code x} and {@code y} fields, which are public.</div>
*
* @return the coordinate.
+ * @deprecated Renamed {@link #getCoordinates()} for consistency with ISO 19111 terminology.
+ */
+ @Override
+ @Deprecated(since="1.5")
+ public final double[] getCoordinate() {
+ return getCoordinates();
+ }
+
+ /**
+ * Returns a sequence of numbers that hold the coordinate of this position in its reference system.
+ *
+ * <div class="note"><b>API note:</b>
+ * This method is final for ensuring consistency with the {@code x} and {@code y} fields, which are public.</div>
+ *
+ * @return the coordinate.
*
* @since 1.5
*/
- @Override
public final double[] getCoordinates() {
return new double[] {x,y};
}
@@ -239,10 +263,26 @@
* @param dimension the dimension in the range 0 to 1 inclusive.
* @return the coordinate at the specified dimension.
* @throws IndexOutOfBoundsException if the specified dimension is out of bounds.
+ * @deprecated Renamed {@link #getCoordinate(int)} for consistency with ISO 19111 terminology.
+ */
+ @Override
+ @Deprecated(since="1.5")
+ public final double getOrdinate(final int dimension) throws IndexOutOfBoundsException {
+ return getCoordinate(dimension);
+ }
+
+ /**
+ * Returns the coordinate at the specified dimension.
+ *
+ * <div class="note"><b>API note:</b>
+ * This method is final for ensuring consistency with the {@code x} and {@code y} fields, which are public.</div>
+ *
+ * @param dimension the dimension in the range 0 to 1 inclusive.
+ * @return the coordinate at the specified dimension.
+ * @throws IndexOutOfBoundsException if the specified dimension is out of bounds.
*
* @since 1.5
*/
- @Override
public final double getCoordinate(final int dimension) throws IndexOutOfBoundsException {
switch (dimension) {
case 0: return x;
@@ -257,10 +297,23 @@
* @param dimension the dimension for the coordinate of interest.
* @param value the coordinate value of interest.
* @throws IndexOutOfBoundsException if the specified dimension is out of bounds.
+ * @deprecated Renamed {@link #setCoordinate(int, double)} for consistency with ISO 19111 terminology.
+ */
+ @Override
+ @Deprecated(since="1.5")
+ public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException {
+ setCoordinate(dimension, value);
+ }
+
+ /**
+ * Sets the coordinate value along the specified dimension.
+ *
+ * @param dimension the dimension for the coordinate of interest.
+ * @param value the coordinate value of interest.
+ * @throws IndexOutOfBoundsException if the specified dimension is out of bounds.
*
* @since 1.5
*/
- @Override
public void setCoordinate(int dimension, double value) throws IndexOutOfBoundsException {
switch (dimension) {
case 0: x = value; break;
@@ -334,8 +387,8 @@
if (object instanceof DirectPosition) {
final DirectPosition other = (DirectPosition) object;
if (other.getDimension() == 2 &&
- doubleToLongBits(other.getCoordinate(0)) == doubleToLongBits(x) &&
- doubleToLongBits(other.getCoordinate(1)) == doubleToLongBits(y) &&
+ doubleToLongBits(other.getOrdinate(0)) == doubleToLongBits(x) &&
+ doubleToLongBits(other.getOrdinate(1)) == doubleToLongBits(y) &&
Objects.equals(other.getCoordinateReferenceSystem(), crs))
{
assert hashCode() == other.hashCode() : this;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelope2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelope2D.java
index e676c4e..f159622 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelope2D.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelope2D.java
@@ -40,9 +40,8 @@
import static org.apache.sis.geometry.AbstractEnvelope.isWrapAround;
import static org.apache.sis.geometry.AbstractEnvelope.isNegativeUnsafe;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -157,8 +156,8 @@
* JDK constraint: The call to ensureDimensionMatch(…) should have been first if Sun/Oracle
* fixed RFE #4093999 (Relax constraint on placement of this()/super() call in constructors).
*/
- this(lowerCorner.getCoordinate(0), lowerCorner.getCoordinate(1),
- upperCorner.getCoordinate(0), upperCorner.getCoordinate(1));
+ this(lowerCorner.getOrdinate(0), lowerCorner.getOrdinate(1),
+ upperCorner.getOrdinate(0), upperCorner.getOrdinate(1));
ensureDimensionMatches("crs", DIMENSION, crs);
this.crs = crs;
}
@@ -171,11 +170,11 @@
*
* @param lowerCorner the first position.
* @param upperCorner the second position.
- * @throws MismatchedCoordinateMetadataException if the two positions don't use the same CRS.
+ * @throws MismatchedReferenceSystemException if the two positions don't use the same CRS.
* @throws MismatchedDimensionException if the two positions are not two-dimensional.
*/
public Envelope2D(final DirectPosition lowerCorner, final DirectPosition upperCorner)
- throws MismatchedCoordinateMetadataException, MismatchedDimensionException
+ throws MismatchedReferenceSystemException, MismatchedDimensionException
{
this(AbstractEnvelope.getCommonCRS(lowerCorner, upperCorner), lowerCorner, upperCorner);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
index 789960d..337cc04 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
@@ -680,18 +680,18 @@
if (sourcePt == null) {
sourcePt = new GeneralDirectPosition(dimension);
for (int j=0; j<dimension; j++) {
- sourcePt.setCoordinate(j, envelope.getMedian(j));
+ sourcePt.setOrdinate(j, envelope.getMedian(j));
}
}
if (b1) {
- sourcePt.setCoordinate(i, v1);
+ sourcePt.setOrdinate(i, v1);
transformed.add(targetPt = mt.transform(sourcePt, targetPt));
}
if (b2) {
- sourcePt.setCoordinate(i, v2);
+ sourcePt.setOrdinate(i, v2);
transformed.add(targetPt = mt.transform(sourcePt, targetPt));
}
- sourcePt.setCoordinate(i, envelope.getMedian(i));
+ sourcePt.setOrdinate(i, envelope.getMedian(i));
}
}
}
@@ -794,7 +794,7 @@
targetPt = new GeneralDirectPosition(centerPt.clone());
sourceBox = AbstractEnvelope.castOrCopy(envelope);
}
- targetPt.setCoordinate(i, extremum);
+ targetPt.setOrdinate(i, extremum);
try {
sourcePt = inverse.transform(targetPt, sourcePt);
if (sourceBox.contains(sourcePt)) {
@@ -808,7 +808,7 @@
*/
if (CoordinateOperations.isWrapAround(axis)) {
revertPt = mt.transform(sourcePt, revertPt);
- final double delta = Math.abs(revertPt.getCoordinate(i) - extremum);
+ final double delta = Math.abs(revertPt.getOrdinate(i) - extremum);
if (!(delta < SPAN_FRACTION_AS_BOUND * (axis.getMaximumValue() - axis.getMinimumValue()))) {
continue;
}
@@ -840,7 +840,7 @@
}
// Restore `targetPt` to its initial state, which is equal to `centerPt`.
if (targetPt != null) {
- targetPt.setCoordinate(i, centerPt[i]);
+ targetPt.setOrdinate(i, centerPt[i]);
}
}
/*
@@ -888,12 +888,12 @@
c++; // Skip also the case for "wrapAroundMax".
continue;
}
- targetPt.setCoordinate(axisIndex, (c == 0) ? axis.getMinimumValue() : axis.getMaximumValue());
+ targetPt.setOrdinate(axisIndex, (c == 0) ? axis.getMinimumValue() : axis.getMaximumValue());
value = min;
} else {
value = max;
}
- targetPt.setCoordinate(wrapAroundDimension, value);
+ targetPt.setOrdinate(wrapAroundDimension, value);
try {
sourcePt = inverse.transform(targetPt, sourcePt);
if (sourceBox.contains(sourcePt)) {
@@ -923,9 +923,9 @@
}
}
}
- targetPt.setCoordinate(axisIndex, centerPt[axisIndex]);
+ targetPt.setOrdinate(axisIndex, centerPt[axisIndex]);
}
- targetPt.setCoordinate(wrapAroundDimension, centerPt[wrapAroundDimension]);
+ targetPt.setOrdinate(wrapAroundDimension, centerPt[wrapAroundDimension]);
}
}
/*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralDirectPosition.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralDirectPosition.java
index a5d50e4..58a5e70 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralDirectPosition.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralDirectPosition.java
@@ -27,7 +27,7 @@
import java.io.Serializable;
import java.lang.reflect.Field;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArraysExt;
@@ -135,7 +135,7 @@
* @param point the position to copy.
*/
public GeneralDirectPosition(final DirectPosition point) {
- coordinates = point.getCoordinates(); // Should already be cloned.
+ coordinates = point.getCoordinate(); // Should already be cloned.
crs = point.getCoordinateReferenceSystem();
ensureDimensionMatches("crs", coordinates.length, crs);
}
@@ -292,7 +292,7 @@
ensureDimensionMatches("position", coordinates.length, position);
setCoordinateReferenceSystem(position.getCoordinateReferenceSystem());
for (int i=0; i<coordinates.length; i++) {
- coordinates[i] = position.getCoordinate(i);
+ coordinates[i] = position.getOrdinate(i);
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralEnvelope.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralEnvelope.java
index 0d3086f..13be0b5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralEnvelope.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/GeneralEnvelope.java
@@ -34,8 +34,7 @@
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.geometry.Envelope;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.apache.sis.referencing.privy.TemporalAccessor;
import org.apache.sis.referencing.privy.AxisDirections;
@@ -159,10 +158,10 @@
* @param lowerCorner the limits in the direction of decreasing coordinate values for each dimension.
* @param upperCorner the limits in the direction of increasing coordinate values for each dimension.
* @throws MismatchedDimensionException if the two positions do not have the same dimension.
- * @throws MismatchedCoordinateMetadataException if the CRS of the two position are not equal.
+ * @throws MismatchedReferenceSystemException if the CRS of the two position are not equal.
*/
public GeneralEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
- throws MismatchedDimensionException, MismatchedCoordinateMetadataException
+ throws MismatchedDimensionException, MismatchedReferenceSystemException
{
super(lowerCorner, upperCorner);
}
@@ -386,7 +385,7 @@
}
final int d = corners.length >>> 1;
if (d != dimension) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, "coordinates", dimension, d));
}
}
@@ -424,8 +423,8 @@
for (int i=0; i<dimension; i++) {
final int iLower = beginIndex + i;
final int iUpper = iLower + d;
- coordinates[iLower] = lower.getCoordinate(i);
- coordinates[iUpper] = upper.getCoordinate(i);
+ coordinates[iLower] = lower.getOrdinate(i);
+ coordinates[iUpper] = upper.getOrdinate(i);
}
}
final CoordinateReferenceSystem envelopeCRS = envelope.getCoordinateReferenceSystem();
@@ -563,7 +562,7 @@
for (int i=0; i<dimension; i++) {
final int iLower = beginIndex + i;
final int iUpper = iLower + d;
- final double value = position.getCoordinate(i);
+ final double value = position.getOrdinate(i);
final double min = coordinates[iLower];
final double max = coordinates[iUpper];
if (!isNegative(max - min)) { // Standard case, or NaN.
@@ -670,8 +669,8 @@
final int iUpper = iLower + d;
final double min0 = coordinates[iLower];
final double max0 = coordinates[iUpper];
- final double min1 = lower.getCoordinate(i);
- final double max1 = upper.getCoordinate(i);
+ final double min1 = lower.getOrdinate(i);
+ final double max1 = upper.getOrdinate(i);
final boolean sp0 = isNegative(max0 - min0);
final boolean sp1 = isNegative(max1 - min1);
if (sp0 == sp1) {
@@ -827,8 +826,8 @@
final int iUpper = iLower + d;
final double min0 = coordinates[iLower];
final double max0 = coordinates[iUpper];
- final double min1 = lower.getCoordinate(i);
- final double max1 = upper.getCoordinate(i);
+ final double min1 = lower.getOrdinate(i);
+ final double max1 = upper.getOrdinate(i);
final double span0 = max0 - min0;
final double span1 = max1 - min1;
if (isSameSign(span0, span1)) { // Always `false` if any value is NaN.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ImmutableEnvelope.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ImmutableEnvelope.java
index a47b29e..64fdfee 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ImmutableEnvelope.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/ImmutableEnvelope.java
@@ -25,8 +25,7 @@
import java.io.Serializable;
import org.opengis.geometry.Envelope;
import org.opengis.geometry.DirectPosition;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
+import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.metadata.extent.GeographicBoundingBox;
@@ -60,10 +59,10 @@
* @param lowerCorner the limits in the direction of decreasing coordinate values for each dimension.
* @param upperCorner the limits in the direction of increasing coordinate values for each dimension.
* @throws MismatchedDimensionException if the two positions do not have the same dimension.
- * @throws MismatchedCoordinateMetadataException if the CRS of the two position are not equal.
+ * @throws MismatchedReferenceSystemException if the CRS of the two position are not equal.
*/
public ImmutableEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
- throws MismatchedDimensionException, MismatchedCoordinateMetadataException
+ throws MismatchedDimensionException, MismatchedReferenceSystemException
{
super(lowerCorner, upperCorner);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/MismatchedReferenceSystemException.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/MismatchedReferenceSystemException.java
index 5bfd193..76b034d 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/MismatchedReferenceSystemException.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/MismatchedReferenceSystemException.java
@@ -16,9 +16,6 @@
*/
package org.apache.sis.geometry;
-// Specific to the geoapi-3.1 branch:
-import org.opengis.coordinate.MismatchedCoordinateMetadataException;
-
/**
* Indicates that an object cannot be constructed because of a mismatch in the
@@ -27,11 +24,8 @@
* @author Martin Desruisseaux (IRD)
* @since 0.3
* @version 0.3
- *
- * @deprecated Replaced by {@link MismatchedCoordinateMetadataException}.
*/
-@Deprecated(since = "2.0") // Temporary version number until this branch is released.
-public class MismatchedReferenceSystemException extends MismatchedCoordinateMetadataException {
+public class MismatchedReferenceSystemException extends IllegalArgumentException {
/**
* Serial number for inter-operability with different versions.
*/
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/UnmodifiableGeometryException.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/UnmodifiableGeometryException.java
new file mode 100644
index 0000000..d27549a
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/UnmodifiableGeometryException.java
@@ -0,0 +1,53 @@
+/*
+ * 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.geometry;
+
+
+/**
+ * Indicates that an operation is not allowed on a geometry object
+ * because it is unmodifiable. Note that unmodifiable geometries are not necessarily immutable;
+ * they are just not allowed to be modified through the {@code setFoo(...)} method that
+ * raised this exception. Whatever an unmodifiable geometry is immutable or not is
+ * implementation dependent.
+ *
+ * @author Martin Desruisseaux (IRD)
+ * @since 0.3
+ * @version 0.3
+ */
+public class UnmodifiableGeometryException extends UnsupportedOperationException {
+ /**
+ * Serial number for inter-operability with different versions.
+ */
+ private static final long serialVersionUID = 8679047625299612669L;
+
+ /**
+ * Creates an exception with no message.
+ */
+ public UnmodifiableGeometryException() {
+ super();
+ }
+
+ /**
+ * Creates an exception with the specified message.
+ *
+ * @param message The detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public UnmodifiableGeometryException(final String message) {
+ super(message);
+ }
+}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
index c4cbca0..b593574 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
@@ -193,7 +193,7 @@
try {
return CRS.findOperation(source, target, geographicDomain);
} catch (FactoryException e) {
- throw new TransformException(e);
+ throw new TransformException(e.getMessage(), e);
}
}
@@ -369,8 +369,8 @@
* how many periods we need to add to those values. We adjust the side which results in the value closest
* to zero, in order to reduce rounding error if no more adjustment is done in the next block.
*/
- final double lower = lowerCorner.getCoordinate(i);
- final double upper = upperCorner.getCoordinate(i);
+ final double lower = lowerCorner.getOrdinate(i);
+ final double upper = upperCorner.getOrdinate(i);
double lowerCycles = 0; // In number of periods.
double upperCycles = 0;
double delta = upper - lower;
@@ -531,7 +531,7 @@
for (int i=0; i<periods.length; i++) {
final double period = periods[i];
if (period > 0) {
- final double x = shifted.getCoordinate(i);
+ final double x = shifted.getOrdinate(i);
double delta = shiftableDomain.getMinimum(i) - x;
if (delta > 0) { // Test for point before domain of validity.
delta = Math.ceil(delta / period);
@@ -549,7 +549,7 @@
shifted = new GeneralDirectPosition(pointOfInterest);
}
pointOfInterest = shifted; // `shifted` may have been set before the loop.
- shifted.setCoordinate(i, Math.fma(period, delta, x));
+ shifted.setOrdinate(i, Math.fma(period, delta, x));
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/ElementKind.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/ElementKind.java
index 68f1f85..6c5649a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/ElementKind.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/ElementKind.java
@@ -27,8 +27,8 @@
import org.opengis.parameter.GeneralParameterValue;
import org.apache.sis.util.Numbers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -157,7 +157,7 @@
* <caption>Mapping from Java type to WKT element</caption>
* <tr><th>Base type</th> <th>Kind</th></tr>
* <tr><td>{@link Datum}</td> <td>{@link #DATUM}</td></tr>
- * <tr><td>{@link DatumEnsemble}</td> <td>{@link #ENSEMBLE}</td></tr>
+ * <tr><td>{@link DefaultDatumEnsemble}</td> <td>{@link #ENSEMBLE}</td></tr>
* <tr><td>{@link OperationMethod}</td> <td>{@link #METHOD}</td></tr>
* <tr><td>{@link GeneralParameterValue}</td> <td>{@link #PARAMETER}</td></tr>
* <tr><td>{@link CoordinateSystemAxis}</td> <td>{@link #AXIS}</td></tr>
@@ -178,7 +178,7 @@
public static ElementKind forType(final Class<?> type) {
if (type != null) {
if (Datum .class.isAssignableFrom(type)) return DATUM;
- if (DatumEnsemble .class.isAssignableFrom(type)) return ENSEMBLE;
+ if (DefaultDatumEnsemble .class.isAssignableFrom(type)) return ENSEMBLE;
if (OperationMethod .class.isAssignableFrom(type)) return METHOD;
if (GeneralParameterValue.class.isAssignableFrom(type)) return PARAMETER;
if (CoordinateSystemAxis .class.isAssignableFrom(type)) return AXIS;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Formatter.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Formatter.java
index 7f94cdd..053a637 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Formatter.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Formatter.java
@@ -88,9 +88,12 @@
import org.apache.sis.geometry.AbstractEnvelope;
import org.apache.sis.xml.NilObject;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.referencing.DefaultObjectDomain;
+import org.apache.sis.referencing.internal.Legacy;
+import org.apache.sis.referencing.datum.AbstractDatum;
/**
@@ -855,17 +858,17 @@
appendForSubtypes(object);
}
if (showIDs) {
- Collection<? extends Identifier> identifiers = object.getIdentifiers();
+ Collection<ReferenceIdentifier> identifiers = object.getIdentifiers();
if (identifiers != null) { // Paranoiac check
if (filterID) {
- for (final Identifier id : identifiers) {
+ for (final ReferenceIdentifier id : identifiers) {
if (Citations.identifierMatches(authority, id.getAuthority())) {
identifiers = Set.of(id);
break;
}
}
}
- for (Identifier id : identifiers) {
+ for (ReferenceIdentifier id : identifiers) {
if (!(id instanceof FormattableObject)) {
id = ImmutableIdentifier.castOrCopy(id);
}
@@ -888,12 +891,12 @@
private void appendForSubtypes(final IdentifiedObject object) {
InternationalString anchor = null, scope = null;
Extent area = null;
- if (object instanceof Datum) {
- anchor = ((Datum) object).getAnchorDefinition().orElse(null);
+ if (object instanceof AbstractDatum) {
+ anchor = ((AbstractDatum) object).getAnchorPoint();
} else if (!(object instanceof ReferenceSystem || object instanceof CoordinateOperation)) {
return;
}
- for (final ObjectDomain domain : object.getDomains()) {
+ for (final DefaultObjectDomain domain : Legacy.getDomains(object)) {
scope = domain.getScope();
area = domain.getDomainOfValidity();
if (area != null) break;
@@ -905,7 +908,7 @@
/**
* Appends the usage (scope and domain of validity) of an object.
- * The arguments are the components of an {@link ObjectDomain}.
+ * The arguments are the components of an {@link DefaultObjectDomain}.
* The given extent is decomposed in horizontal, vertical and temporal components.
* The horizontal component uses the default number of fraction digits recommended by ISO 19162.
*
@@ -1182,7 +1185,7 @@
*
* @param code the code list to append to the WKT, or {@code null} if none.
*/
- public void append(final ControlledVocabulary code) {
+ public void append(final CodeList<?> code) {
if (code != null) {
appendSeparator();
final String name = convention.majorVersion() == 1 ? code.name() : Types.getCodeName(code);
@@ -1609,15 +1612,12 @@
} else {
append(number.doubleValue());
}
- } else if (value instanceof ControlledVocabulary) {
- append((ControlledVocabulary) value);
- } else if (value instanceof Date) {
- append((Date) value);
- } else if (value instanceof Temporal) {
- append((Temporal) value);
- } else if (value instanceof Boolean) {
- append((Boolean) value);
- } else if (value instanceof CharSequence) {
+ }
+ else if (value instanceof CodeList<?>) append((CodeList<?>) value);
+ else if (value instanceof Date) append((Date) value);
+ else if (value instanceof Temporal) append((Temporal) value);
+ else if (value instanceof Boolean) append((Boolean) value);
+ else if (value instanceof CharSequence) {
append((value instanceof InternationalString) ?
((InternationalString) value).toString(locale) : value.toString(), null);
} else if (value.getClass().isArray()) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
index e473ae0..4e1266c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -87,8 +87,11 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceSystem;
+import org.apache.sis.referencing.internal.ServicesForMetadata;
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.temporal.TemporalDate;
/**
@@ -103,6 +106,14 @@
*/
@SuppressWarnings("LocalVariableHidesMemberVariable") // We hide with the same value made final.
class GeodeticObjectParser extends MathTransformParser implements Comparator<CoordinateSystemAxis> {
+ /*
+ * Force class initialization of `AxisDirections` in order to have
+ * its constants added to the list of know `AxisDirection` values.
+ */
+ static {
+ AxisDirections.AWAY_FROM.toString();
+ }
+
/**
* The names of the 7 parameters in a {@code TOWGS84[…]} element.
* Those names are derived from the <cite>Well Known Text</cite> (WKT) version 1 specification.
@@ -476,7 +487,7 @@
*/
element = parent.pullElement(OPTIONAL, WKTKeywords.Scope);
if (element != null) {
- properties.put(ObjectDomain.SCOPE_KEY, element.pullString("scope"));
+ properties.put(ReferenceSystem.SCOPE_KEY, element.pullString("scope")); // Other types like Datum use the same key.
element.close(ignoredElements);
}
/*
@@ -541,7 +552,7 @@
}
}
if (extent != null) {
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, extent);
+ properties.put(ReferenceSystem.DOMAIN_OF_VALIDITY_KEY, extent);
}
/*
* Example: REMARK["Замечание на русском языке"]
@@ -567,7 +578,7 @@
final Element anchor = element.pullElement(OPTIONAL, WKTKeywords.Anchor);
final Map<String,Object> properties = parseMetadataAndClose(element, name, null);
if (anchor != null) {
- properties.put(Datum.ANCHOR_DEFINITION_KEY, anchor.pullString("anchorDefinition"));
+ properties.put(Datum.ANCHOR_POINT_KEY, anchor.pullString(DefaultGeodeticDatum.ANCHOR_DEFINITION_KEY));
anchor.close(ignoredElements);
}
return properties;
@@ -829,11 +840,11 @@
nz = "Height";
direction = AxisDirection.UP;
if (datum instanceof VerticalDatum) {
- final RealizationMethod vt = ((VerticalDatum) datum).getRealizationMethod().orElse(null);
- if (vt == RealizationMethod.GEOID) {
+ final VerticalDatumType vt = ((VerticalDatum) datum).getVerticalDatumType();
+ if (vt == VerticalDatumType.GEOIDAL) {
nz = AxisNames.GRAVITY_RELATED_HEIGHT;
z = "H";
- } else if (vt == RealizationMethod.TIDAL) {
+ } else if (vt == VerticalDatumType.DEPTH) {
direction = AxisDirection.DOWN;
nz = AxisNames.DEPTH;
z = "D";
@@ -864,7 +875,7 @@
if (defaultUnit == null) {
throw parent.missingComponent(WKTKeywords.ParametricUnit);
}
- direction = AxisDirection.UNSPECIFIED;
+ direction = AxisDirections.UNSPECIFIED;
nz = "Parametric";
z = "p";
break;
@@ -924,7 +935,10 @@
}
case WKTKeywords.spherical: {
switch (axes.length) {
- case 2: return csFactory.createSphericalCS(csProperties, axes[0], axes[1]);
+ case 2: if (csFactory instanceof GeodeticObjectFactory) {
+ return ((GeodeticObjectFactory) csFactory).createSphericalCS(csProperties, axes[0], axes[1]);
+ }
+ break;
case 3: return csFactory.createSphericalCS(csProperties, axes[0], axes[1], axes[2]);
}
dimension = (axes.length < 2) ? 2 : 3; // For error message.
@@ -968,7 +982,7 @@
}
case WKTKeywords.parametric: {
if (axes.length != (dimension = 1)) break;
- return csFactory.createParametricCS(csProperties, axes[0]);
+ return ServicesForMetadata.createParametricCS(csProperties, axes[0], csFactory);
}
default: {
warning(parent, WKTKeywords.CS, Errors.formatInternational(Errors.Keys.UnknownType_1, type), null);
@@ -1285,9 +1299,10 @@
* not use the identifier.
*/
FactoryException suppressed = null;
- if (id != null) try {
+ if (id instanceof ReferenceIdentifier) try {
// CodeSpace is a mandatory attribute in ID[…] elements, so we do not test for null values.
- return factories.findOperationMethod(id.getCodeSpace() + Constants.DEFAULT_SEPARATOR + id.getCode());
+ final var rid = (ReferenceIdentifier) id;
+ return factories.findOperationMethod(rid.getCodeSpace() + Constants.DEFAULT_SEPARATOR + rid.getCode());
} catch (FactoryException e) {
suppressed = e;
}
@@ -1444,7 +1459,7 @@
return null;
}
final String name = element.pullString("name");
- RealizationMethod method = null;
+ VerticalDatumType method = null;
if (isWKT1) {
method = VerticalDatumTypes.fromLegacyCode(element.pullInteger("datum"));
}
@@ -1482,7 +1497,7 @@
origin.close(ignoredElements);
final DatumFactory datumFactory = factories.getDatumFactory();
try {
- return datumFactory.createTemporalDatum(parseAnchorAndClose(element, name), epoch);
+ return datumFactory.createTemporalDatum(parseAnchorAndClose(element, name), TemporalDate.toDate(epoch));
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1497,10 +1512,10 @@
*
* @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
* @param parent the parent element.
- * @return the {@code "ParametricDatum"} element as a {@link ParametricDatum} object.
+ * @return the {@code "ParametricDatum"} element as a {@code ParametricDatum} object.
* @throws ParseException if the {@code "ParametricDatum"} element cannot be parsed.
*/
- private ParametricDatum parseParametricDatum(final int mode, final Element parent) throws ParseException {
+ private Datum parseParametricDatum(final int mode, final Element parent) throws ParseException {
final Element element = parent.pullElement(mode, WKTKeywords.ParametricDatum, WKTKeywords.PDatum);
if (element == null) {
return null;
@@ -1508,7 +1523,7 @@
final String name = element.pullString("name");
final DatumFactory datumFactory = factories.getDatumFactory();
try {
- return datumFactory.createParametricDatum(parseAnchorAndClose(element, name));
+ return ServicesForMetadata.createParametricDatum(parseAnchorAndClose(element, name), datumFactory);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1561,7 +1576,6 @@
* @return the {@code "ImageDatum"} element.
* @throws ParseException if the {@code "ImageDatum"} element cannot be parsed.
*/
- @SuppressWarnings("removal")
private ImageDatum parseImageDatum(final int mode, final Element parent) throws ParseException {
final Element element = parent.pullElement(mode, WKTKeywords.ImageDatum, WKTKeywords.IDatum);
if (element == null) {
@@ -1668,7 +1682,6 @@
* @return the {@code "ImageCRS"} element as an {@link ImageCRS} object.
* @throws ParseException if the {@code "ImageCRS"} element cannot be parsed.
*/
- @SuppressWarnings("removal")
private ImageCRS parseImageCRS(final int mode, final Element parent) throws ParseException {
final Element element = parent.pullElement(mode, WKTKeywords.ImageCRS);
if (element == null) {
@@ -1851,17 +1864,16 @@
}
final PrimeMeridian meridian = parsePrimeMeridian(OPTIONAL, element, isWKT1, longitudeUnit);
final GeodeticDatum datum = parseDatum(MANDATORY, element, meridian);
- final DatumEnsemble<GeodeticDatum> datumEnsemble = null; // TODO
final Map<String,?> properties = parseMetadataAndClose(element, name, datum);
if (cs instanceof EllipsoidalCS) { // By far the most frequent case.
- return crsFactory.createGeographicCRS(properties, datum, datumEnsemble, (EllipsoidalCS) cs);
+ return crsFactory.createGeographicCRS(properties, datum, (EllipsoidalCS) cs);
}
if (cs instanceof CartesianCS) { // The second most frequent case.
- return crsFactory.createGeodeticCRS(properties, datum, datumEnsemble,
+ return crsFactory.createGeocentricCRS(properties, datum,
Legacy.forGeocentricCRS((CartesianCS) cs, false));
}
if (cs instanceof SphericalCS) { // Not very common case.
- return crsFactory.createGeodeticCRS(properties, datum, datumEnsemble, (SphericalCS) cs);
+ return crsFactory.createGeocentricCRS(properties, datum, (SphericalCS) cs);
}
} catch (FactoryException exception) {
throw element.parseFailed(exception);
@@ -1939,9 +1951,9 @@
* But sometimes the axis (which was not available when we created the datum) provides
* more information. Verify if we can have a better type now, and if so rebuild the datum.
*/
- if (datum.getRealizationMethod().isEmpty()) {
+ if (datum.getVerticalDatumType() == VerticalDatumType.OTHER_SURFACE) {
var type = VerticalDatumTypes.fromDatum(datum.getName().getCode(), datum.getAlias(), cs.getAxis(0));
- if (type != null) {
+ if (type != VerticalDatumType.OTHER_SURFACE) {
final DatumFactory datumFactory = factories.getDatumFactory();
datum = datumFactory.createVerticalDatum(IdentifiedObjects.getProperties(datum), type);
}
@@ -2045,8 +2057,7 @@
* A ParametricCRS can be either a "normal" one (with a non-null datum), or a DerivedCRS of kind ParametricCRS.
* In the latter case, the datum is null and we have instead DerivingConversion element from a BaseParametricCRS.
*/
- ParametricDatum datum = null;
- DatumEnsemble<ParametricDatum> datumEnsemble = null; // TODO
+ Datum datum = null;
SingleCRS baseCRS = null;
Conversion fromBase = null;
if (!isBaseCRS) {
@@ -2072,12 +2083,12 @@
try {
cs = parseCoordinateSystem(element, WKTKeywords.parametric, 1, false, unit, datum);
final Map<String,?> properties = parseMetadataAndClose(element, name, datum);
- if (cs instanceof ParametricCS) {
+ if (cs != null) {
final CRSFactory crsFactory = factories.getCRSFactory();
if (baseCRS != null) {
return crsFactory.createDerivedCRS(properties, baseCRS, fromBase, cs);
}
- return crsFactory.createParametricCRS(properties, datum, datumEnsemble, (ParametricCS) cs);
+ return ServicesForMetadata.createParametricCRS(properties, datum, cs, crsFactory);
}
} catch (FactoryException exception) {
throw element.parseFailed(exception);
@@ -2252,7 +2263,7 @@
buffer.append(number);
axes[i] = csFactory.createCoordinateSystemAxis(
singletonMap(CoordinateSystemAxis.NAME_KEY, buffer.toString()),
- number, AxisDirection.UNSPECIFIED, Units.UNITY);
+ number, AxisDirections.UNSPECIFIED, Units.UNITY);
}
final Map<String,Object> properties = parseMetadataAndClose(element, name, baseCRS);
final Map<String,Object> axisName = singletonMap(CoordinateSystem.NAME_KEY, AxisDirections.appendTo(new StringBuilder("CS"), axes));
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/MathTransformParser.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/MathTransformParser.java
index 0226437..f2869be 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/MathTransformParser.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/MathTransformParser.java
@@ -47,6 +47,10 @@
import org.apache.sis.measure.UnitFormat;
import org.apache.sis.measure.Units;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.CoordinateOperations;
+import org.apache.sis.referencing.operation.transform.MathTransformBuilder;
+
/**
* Well Known Text (WKT) parser for {@linkplain MathTransform math transform}s.
@@ -56,7 +60,7 @@
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Rueben Schulz (UBC)
*
- * @see <a href="http://www.geoapi.org/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html">Well Know Text specification</a>
+ * @see <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html">Well Know Text specification</a>
*/
class MathTransformParser extends AbstractParser {
/**
@@ -415,9 +419,9 @@
return null;
}
classification = element.pullString("classification");
- final MathTransform.Builder builder;
+ final MathTransformBuilder builder;
try {
- builder = factories.getMathTransformFactory().builder(classification);
+ builder = CoordinateOperations.builder(factories.getMathTransformFactory(), classification);
} catch (NoSuchIdentifierException exception) {
throw element.parseFailed(exception);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java
index 89bd846..9a58284 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java
@@ -32,8 +32,8 @@
import org.apache.sis.metadata.iso.extent.DefaultExtent;
import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
/**
@@ -97,7 +97,7 @@
* This method invokes {@link DefaultVerticalExtent#setVerticalCRS(VerticalCRS)} with the given CRS if:
*
* <ul>
- * <li>realization method is {@link RealizationMethod#GEOID},</li>
+ * <li>datum type is {@link VerticalDatumType#GEOIDAL},</li>
* <li>increasing height values are up, and</li>
* <li>axis unit of measurement is the given linear unit.</li>
* </ul>
@@ -109,7 +109,7 @@
*/
final VerticalInfo resolve(final VerticalCRS crs) {
if (crs != null) {
- if (DatumOrEnsemble.asDatum(crs).getRealizationMethod().orElse(null) == RealizationMethod.GEOID) {
+ if (DatumOrEnsemble.asDatum(crs).getVerticalDatumType() == VerticalDatumType.GEOIDAL) {
return resolve(crs, crs.getCoordinateSystem().getAxis(0));
}
}
@@ -139,7 +139,7 @@
* The CRS created by this method is implementation-dependent. The only guarantees are:
*
* <ul>
- * <li>realization method is {@link RealizationMethod#GEOID},</li>
+ * <li>datum type is {@link VerticalDatumType#GEOIDAL},</li>
* <li>increasing height values are up, and</li>
* <li>axis unit of measurement is the given linear unit.</li>
* </ul>
@@ -183,8 +183,7 @@
*/
final VerticalCS cs = csFactory.createVerticalCS (properties(axis.getName()), axis);
extent.setVerticalCRS(crsFactory.createVerticalCRS(properties((isUP ? compatibleCRS : axis).getName()),
- compatibleCRS.getDatum(),
- compatibleCRS.getDatumEnsemble(),
+ DatumOrEnsemble.asDatum(compatibleCRS),
cs));
return next;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTDictionary.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTDictionary.java
index fdbf241..950fc0e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTDictionary.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTDictionary.java
@@ -58,8 +58,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.FrequencySortedSet;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -255,7 +255,7 @@
* Identifier should never be null because `WKTDictionary` accepts only definitions having
* an `ID[…]` or `AUTHORITY[…]` element. A WKT can contain at most one of those elements.
*/
- final Identifier id = CollectionsExt.first(object.getIdentifiers());
+ final ReferenceIdentifier id = CollectionsExt.first(object.getIdentifiers());
codespace = id.getCodeSpace();
version = id.getVersion();
value = object;
@@ -755,7 +755,7 @@
* @throws FactoryException if parsing failed.
*/
private IdentifiedObject parseAndAdd(final String codespace, final String version,
- final String code, final String wkt, final Identifier defaultIdentifier) throws FactoryException
+ final String code, final String wkt, final DefaultIdentifier defaultIdentifier) throws FactoryException
{
ArgumentChecks.ensureNonEmpty("code", code);
ArgumentChecks.ensureNonEmpty("wkt", wkt);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTFormat.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTFormat.java
index 62390ce..e611416 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTFormat.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/WKTFormat.java
@@ -61,8 +61,8 @@
import org.apache.sis.referencing.ImmutableIdentifier;
import org.apache.sis.referencing.privy.ReferencingFactoryContainer;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.DefaultIdentifier;
/**
@@ -226,9 +226,9 @@
* <p>This field is transient because this is not yet a public API. The {@code transient}
* keyword may be removed in a future version if we commit to this API.</p>
*
- * @see #setDefaultIdentifier(Identifier)
+ * @see #setDefaultIdentifier(DefaultIdentifier)
*/
- private transient Identifier defaultIdentifier;
+ private transient DefaultIdentifier defaultIdentifier;
/**
* WKT fragments that can be inserted in longer WKT strings, or {@code null} if none. Keys are short identifiers
@@ -714,7 +714,7 @@
*
* @param identifier the default identifier, or {@code null} if none.
*/
- final void setDefaultIdentifier(final Identifier identifier) {
+ final void setDefaultIdentifier(final DefaultIdentifier identifier) {
defaultIdentifier = identifier;
}
@@ -1059,7 +1059,10 @@
@Override String getFacadeMethod() {return "parse";}
/** Invoked when an identifier need to be supplied to root {@link IdentifiedObject}. */
- @Override public Object apply(Object key) {return new ImmutableIdentifier(defaultIdentifier);}
+ @Override public Object apply(Object key) {
+ return new ImmutableIdentifier(defaultIdentifier.getAuthority(), defaultIdentifier.getCodeSpace(),
+ defaultIdentifier.getCode(), defaultIdentifier.getVersion(), defaultIdentifier.getDescription());
+ }
/** Invoked when a root {@link IdentifiedObject} is about to be created. */
@Override void completeRoot(final Map<String,Object> properties) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/AbstractParameterDescriptor.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/AbstractParameterDescriptor.java
index 8af3850..777b2f5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/AbstractParameterDescriptor.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/AbstractParameterDescriptor.java
@@ -33,10 +33,6 @@
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.xml.bind.referencing.CC_GeneralOperationParameter.DEFAULT_OCCURRENCE;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Objects;
-import static org.apache.sis.util.Utilities.deepEquals;
-
/**
* Abstract definition of a parameter or group of parameters used by a coordinate operation or a process.
@@ -67,7 +63,7 @@
* <td class="sep">{@code description}</td>
* <td class="sep">Also known as “definition”.</td>
* </tr><tr>
- * <td>{@link #getDirection()}</td>
+ * <td>{@code getDirection()}</td>
* <td class="sep"></td>
* <td class="sep"></td>
* <td class="sep">{@code direction}</td>
@@ -141,7 +137,7 @@
* </tr>
* <tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr>
* <tr>
@@ -151,7 +147,7 @@
* </tr>
* <tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr>
* <tr>
@@ -261,9 +257,7 @@
default: {
final GeneralParameterDescriptor that = (GeneralParameterDescriptor) object;
return getMinimumOccurs() == that.getMinimumOccurs() &&
- getMaximumOccurs() == that.getMaximumOccurs() &&
- Objects.equals(getDirection(), that.getDirection()) &&
- deepEquals(getDescription(), that.getDescription(), mode);
+ getMaximumOccurs() == that.getMaximumOccurs();
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
index 04612d3..fe773ce 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
@@ -138,7 +138,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -146,10 +146,10 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>"description"</td>
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link #getDescription()}</td>
* </tr><tr>
@@ -326,7 +326,6 @@
*
* @since 1.3
*/
- @Override
public TypeName getValueType() {
return QualityParameter.getValueType(valueClass);
}
@@ -510,7 +509,6 @@
return getMinimumOccurs() == that.getMinimumOccurs() &&
getMaximumOccurs() == that.getMaximumOccurs() &&
getValueClass() == that.getValueClass() &&
- Utilities.deepEquals(getValueType(), that.getValueType(), mode) &&
Objects. equals(getValidValues(), that.getValidValues()) &&
Objects. equals(getMinimumValue(), that.getMinimumValue()) &&
Objects. equals(getMaximumValue(), that.getMaximumValue()) &&
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
index 0a99960..fcd7c87 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
@@ -39,9 +39,6 @@
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.Utilities.deepEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.parameter.ParameterDirection;
-
/**
* The definition of a group of related parameters used by an operation method.
@@ -124,7 +121,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -132,10 +129,10 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>"description"</td>
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link #getDescription()}</td>
* </tr><tr>
@@ -318,31 +315,6 @@
}
/**
- * Returns an indication if all parameters in this group are inputs to the service, outputs or both.
- * If this group contains parameters with different direction, then this method returns {@code null}.
- *
- * @return indication if all parameters are inputs or outputs to the service, or {@code null} if undetermined.
- */
- @Override
- public ParameterDirection getDirection() {
- ParameterDirection dir = null;
- for (final GeneralParameterDescriptor param : descriptors) {
- final ParameterDirection c = param.getDirection();
- if (c == null) {
- return null;
- }
- if (c != dir) {
- if (dir == null) {
- dir = c;
- } else {
- return null;
- }
- }
- }
- return dir;
- }
-
- /**
* Returns all parameters in this group.
*
* @return the parameter descriptors in this group.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterFormat.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterFormat.java
index 6049b10..2b5d21d 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterFormat.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterFormat.java
@@ -62,8 +62,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -341,7 +341,7 @@
/**
* Filters names, aliases and identifiers by their code spaces. If the given array is non-null, then the only names,
- * aliases and identifiers to be formatted are those having a {@link Identifier#getCodeSpace()},
+ * aliases and identifiers to be formatted are those having a {@link ReferenceIdentifier#getCodeSpace()},
* {@link ScopedName#head()} or {@link GenericName#scope()} value in the given list, unless no name or alias
* matches this criterion.
*
@@ -720,8 +720,8 @@
configure((NumberFormat) format, Math.abs(((Number) value).doubleValue()));
}
text = format.format(value, buffer, dummyFP);
- } else if (value instanceof ControlledVocabulary) {
- text = Types.getCodeTitle((ControlledVocabulary) value).toString(getLocale());
+ } else if (value instanceof CodeList<?>) {
+ text = Types.getCodeTitle((CodeList<?>) value).toString(getLocale());
} else if (value instanceof InternationalString) {
text = ((InternationalString) value).toString(getLocale());
} else {
@@ -846,7 +846,7 @@
final Set<ReferenceIdentifier> identifiers = object.getIdentifiers();
if (identifiers != null) { // Paranoiac check.
Identifier identifier = null;
- for (final Identifier candidate : identifiers) {
+ for (final ReferenceIdentifier candidate : identifiers) {
if (candidate != null) { // Paranoiac check.
if (isPreferredCodespace(candidate.getCodeSpace())) {
identifier = candidate;
@@ -867,7 +867,7 @@
* in the current row and clear the 'name' locale variable. Otherwise, keep the 'name'
* locale variable in case we found no alias to format.
*/
- Identifier name = object.getName();
+ ReferenceIdentifier name = object.getName();
if (name != null) { // Paranoiac check.
final String codespace = name.getCodeSpace();
if (isPreferredCodespace(codespace)) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterTableRow.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterTableRow.java
index a98e17d..8cacca3 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterTableRow.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/ParameterTableRow.java
@@ -48,6 +48,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.util.InternationalString;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* A row in the table to be formatted by {@link ParameterFormat}.
@@ -127,7 +130,7 @@
values = new ArrayList<>(2); // In the vast majority of cases, we will have only one value.
units = new ArrayList<>(2);
identifiers = new LinkedHashMap<>();
- Identifier name = object.getName();
+ ReferenceIdentifier name = object.getName();
if (name != null) { // Paranoiac check.
final String codespace = name.getCodeSpace();
if (preferredCodespaces == null || preferredCodespaces.contains(codespace)) {
@@ -170,9 +173,9 @@
* Add identifiers (detailed mode only).
*/
if (!isBrief) {
- final Collection<? extends Identifier> ids = object.getIdentifiers();
+ final Collection<? extends ReferenceIdentifier> ids = object.getIdentifiers();
if (ids != null) { // Paranoiac check.
- for (final Identifier id : ids) {
+ for (final ReferenceIdentifier id : ids) {
if (!isDeprecated(id)) {
final String codespace = id.getCodeSpace();
if (preferredCodespaces == null || preferredCodespaces.contains(codespace)) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java
index 49534f9..fe4003b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java
@@ -920,8 +920,8 @@
try {
target = destination.parameter(name);
} catch (ParameterNotFoundException cause) {
- throw new InvalidParameterNameException(Errors.format(
- Errors.Keys.UnexpectedParameter_1, name), cause, name);
+ throw (InvalidParameterNameException) new InvalidParameterNameException(Errors.format(
+ Errors.Keys.UnexpectedParameter_1, name), name).initCause(cause);
}
} else {
target = (ParameterValue<?>) getOrCreate(destination, name, occurrence);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/TensorParameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/TensorParameters.java
index a69f5e3..e572812 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/TensorParameters.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/TensorParameters.java
@@ -701,7 +701,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link DefaultParameterDescriptorGroup#getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -709,7 +709,7 @@
* <td>{@link DefaultParameterDescriptorGroup#getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link DefaultParameterDescriptorGroup#getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -781,8 +781,8 @@
cause = e;
}
if (indices == null) {
- throw new InvalidParameterNameException(Errors.format(
- Errors.Keys.UnexpectedParameter_1, name), cause, name);
+ throw (InvalidParameterNameException) new InvalidParameterNameException(Errors.format(
+ Errors.Keys.UnexpectedParameter_1, name), name).initCause(cause);
}
matrix.setElement(indices[0], indices[1], ((ParameterValue<?>) param).doubleValue());
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/DynamicReferenceFrame.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/DynamicReferenceFrame.java
new file mode 100644
index 0000000..e22df3a
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/DynamicReferenceFrame.java
@@ -0,0 +1,35 @@
+/*
+ * 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.pending.geoapi.referencing;
+
+import java.time.temporal.Temporal;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.*;
+import static org.opengis.annotation.Specification.*;
+
+
+/**
+ * Placeholder for an interface that may be added in GeoAPI 3.1.
+ */
+public interface DynamicReferenceFrame extends Datum {
+ /**
+ * {@return the epoch to which the coordinates of stations defining the dynamic datum are referenced}.
+ */
+ @UML(identifier="frameReferenceEpoch", obligation=MANDATORY, specification=ISO_19111)
+ Temporal getFrameReferenceEpoch();
+}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/MissingMethods.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/MissingMethods.java
new file mode 100644
index 0000000..a84e462
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/MissingMethods.java
@@ -0,0 +1,96 @@
+/*
+ * 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.pending.geoapi.referencing;
+
+import java.util.function.Function;
+import org.opengis.referencing.crs.*;
+import org.opengis.referencing.datum.*;
+import org.apache.sis.referencing.crs.DefaultVerticalCRS;
+import org.apache.sis.referencing.crs.DefaultTemporalCRS;
+import org.apache.sis.referencing.crs.DefaultEngineeringCRS;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+
+
+/**
+ * Placeholder for methods missing in the GeoAPI 3.0 interface.
+ */
+public final class MissingMethods {
+ /**
+ * To be set by static {@code AbstractCRS} initializer.
+ */
+ public static volatile Function<CoordinateReferenceSystem, DefaultDatumEnsemble<?>> datumEnsemble;
+
+ /**
+ * To be set by static {@code DefaultGeodeticCRS} initializer.
+ */
+ public static volatile Function<GeodeticCRS, DefaultDatumEnsemble<GeodeticDatum>> geodeticDatumEnsemble;
+
+ private MissingMethods() {
+ }
+
+ /**
+ * Returns the datum ensemble of an arbitrary CRS.
+ *
+ * @param datum the CRS from which to get a datum ensemble, or {@code null} if none.
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ public static DefaultDatumEnsemble<?> getDatumEnsemble(final CoordinateReferenceSystem crs) {
+ final var m = datumEnsemble;
+ return (m != null) ? m.apply(crs) : null;
+ }
+
+ /**
+ * Returns the datum ensemble of an arbitrary geodetic CRS.
+ *
+ * @param datum the CRS from which to get a datum ensemble, or {@code null} if none.
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ public static DefaultDatumEnsemble<GeodeticDatum> getDatumEnsemble(final GeodeticCRS crs) {
+ final var m = geodeticDatumEnsemble;
+ return (m != null) ? m.apply(crs) : null;
+ }
+
+ /**
+ * Returns the datum ensemble of an arbitrary vertical CRS.
+ *
+ * @param datum the CRS from which to get a datum ensemble, or {@code null} if none.
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ public static DefaultDatumEnsemble<VerticalDatum> getDatumEnsemble(final VerticalCRS crs) {
+ return (crs instanceof DefaultVerticalCRS) ? ((DefaultVerticalCRS) crs).getDatumEnsemble() : null;
+ }
+
+ /**
+ * Returns the datum ensemble of an arbitrary temporal CRS.
+ *
+ * @param datum the CRS from which to get a datum ensemble, or {@code null} if none.
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ public static DefaultDatumEnsemble<TemporalDatum> getDatumEnsemble(final TemporalCRS crs) {
+ return (crs instanceof DefaultTemporalCRS) ? ((DefaultTemporalCRS) crs).getDatumEnsemble() : null;
+ }
+
+ /**
+ * Returns the datum ensemble of an arbitrary engineering CRS.
+ *
+ * @param datum the CRS from which to get a datum ensemble, or {@code null} if none.
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ public static DefaultDatumEnsemble<EngineeringDatum> getDatumEnsemble(final EngineeringCRS crs) {
+ return (crs instanceof DefaultEngineeringCRS) ? ((DefaultEngineeringCRS) crs).getDatumEnsemble() : null;
+ }
+}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/package-info.java
similarity index 83%
rename from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
rename to endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/package-info.java
index 8fb81f9..3172e99 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/pending/geoapi/referencing/package-info.java
@@ -14,13 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
-
/**
- *
- * @author Johann Sorel (Geomatys)
+ * Place-holder for some interfaces not present in GeoAPI 3.0 but proposed for addition in GeoAPI 3.1.
*/
-public interface Ellipse {
-
-}
+package org.apache.sis.pending.geoapi.referencing;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
index 6cde748..f62d17c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
@@ -77,8 +77,10 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceSystem;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -182,6 +184,15 @@
public static final String DEPRECATED_KEY = "deprecated";
/**
+ * Key for the <code>{@value}</code> property to be given to the
+ * {@code ObjectFactory.createFoo(Map, ...)} methods.
+ * This is used for setting the value to be returned by {@link #getDomains()}.
+ *
+ * @since 1.5
+ */
+ public static final String DOMAINS_KEY = "domains";
+
+ /**
* The name for this object or code. Shall never be {@code null}.
*
* <p><b>Consider this field as final!</b>
@@ -229,7 +240,7 @@
* @see #getDomains()
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
- private Collection<ObjectDomain> domains;
+ private Collection<DefaultObjectDomain> domains;
/**
* Comments on or information about this object, or {@code null} if none.
@@ -291,7 +302,7 @@
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getVersion()} on the {@linkplain #getName() name}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>"description"</td>
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getDescription()} on the {@linkplain #getName() name}</td>
* </tr><tr>
@@ -303,15 +314,15 @@
* <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#SCOPE_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td>
* <td>{@link String} or {@link InternationalString}</td>
* <td>{@link DefaultObjectDomain#getScope()} on the {@linkplain #getDomains() domain}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link Extent}</td>
* <td>{@link DefaultObjectDomain#getDomainOfValidity()} on the {@linkplain #getDomains() domain}</td>
* </tr><tr>
@@ -402,16 +413,16 @@
// "domains": ObjectDomain or ObjectDomain[]
// -----------------------------------------
value = properties.get(DOMAINS_KEY);
- if (value instanceof ObjectDomain) {
- domains = Collections.singleton((ObjectDomain) value);
- } else if (value instanceof ObjectDomain[]) {
- domains = immutableSet(true, (ObjectDomain[]) value);
+ if (value instanceof DefaultObjectDomain) {
+ domains = Collections.singleton((DefaultObjectDomain) value);
+ } else if (value instanceof DefaultObjectDomain[]) {
+ domains = immutableSet(true, (DefaultObjectDomain[]) value);
} else if (value != null) {
throw illegalPropertyType(properties, DOMAINS_KEY, value);
} else {
// Compatibility with previous way to specify domain.
- final InternationalString scope = Types.toInternationalString(properties, ObjectDomain.SCOPE_KEY);
- final Extent domainOfValidity = Containers.property(properties, ObjectDomain.DOMAIN_OF_VALIDITY_KEY, Extent.class);
+ final InternationalString scope = Types.toInternationalString(properties, ReferenceSystem.SCOPE_KEY);
+ final Extent domainOfValidity = Containers.property(properties, ReferenceSystem.DOMAIN_OF_VALIDITY_KEY, Extent.class);
if (scope != null || domainOfValidity != null) {
domains = Collections.singleton(new DefaultObjectDomain(scope, domainOfValidity));
}
@@ -461,7 +472,7 @@
}
alias = nonEmpty(object.getAlias()); // Favor null for empty set in case it is not Collections.EMPTY_SET
identifiers = nonEmpty(object.getIdentifiers());
- domains = nonEmpty(object.getDomains());
+ domains = nonEmpty(Legacy.getDomains(object));
remarks = object.getRemarks();
deprecated = (object instanceof Deprecable) ? ((Deprecable) object).isDeprecated() : false;
}
@@ -567,12 +578,14 @@
* The domain includes a scope (description of the primary purpose of this object) together
* with a domain of validity (spatial and temporal extent in which the object can be used).
*
+ * <div class="note"><b>Upcoming API change:</b>
+ * the type of collection elements may become {@code ObjectDomain} after the next GeoAPI release.</div>
+ *
* @return scopes and domains of validity of this object.
*
* @since 1.4
*/
- @Override
- public Collection<ObjectDomain> getDomains() {
+ public Collection<DefaultObjectDomain> getDomains() {
return nonNull(domains);
}
@@ -590,7 +603,15 @@
* @since 0.6
*/
public Optional<InternationalString> getDescription() {
- return Optional.ofNullable((name != null) ? name.getDescription() : null);
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
+ final ReferenceIdentifier name = getName();
+ if (name instanceof ImmutableIdentifier) {
+ return Optional.ofNullable(((ImmutableIdentifier) name).getDescription());
+ }
+ if (name instanceof DefaultIdentifier) {
+ return Optional.ofNullable(((DefaultIdentifier) name).getDescription());
+ }
+ return Optional.empty();
}
/**
@@ -785,7 +806,7 @@
return deepEquals(getName(), that.getName(), mode) &&
deepEquals(getAlias(), that.getAlias(), mode) &&
deepEquals(getIdentifiers(), that.getIdentifiers(), mode) &&
- deepEquals(getDomains(), that.getDomains(), mode) &&
+ deepEquals(getDomains(), Legacy.getDomains(that), mode) &&
deepEquals(getRemarks(), that.getRemarks(), mode);
}
case IGNORE_METADATA:
@@ -1197,10 +1218,10 @@
* Finds the first non-null domain element.
*
* @param <T> type of domain element to get.
- * @param getter {@link ObjectDomain} getter method to invoke.
+ * @param getter {@code ObjectDomain} getter method to invoke.
* @return first non-null value, or {@code null} if none.
*/
- private <T> T findFirst(final Function<ObjectDomain,T> getter) {
+ private <T> T findFirst(final Function<DefaultObjectDomain,T> getter) {
if (domains == null) return null;
return domains.stream().map(getter).filter(ImplementationHelper::nonNil).findFirst().orElse(null);
}
@@ -1216,7 +1237,7 @@
@Workaround(library = "JDK", version = "1.8")
@XmlJavaTypeAdapter(EX_Extent.class)
private Extent getDomainExtent() {
- return findFirst(ObjectDomain::getDomainOfValidity);
+ return findFirst(DefaultObjectDomain::getDomainOfValidity);
}
/**
@@ -1229,7 +1250,7 @@
*/
@XmlElement(name ="scope")
private InternationalString getDomainScope() {
- return findFirst(ObjectDomain::getScope);
+ return findFirst(DefaultObjectDomain::getScope);
}
/**
@@ -1237,7 +1258,7 @@
*/
private void setDomainExtent(final Extent value) {
InternationalString scope = null;
- final DefaultObjectDomain domain = DefaultObjectDomain.castOrCopy(CollectionsExt.first(domains));
+ final DefaultObjectDomain domain = CollectionsExt.first(domains);
if (domain != null) {
if (domain.domainOfValidity != null) {
propertyAlreadySet("setDomain", "domainOfValidity");
@@ -1253,7 +1274,7 @@
*/
private void setDomainScope(final InternationalString value) {
Extent area = null;
- final DefaultObjectDomain domain = DefaultObjectDomain.castOrCopy(CollectionsExt.first(domains));
+ final DefaultObjectDomain domain = CollectionsExt.first(domains);
if (domain != null) {
if (domain.scope != null) {
propertyAlreadySet("setDomainScope", "scope");
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractReferenceSystem.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractReferenceSystem.java
index 8cb50ff..baf4a29 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractReferenceSystem.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractReferenceSystem.java
@@ -22,8 +22,10 @@
import org.opengis.util.InternationalString;
import org.opengis.referencing.ReferenceSystem;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.metadata.extent.Extent;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -72,7 +74,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -80,11 +82,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -124,6 +126,33 @@
return ReferenceSystem.class;
}
+ /**
+ * Returns the region or timeframe in which this reference system is valid, or {@code null} if unspecified.
+ *
+ * @return area or region or timeframe in which this (coordinate) reference system is valid, or {@code null}.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public Extent getDomainOfValidity() {
+ return Legacy.getDomainOfValidity(getDomains());
+ }
+
+ /**
+ * Returns the domain or limitations of usage, or {@code null} if unspecified.
+ *
+ * @return description of domain of usage, or limitations of usage, for which this
+ * (coordinate) reference system object is valid, or {@code null}.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public InternationalString getScope() {
+ return Legacy.getScope(getDomains());
+ }
+
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Builder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Builder.java
index 5f668f0..53120f6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Builder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Builder.java
@@ -186,8 +186,8 @@
* {@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY} and
* {@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY} keys.
* Subclasses may add other entries like
- * {@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY} and
- * {@value org.opengis.referencing.ObjectDomain#SCOPE_KEY} keys.
+ * {@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY} and
+ * {@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY} keys.
*
* <p>See <cite>Notes for subclass implementers</cite> in class javadoc for usage conditions.</p>
*
@@ -207,7 +207,7 @@
/**
* The codespace as a {@code NameSpace} object, or {@code null} if not yet created.
- * This object is built from the {@value org.opengis.metadata.Identifier#CODESPACE_KEY} value when first needed.
+ * This object is built from the "codespace" value when first needed.
*/
private transient NameSpace namespace;
@@ -404,7 +404,7 @@
* @return the string specified by the last call to {@code setCodeSpace(…)}, or {@code null} if none.
*/
private String getCodeSpace() {
- return (String) properties.get(Identifier.CODESPACE_KEY);
+ return (String) properties.get(ReferenceIdentifier.CODESPACE_KEY);
}
/**
@@ -436,7 +436,7 @@
* @see ImmutableIdentifier#getCodeSpace()
*/
public B setCodeSpace(final Citation authority, final String codespace) {
- if (!setProperty(Identifier.CODESPACE_KEY, codespace)) {
+ if (!setProperty(ReferenceIdentifier.CODESPACE_KEY, codespace)) {
namespace = null;
}
setProperty(Identifier.AUTHORITY_KEY, authority);
@@ -450,7 +450,7 @@
* @return the value specified by the last call to {@code setVersion(…)}, or {@code null} if none.
*/
private String getVersion() {
- return (String) properties.get(Identifier.VERSION_KEY);
+ return (String) properties.get(ReferenceIdentifier.VERSION_KEY);
}
/**
@@ -471,7 +471,7 @@
* once since builder construction or since the last call to a {@code createXXX(…)} method.
*/
public B setVersion(final String version) {
- setProperty(Identifier.VERSION_KEY, version);
+ setProperty(ReferenceIdentifier.VERSION_KEY, version);
return self();
}
@@ -910,7 +910,7 @@
* or {@code null} if none.
*/
private InternationalString getDescription() {
- return (InternationalString) properties.get(Identifier.DESCRIPTION_KEY);
+ return (InternationalString) properties.get("description");
}
/**
@@ -944,7 +944,7 @@
* Convert to InternationalString now in order to share the same instance if
* the same description is used both for an Identifier and an IdentifiedObject.
*/
- properties.put(Identifier.DESCRIPTION_KEY, Types.toInternationalString(description));
+ properties.put("description", Types.toInternationalString(description));
return self();
}
@@ -1038,7 +1038,7 @@
if (cleanup) {
properties .put(IdentifiedObject.NAME_KEY, null);
properties .remove(IdentifiedObject.REMARKS_KEY);
- properties .remove(Identifier.DESCRIPTION_KEY);
+ properties .remove("description");
properties .remove(AbstractIdentifiedObject.DEPRECATED_KEY);
aliases .clear();
identifiers.clear();
diff --git 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
index b6c207e..3e05ff4 100644
--- 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
@@ -96,14 +96,10 @@
// 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.geometry.Geometry;
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.referencing.crs.DerivedCRS;
-import org.opengis.referencing.datum.DynamicReferenceFrame;
-import org.opengis.metadata.extent.BoundingPolygon;
-import org.opengis.metadata.extent.GeographicExtent;
-import org.opengis.coordinate.CoordinateMetadata;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.referencing.DynamicReferenceFrame;
+import org.apache.sis.coordinate.DefaultCoordinateMetadata;
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
/**
@@ -485,7 +481,7 @@
* Suggests a coordinate reference system which could be a common target for coordinate operations having the
* given sources. This method compares the {@linkplain #getGeographicBoundingBox(CoordinateReferenceSystem)
* domain of validity} of all given CRSs. If a CRS has a domain of validity that contains the domain of all other
- * CRS, then that CRS is returned. Otherwise this method verifies if a {@linkplain DerivedCRS#getBaseCRS()
+ * CRS, then that CRS is returned. Otherwise this method verifies if a {@linkplain GeneralDerivedCRS#getBaseCRS()
* base CRS} (usually a {@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS geographic CRS} instance)
* would be suitable. If no suitable CRS is found, then this method returns {@code null}.
*
@@ -644,8 +640,8 @@
*
* @since 1.5
*/
- public static CoordinateOperation findOperation(final CoordinateMetadata source,
- final CoordinateMetadata target,
+ public static CoordinateOperation findOperation(final DefaultCoordinateMetadata source,
+ final DefaultCoordinateMetadata target,
final GeographicBoundingBox areaOfInterest)
throws FactoryException
{
@@ -868,16 +864,6 @@
* If non-null, then the returned envelope will use the same coordinate reference system than the given CRS
* argument.
*
- * <p>This method looks in two places:</p>
- * <ol>
- * <li>First, it checks the {@linkplain DefaultObjectDomain#getDomainOfValidity() domain of validity}
- * associated with the given CRS. Only geographic extents that are instances of
- * {@link BoundingPolygon} associated to the given CRS are taken in account for this first step.</li>
- * <li>If the above step did not found found any bounding polygon, then the
- * {@linkplain #getGeographicBoundingBox(CoordinateReferenceSystem) geographic bounding boxes}
- * are used as a fallback and transformed to the given CRS.</li>
- * </ol>
- *
* @param crs the coordinate reference system, or {@code null}.
* @return the envelope with coordinates in the given CRS, or {@code null} if none.
*
@@ -890,39 +876,7 @@
public static Envelope getDomainOfValidity(final CoordinateReferenceSystem crs) {
Envelope envelope = null;
GeneralEnvelope merged = null;
- if (crs != null) {
- for (final ObjectDomain domain : crs.getDomains()) {
- final Extent domainOfValidity = domain.getDomainOfValidity();
- if (domainOfValidity != null) {
- for (final GeographicExtent extent : domainOfValidity.getGeographicElements()) {
- if (extent instanceof BoundingPolygon && !Boolean.FALSE.equals(extent.getInclusion())) {
- for (final Geometry geometry : ((BoundingPolygon) extent).getPolygons()) {
- final Envelope candidate = geometry.getEnvelope();
- if (candidate != null) {
- final CoordinateReferenceSystem sourceCRS = candidate.getCoordinateReferenceSystem();
- if (sourceCRS == null || Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
- if (envelope == null) {
- envelope = candidate;
- } else {
- if (merged == null) {
- envelope = merged = new GeneralEnvelope(envelope);
- }
- merged.add(envelope);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- /*
- * If no envelope was found, uses the geographic bounding box as a fallback. We will
- * need to transform it from WGS84 to the supplied CRS. This step was not required in
- * the previous block because the latter selected only envelopes in the right CRS.
- */
- if (envelope == null) {
+ /* if (envelope == null) */ { // Condition needed on other branches but not on trunk.
final GeographicBoundingBox bounds = getGeographicBoundingBox(crs);
if (bounds != null && !Boolean.FALSE.equals(bounds.getInclusion())) {
/*
@@ -957,7 +911,7 @@
/**
* Returns the epoch to which the coordinates of stations defining the dynamic CRS are referenced.
- * If the CRS is associated to a {@linkplain DynamicReferenceFrame dynamic datum}, then the epoch
+ * If the CRS is associated to a dynamic datum, then the epoch
* of that datum is returned. Otherwise if the CRS is {@linkplain CompoundCRS compound}, then this
* method requires that all dynamic components have the same epoch.
*
@@ -975,7 +929,7 @@
epoch = ((DynamicReferenceFrame) datum).getFrameReferenceEpoch();
}
} else if (crs instanceof CompoundCRS) {
- for (SingleCRS component : ((CompoundCRS) crs).getSingleComponents()) {
+ for (SingleCRS component : getSingleComponents(crs)) {
final Datum datum = component.getDatum();
if (datum instanceof DynamicReferenceFrame) {
final Temporal t = ((DynamicReferenceFrame) datum).getFrameReferenceEpoch();
@@ -999,7 +953,7 @@
*
* <h4>Ellipsoidal height</h4>
* If a two-dimensional geographic or projected CRS is followed or preceded by a vertical CRS with ellipsoidal
- * {@linkplain org.apache.sis.referencing.datum.DefaultVerticalDatum#getRealizationMethod() realization method},
+ * {@linkplain org.apache.sis.referencing.datum.DefaultVerticalDatum#getVerticalDatumType() datum type},
* this method combines them in a single three-dimensional geographic or projected CRS. Note that standalone
* ellipsoidal heights are not allowed according ISO 19111. But if such situation is nevertheless found, then
* the action described here fixes the issue. This is the reverse of <code>{@linkplain #getVerticalComponent
@@ -1303,7 +1257,7 @@
final Map<String, ?> properties = ReferencingUtilities.getPropertiesForModifiedCRS(crs);
if (crs instanceof GeodeticCRS) {
final var source = (GeodeticCRS) crs;
- return new DefaultGeographicCRS(properties, source.getDatum(), source.getDatumEnsemble(), (EllipsoidalCS) cs);
+ return new DefaultGeographicCRS(properties, source.getDatum(), getDatumEnsemble(source), (EllipsoidalCS) cs);
}
/*
* In Apache SIS implementation, the Conversion contains the source and target CRS together with
@@ -1322,7 +1276,7 @@
* If the CRS is neither geographic or projected, then it is engineering.
*/
final var source = (EngineeringCRS) crs;
- return new DefaultEngineeringCRS(properties, source.getDatum(), source.getDatumEnsemble(), cs);
+ return new DefaultEngineeringCRS(properties, source.getDatum(), getDatumEnsemble(source), cs);
}
}
if (crs instanceof CompoundCRS) {
@@ -1393,7 +1347,7 @@
VerticalCRS c = CommonCRS.Vertical.ELLIPSOIDAL.crs();
if (!c.getCoordinateSystem().getAxis(0).equals(axis)) {
final Map<String,?> properties = IdentifiedObjects.getProperties(c);
- c = new DefaultVerticalCRS(properties, c.getDatum(), c.getDatumEnsemble(), new DefaultVerticalCS(properties, axis));
+ c = new DefaultVerticalCRS(properties, c.getDatum(), getDatumEnsemble(c), new DefaultVerticalCS(properties, axis));
}
return c;
}
@@ -1480,7 +1434,13 @@
if (crs == null) {
singles = List.of();
} else if (crs instanceof CompoundCRS) {
- singles = ((CompoundCRS) crs).getSingleComponents();
+ if (crs instanceof DefaultCompoundCRS) {
+ singles = ((DefaultCompoundCRS) crs).getSingleComponents();
+ } else {
+ final List<CoordinateReferenceSystem> elements = ((CompoundCRS) crs).getComponents();
+ singles = new ArrayList<>(elements.size());
+ ReferencingUtilities.getSingleComponents(elements, singles);
+ }
} else {
// Intentional CassCastException here if the crs is not a SingleCRS.
singles = List.of((SingleCRS) crs);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
index 404beba..0b70f97 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
@@ -87,9 +87,11 @@
import org.apache.sis.measure.Units;
import static org.apache.sis.util.privy.Constants.SECONDS_PER_DAY;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.referencing.crs.GeocentricCRS;
+import org.opengis.referencing.datum.VerticalDatumType;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
/**
@@ -380,14 +382,14 @@
*
* @see #geocentric()
*/
- private transient GeodeticCRS cachedGeocentric;
+ private transient GeocentricCRS cachedGeocentric;
/**
* The geocentric CRS using spherical coordinate system, created when first needed.
*
* @see #spherical()
*/
- private transient GeodeticCRS cachedSpherical;
+ private transient GeocentricCRS cachedSpherical;
/**
* The Universal Transverse Mercator (UTM) or Universal Polar Stereographic (UPS) projections,
@@ -502,7 +504,7 @@
}
final Datum datum = single.getDatum();
if (datum instanceof GeodeticDatum) {
- final CommonCRS c = forDatum((GeodeticDatum) datum, single.getDatumEnsemble());
+ final CommonCRS c = forDatum((GeodeticDatum) datum, getDatumEnsemble(single));
if (c != null) return c;
}
throw new IllegalArgumentException(Errors.format(
@@ -516,7 +518,7 @@
* @param ensemble the datum ensemble to represent as an enumeration value, or {@code null}.
* @return enumeration value for the given datum, or {@code null} if none.
*/
- static CommonCRS forDatum(final GeodeticDatum datum, final DatumEnsemble<?> ensemble) {
+ static CommonCRS forDatum(final GeodeticDatum datum, final DefaultDatumEnsemble<?> ensemble) {
/*
* First, try to search using only the EPSG code. This approach avoid initializing unneeded
* geodetic objects (such initializations are costly if they require connection to the EPSG
@@ -716,7 +718,7 @@
cs = (EllipsoidalCS) StandardDefinitions.createCoordinateSystem(StandardDefinitions.ELLIPSOIDAL_3D, true);
}
// Use same name and datum than the geographic CRS.
- cachedGeo3D = new DefaultGeographicCRS(properties(base, geo3D), base.getDatum(), base.getDatumEnsemble(), cs);
+ cachedGeo3D = new DefaultGeographicCRS(properties(base, geo3D), base.getDatum(), getDatumEnsemble(base), cs);
}
return cachedGeo3D;
}
@@ -739,17 +741,21 @@
* <tr><td>WGS 84</td> <td>{@link #WGS84}</td> <td>4978</td></tr>
* </table></blockquote>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
+ *
* @return the geocentric CRS associated to this enum.
*
* @see CRS#forCode(String)
* @see DefaultGeocentricCRS
*/
- public synchronized GeodeticCRS geocentric() {
+ public synchronized GeocentricCRS geocentric() {
if (cachedGeocentric == null) {
if (geocentric != 0) {
final GeodeticAuthorityFactory factory = factory();
if (factory != null) try {
- return cachedGeocentric = factory.createGeodeticCRS(String.valueOf(geocentric));
+ return cachedGeocentric = factory.createGeocentricCRS(String.valueOf(geocentric));
} catch (FactoryException e) {
failure(this, "geocentric", e, geocentric);
}
@@ -767,7 +773,7 @@
} else {
cs = (CartesianCS) StandardDefinitions.createCoordinateSystem(StandardDefinitions.EARTH_CENTRED, true);
}
- cachedGeocentric = new DefaultGeocentricCRS(properties(base, geocentric), base.getDatum(), base.getDatumEnsemble(), cs);
+ cachedGeocentric = new DefaultGeocentricCRS(properties(base, geocentric), base.getDatum(), getDatumEnsemble(base), cs);
}
return cachedGeocentric;
}
@@ -781,13 +787,17 @@
* <li>Geocentric radius in metres oriented toward {@linkplain AxisDirection#UP up}.</li>
* </ol>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
+ *
* @return the geocentric CRS associated to this enum.
*
* @see DefaultGeocentricCRS
*
* @since 0.7
*/
- public synchronized GeodeticCRS spherical() {
+ public synchronized GeocentricCRS spherical() {
if (cachedSpherical == null) {
/*
* All constants defined in this enumeration use the same coordinate system, EPSG:6404.
@@ -812,7 +822,7 @@
final GeographicCRS base = geographic();
cachedSpherical = new DefaultGeocentricCRS(IdentifiedObjects.getProperties(base, exclude()),
base.getDatum(),
- base.getDatumEnsemble(),
+ getDatumEnsemble(base),
cs);
}
return cachedSpherical;
@@ -865,8 +875,8 @@
*
* @since 1.5
*/
- public DatumEnsemble<GeodeticDatum> datumEnsemble() {
- return geographic().getDatumEnsemble();
+ public DefaultDatumEnsemble<GeodeticDatum> datumEnsemble() {
+ return getDatumEnsemble(geographic());
}
/**
@@ -1233,8 +1243,6 @@
* <tr><th>Direction:</th> <td>{@link AxisDirection#UP}</td></tr>
* <tr><th>Unit:</th> <td>{@link Units#METRE}</td></tr>
* </table></blockquote>
- *
- * @see RealizationMethod#TIDAL
*/
MEAN_SEA_LEVEL(true, (short) 5714, (short) 5100),
@@ -1248,8 +1256,6 @@
* <tr><th>Direction:</th> <td>{@link AxisDirection#DOWN}</td></tr>
* <tr><th>Unit:</th> <td>{@link Units#METRE}</td></tr>
* </table></blockquote>
- *
- * @see RealizationMethod#TIDAL
*/
DEPTH(true, (short) 5715, (short) 5100),
@@ -1317,7 +1323,7 @@
* Creates a new enumeration value of the given name.
*
* <h4>API design note</h4>
- * This constructor does not expect {@link RealizationMethod} constant in order to avoid
+ * This constructor does not expect {@link VerticalDatumType} constant in order to avoid
* the creation of non-standard code list value before they are actually needed.
*/
private Vertical(final boolean isEPSG, final short crs, final short datum) {
@@ -1447,11 +1453,7 @@
* ELLIPSOIDAL. The way to construct the ellipsoidal pseudo-method shall be equivalent
* to a call to `VerticalDatumTypes.ellipsoidal()`.
*/
- RealizationMethod method = null;
- if (this != OTHER_SURFACE) {
- method = RealizationMethod.valueOf(name());
- }
- object = new DefaultVerticalDatum(properties(datum), method);
+ object = new DefaultVerticalDatum(properties(datum), VerticalDatumType.valueOf(name()));
}
cached = object;
}
@@ -1871,7 +1873,7 @@
*/
GEODISPLAY(new DefaultEngineeringDatum(Map.of(
EngineeringDatum.NAME_KEY, "Computer display",
- EngineeringDatum.ANCHOR_DEFINITION_KEY, "Origin is in upper left."))),
+ EngineeringDatum.ANCHOR_POINT_KEY, "Origin is in upper left."))),
/**
* Cartesian coordinate system with (right, down) oriented axes in pixel units.
@@ -1997,7 +1999,7 @@
/**
* Returns {@code true} is the given <abbr>CRS</abbr> uses the datum identified by this enumeration value.
* The association may be direct through {@link SingleCRS#getDatum()}, or indirect throw at least one of
- * the members of {@link SingleCRS#getDatumEnsemble()}.
+ * the members of {@code getDatumEnsemble(SingleCRS)}.
*
* @param crs the CRS to compare against the datum of this enumeration value. May be {@code null}.
* @return whether the given <abbr>CRS</abbr> uses the datum, directly or indirectly.
@@ -2008,7 +2010,7 @@
if (Utilities.equalsIgnoreMetadata(datum, component.getDatum())) {
return true;
}
- final var ensemble = component.getDatumEnsemble();
+ final var ensemble = getDatumEnsemble(component);
if (ensemble != null) {
for (final Datum member : ensemble.getMembers()) {
if (Utilities.equalsIgnoreMetadata(datum, member)) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
index 3241d94..7e8a78c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
@@ -32,9 +32,6 @@
import org.apache.sis.xml.NilReason;
import org.apache.sis.metadata.iso.extent.DefaultExtent;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* Scope and domain of validity of a CRS-related object.
@@ -44,6 +41,14 @@
* object implementing the {@link NilObject} interface with {@link NilReason#UNKNOWN}.
* The use of <i>"not known"</i> text is an ISO 19111 recommendation.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19111 international standard published in 2019,
+ * while GeoAPI 3.0 is based on the version published in 2007. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the {@code ObjectDomain} interface.
+ * </div>
+ *
* <h2>Immutability and thread safety</h2>
* This class is immutable and thus thread-safe if the property values
* given to the constructor are also immutable.
@@ -52,7 +57,7 @@
* @version 1.4
* @since 1.4
*/
-public class DefaultObjectDomain extends FormattableObject implements ObjectDomain, LenientComparable, Serializable {
+public class DefaultObjectDomain extends FormattableObject implements LenientComparable, Serializable {
/**
* Serial number for inter-operability with different versions.
*/
@@ -163,44 +168,12 @@
}
/**
- * Creates a new domain with the same values as the specified one.
- * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
- * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
- *
- * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
- *
- * @param domain the domain to copy.
- *
- * @see #castOrCopy(ObjectDomain)
- */
- public DefaultObjectDomain(final ObjectDomain domain) {
- scope = domain.getScope();
- domainOfValidity = domain.getDomainOfValidity();
- }
-
- /**
- * Returns a SIS datum implementation with the same values as the given arbitrary implementation.
- * If the given object is {@code null}, then this method returns {@code null}.
- * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
- * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultObjectDomain castOrCopy(final ObjectDomain object) {
- return (object == null) || (object instanceof DefaultObjectDomain)
- ? (DefaultObjectDomain) object : new DefaultObjectDomain(object);
- }
-
- /**
* Returns a description of usage, or limitations of usage, for which this object is valid.
* If no scope was specified to the constructor, then this method returns <i>"not known"</i>
* in an instance implementing the {@link NilObject} interface with {@link NilReason#UNKNOWN}.
*
* @return the domain of usage.
*/
- @Override
public InternationalString getScope() {
return (scope != null) ? scope : UnknownScope.INSTANCE;
}
@@ -212,7 +185,6 @@
*
* @return the area or time frame of usage.
*/
- @Override
public Extent getDomainOfValidity() {
return (domainOfValidity != null) ? domainOfValidity : UnknownExtent.INSTANCE;
}
@@ -255,8 +227,8 @@
Objects.equals(domainOfValidity, that.domainOfValidity);
}
} else {
- if (object instanceof ObjectDomain) {
- final var that = (ObjectDomain) object;
+ if (object instanceof DefaultObjectDomain) {
+ final var that = (DefaultObjectDomain) object;
return Utilities.deepEquals(getScope(), that.getScope(), mode) &&
Utilities.deepEquals(getDomainOfValidity(), that.getDomainOfValidity(), mode);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
index fdcf1d4..dab6091 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java
@@ -133,7 +133,6 @@
final boolean ellipsoid = type.isAssignableFrom(Ellipsoid .class);
final boolean datum = type.isAssignableFrom(GeodeticDatum.class);
final boolean geographic = type.isAssignableFrom(GeographicCRS.class);
- @SuppressWarnings("deprecation")
final boolean geocentric = type.isAssignableFrom(GeocentricCRS.class);
final boolean projected = type.isAssignableFrom(ProjectedCRS .class);
final Set<String> codes = new LinkedHashSet<>();
@@ -266,7 +265,6 @@
* Returns a coordinate reference system, datum or ellipsoid for the given EPSG code.
*/
@Override
- @SuppressWarnings("removal")
public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException {
return (IdentifiedObject) predefined(code, -1 & ~UNIT);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
index 366257c..bc11f13 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
@@ -42,8 +42,10 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.crs.GeographicCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DatumOrEnsemble;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
/**
@@ -63,7 +65,12 @@
/**
* The datum ensemble of the <abbr>CRS</abbr> to separate, or {@code null} if none.
*/
- private final DatumEnsemble<GeodeticDatum> ensemble;
+ private final DefaultDatumEnsemble<GeodeticDatum> ensemble;
+
+ /**
+ * Workaround for GeoAPI 3.0 (to be removed with GeoAPI 3.1).
+ */
+ private final GeodeticDatum pseudo;
/**
* Whether to extract the vertical component ({@code true}) or the horizontal component ({@code false}).
@@ -78,7 +85,8 @@
*/
EllipsoidalHeightSeparator(final GeodeticCRS baseCRS, final boolean vertical) {
this.datum = baseCRS.getDatum();
- this.ensemble = baseCRS.getDatumEnsemble();
+ this.ensemble = getDatumEnsemble(baseCRS);
+ this.pseudo = DatumOrEnsemble.asDatum(baseCRS);
this.vertical = vertical;
}
@@ -113,8 +121,7 @@
VerticalCRS component = CommonCRS.Vertical.ELLIPSOIDAL.crs();
if (!Utilities.equalsIgnoreMetadata(component.getCoordinateSystem(), cs)) {
component = factory().createVerticalCRS(getPropertiesForModifiedCRS(component),
- component.getDatum(),
- component.getDatumEnsemble(),
+ DatumOrEnsemble.asDatum(component),
(VerticalCS) cs);
}
return component;
@@ -136,7 +143,7 @@
final CommonCRS c = CommonCRS.forDatum(datum, ensemble);
if (c != null) return c.normalizedGeographic();
}
- return factory().createGeographicCRS(getPropertiesForModifiedCRS(crs), datum, ensemble, (EllipsoidalCS) cs);
+ return factory().createGeographicCRS(getPropertiesForModifiedCRS(crs), pseudo, (EllipsoidalCS) cs);
}
/*
* In the projected CRS case, in addition of reducing the number of dimensions in the CartesianCS,
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
index 72778a9..fe09dfb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
@@ -408,7 +408,7 @@
} catch (TransformException e) {
throw new IllegalArgumentException(transformError(false), e);
}
- setStartGeographicPoint(p.getCoordinate(0), p.getCoordinate(1));
+ setStartGeographicPoint(p.getOrdinate(0), p.getOrdinate(1));
}
/**
@@ -475,7 +475,7 @@
} catch (TransformException e) {
throw new IllegalArgumentException(transformError(false), e);
}
- setEndGeographicPoint(p.getCoordinate(0), p.getCoordinate(1));
+ setEndGeographicPoint(p.getOrdinate(0), p.getOrdinate(1));
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
index 18cfc66..2decb80 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
@@ -59,8 +59,9 @@
import org.apache.sis.referencing.factory.UnavailableFactoryException;
import org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -96,14 +97,14 @@
* <td>{@link IdentifiedObject#getAlias()}</td></tr>
* <tr><td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
* <td>{@link IdentifiedObject#getIdentifiers()}</td></tr>
- * <tr><td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link IdentifiedObject#getDomains()}</td></tr>
+ * <tr><td>"domains"</td>
+ * <td>{@link AbstractIdentifiedObject#getDomains()}</td></tr>
* <tr><td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link IdentifiedObject#getRemarks()}</td></tr>
- * <tr><td>{@value org.opengis.referencing.ObjectDomain#SCOPE_KEY}</td>
- * <td>{@link ObjectDomain#getScope()}</td></tr>
- * <tr><td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
- * <td>{@link ObjectDomain#getDomainOfValidity()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td>
+ * <td>{@link DefaultObjectDomain#getScope()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@link DefaultObjectDomain#getDomainOfValidity()}</td></tr>
* <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#OPERATION_VERSION_KEY}</td>
* <td>{@link CoordinateOperation#getOperationVersion()}</td></tr>
* <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#COORDINATE_OPERATION_ACCURACY_KEY}</td>
@@ -271,7 +272,7 @@
if (authority instanceof IdentifierSpace<?>) {
cs = ((IdentifierSpace<?>) authority).getName();
}
- for (final Identifier identifier : nonNull(object.getIdentifiers())) {
+ for (final ReferenceIdentifier identifier : nonNull(object.getIdentifiers())) {
if (identifier != null) { // Paranoiac check.
if (cs != null && cs.equalsIgnoreCase(identifier.getCodeSpace())) {
return identifier; // Match based on codespace.
@@ -455,7 +456,7 @@
public static Optional<Extent> getDomainOfValidity(final IdentifiedObject object) {
Extent domain = null;
if (object != null) {
- for (ObjectDomain obj : object.getDomains()) {
+ for (DefaultObjectDomain obj : Legacy.getDomains(object)) {
domain = Extents.intersection(domain, obj.getDomainOfValidity());
}
}
@@ -480,7 +481,7 @@
if (object == null) {
return Optional.empty();
}
- return Extents.getGeographicBoundingBox(object.getDomains().stream().map(ObjectDomain::getDomainOfValidity));
+ return Extents.getGeographicBoundingBox(Legacy.getDomains(object).stream().map(DefaultObjectDomain::getDomainOfValidity));
}
/**
@@ -544,7 +545,7 @@
*/
final List<? extends IdentifiedObject> components;
if (object instanceof CompoundCRS) {
- components = ((CompoundCRS) object).getSingleComponents();
+ components = CRS.getSingleComponents((CompoundCRS) object);
} else if (object instanceof ConcatenatedOperation) {
final var cop = (ConcatenatedOperation) object;
final List<? extends CoordinateOperation> steps = cop.getOperations();
@@ -838,11 +839,16 @@
if (identifier == null) {
return null;
}
- String cs = identifier.getCodeSpace();
+ String cs = null;
+ if (identifier instanceof ReferenceIdentifier) {
+ cs = ((ReferenceIdentifier) identifier).getCodeSpace();
+ }
if (Strings.isNullOrEmpty(cs)) {
cs = Identifiers.getIdentifier(identifier.getAuthority(), true);
}
- return NameMeaning.toURN(type, cs, identifier.getVersion(), identifier.getCode());
+ return NameMeaning.toURN(type, cs,
+ (identifier instanceof ReferenceIdentifier) ? ((ReferenceIdentifier) identifier).getVersion() : null,
+ identifier.getCode());
}
/**
@@ -852,7 +858,7 @@
* <ul>
* <li>If the given identifier implements the {@link GenericName} interface,
* then this method delegates to the {@link GenericName#toString()} method.</li>
- * <li>Otherwise if the given identifier has a {@linkplain Identifier#getCodeSpace() code space},
+ * <li>Otherwise if the given identifier has a {@linkplain ReferenceIdentifier#getCodeSpace() code space},
* then formats the identifier as "{@code codespace:code}".</li>
* <li>Otherwise if the given identifier has an {@linkplain Identifier#getAuthority() authority},
* then formats the identifier as "{@code authority:code}".</li>
@@ -879,7 +885,10 @@
return identifier.toString();
}
final String code = identifier.getCode();
- String cs = identifier.getCodeSpace();
+ String cs = null;
+ if (identifier instanceof ReferenceIdentifier) {
+ cs = ((ReferenceIdentifier) identifier).getCodeSpace();
+ }
if (Strings.isNullOrEmpty(cs)) {
cs = Citations.toCodeSpace(identifier.getAuthority());
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/ImmutableIdentifier.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/ImmutableIdentifier.java
index c5283d5..a7441b1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/ImmutableIdentifier.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/ImmutableIdentifier.java
@@ -41,6 +41,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.DefaultIdentifier;
+
/**
* Immutable value uniquely identifying an object within a namespace, together with a version.
@@ -118,6 +121,12 @@
private static final long serialVersionUID = 1804606250548055829L;
/**
+ * Key for the {@value} property in the map to be given to the constructor.
+ * This can be used for setting the value to be returned by {@link #getDescription()}.
+ */
+ public static final String DESCRIPTION_KEY = "description";
+
+ /**
* The person or party responsible for maintenance of the namespace, or {@code null} if not available.
*
* @see #getAuthority()
@@ -161,14 +170,18 @@
*
* @param identifier the identifier to copy.
*
- * @see #castOrCopy(Identifier)
+ * @see #castOrCopy(ReferenceIdentifier)
*/
- public ImmutableIdentifier(final Identifier identifier) {
+ public ImmutableIdentifier(final ReferenceIdentifier identifier) {
code = identifier.getCode();
codeSpace = identifier.getCodeSpace();
authority = identifier.getAuthority();
version = identifier.getVersion();
- description = identifier.getDescription();
+ if (identifier instanceof DefaultIdentifier) {
+ description = ((DefaultIdentifier) identifier).getDescription();
+ } else {
+ description = null;
+ }
validate(null);
}
@@ -223,19 +236,19 @@
* <td>{@link String}</td>
* <td>{@link #getCode()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#CODESPACE_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceIdentifier#CODESPACE_KEY}</td>
* <td>{@link String}</td>
* <td>{@link #getCodeSpace()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#AUTHORITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceIdentifier#AUTHORITY_KEY}</td>
* <td>{@link String} or {@link Citation}</td>
* <td>{@link #getAuthority()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#VERSION_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceIdentifier#VERSION_KEY}</td>
* <td>{@link String}</td>
* <td>{@link #getVersion()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>{@value #DESCRIPTION_KEY}</td>
* <td>{@link String} or {@link InternationalString}</td>
* <td>{@link #getDescription()}</td>
* </tr><tr>
@@ -321,7 +334,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code ImmutableIdentifier}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code ImmutableIdentifier} instance is created using the
- * {@linkplain #ImmutableIdentifier(Identifier) copy constructor} and returned.
+ * {@linkplain #ImmutableIdentifier(ReferenceIdentifier) copy constructor} and returned.
* Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -330,7 +343,7 @@
* @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
- public static ImmutableIdentifier castOrCopy(final Identifier object) {
+ public static ImmutableIdentifier castOrCopy(final ReferenceIdentifier object) {
if (object == null || object instanceof ImmutableIdentifier) {
return (ImmutableIdentifier) object;
}
@@ -406,7 +419,6 @@
*
* @since 0.5
*/
- @Override
public InternationalString getDescription() {
return description;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java
index 75d8613..be5d3e4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java
@@ -47,11 +47,6 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.AbstractFactory;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.RegisterOperations;
-import org.opengis.referencing.crs.SingleCRS;
-import org.apache.sis.referencing.datum.DatumOrEnsemble;
-
/**
* Finds <abbr>CRS</abbr>s or coordinate operations in one or many geodetic registries.
@@ -62,7 +57,7 @@
* <p>This class delegates its work to {@linkplain CRS#forCode(String) static methods} or to
* {@link MultiAuthoritiesFactory}. It does not provide new services compared to the above,
* but provides a more high-level <abbr>API</abbr> with the most important registry-based
- * services in a single place. {@link RegisterOperations} can also be used as en entry point,
+ * services in a single place. {@code RegisterOperations} can also be used as en entry point,
* with accesses to the low-level <abbr>API</abbr> granted by {@link #getFactory(Class)}.</p>
*
* <h2>User-defined geodetic registries</h2>
@@ -75,7 +70,7 @@
* @version 1.5
* @since 1.5
*/
-public class MultiRegisterOperations extends AbstractFactory implements RegisterOperations {
+public class MultiRegisterOperations extends AbstractFactory {
/**
* Types of factories supported by this implementation.
* A value of {@code true} means that the factory is an authority factory.
@@ -280,7 +275,6 @@
*
* @see CRS#forCode(String)
*/
- @Override
public CoordinateReferenceSystem findCoordinateReferenceSystem(final String code) throws FactoryException {
if (crsFactory != null) {
return crsFactory.createCoordinateReferenceSystem(code);
@@ -298,7 +292,6 @@
* @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
* @throws FactoryException if the search failed for some other reason.
*/
- @Override
public CoordinateOperation findCoordinateOperation(String code) throws FactoryException {
if (crsFactory instanceof CoordinateOperationAuthorityFactory) {
((CoordinateOperationAuthorityFactory) crsFactory).createCoordinateOperation(code);
@@ -316,7 +309,6 @@
* @return coordinate operations found or inferred between the given pair <abbr>CRS</abbr>s. May be an empty set.
* @throws FactoryException if an error occurred while searching for coordinate operations.
*/
- @Override
public Set<CoordinateOperation> findCoordinateOperations(CoordinateReferenceSystem source, CoordinateReferenceSystem target)
throws FactoryException
{
@@ -329,36 +321,6 @@
}
/**
- * Determines whether two <abbr>CRS</abbr>s are members of one ensemble.
- * If this method returns {@code true}, then for low accuracy purposes coordinate sets referenced
- * to these <abbr>CRS</abbr>s may be merged without coordinate transformation.
- * The attribute {@link DatumEnsemble#getEnsembleAccuracy()} gives some indication
- * of the inaccuracy introduced through such merger.
- *
- * @param source the source <abbr>CRS</abbr>.
- * @param target the target <abbr>CRS</abbr>.
- * @return whether the two <abbr>CRS</abbr>s are members of one ensemble.
- * @throws FactoryException if an error occurred while searching for ensemble information in the registry.
- */
- @Override
- public boolean areMembersOfSameEnsemble(CoordinateReferenceSystem source, CoordinateReferenceSystem target)
- throws FactoryException
- {
- final List<SingleCRS> sources = CRS.getSingleComponents(source);
- final List<SingleCRS> targets = CRS.getSingleComponents(target);
- final int n = targets.size();
- if (sources.size() != n) {
- return false;
- }
- for (int i=0; i<n; i++) {
- if (DatumOrEnsemble.ofTarget(sources.get(i), targets.get(i)).isEmpty()) {
- return false;
- }
- }
- return true;
- }
-
- /**
* Returns a factory used for building components of <abbr>CRS</abbr> or coordinate operations.
* The factories returned by this method provide accesses to the low-level services used by this
* {@code RegisterOperations} instance for implementing its high-level services.
@@ -370,7 +332,6 @@
* @throws IllegalArgumentException if the specified type is not one of the above-cited values.
* @throws FactoryException if an error occurred while searching or preparing the requested factory.
*/
- @Override
public <T extends Factory> Optional<T> getFactory(final Class<? extends T> type) throws FactoryException {
final Factory factory;
final Boolean b = FACTORY_TYPES.get(type);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/NamedIdentifier.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/NamedIdentifier.java
index acd8c41..c3a4e59 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/NamedIdentifier.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/NamedIdentifier.java
@@ -94,7 +94,7 @@
*
* @since 0.4
*/
-public class NamedIdentifier extends ImmutableIdentifier implements GenericName, ReferenceIdentifier {
+public class NamedIdentifier extends ImmutableIdentifier implements GenericName {
/**
* Serial number for inter-operability with different versions.
*/
@@ -122,9 +122,9 @@
*
* @param identifier the identifier to copy.
*
- * @see #castOrCopy(Identifier)
+ * @see #castOrCopy(ReferenceIdentifier)
*/
- public NamedIdentifier(final Identifier identifier) {
+ public NamedIdentifier(final ReferenceIdentifier identifier) {
super(identifier);
if (identifier instanceof GenericName) {
name = (GenericName) identifier;
@@ -142,7 +142,7 @@
* @see #castOrCopy(GenericName)
*/
public NamedIdentifier(final GenericName name) {
- super(name instanceof Identifier ? (Identifier) name : new NameToIdentifier(name));
+ super(name instanceof ReferenceIdentifier ? (ReferenceIdentifier) name : new NameToIdentifier(name));
this.name = name;
isNameSupplied = true;
}
@@ -169,7 +169,7 @@
* <td>{@link String}</td>
* <td>{@link #getCode()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#CODESPACE_KEY}</td>
+ * <td>"codespace"</td>
* <td>{@link String}</td>
* <td>{@link #getCodeSpace()}</td>
* </tr><tr>
@@ -177,11 +177,11 @@
* <td>{@link String} or {@link Citation}</td>
* <td>{@link #getAuthority()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#VERSION_KEY}</td>
+ * <td>"version"</td>
* <td>{@link String}</td>
* <td>{@link #getVersion()}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>"description"</td>
* <td>{@link String} or {@link InternationalString}</td>
* <td>{@link #getDescription()}</td>
* </tr><tr>
@@ -333,7 +333,7 @@
* <li>Otherwise if the given object is already an instance of
* {@code NamedIdentifier}, then it is returned unchanged.</li>
* <li>Otherwise a new {@code NamedIdentifier} instance is created using the
- * {@linkplain #NamedIdentifier(Identifier) copy constructor} and returned.
+ * {@linkplain #NamedIdentifier(ReferenceIdentifier) copy constructor} and returned.
* Note that this is a <em>shallow</em> copy operation, because the other
* metadata contained in the given object are not recursively copied.</li>
* </ul>
@@ -344,7 +344,7 @@
*
* @since 1.0
*/
- public static NamedIdentifier castOrCopy(final Identifier object) {
+ public static NamedIdentifier castOrCopy(final ReferenceIdentifier object) {
if (object == null || object instanceof NamedIdentifier) {
return (NamedIdentifier) object;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Properties.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Properties.java
index 5a3d432..66f1979 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Properties.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/Properties.java
@@ -36,8 +36,8 @@
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.datum.Datum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -64,10 +64,10 @@
/*[ 0]*/ IdentifiedObject .NAME_KEY,
/*[ 1]*/ IdentifiedObject .IDENTIFIERS_KEY,
/*[ 2]*/ IdentifiedObject .ALIAS_KEY,
- /*[ 3]*/ IdentifiedObject .DOMAINS_KEY,
+ /*[ 3]*/ AbstractIdentifiedObject.DOMAINS_KEY,
/*[ 4]*/ IdentifiedObject .REMARKS_KEY,
- /*[ 5]*/ ObjectDomain .SCOPE_KEY,
- /*[ 6]*/ ObjectDomain .DOMAIN_OF_VALIDITY_KEY,
+ /*[ 5]*/ CoordinateOperation .SCOPE_KEY, // same in Datum and ReferenceSystem
+ /*[ 6]*/ CoordinateOperation .DOMAIN_OF_VALIDITY_KEY, // same in Datum and ReferenceSystem
/*[ 7]*/ CoordinateOperation .OPERATION_VERSION_KEY,
/*[ 8]*/ CoordinateOperation .COORDINATE_OPERATION_ACCURACY_KEY,
/*[ 9]*/ OperationMethod .FORMULA_KEY,
@@ -130,11 +130,11 @@
final Object getAt(final int key) {
if ((excludeMask & (1 << key)) == 0) {
switch (key) {
- case 0: return object.getName(); // NAME_KEY
- case 1: return toArray(object.getIdentifiers(), ReferenceIdentifier[]::new); // IDENTIFIERS_KEY
- case 2: return toArray(object.getAlias(), GenericName[]::new); // ALIAS_KEY
- case 3: return toArray(object.getDomains(), ObjectDomain[]::new); // DOMAINS_KEY
- case 4: return object.getRemarks(); // REMARKS_KEY
+ case 0: return object.getName(); // NAME_KEY
+ case 1: return toArray(object.getIdentifiers(), ReferenceIdentifier[]::new); // IDENTIFIERS_KEY
+ case 2: return toArray(object.getAlias(), GenericName[]::new); // ALIAS_KEY
+ case 3: return toArray(Legacy.getDomains(object), DefaultObjectDomain[]::new); // DOMAINS_KEY
+ case 4: return object.getRemarks(); // REMARKS_KEY
case 5: { // SCOPE_KEY
if (object instanceof ReferenceSystem) {
return ((ReferenceSystem) object).getScope();
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java
index bfd2f36..4290ba0 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java
@@ -73,11 +73,9 @@
import org.apache.sis.measure.Units;
import static org.apache.sis.metadata.privy.ReferencingServices.AUTHALIC_RADIUS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.referencing.ObjectDomain.DOMAIN_OF_VALIDITY_KEY;
-
-// Specific to the geoapi-3.1 branch:
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
+import static org.opengis.referencing.datum.Datum.DOMAIN_OF_VALIDITY_KEY;
/**
@@ -350,7 +348,7 @@
case 5103: name = "North American Vertical Datum 1988"; alias = "NAVD88"; break;
default: throw new AssertionError(code);
}
- return new DefaultVerticalDatum(properties(code, name, alias, true), (RealizationMethod) null);
+ return new DefaultVerticalDatum(properties(code, name, alias, true), VerticalDatumType.GEOIDAL);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
index d09fa36..3afcfb5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
@@ -46,8 +46,10 @@
import org.opengis.referencing.crs.GeneralDerivedCRS;
import org.opengis.geometry.MismatchedDimensionException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -148,7 +150,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -156,11 +158,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -210,7 +212,7 @@
*
* @see #createSameType(AbstractCS)
*/
- AbstractCRS(final AbstractCRS original, final Identifier id, final AbstractCS cs) {
+ AbstractCRS(final AbstractCRS original, final ReferenceIdentifier id, final AbstractCS cs) {
super(ReferencingUtilities.getPropertiesWithoutIdentifiers(original, (id == null) ? null : Map.of(IDENTIFIERS_KEY, id)));
coordinateSystem = cs;
forConvention = cs.hasSameAxes(original.coordinateSystem) ? original.forConvention : original.forConvention();
@@ -245,7 +247,8 @@
* <li>If the given object is {@code null}, then this method returns {@code null}.</li>
* <li>Otherwise if the given object is an instance of
* {@link org.opengis.referencing.crs.GeodeticCRS} (including the
- * {@link org.opengis.referencing.crs.GeographicCRS subtype}),
+ * {@link org.opengis.referencing.crs.GeographicCRS} and
+ * {@link org.opengis.referencing.crs.GeocentricCRS} subtypes),
* {@link org.opengis.referencing.crs.VerticalCRS},
* {@link org.opengis.referencing.crs.TemporalCRS},
* {@link org.opengis.referencing.crs.EngineeringCRS},
@@ -300,6 +303,22 @@
}
/**
+ * Returns the datum ensemble.
+ *
+ * @return the datum ensemble, or {@code null} if none.
+ */
+ DefaultDatumEnsemble<?> getDatumEnsemble() {
+ return null;
+ }
+
+ /**
+ * Initializes the handler for getting datum ensemble of an arbitrary CRS.
+ */
+ static {
+ MissingMethods.datumEnsemble = (crs) -> (crs instanceof AbstractCRS) ? ((AbstractCRS) crs).getDatumEnsemble() : null;
+ }
+
+ /**
* Returns the coordinate system.
*
* @return the coordinate system.
@@ -477,7 +496,6 @@
*
* <p>This method should be invoked for WKT 2 formatting only.</p>
*/
- @SuppressWarnings("deprecation")
static boolean isBaseCRS(final Formatter formatter) {
return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
index 7a6753e..db2cd1a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
@@ -47,8 +47,8 @@
// 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.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -64,7 +64,6 @@
DefaultDerivedCRS.class,
DefaultProjectedCRS.class
})
-@SuppressWarnings("deprecation")
abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS implements GeneralDerivedCRS {
/**
* Serial number for inter-operability with different versions.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
index 686ef5b..e6d0cea 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
@@ -33,9 +33,10 @@
import org.apache.sis.referencing.internal.Resources;
import org.apache.sis.metadata.privy.ImplementationHelper;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
/**
@@ -80,7 +81,7 @@
* @see #getDatumEnsemble()
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
- private final DatumEnsemble<D> ensemble;
+ private final DefaultDatumEnsemble<D> ensemble;
/**
* Creates a coordinate reference system from the given properties, datum and coordinate system.
@@ -98,13 +99,13 @@
AbstractSingleCRS(final Map<String,?> properties,
final Class<D> datumType,
final D datum,
- final DatumEnsemble<D> ensemble,
+ final DefaultDatumEnsemble<D> ensemble,
final CoordinateSystem cs)
{
super(properties, cs);
- if (datum instanceof DatumEnsemble<?>) {
+ if (datum instanceof DefaultDatumEnsemble<?>) {
throw new IllegalArgumentException(Errors.forProperties(properties)
- .getString(Errors.Keys.IllegalArgumentClass_2, "datum", DatumEnsemble.class.getSimpleName()));
+ .getString(Errors.Keys.IllegalArgumentClass_2, "datum", DefaultDatumEnsemble.class.getSimpleName()));
}
this.datum = datum;
this.ensemble = ensemble;
@@ -144,7 +145,7 @@
* @param id new identifier for this CRS, or {@code null} if none.
* @param cs coordinate system with new axis order or units of measurement.
*/
- AbstractSingleCRS(final AbstractSingleCRS<D> original, final Identifier id, final AbstractCS cs) {
+ AbstractSingleCRS(final AbstractSingleCRS<D> original, final ReferenceIdentifier id, final AbstractCS cs) {
super(original, id, cs);
datum = original.datum;
ensemble = original.ensemble;
@@ -168,11 +169,11 @@
AbstractSingleCRS(final SingleCRS crs) {
super(crs);
datum = (D) crs.getDatum();
- if (datum instanceof DatumEnsemble<?>) {
+ if (datum instanceof DefaultDatumEnsemble<?>) {
throw new IllegalArgumentException(
- Errors.format(Errors.Keys.IllegalPropertyValueClass_2, "datum", DatumEnsemble.class));
+ Errors.format(Errors.Keys.IllegalPropertyValueClass_2, "datum", DefaultDatumEnsemble.class));
}
- ensemble = (DatumEnsemble<D>) crs.getDatumEnsemble();
+ ensemble = (DefaultDatumEnsemble<D>) MissingMethods.getDatumEnsemble(crs);
checkDatum(null);
}
@@ -204,7 +205,7 @@
* @return the datum ensemble, or {@code null} if none.
*/
@Override
- public DatumEnsemble<D> getDatumEnsemble() {
+ public DefaultDatumEnsemble<D> getDatumEnsemble() {
return ensemble;
}
@@ -228,7 +229,7 @@
default: {
final var that = (SingleCRS) object;
return Utilities.deepEquals(getDatum(), that.getDatum(), mode) &&
- Utilities.deepEquals(getDatumEnsemble(), that.getDatumEnsemble(), mode);
+ Utilities.deepEquals(getDatumEnsemble(), MissingMethods.getDatumEnsemble(that), mode);
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
index f9a0db0..853c5d1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
@@ -56,13 +56,6 @@
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Collection;
-import java.util.NoSuchElementException;
-import org.opengis.referencing.crs.ParametricCRS;
-import org.apache.sis.xml.NilObject;
-import org.apache.sis.metadata.privy.Identifiers;
-
/**
* A CRS describing the position of points through two or more independent coordinate reference systems.
@@ -153,7 +146,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -161,11 +154,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -362,7 +355,6 @@
*
* @see org.apache.sis.referencing.CRS#getSingleComponents(CoordinateReferenceSystem)
*/
- @Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<SingleCRS> getSingleComponents() {
return singles;
@@ -381,57 +373,12 @@
*/
private boolean setSingleComponents(final List<? extends CoordinateReferenceSystem> elements) {
final List<SingleCRS> flattened = new ArrayList<>(elements.size());
- final boolean identical = getSingleComponents(elements, flattened);
+ final boolean identical = ReferencingUtilities.getSingleComponents(elements, flattened);
singles = UnmodifiableArrayList.wrap(flattened.toArray(SingleCRS[]::new));
return identical;
}
/**
- * Copies all {@link SingleCRS} components from the given source to the given collection.
- * For each {@link CompoundCRS} element found in the iteration, this method replaces the
- * {@code CompoundCRS} by its {@linkplain CompoundCRS#getComponents() components}, which
- * may themselves have other {@code CompoundCRS}. Those replacements are performed recursively
- * until we obtain a flat view of CRS components.
- *
- * @param source the collection of single or compound CRS.
- * @param addTo where to add the single CRS in order to obtain a flat view of {@code source}.
- * @return {@code true} if this method found only single CRS in {@code source}, in which case {@code addTo}
- * got the same content (assuming that {@code addTo} was empty prior this method call).
- * @throws NoSuchElementException if a CRS component is missing.
- * @throws ClassCastException if a CRS is neither a {@link SingleCRS} or a {@link CompoundCRS}.
- *
- * @see org.apache.sis.referencing.CRS#getSingleComponents(CoordinateReferenceSystem)
- */
- private static boolean getSingleComponents(final Iterable<? extends CoordinateReferenceSystem> source,
- final Collection<? super SingleCRS> addTo) throws ClassCastException
- {
- boolean sameContent = true;
- for (final CoordinateReferenceSystem candidate : source) {
- if (candidate instanceof CompoundCRS) {
- getSingleComponents(((CompoundCRS) candidate).getComponents(), addTo);
- sameContent = false;
- } else if (candidate instanceof SingleCRS) {
- addTo.add((SingleCRS) candidate);
- } else {
- /*
- * Illegal class. Try to provide a better error message, in particular when the CRS component
- * is nil because it is an unresolved xlink in a GML document. Nil objects are proxies, which
- * have hard to understand class names.
- */
- final String message;
- if (candidate instanceof NilObject) {
- message = Errors.format(Errors.Keys.NilObject_1, Identifiers.getNilReason((NilObject) candidate));
- throw new NoSuchElementException(message);
- } else {
- message = Errors.format(Errors.Keys.NestedElementNotAllowed_1, ReferencingUtilities.getInterface(candidate));
- throw new ClassCastException(message);
- }
- }
- }
- return sameContent;
- }
-
- /**
* Computes the single CRS list on deserialization.
*
* @param in the input stream from which to deserialize a compound CRS.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
index 7fe8075..6574271 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
@@ -59,12 +59,12 @@
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.collection.Containers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.referencing.datum.ParametricDatum;
-import org.opengis.referencing.crs.ParametricCRS;
-import org.opengis.referencing.cs.ParametricCS;
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
/**
@@ -136,8 +136,8 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -212,7 +212,7 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@code this.getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@code domain.getDomainOfValidity()}</td>
* </tr>
@@ -287,7 +287,7 @@
case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, baseToDerived, derivedCS);
case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, baseToDerived, (VerticalCS) derivedCS);
case WKTKeywords.TimeCRS: return new Temporal (properties, (TemporalCRS) baseCRS, baseToDerived, (TimeCS) derivedCS);
- case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, baseToDerived, (ParametricCS) derivedCS);
+ case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, baseToDerived, (DefaultParametricCS) derivedCS);
case WKTKeywords.EngineeringCRS: {
/*
* This case may happen for baseCRS of kind GeodeticCRS, ProjectedCRS or EngineeringCRS.
@@ -341,7 +341,7 @@
case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, interpolationCRS, method, baseToDerived, derivedCS);
case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, interpolationCRS, method, baseToDerived, (VerticalCS) derivedCS);
case WKTKeywords.TimeCRS: return new Temporal (properties, (TemporalCRS) baseCRS, interpolationCRS, method, baseToDerived, (TimeCS) derivedCS);
- case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, interpolationCRS, method, baseToDerived, (ParametricCS) derivedCS);
+ case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, interpolationCRS, method, baseToDerived, (DefaultParametricCS) derivedCS);
case WKTKeywords.EngineeringCRS: {
if (baseCRS instanceof EngineeringCRS) {
// See the comment in create(Map, SingleCRS, Conversion, CoordinateSystem)
@@ -429,8 +429,8 @@
* @since 1.5
*/
@Override
- public DatumEnsemble<?> getDatumEnsemble() {
- return getBaseCRS().getDatumEnsemble();
+ public DefaultDatumEnsemble<?> getDatumEnsemble() {
+ return MissingMethods.getDatumEnsemble(getBaseCRS());
}
/**
@@ -632,7 +632,7 @@
return WKTKeywords.VerticalCRS;
} else if (TemporalCRS.class.isAssignableFrom(type) && derivedCS instanceof TimeCS) {
return WKTKeywords.TimeCRS;
- } else if (ParametricCRS.class.isAssignableFrom(type) && derivedCS instanceof ParametricCS) {
+ } else if (ParametricCRS.class.isAssignableFrom(type) && derivedCS instanceof DefaultParametricCS) {
return WKTKeywords.ParametricCRS;
} else if (ProjectedCRS.class.isAssignableFrom(type) || EngineeringCRS.class.isAssignableFrom(type)) {
return WKTKeywords.EngineeringCRS;
@@ -681,11 +681,6 @@
return (GeodeticDatum) super.getDatum();
}
- /** Returns the datum ensemble of the base geodetic CRS. */
- @Override public DatumEnsemble<GeodeticDatum> getDatumEnsemble() {
- return ((GeodeticCRS) getBaseCRS()).getDatumEnsemble();
- }
-
/** Returns a coordinate reference system of the same type as this CRS but with different axes. */
@Override AbstractCRS createSameType(final AbstractCS derivedCS) {
return new Geodetic(this, derivedCS);
@@ -737,11 +732,6 @@
return (VerticalDatum) super.getDatum();
}
- /** Returns the datum ensemble of the base vertical CRS. */
- @Override public DatumEnsemble<VerticalDatum> getDatumEnsemble() {
- return ((VerticalCRS) getBaseCRS()).getDatumEnsemble();
- }
-
/** Returns the coordinate system given at construction time. */
@Override public VerticalCS getCoordinateSystem() {
return (VerticalCS) super.getCoordinateSystem();
@@ -798,11 +788,6 @@
return (TemporalDatum) super.getDatum();
}
- /** Returns the datum ensemble of the base temporal CRS. */
- @Override public DatumEnsemble<TemporalDatum> getDatumEnsemble() {
- return ((TemporalCRS) getBaseCRS()).getDatumEnsemble();
- }
-
/** Returns the coordinate system given at construction time. */
@Override public TimeCS getCoordinateSystem() {
return (TimeCS) super.getCoordinateSystem();
@@ -843,30 +828,25 @@
}
/** Creates a new parametric CRS from the given properties. */
- Parametric(Map<String,?> properties, ParametricCRS baseCRS, Conversion baseToDerived, ParametricCS derivedCS) {
+ Parametric(Map<String,?> properties, ParametricCRS baseCRS, Conversion baseToDerived, DefaultParametricCS derivedCS) {
super(properties, baseCRS, baseToDerived, derivedCS);
}
/** Creates a new parametric CRS from the given properties. */
Parametric(Map<String,?> properties, ParametricCRS baseCRS, CoordinateReferenceSystem interpolationCRS,
- OperationMethod method, MathTransform baseToDerived, ParametricCS derivedCS)
+ OperationMethod method, MathTransform baseToDerived, DefaultParametricCS derivedCS)
{
super(properties, baseCRS, interpolationCRS, method, baseToDerived, derivedCS);
}
/** Returns the datum of the base parametric CRS. */
- @Override public ParametricDatum getDatum() {
- return (ParametricDatum) super.getDatum();
- }
-
- /** Returns the datum ensemble of the base parametric CRS. */
- @Override public DatumEnsemble<ParametricDatum> getDatumEnsemble() {
- return ((ParametricCRS) getBaseCRS()).getDatumEnsemble();
+ @Override public DefaultParametricDatum getDatum() {
+ return (DefaultParametricDatum) super.getDatum();
}
/** Returns the coordinate system given at construction time. */
- @Override public ParametricCS getCoordinateSystem() {
- return (ParametricCS) super.getCoordinateSystem();
+ @Override public DefaultParametricCS getCoordinateSystem() {
+ return (DefaultParametricCS) super.getCoordinateSystem();
}
/** Returns a coordinate reference system of the same type as this CRS but with different axes. */
@@ -923,11 +903,6 @@
return (EngineeringDatum) super.getDatum();
}
- /** Returns the datum ensemble of the base engineering CRS. */
- @Override public DatumEnsemble<EngineeringDatum> getDatumEnsemble() {
- return ((EngineeringCRS) getBaseCRS()).getDatumEnsemble();
- }
-
/** Returns a coordinate reference system of the same type as this CRS but with different axes. */
@Override AbstractCRS createSameType(final AbstractCS derivedCS) {
return new Engineering(this, derivedCS);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
index b4a6f31..710e920 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
@@ -30,8 +30,8 @@
import org.apache.sis.xml.bind.referencing.CS_CoordinateSystem;
import org.apache.sis.io.wkt.Formatter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -101,7 +101,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -109,11 +109,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -128,20 +128,20 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createEngineeringCRS(Map, EngineeringDatum, DatumEnsemble, CoordinateSystem)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createEngineeringCRS(Map, EngineeringDatum, DefaultDatumEnsemble, CoordinateSystem)
*
* @since 1.5
*/
public DefaultEngineeringCRS(final Map<String,?> properties,
final EngineeringDatum datum,
- final DatumEnsemble<EngineeringDatum> ensemble,
+ final DefaultDatumEnsemble<EngineeringDatum> ensemble,
final CoordinateSystem cs)
{
super(properties, EngineeringDatum.class, datum, ensemble, cs);
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultEngineeringCRS(final Map<String,?> properties,
@@ -225,13 +225,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<EngineeringDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<EngineeringDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
@@ -367,14 +371,13 @@
* The types for which a specialized method exists.
* Not including {@link CartesianCS}, because this case is already covered by {@link AffineCS}.
*/
- @SuppressWarnings("deprecation")
private static final Class<?>[] SPECIALIZED_TYPES = {
AffineCS.class, SphericalCS.class, CylindricalCS.class, PolarCS.class, LinearCS.class, UserDefinedCS.class
};
/**
* Returns the coordinate system if it is not an instance of any of the types handled by specialized methods.
- * It is the case of {@link EllipsoidalCS}, {@link VerticalCS}, {@link TimeCS} and {@link ParametricCS}.
+ * It is the case of {@link EllipsoidalCS}, {@link VerticalCS}, {@link TimeCS} and {@link DefaultParametricCS}.
*/
@XmlElement(name = "coordinateSystem", required = true)
@XmlJavaTypeAdapter(CS_CoordinateSystem.class)
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
index b35fdc3..20bc0f7 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
@@ -32,8 +32,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.crs.GeocentricCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -58,8 +58,8 @@
* <li>Create a {@code GeodeticCRS} from one of the static convenience shortcuts listed in
* {@link org.apache.sis.referencing.CommonCRS#geocentric()}.</li>
* <li>Create a {@code GeodeticCRS} from an identifier in a database by invoking
- * {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeodeticCRS(String)}.</li>
- * <li>Create a {@code GeodeticCRS} by invoking the {@code CRSFactory.createGeodeticCRS(…)} method
+ * {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeocentricCRS(String)}.</li>
+ * <li>Create a {@code GeodeticCRS} by invoking the {@code CRSFactory.createGeocentricCRS(…)} method
* (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
* <li>Create a {@code GeodeticCRS} by invoking the
* {@linkplain #DefaultGeocentricCRS(Map, GeodeticDatum, CartesianCS) constructor}.</li>
@@ -79,12 +79,11 @@
* @author Martin Desruisseaux (IRD, Geomatys)
* @version 1.5
*
- * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeodeticCRS(String)
+ * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeocentricCRS(String)
*
* @since 0.4
*/
@XmlTransient
-@SuppressWarnings("deprecation")
public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements GeocentricCRS {
/**
* Serial number for inter-operability with different versions.
@@ -106,7 +105,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -114,11 +113,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -133,13 +132,13 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system, which must be three-dimensional.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, DatumEnsemble, CartesianCS)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, DefaultDatumEnsemble, CartesianCS)
*
* @since 1.5
*/
public DefaultGeocentricCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final CartesianCS cs)
{
super(properties, datum, ensemble, cs);
@@ -158,13 +157,13 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, DatumEnsemble, SphericalCS)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, DefaultDatumEnsemble, SphericalCS)
*
* @since 1.5
*/
public DefaultGeocentricCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final SphericalCS cs)
{
super(properties, datum, ensemble, cs);
@@ -172,7 +171,7 @@
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultGeocentricCRS(final Map<String,?> properties,
@@ -183,7 +182,7 @@
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultGeocentricCRS(final Map<String,?> properties,
@@ -246,6 +245,11 @@
* Returns the GeoAPI interface implemented by this class.
* The SIS implementation returns {@code GeocentricCRS.class}.
*
+ * <h4>Note for implementers</h4>
+ * Subclasses usually do not need to override this method since GeoAPI does not define {@code GeocentricCRS}
+ * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their
+ * own set of interfaces.
+ *
* @return {@code GeocentricCRS.class} or a user-defined sub-interface.
*/
@Override
@@ -272,13 +276,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<GeodeticDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<GeodeticDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
index e1ad9ff..06f36fb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
@@ -44,9 +44,10 @@
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -92,7 +93,7 @@
*/
DefaultGeodeticCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final CoordinateSystem cs)
{
super(properties, GeodeticDatum.class, datum, ensemble, cs);
@@ -102,7 +103,7 @@
* Creates a new CRS derived from the specified one, but with different axis order or unit.
* This is for implementing the {@link #createSameType(AbstractCS)} method only.
*/
- DefaultGeodeticCRS(final DefaultGeodeticCRS original, final Identifier id, final AbstractCS cs) {
+ DefaultGeodeticCRS(final DefaultGeodeticCRS original, final ReferenceIdentifier id, final AbstractCS cs) {
super(original, id, cs);
}
@@ -160,6 +161,14 @@
}
/**
+ * Initializes the handler for getting datum ensemble of an arbitrary CRS.
+ */
+ static {
+ MissingMethods.geodeticDatumEnsemble = (crs) ->
+ (crs instanceof DefaultGeodeticCRS) ? ((DefaultGeodeticCRS) crs).getDatumEnsemble() : null;
+ }
+
+ /**
* Returns a coordinate reference system of the same type as this CRS but with different axes.
* This method shall be overridden by all {@code DefaultGeodeticCRS} subclasses in this package.
*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
index e366e34..b8d56d6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
@@ -43,9 +43,9 @@
import static org.apache.sis.util.privy.Constants.CRS83;
import static org.apache.sis.util.privy.Constants.CRS84;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -129,7 +129,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -137,11 +137,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -156,13 +156,13 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the two- or three-dimensional coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeographicCRS(Map, GeodeticDatum, DatumEnsemble, EllipsoidalCS)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeographicCRS(Map, GeodeticDatum, DefaultDatumEnsemble, EllipsoidalCS)
*
* @since 1.5
*/
public DefaultGeographicCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final EllipsoidalCS cs)
{
super(properties, datum, ensemble, cs);
@@ -170,7 +170,7 @@
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultGeographicCRS(final Map<String,?> properties,
@@ -184,7 +184,7 @@
* Creates a new CRS derived from the specified one, but with different axis order or unit.
* This is for implementing the {@link #createSameType(AbstractCS)} method only.
*/
- private DefaultGeographicCRS(final DefaultGeographicCRS original, final Identifier id, final AbstractCS cs) {
+ private DefaultGeographicCRS(final DefaultGeographicCRS original, final ReferenceIdentifier id, final AbstractCS cs) {
super(original, id, cs);
}
@@ -301,13 +301,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<GeodeticDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<GeodeticDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
@@ -345,12 +349,12 @@
*/
@Override
final AbstractCRS createSameType(final AbstractCS cs) {
- Identifier id = null;
+ ReferenceIdentifier id = null;
final CoordinateSystemAxis axis = cs.getAxis(0);
if (axis.getMinimumValue() == Longitude.MIN_VALUE &&
axis.getMaximumValue() == Longitude.MAX_VALUE) // For excluding the AxesConvention.POSITIVE_RANGE case.
{
- for (final Identifier identifier : super.getIdentifiers()) {
+ for (final ReferenceIdentifier identifier : super.getIdentifiers()) {
if (EPSG.equals(identifier.getCodeSpace())) try {
final int i = Arrays.binarySearch(EPSG_CODES, Short.parseShort(identifier.getCode()));
if (i >= 0) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
index 3f46606..79f1052 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
@@ -88,7 +88,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -96,11 +96,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
index adcee10..f637341 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
@@ -25,11 +25,10 @@
import org.apache.sis.referencing.cs.AbstractCS;
import org.apache.sis.io.wkt.Formatter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.cs.ParametricCS;
-import org.opengis.referencing.crs.ParametricCRS;
-import org.opengis.referencing.datum.ParametricDatum;
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -62,7 +61,7 @@
"datum"
})
@XmlRootElement(name = "ParametricCRS")
-public class DefaultParametricCRS extends AbstractSingleCRS<ParametricDatum> implements ParametricCRS {
+public class DefaultParametricCRS extends AbstractSingleCRS<DefaultParametricDatum> implements ParametricCRS {
/**
* Serial number for inter-operability with different versions.
*/
@@ -94,8 +93,8 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -104,32 +103,34 @@
* </tr>
* </table>
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter types may be changed to
+ * {@code org.opengis.referencing.datum.ParametricDatum} and {@code org.opengis.referencing.cs.ParametricCS}
+ * Those change are pending GeoAPI revision.</div>
+ *
* @param properties the properties to be given to the coordinate reference system.
* @param datum the datum, or {@code null} if the CRS is associated only to a datum ensemble.
* @param ensemble collection of reference frames which for low accuracy requirements may be considered to be
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createParametricCRS(Map, ParametricDatum, DatumEnsemble, ParametricCS)
- *
* @since 1.5
*/
public DefaultParametricCRS(final Map<String,?> properties,
- final ParametricDatum datum,
- final DatumEnsemble<ParametricDatum> ensemble,
- final ParametricCS cs)
+ final DefaultParametricDatum datum,
+ final DefaultDatumEnsemble<DefaultParametricDatum> ensemble,
+ final DefaultParametricCS cs)
{
- super(properties, ParametricDatum.class, datum, ensemble, cs);
+ super(properties, DefaultParametricDatum.class, datum, ensemble, cs);
checkDimension(1, 1, cs);
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultParametricCRS(final Map<String,?> properties,
- final ParametricDatum datum,
- final ParametricCS cs)
+ final DefaultParametricDatum datum,
+ final DefaultParametricCS cs)
{
this(properties, datum, null, cs);
}
@@ -149,46 +150,16 @@
*
* <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter type may be changed
+ * to {@code org.opengis.referencing.crs.ParametricCRS}. This change is pending GeoAPI revision.</div>
+ *
* @param crs the coordinate reference system to copy.
- *
- * @see #castOrCopy(ParametricCRS)
*/
- protected DefaultParametricCRS(final ParametricCRS crs) {
+ protected DefaultParametricCRS(final DefaultParametricCRS crs) {
super(crs);
}
/**
- * Returns a SIS coordinate reference system implementation with the same values as the given
- * arbitrary implementation. If the given object is {@code null}, then this method returns {@code null}.
- * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
- * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultParametricCRS castOrCopy(final ParametricCRS object) {
- return (object == null || object instanceof DefaultParametricCRS)
- ? (DefaultParametricCRS) object : new DefaultParametricCRS(object);
- }
-
- /**
- * Returns the GeoAPI interface implemented by this class.
- * The SIS implementation returns {@code ParametricCRS.class}.
- *
- * <h4>Note for implementers</h4>
- * Subclasses usually do not need to override this method since GeoAPI does not define {@code ParametricCRS}
- * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their
- * own set of interfaces.
- *
- * @return {@code ParametricCRS.class} or a user-defined sub-interface.
- */
- @Override
- public Class<? extends ParametricCRS> getInterface() {
- return ParametricCRS.class;
- }
-
- /**
* Returns the reference surface used as the origin of this <abbr>CRS</abbr>.
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a {@linkplain #getDatumEnsemble() datum ensemble}.
@@ -198,7 +169,7 @@
*/
@Override
@XmlElement(name = "parametricDatum", required = true)
- public ParametricDatum getDatum() {
+ public DefaultParametricDatum getDatum() {
return super.getDatum();
}
@@ -208,13 +179,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<ParametricDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<DefaultParametricDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
@@ -225,8 +200,8 @@
*/
@Override
@XmlElement(name = "parametricCS", required = true)
- public ParametricCS getCoordinateSystem() {
- return (ParametricCS) super.getCoordinateSystem();
+ public DefaultParametricCS getCoordinateSystem() {
+ return (DefaultParametricCS) super.getCoordinateSystem();
}
/**
@@ -305,7 +280,7 @@
*
* @see #getDatum()
*/
- private void setDatum(final ParametricDatum value) {
+ private void setDatum(final DefaultParametricDatum value) {
setDatum("parametricDatum", value);
}
@@ -314,7 +289,7 @@
*
* @see #getCoordinateSystem()
*/
- private void setCoordinateSystem(final ParametricCS cs) {
+ private void setCoordinateSystem(final DefaultParametricCS cs) {
setCoordinateSystem("parametricCS", cs);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
index 88f81fb..346f14e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
@@ -44,9 +44,10 @@
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.operation.Projection;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
/**
@@ -109,8 +110,8 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -246,8 +247,8 @@
* @since 1.5
*/
@Override
- public DatumEnsemble<GeodeticDatum> getDatumEnsemble() {
- return getBaseCRS().getDatumEnsemble();
+ public DefaultDatumEnsemble<GeodeticDatum> getDatumEnsemble() {
+ return MissingMethods.getDatumEnsemble(getBaseCRS());
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
index f81040f..cf11401 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
@@ -48,8 +48,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -123,7 +123,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -131,11 +131,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -150,14 +150,14 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createTemporalCRS(Map, TemporalDatum, DatumEnsemble, TimeCS)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createTemporalCRS(Map, TemporalDatum, DefaultDatumEnsemble, TimeCS)
*
* @since 1.5
*/
@SuppressWarnings("this-escape")
public DefaultTemporalCRS(final Map<String,?> properties,
final TemporalDatum datum,
- final DatumEnsemble<TemporalDatum> ensemble,
+ final DefaultDatumEnsemble<TemporalDatum> ensemble,
final TimeCS cs)
{
super(properties, TemporalDatum.class, datum, ensemble, cs);
@@ -166,7 +166,7 @@
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultTemporalCRS(final Map<String,?> properties,
@@ -284,13 +284,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<TemporalDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<TemporalDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
index 41ef613..3eff4ea 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
@@ -29,8 +29,8 @@
import org.apache.sis.referencing.privy.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
/**
@@ -84,7 +84,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -92,11 +92,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -111,13 +111,13 @@
* insignificantly different from each other, or {@code null} if there is no such ensemble.
* @param cs the coordinate system.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createVerticalCRS(Map, VerticalDatum, DatumEnsemble, VerticalCS)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createVerticalCRS(Map, VerticalDatum, DefaultDatumEnsemble, VerticalCS)
*
* @since 1.5
*/
public DefaultVerticalCRS(final Map<String,?> properties,
final VerticalDatum datum,
- final DatumEnsemble<VerticalDatum> ensemble,
+ final DefaultDatumEnsemble<VerticalDatum> ensemble,
final VerticalCS cs)
{
super(properties, VerticalDatum.class, datum, ensemble, cs);
@@ -125,7 +125,7 @@
}
/**
- * @deprecated A {@code DatumEnsemble} argument has been added.
+ * @deprecated A {@code DefaultDatumEnsemble} argument has been added.
*/
@Deprecated(since="1.5", forRemoval=true)
public DefaultVerticalCRS(final Map<String,?> properties,
@@ -209,13 +209,17 @@
* This property may be null if this <abbr>CRS</abbr> is related to an object
* identified only by a single {@linkplain #getDatum() datum}.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may
+ * be changed to the {@code org.opengis.referencing.datum.DatumEnsemble} interface.
+ * This change is pending GeoAPI revision.</div>
+ *
* @return the datum ensemble, or {@code null} if this <abbr>CRS</abbr> is related
* to an object identified only by a single {@linkplain #getDatum() datum}.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<VerticalDatum> getDatumEnsemble() {
+ public DefaultDatumEnsemble<VerticalDatum> getDatumEnsemble() {
return super.getDatumEnsemble();
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/ParametricCRS.java
similarity index 76%
copy from incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
copy to endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/ParametricCRS.java
index 8fb81f9..a1d7d8a 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Ellipse.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/ParametricCRS.java
@@ -14,13 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.geometries.conics;
+package org.apache.sis.referencing.crs;
+
+import org.opengis.referencing.crs.SingleCRS;
/**
+ * Place-holder for an interface not yet present in GeoAPI 3.0.
*
- * @author Johann Sorel (Geomatys)
+ * @author Martin Desruisseaux (Geomatys)
*/
-public interface Ellipse {
-
+interface ParametricCRS extends SingleCRS {
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
index 3b38a84..af100a1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
@@ -163,7 +163,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -171,7 +171,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -199,7 +199,6 @@
* @param properties properties given at construction time, or {@code null} if none.
* @throws IllegalArgumentException if an axis has an illegal direction or an illegal unit of measurement.
*/
- @SuppressWarnings("deprecation")
void validate(final Map<String,?> properties) {
for (int i=0; i<axes.length; i++) {
final CoordinateSystemAxis axis = axes[i];
@@ -231,7 +230,7 @@
* more than one time axis. Such case happen in meteorological models.
*/
final AxisDirection dir = AxisDirections.absolute(direction);
- if (dir != AxisDirection.UNSPECIFIED && dir != AxisDirection.OTHER) {
+ if (dir != AxisDirections.UNSPECIFIED && dir != AxisDirection.OTHER) {
for (int j=i; --j>=0;) {
final AxisDirection other = axes[j].getDirection();
final AxisDirection abs = AxisDirections.absolute(other);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
index debcf1f..12c32d4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
@@ -73,7 +73,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -81,7 +81,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
index 29055ae..28e97a3 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
@@ -81,7 +81,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -89,7 +89,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
index b77b1d6..d12c89f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
@@ -80,7 +80,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -88,7 +88,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
index 120198b..770488b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
@@ -255,7 +255,7 @@
* <th colspan="3" class="hsep">Defined in parent class (reminder)</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -263,7 +263,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
index 1339cae..3878337 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
@@ -77,7 +77,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -85,7 +85,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
index 526bcf8..0695130 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
@@ -76,7 +76,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -84,7 +84,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
index b5a5934..ad4077f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
@@ -74,7 +74,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -82,7 +82,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
index be8df74..9742a55 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
@@ -21,9 +21,6 @@
import jakarta.xml.bind.annotation.XmlType;
import org.opengis.referencing.cs.CoordinateSystemAxis;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.cs.ParametricCS;
-
/**
* A 1-dimensional coordinate system for parametric values or functions.
@@ -55,7 +52,7 @@
*/
@XmlType(name = "ParametricCSType")
@XmlRootElement(name = "ParametricCS")
-public class DefaultParametricCS extends AbstractCS implements ParametricCS {
+public class DefaultParametricCS extends AbstractCS {
/**
* Serial number for inter-operability with different versions.
*/
@@ -117,46 +114,16 @@
*
* <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter type may be changed
+ * to {@code org.opengis.referencing.cs.ParametricCS}. This change is pending GeoAPI revision.</div>
+ *
* @param original the coordinate system to copy.
- *
- * @see #castOrCopy(ParametricCS)
*/
- protected DefaultParametricCS(final ParametricCS original) {
+ protected DefaultParametricCS(final DefaultParametricCS original) {
super(original);
}
/**
- * Returns a SIS coordinate system implementation with the same values as the given arbitrary implementation.
- * If the given object is {@code null}, then this method returns {@code null}.
- * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
- * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultParametricCS castOrCopy(final ParametricCS object) {
- return (object == null) || (object instanceof DefaultParametricCS)
- ? (DefaultParametricCS) object : new DefaultParametricCS(object);
- }
-
- /**
- * Returns the GeoAPI interface implemented by this class.
- * The SIS implementation returns {@code ParametricCS.class}.
- *
- * <h4>Note for implementers</h4>
- * Subclasses usually do not need to override this method since GeoAPI does not define {@code ParametricCS}
- * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with
- * their own set of interfaces.
- *
- * @return {@code ParametricCS.class} or a user-defined sub-interface.
- */
- @Override
- public Class<? extends ParametricCS> getInterface() {
- return ParametricCS.class;
- }
-
- /**
* {@inheritDoc}
*
* @return {@inheritDoc}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
index 94ff57e..9889dd5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
@@ -77,7 +77,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -85,7 +85,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
index 86bbdae..d1f7ccb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
@@ -81,7 +81,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -89,7 +89,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
index 7c187e6..91d9b5f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
@@ -26,9 +26,6 @@
import org.apache.sis.referencing.privy.AxisDirections;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.cs.CoordinateDataType;
-
/**
* A 1-dimensional coordinate system for time elapsed in the specified time units from a specified time origin.
@@ -80,7 +77,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -88,7 +85,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -179,19 +176,6 @@
}
/**
- * Returns the type (measure, integer or data-time) of coordinate values.
- * The current implementation supports only {@link CoordinateDataType#MEASURE}.
- *
- * @return the type of coordinate values.
- *
- * @since 1.5
- */
- @Override
- public CoordinateDataType getCoordinateType() {
- return CoordinateDataType.MEASURE;
- }
-
- /**
* {@inheritDoc}
*
* @return {@inheritDoc}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
index 525b514..9132237 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
@@ -73,7 +73,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -81,7 +81,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
index 5a240bf..3edc1fb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
@@ -88,7 +88,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -96,7 +96,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
index 0ccd5f3..f7a9cd8 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
@@ -114,11 +114,11 @@
// Get ordinal of last compass direction defined by GeoAPI. We will continue on the horizontal plane.
int code = (AxisDirection.NORTH.ordinal() + (AxisDirections.COMPASS_COUNT - 1)) << SHIFT;
for (final AxisDirection d : new AxisDirection[] {
- AxisDirection.FORWARD,
- AxisDirection.STARBOARD,
- AxisDirection.COUNTER_CLOCKWISE,
- AxisDirection.CLOCKWISE,
- AxisDirection.AWAY_FROM
+ AxisDirections.FORWARD,
+ AxisDirections.STARBOARD,
+ AxisDirections.COUNTER_CLOCKWISE,
+ AxisDirections.CLOCKWISE,
+ AxisDirections.AWAY_FROM
}) ORDER.put(d, ++code);
// Set the time coordinate as the last coordinate in all cases.
ORDER.put(AxisDirection.PAST, (Integer.MAX_VALUE >>> 1) - 1);
@@ -332,7 +332,7 @@
* If we were not allowed to normalize the axis direction, we may have a
* left-handed coordinate system here. If so, make it right-handed.
*/
- if (newAxes[1].getDirection() == AxisDirection.CLOCKWISE && isLengthAndAngle(newAxes, 0)) {
+ if (newAxes[1].getDirection() == AxisDirections.CLOCKWISE && isLengthAndAngle(newAxes, 0)) {
ArraysExt.swap(newAxes, 0, 1);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
index 3bbfaa0..864983a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
@@ -46,9 +46,11 @@
import static org.apache.sis.util.Utilities.deepEquals;
import static org.apache.sis.util.collection.Containers.property;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.datum.DynamicReferenceFrame;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.metadata.extent.Extent;
+import org.apache.sis.referencing.internal.Legacy;
+import org.apache.sis.pending.geoapi.referencing.DynamicReferenceFrame;
/**
@@ -96,6 +98,48 @@
private static final long serialVersionUID = 5380816794438838309L;
/**
+ * Key for the <code>{@value}</code> property to be given to the
+ * {@code DatumFactory.createFoo(Map, ...)} methods.
+ * This is used for setting the value to be returned by {@link #getAnchorDefinition()}.
+ *
+ * @see DatumFactory
+ * @see #getAnchorDefinition()
+ *
+ * @since 1.5
+ */
+ public static final String ANCHOR_DEFINITION_KEY = "anchorDefinition";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the
+ * {@code DatumFactory.createFoo(Map, ...)} methods.
+ * This is used for setting the value to be returned by {@link #getAnchorEpoch()}.
+ *
+ * @see DatumFactory
+ * @see #getAnchorEpoch()
+ *
+ * @since 1.5
+ */
+ public static final String ANCHOR_EPOCH_KEY = "anchorEpoch";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the
+ * {@code DatumFactory.createFoo(Map, ...)} methods.
+ * This is used for setting the value to be returned by {@link #getPublicationDate()}.
+ *
+ * @since 1.5
+ */
+ public static final String PUBLICATION_DATE_KEY = "publicationDate";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the
+ * {@code DatumFactory.createFoo(Map, ...)} methods.
+ * This is used for setting the value to be returned by {@link #getConventionalRS()}.
+ *
+ * @since 1.5
+ */
+ public static final String CONVENTIONAL_RS_KEY = "conventionalRS";
+
+ /**
* Description, possibly including coordinates, of the point or points used to anchor the datum to the Earth.
* Also known as the "origin", especially for Engineering and Image Datums.
*
@@ -148,26 +192,26 @@
* <th>Value type</th>
* <th>Returned by</th>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@value #ANCHOR_EPOCH_KEY}</td>
* <td>{@link Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#PUBLICATION_DATE_KEY}</td>
+ * <td>{@value #PUBLICATION_DATE_KEY}</td>
* <td>{@link Temporal}</td>
* <td>{@link #getPublicationDate()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#CONVENTIONAL_RS_KEY}</td>
+ * <td>{@value #CONVENTIONAL_RS_KEY}</td>
* <td>{@link IdentifiedObject}</td>
* <td>{@link #getConventionalRS()}</td>
* </tr><tr>
* <th colspan="3" class="hsep">Defined in parent class (reminder)</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -175,11 +219,11 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -190,7 +234,6 @@
*
* @param properties the properties to be given to the identified object.
*/
- @SuppressWarnings("deprecation")
public AbstractDatum(final Map<String,?> properties) {
super(properties);
anchorDefinition = Types.toInternationalString(properties, ANCHOR_DEFINITION_KEY);
@@ -219,10 +262,19 @@
*/
protected AbstractDatum(final Datum datum) {
super(datum);
- anchorEpoch = datum.getAnchorEpoch().orElse(null);
- anchorDefinition = datum.getAnchorDefinition().orElse(null);
- publicationDate = datum.getPublicationDate().orElse(null);
- conventionalRS = datum.getConventionalRS().orElse(null);
+ Date date = datum.getRealizationEpoch();
+ if (date != null) {
+ anchorEpoch = date.toInstant();
+ }
+ anchorDefinition = datum.getAnchorPoint();
+ if (datum instanceof AbstractDatum) {
+ final var cd = (AbstractDatum) datum;
+ publicationDate = cd.getPublicationDate().orElse(null);
+ conventionalRS = cd.getConventionalRS().orElse(null);
+ } else {
+ publicationDate = null;
+ conventionalRS = null;
+ }
}
/**
@@ -287,7 +339,6 @@
*
* @since 1.5
*/
- @Override
public Optional<InternationalString> getAnchorDefinition() {
return Optional.ofNullable(anchorDefinition);
}
@@ -318,7 +369,6 @@
*
* @since 1.5
*/
- @Override
public Optional<Temporal> getAnchorEpoch() {
return Optional.ofNullable(anchorEpoch);
}
@@ -335,7 +385,33 @@
@XmlSchemaType(name = "date")
@XmlElement(name = "realizationEpoch")
public Date getRealizationEpoch() {
- return Datum.super.getRealizationEpoch();
+ return getAnchorEpoch().map(Legacy::toDate).orElse(null);
+ }
+
+ /**
+ * Returns the region or timeframe in which this datum is valid, or {@code null} if unspecified.
+ *
+ * @return area or region or timeframe in which this datum is valid, or {@code null}.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public Extent getDomainOfValidity() {
+ return Legacy.getDomainOfValidity(getDomains());
+ }
+
+ /**
+ * Returns the domain or limitations of usage, or {@code null} if unspecified.
+ *
+ * @return description of domain of usage, or limitations of usage, for which this datum object is valid.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public InternationalString getScope() {
+ return Legacy.getScope(getDomains());
}
/**
@@ -356,7 +432,6 @@
*
* @since 1.5
*/
- @Override
public Optional<Temporal> getPublicationDate() {
return Optional.ofNullable(publicationDate);
}
@@ -370,7 +445,6 @@
*
* @since 1.5
*/
- @Override
public Optional<IdentifiedObject> getConventionalRS() {
return Optional.ofNullable(conventionalRS);
}
@@ -434,9 +508,9 @@
* and the {@linkplain #getDomains() domains}.
*
* <h4>Static versus dynamic datum</h4>
- * If this datum implements the {@link DynamicReferenceFrame} interface, then the given object needs
+ * If this datum implements the {@code DynamicReferenceFrame} interface, then the given object needs
* to also implement that interfaces and provide the same reference epoch for being considered equal.
- * Conversely, if this datum does not implement {@link DynamicReferenceFrame}, then the given object
+ * Conversely, if this datum does not implement {@code DynamicReferenceFrame}, then the given object
* also need to <em>not</em> implement that interface for being considered equal.
*
* @param object the object to compare to {@code this}.
@@ -459,7 +533,13 @@
Objects.equals(conventionalRS, that.conventionalRS);
}
case BY_CONTRACT: {
- final var that = (Datum) object;
+ if (!(object instanceof AbstractDatum)) {
+ return getAnchorEpoch().isEmpty() &&
+ getAnchorDefinition().isEmpty() &&
+ getPublicationDate().isEmpty() &&
+ getConventionalRS().isEmpty();
+ }
+ final var that = (AbstractDatum) object;
return compareDynamicReferenceFrames(that, mode) &&
deepEquals(getAnchorEpoch(), that.getAnchorEpoch(), mode) &&
deepEquals(getAnchorDefinition(), that.getAnchorDefinition(), mode) &&
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java
index 840aba2..5ef83e2 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java
@@ -616,7 +616,7 @@
@OptionalCandidate
public Extent getDomainOfValidity() {
if (domainOfValidity == null && targetDatum != null) {
- return IdentifiedObjects.getDomainOfValidity(targetDatum).orElse(null);
+ return targetDatum.getDomainOfValidity();
}
return domainOfValidity;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DatumOrEnsemble.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DatumOrEnsemble.java
index 7cf5218..9823622 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DatumOrEnsemble.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DatumOrEnsemble.java
@@ -42,10 +42,10 @@
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.GeodeticException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.crs.ParametricCRS;
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.referencing.datum.ParametricDatum;
+// Specific to the main branch:
+import java.util.logging.Logger;
+import org.apache.sis.system.Modules;
+import org.apache.sis.util.logging.Logging;
/**
@@ -60,6 +60,7 @@
* @version 1.5
* @since 1.5
*/
+@SuppressWarnings("unchecked") // See `getDatumEnsemble(…)`
public final class DatumOrEnsemble extends Static {
/**
* Do not allow instantiation of this class.
@@ -78,7 +79,28 @@
public static IdentifiedObject of(final SingleCRS crs) {
if (crs == null) return null;
final Datum datum = crs.getDatum();
- return (datum != null) ? datum : crs.getDatumEnsemble();
+ return (datum != null) ? datum : getDatumEnsemble(crs);
+ }
+
+ /**
+ * Returns the datum ensemble of the given <abbr>CRS</abbr>. This method uses reflection
+ * because the {@code SingleCRS.getDatumEnsemble()} method was not available in GeoAPI 3.0.
+ *
+ * <p>The {@code <?>} parameterized type is intentionally omitted. It makes this method unsafe,
+ * but it should be okay for datum ensembles created by {@link DefaultDatumEnsemble} static methods.
+ * The safety problem is resolved on the GeoAP 3.1 branch.</p>
+ */
+ @SuppressWarnings("rawtypes")
+ private static DefaultDatumEnsemble getDatumEnsemble(final CoordinateReferenceSystem crs) {
+ try {
+ final Object ensemble = crs.getClass().getMethod("getDatumEnsemble", (Class<?>[]) null).invoke(crs, (Object[]) null);
+ if (ensemble instanceof DefaultDatumEnsemble<?>) {
+ return (DefaultDatumEnsemble<?>) ensemble;
+ }
+ } catch (ReflectiveOperationException e) {
+ Logging.ignorableException(Logger.getLogger(Modules.REFERENCING), DatumOrEnsemble.class, "getDatumEnsemble", e);
+ }
+ return null;
}
/**
@@ -123,7 +145,7 @@
public static GeodeticDatum asDatum(final GeodeticCRS crs) {
if (crs == null) return null;
final GeodeticDatum datum = crs.getDatum();
- return (datum != null) ? datum : DefaultDatumEnsemble.Geodetic.datum(crs.getDatumEnsemble());
+ return (datum != null) ? datum : DefaultDatumEnsemble.Geodetic.datum(getDatumEnsemble(crs));
}
/**
@@ -137,7 +159,7 @@
public static VerticalDatum asDatum(final VerticalCRS crs) {
if (crs == null) return null;
final VerticalDatum datum = crs.getDatum();
- return (datum != null) ? datum : DefaultDatumEnsemble.Vertical.datum(crs.getDatumEnsemble());
+ return (datum != null) ? datum : DefaultDatumEnsemble.Vertical.datum(getDatumEnsemble(crs));
}
/**
@@ -157,23 +179,7 @@
public static TemporalDatum asDatum(final TemporalCRS crs) {
if (crs == null) return null;
final TemporalDatum datum = crs.getDatum();
- return (datum != null) ? datum : DefaultDatumEnsemble.Time.datum(crs.getDatumEnsemble());
- }
-
- /**
- * Returns the datum (preferred) or ensemble (fallback) of the given parametric <abbr>CRS</abbr>.
- * If the given <abbr>CRS</abbr> is associated to a non-null datum, then this method returns that datum.
- * Otherwise, this method returns the <abbr>CRS</abbr> datum ensemble as a pseudo-datum.
- *
- * @param crs the coordinate reference system for which to get the datum or datum ensemble, or {@code null}.
- * @return the datum or pseudo-datum of the given <abbr>CRS</abbr>, or {@code null}.
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- public static ParametricDatum asDatum(final ParametricCRS crs) {
- if (crs == null) return null;
- final ParametricDatum datum = crs.getDatum();
- return (datum != null) ? datum : DefaultDatumEnsemble.Parametric.datum(crs.getDatumEnsemble());
+ return (datum != null) ? datum : DefaultDatumEnsemble.Time.datum(getDatumEnsemble(crs));
}
/**
@@ -187,7 +193,7 @@
public static EngineeringDatum asDatum(final EngineeringCRS crs) {
if (crs == null) return null;
final EngineeringDatum datum = crs.getDatum();
- return (datum != null) ? datum : DefaultDatumEnsemble.Engineering.datum(crs.getDatumEnsemble());
+ return (datum != null) ? datum : DefaultDatumEnsemble.Engineering.datum(getDatumEnsemble(crs));
}
/**
@@ -242,21 +248,6 @@
}
/**
- * Returns the datum or pseudo-datum of the result of an operation between the given parametric <abbr>CRS</abbr>s.
- * See {@link #asTargetDatum(GeodeticCRS, GeodeticCRS)} for more information.
- *
- * @param source the source <abbr>CRS</abbr> of a coordinate operation.
- * @param target the target <abbr>CRS</abbr> of a coordinate operation.
- * @return datum or pseudo-datum of the coordinate operation result if it is okay to ignore datum shift.
- * @throws NullPointerException if any argument is null.
- */
- public static Optional<ParametricDatum> asTargetDatum(final ParametricCRS source, final ParametricCRS target) {
- return asTargetDatum(source, source.getDatum(),
- target, target.getDatum(),
- DefaultDatumEnsemble.Parametric::datum);
- }
-
- /**
* Returns the datum or pseudo-datum of the result of an operation between the given engineering <abbr>CRS</abbr>s.
* See {@link #asTargetDatum(GeodeticCRS, GeodeticCRS)} for more information.
*
@@ -290,16 +281,16 @@
private static <C extends SingleCRS, D extends Datum, R extends IdentifiedObject> Optional<R> asTargetDatum(
final C source, final R sourceDatum,
final C target, final R targetDatum,
- final Function<DatumEnsemble<D>, R> constructor)
+ final Function<DefaultDatumEnsemble<D>, R> constructor)
{
if (sourceDatum != null && Utilities.equalsIgnoreMetadata(sourceDatum, targetDatum)) {
return Optional.of(targetDatum);
}
- DatumEnsemble<D> sourceEnsemble;
- DatumEnsemble<D> targetEnsemble;
- DatumEnsemble<D> selected;
- if ((isMember(selected = targetEnsemble = (DatumEnsemble<D>) target.getDatumEnsemble(), sourceDatum)) ||
- (isMember(selected = sourceEnsemble = (DatumEnsemble<D>) source.getDatumEnsemble(), targetDatum)))
+ DefaultDatumEnsemble<D> sourceEnsemble;
+ DefaultDatumEnsemble<D> targetEnsemble;
+ DefaultDatumEnsemble<D> selected;
+ if ((isMember(selected = targetEnsemble = (DefaultDatumEnsemble<D>) getDatumEnsemble(target), sourceDatum)) ||
+ (isMember(selected = sourceEnsemble = (DefaultDatumEnsemble<D>) getDatumEnsemble(source), targetDatum)))
{
return Optional.of(constructor.apply(selected));
}
@@ -341,7 +332,7 @@
* @param ensemble the ensemble to test, or {@code null}.
* @return whether the ensemble contains the given datum.
*/
- private static boolean isMember(final DatumEnsemble<?> ensemble, final IdentifiedObject datum) {
+ private static boolean isMember(final DefaultDatumEnsemble<?> ensemble, final IdentifiedObject datum) {
if (ensemble != null) {
for (final Datum member : ensemble.getMembers()) {
if (Utilities.equalsIgnoreMetadata(datum, member)) {
@@ -359,7 +350,7 @@
* <ul>
* <li>If the given <abbr>CRS</abbr> is an instance of {@link SingleCRS} and its datum
* is a {@link GeodeticDatum}, then this method returns the datum ellipsoid.</li>
- * <li>Otherwise, if the given <abbr>CRS</abbr> is associated to a {@link DatumEnsemble} and all members
+ * <li>Otherwise, if the given <abbr>CRS</abbr> is associated to a {@code DatumEnsemble} and all members
* of the ensemble have equal (ignoring metadata) ellipsoid, then returns that ellipsoid.</li>
* <li>Otherwise, if the given <abbr>CRS</abbr> is an instance of {@link CompoundCRS}, then this method
* searches recursively in each component until a geodetic reference frame is found.</li>
@@ -408,7 +399,7 @@
return Optional.of(property);
}
}
- final DatumEnsemble<?> ensemble = scrs.getDatumEnsemble();
+ final DefaultDatumEnsemble<?> ensemble = getDatumEnsemble(crs);
if (ensemble != null) {
P common = null;
for (Datum member : ensemble.getMembers()) {
@@ -445,9 +436,9 @@
* @throws NullPointerException if the given object should provide an accuracy but didn't.
*/
public static Optional<PositionalAccuracy> getAccuracy(final IdentifiedObject object) {
- final DatumEnsemble<?> ensemble;
- if (object instanceof DatumEnsemble<?>) {
- ensemble = (DatumEnsemble<?>) object;
+ final DefaultDatumEnsemble<?> ensemble;
+ if (object instanceof DefaultDatumEnsemble<?>) {
+ ensemble = (DefaultDatumEnsemble<?>) object;
} else {
return Optional.empty();
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
index 064b1e7..9ff2aa3 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
@@ -54,13 +54,8 @@
import java.util.Date;
import org.opengis.referencing.datum.VerticalDatumType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import java.time.temporal.Temporal;
-import org.opengis.referencing.crs.ParametricCRS;
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.referencing.datum.ParametricDatum;
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.metadata.extent.Extent;
/**
@@ -72,7 +67,7 @@
* <h2>Ensemble viewed as a datum</h2>
* While a {@code DatumEnsemble} is theoretically <em>not</em> a {@code Datum},
* it is sometime convenient to handle the ensemble <em>as if</em> it was a datum.
- * Therefore, Apache <abbr>SIS</abbr> implementation of {@link DatumEnsemble} implements also the {@link Datum} interface.
+ * Therefore, Apache <abbr>SIS</abbr> implementation of {@code DatumEnsemble} implements also the {@link Datum} interface.
* This is a non-standard approach for making easier to handle {@code Datum} and {@code DatumEnsemble} with the same code.
* A similar approach is used in the <abbr>EPSG</abbr> database, which stores ensembles in the same table as the datums.
*
@@ -89,7 +84,7 @@
* @since 1.5
*/
@SecondaryTrait(Datum.class)
-public class DefaultDatumEnsemble<D extends Datum> extends AbstractIdentifiedObject implements DatumEnsemble<D>, Datum {
+public class DefaultDatumEnsemble<D extends Datum> extends AbstractIdentifiedObject implements Datum {
/**
* Serial number for inter-operability with different versions.
*/
@@ -136,7 +131,7 @@
* <td>{@link Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
+ * <td>{@code "domains"}</td>
* <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
@@ -151,7 +146,7 @@
* @param accuracy inaccuracy introduced through use of this ensemble (mandatory).
* @param memberType the base type of datum members contained in this ensemble.
* @throws ClassCastException if a member is not an instance of {@code memberType}.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
*
* @see #create(Map, Collection, PositionalAccuracy)
@@ -178,12 +173,10 @@
* @param ensemble the ensemble to copy.
* @param memberType the base type of datum members contained in this ensemble.
* @throws ClassCastException if a member is not an instance of {@code memberType}.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
- *
- * @see #castOrCopy(DatumEnsemble)
*/
- protected DefaultDatumEnsemble(final DatumEnsemble<? extends D> ensemble, final Class<D> memberType) {
+ protected DefaultDatumEnsemble(final DefaultDatumEnsemble<? extends D> ensemble, final Class<D> memberType) {
super(ensemble);
members = List.copyOf(ensemble.getMembers());
ensembleAccuracy = Objects.requireNonNull(ensemble.getEnsembleAccuracy());
@@ -192,25 +185,26 @@
/**
* Verifies this ensemble. All members shall be instances of the specified type and shall have
- * the same conventional reference system. No member can be an instance of {@link DatumEnsemble}.
+ * the same conventional reference system. No member can be an instance of {@code DatumEnsemble}.
*
* @param memberType the base type of datum members contained in this ensemble.
* @throws ClassCastException if a member is not an instance of {@code memberType}.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
*/
private void validate(final Class<D> memberType) {
IdentifiedObject rs = null;
for (final D datum : members) {
- if (datum instanceof DatumEnsemble<?>) {
+ if (datum instanceof DefaultDatumEnsemble<?>) {
throw new IllegalArgumentException(
- Errors.format(Errors.Keys.IllegalPropertyValueClass_2, "members", DatumEnsemble.class));
+ Errors.format(Errors.Keys.IllegalPropertyValueClass_2, "members", DefaultDatumEnsemble.class));
}
if (!memberType.isInstance(datum)) {
throw new ClassCastException(
Errors.format(Errors.Keys.IllegalClass_2, memberType, Classes.getClass(datum)));
}
- final IdentifiedObject dr = datum.getConventionalRS().orElse(null);
+ if (!(datum instanceof AbstractDatum)) continue;
+ final IdentifiedObject dr = ((AbstractDatum) datum).getConventionalRS().orElse(null);
if (dr != null) {
if (rs == null) {
rs = dr;
@@ -232,7 +226,7 @@
* @param members datum or reference frames which are members of this ensemble.
* @param accuracy inaccuracy introduced through use of this ensemble (mandatory).
* @return the datum ensemble.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
*/
public static <D extends Datum> DefaultDatumEnsemble<D> create(
@@ -244,35 +238,6 @@
}
/**
- * Returns a SIS ensemble implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise, if the given object is already an instance of
- * {@code DefaultDatumEnsemble}, then it is returned unchanged.</li>
- * <li>Otherwise, a new {@code DefaultDatumEnsemble} instance is created using the
- * {@linkplain #DefaultDatumEnsemble(DatumEnsemble, Class) copy constructor} and returned.
- * Note that this is a <em>shallow</em> copy operation,
- * because the other properties contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * The returned ensemble may implement the {@link GeodeticDatum}, {@link VerticalDatum}, {@link TemporalDatum},
- * {@link ParametricDatum} or {@link EngineeringDatum} interface if all members are instances of the same interface.
- *
- * @param <D> the type of datum members contained in the ensemble.
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static <D extends Datum> DefaultDatumEnsemble<D> castOrCopy(final DatumEnsemble<D> object) {
- if (object == null || object instanceof DefaultDatumEnsemble<?>) {
- return (DefaultDatumEnsemble<D>) object;
- }
- return Factory.forMemberType(Datum.class, object, null, List.copyOf(object.getMembers()), object.getEnsembleAccuracy());
- }
-
- /**
* Returns this datum ensemble as a collection of datum of the given type.
* This method casts the datum members, it does not copy or rewrite them.
* However, the returned {@code DatumEnsemble} may be a different instance.
@@ -301,23 +266,6 @@
return ensemble;
}
- /**
- * Returns the GeoAPI interface implemented by this class.
- * The SIS implementation returns {@code DatumEnsemble.class}.
- *
- * <h4>Note for implementers</h4>
- * Subclasses usually do not need to override this method since GeoAPI does not define {@code DatumEnsemble}
- * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their
- * own set of interfaces.
- *
- * @return the datum interface implemented by this class.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Class<? extends DatumEnsemble<D>> getInterface() {
- return (Class) DatumEnsemble.class;
- }
-
/*
* NOTE: a previous version provided the following method:
*
@@ -335,7 +283,6 @@
*
* @return datum or reference frames which are members of this ensemble.
*/
- @Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Collection is unmodifiable.
public final Collection<D> getMembers() { // Must be final for type safety. See `forMemberType(…)`
return members;
@@ -346,95 +293,58 @@
*
* @return inaccuracy introduced through use of this ensemble.
*/
- @Override
public PositionalAccuracy getEnsembleAccuracy() {
return ensembleAccuracy;
}
/**
- * Returns an anchor definition which is common to all members of the datum ensemble.
- * If the value is not the same for all members, or if at least one member returned
- * an empty value, then this method returns an empty value.
- *
- * @return the common anchor definition, or empty if there is no common value.
- */
- @Override
- public Optional<InternationalString> getAnchorDefinition() {
- return getCommonOptionalValue(Datum::getAnchorDefinition);
- }
-
- /**
* Returns an anchor point which is common to all members of the datum ensemble.
* If the value is not the same for all members, or if at least one member returned
* null, then this method returns null.
*
* @return the common anchor point, or null if there is no common value.
- *
- * @deprecated Renamed {@link #getAnchorDefinition()} for conformance with ISO 19111:2019 revision.
*/
@Override
- @Deprecated
public InternationalString getAnchorPoint() {
return getCommonValue(Datum::getAnchorPoint);
}
/**
- * Returns an anchor epoch which is common to all members of the datum ensemble.
- * If the value is not the same for all members, or if at least one member returned
- * an empty value, then this method returns an empty value.
- *
- * @return the common anchor epoch, or empty if there is no common value.
- */
- @Override
- public Optional<Temporal> getAnchorEpoch() {
- return getCommonOptionalValue(Datum::getAnchorEpoch);
- }
-
- /**
* Returns a realization epoch which is common to all members of the datum ensemble.
* If the value is not the same for all members, or if at least one member returned
* null, then this method returns null.
*
* @return the common realization epoch, null if there is no common value.
- *
- * @deprecated Renamed {@link #getAnchorEpoch()} for conformance with ISO 19111:2019 revision.
*/
@Override
- @Deprecated
public Date getRealizationEpoch() {
return getCommonValue(Datum::getRealizationEpoch);
}
/**
- * Returns a publication date which is common to all members of the datum ensemble.
+ * Returns a domain of validity which is common to all members of the datum ensemble.
* If the value is not the same for all members, or if at least one member returned
- * an empty value, then this method returns an empty value.
+ * null, then this method returns null.
*
- * @return the common publication date, or empty if there is no common value.
+ * @return the common domain of validity, or null if there is no common value.
*/
@Override
- public Optional<Temporal> getPublicationDate() {
- return getCommonOptionalValue(Datum::getPublicationDate);
+ public Extent getDomainOfValidity() {
+ return getCommonValue(Datum::getDomainOfValidity);
}
/**
- * Returns a conventional reference system which is common to all members of the datum ensemble.
- * The returned value should never be empty, because it is illegal for a datum ensemble to have
- * members with different conventional reference system. If this case nevertheless happens,
- * then this method returns an empty value.
+ * Returns a scope which is common to all members of the datum ensemble.
+ * If the value is not the same for all members, or if at least one member returned
+ * null, then this method returns null.
*
- * @return the common conventional reference system, or empty if there is no common value.
+ * @return the common scope, or null if there is no common value.
*/
@Override
- public Optional<IdentifiedObject> getConventionalRS() {
- return getCommonOptionalValue(Datum::getConventionalRS);
+ public InternationalString getScope() {
+ return getCommonValue(Datum::getScope);
}
- /*
- * Do not override `getScope()` and other methods from `IdentifiedObject`.
- * Inherit the properties specified to `AbstractIdentifiedObject` instead.
- */
-
/**
* Returns a value which is common to all ensemble members.
* If all members do not have the same value, returns null.
@@ -442,10 +352,7 @@
* @param <V> type of value.
* @param getter method to invoke on each member for getting the value.
* @return a value common to all members, or null if there is no common value.
- *
- * @deprecated For implementation of deprecated methods only.
*/
- @Deprecated
final <V> V getCommonValue(final Function<D,V> getter) {
final Iterator<D> it = members.iterator();
check: if (it.hasNext()) {
@@ -463,30 +370,6 @@
}
/**
- * Returns an optional value which is common to all ensemble members.
- * If all members do not have the same value, returns an empty value.
- *
- * @param <V> type of value.
- * @param getter method to invoke on each member for getting the value.
- * @return a value common to all members, or empty if there is no common value.
- */
- final <V> Optional<V> getCommonOptionalValue(final Function<D, Optional<V>> getter) {
- final Iterator<D> it = members.iterator();
-check: if (it.hasNext()) {
- final Optional<V> value = getter.apply(it.next());
- if (value.isPresent()) {
- while (it.hasNext()) {
- if (!value.equals(getter.apply(it.next()))) {
- break check;
- }
- }
- return value;
- }
- }
- return Optional.empty();
- }
-
- /**
* Returns a mandatory value which is common to all ensemble members.
*
* @param <V> type of value.
@@ -531,7 +414,10 @@
return members.equals(that.members) && ensembleAccuracy.equals(that.ensembleAccuracy);
}
default: {
- final var that = (DatumEnsemble<?>) object;
+ if (!(object instanceof DefaultDatumEnsemble<?>)) {
+ return false;
+ }
+ final var that = (DefaultDatumEnsemble<?>) object;
return Utilities.deepEquals(getMembers(), that.getMembers(), mode) &&
Utilities.deepEquals(getEnsembleAccuracy(), that.getEnsembleAccuracy(), mode);
}
@@ -575,7 +461,6 @@
* An ensemble viewed as a low-accuracy geodetic datum.
*
* @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
* @see DatumOrEnsemble#of(GeodeticCRS)
* @see DatumOrEnsemble#asTargetDatum(GeodeticCRS, GeodeticCRS)
*/
@@ -584,13 +469,13 @@
private static final long serialVersionUID = 7669230365507661290L;
/** Returns the given ensemble as a pseudo-datum. */
- static GeodeticDatum datum(DatumEnsemble<GeodeticDatum> ensemble) {
+ static GeodeticDatum datum(DefaultDatumEnsemble<GeodeticDatum> ensemble) {
return (ensemble == null || ensemble instanceof GeodeticDatum)
? (GeodeticDatum) ensemble : new Geodetic(ensemble);
}
/** Creates a new ensemble as a copy of the given ensemble. */
- Geodetic(DatumEnsemble<? extends GeodeticDatum> ensemble) {
+ Geodetic(DefaultDatumEnsemble<? extends GeodeticDatum> ensemble) {
super(ensemble, GeodeticDatum.class);
}
@@ -630,7 +515,6 @@
* An ensemble viewed as a low-accuracy vertical datum.
*
* @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
* @see DatumOrEnsemble#of(VerticalCRS)
* @see DatumOrEnsemble#asTargetDatum(VerticalCRS, VerticalCRS)
*/
@@ -639,13 +523,13 @@
private static final long serialVersionUID = 7242417944400289818L;
/** Returns the given ensemble as a pseudo-datum. */
- static VerticalDatum datum(DatumEnsemble<VerticalDatum> ensemble) {
+ static VerticalDatum datum(DefaultDatumEnsemble<VerticalDatum> ensemble) {
return (ensemble == null || ensemble instanceof VerticalDatum)
? (VerticalDatum) ensemble : new Vertical(ensemble);
}
/** Creates a new ensemble as a copy of the given ensemble. */
- Vertical(DatumEnsemble<? extends VerticalDatum> ensemble) {
+ Vertical(DefaultDatumEnsemble<? extends VerticalDatum> ensemble) {
super(ensemble, VerticalDatum.class);
}
@@ -655,28 +539,13 @@
}
/**
- * Returns a realization method which is common to all members of the datum ensemble.
- * If the value is not the same for all members, or if at least one member has an empty value,
- * then this method returns an empty value.
- *
- * @return the common realization method, or empty if there is no common value.
- */
- @Override
- public Optional<RealizationMethod> getRealizationMethod() {
- return getCommonOptionalValue(VerticalDatum::getRealizationMethod);
- }
-
- /**
* Returns a vertical datum type which is common to all members of the datum ensemble.
* If the value is not the same for all members, or if at least one member has a null value,
* then this method returns null.
*
* @return the common realization method, or null if there is no common value.
- *
- * @deprecated Replaced by {@link #getRealizationMethod()}.
*/
@Override
- @Deprecated
public VerticalDatumType getVerticalDatumType() {
return getCommonValue(VerticalDatum::getVerticalDatumType);
}
@@ -686,7 +555,6 @@
* An ensemble viewed as a low-accuracy temporal datum.
*
* @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
* @see DatumOrEnsemble#of(TemporalCRS)
* @see DatumOrEnsemble#asTargetDatum(TemporalCRS, TemporalCRS)
*/
@@ -695,13 +563,13 @@
private static final long serialVersionUID = -4208563828181087035L;
/** Returns the given ensemble as a pseudo-datum. */
- static TemporalDatum datum(DatumEnsemble<TemporalDatum> ensemble) {
+ static TemporalDatum datum(DefaultDatumEnsemble<TemporalDatum> ensemble) {
return (ensemble == null || ensemble instanceof TemporalDatum)
? (TemporalDatum) ensemble : new Time(ensemble);
}
/** Creates a new ensemble as a copy of the given ensemble. */
- Time(DatumEnsemble<? extends TemporalDatum> ensemble) {
+ Time(DefaultDatumEnsemble<? extends TemporalDatum> ensemble) {
super(ensemble, TemporalDatum.class);
}
@@ -725,39 +593,9 @@
}
/**
- * An ensemble viewed as a low-accuracy parametric datum.
- *
- * @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
- * @see DatumOrEnsemble#of(ParametricCRS)
- * @see DatumOrEnsemble#asTargetDatum(ParametricCRS, ParametricCRS)
- */
- static final class Parametric extends DefaultDatumEnsemble<ParametricDatum> implements ParametricDatum {
- /** For cross-versions compatibility. */
- private static final long serialVersionUID = -8277774591738789437L;
-
- /** Returns the given ensemble as a pseudo-datum. */
- static ParametricDatum datum(DatumEnsemble<ParametricDatum> ensemble) {
- return (ensemble == null || ensemble instanceof ParametricDatum)
- ? (ParametricDatum) ensemble : new Parametric(ensemble);
- }
-
- /** Creates a new ensemble as a copy of the given ensemble. */
- Parametric(DatumEnsemble<? extends ParametricDatum> ensemble) {
- super(ensemble, ParametricDatum.class);
- }
-
- /** Creates a new ensemble from the given properties. */
- Parametric(Map<String,?> properties, List<? extends ParametricDatum> members, PositionalAccuracy accuracy) {
- super(properties, members, accuracy, ParametricDatum.class);
- }
- }
-
- /**
* An ensemble viewed as a low-accuracy engineering datum.
*
* @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
* @see DatumOrEnsemble#of(EngineeringCRS)
* @see DatumOrEnsemble#asTargetDatum(EngineeringCRS, EngineeringCRS)
*/
@@ -766,13 +604,13 @@
private static final long serialVersionUID = -8978468990963666861L;
/** Returns the given ensemble as a pseudo-datum. */
- static EngineeringDatum datum(DatumEnsemble<EngineeringDatum> ensemble) {
+ static EngineeringDatum datum(DefaultDatumEnsemble<EngineeringDatum> ensemble) {
return (ensemble == null || ensemble instanceof EngineeringDatum)
? (EngineeringDatum) ensemble : new Engineering(ensemble);
}
/** Creates a new ensemble as a copy of the given ensemble. */
- Engineering(DatumEnsemble<? extends EngineeringDatum> ensemble) {
+ Engineering(DefaultDatumEnsemble<? extends EngineeringDatum> ensemble) {
super(ensemble, EngineeringDatum.class);
}
@@ -791,7 +629,6 @@
* @param <D> base type of all members in the ensembles constructed by this factory instance.
*
* @see #create(Map, Collection, PositionalAccuracy)
- * @see #castOrCopy(DatumEnsemble)
*/
private static abstract class Factory<D extends Datum> {
/**
@@ -833,7 +670,7 @@
*/
static <D extends Datum> DefaultDatumEnsemble<D> forMemberType(
final Class<? extends Datum> memberType,
- final DatumEnsemble<? extends D> object,
+ final DefaultDatumEnsemble<? extends D> object,
final Map<String,?> properties,
final List<? extends D> members,
final PositionalAccuracy accuracy)
@@ -875,7 +712,7 @@
* @param members datum or reference frames which are members of this ensemble.
* @param accuracy inaccuracy introduced through use of this ensemble (mandatory).
* @return the datum ensemble.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
*
* @see #create(Map, Collection, PositionalAccuracy)
@@ -886,12 +723,10 @@
* Creates a new ensemble with the same values as the specified one.
*
* @param ensemble the ensemble to copy.
- * @throws IllegalArgumentException if a member is an instance of {@link DatumEnsemble}, of if at least two
+ * @throws IllegalArgumentException if a member is an instance of {@code DatumEnsemble}, of if at least two
* different {@linkplain AbstractDatum#getConventionalRS() conventional reference systems} are found.
- *
- * @see #castOrCopy(DatumEnsemble)
*/
- abstract DefaultDatumEnsemble<D> copy(DatumEnsemble<? extends D> object);
+ abstract DefaultDatumEnsemble<D> copy(DefaultDatumEnsemble<? extends D> object);
/**
* Factories for all datum types supported by this class. The types are (in order) {@link GeodeticDatum},
@@ -902,7 +737,7 @@
private static final Factory<?>[] FACTORIES = {
new Factory<GeodeticDatum>(GeodeticDatum.class) {
@Override
- DefaultDatumEnsemble<GeodeticDatum> copy(DatumEnsemble<? extends GeodeticDatum> object) {
+ DefaultDatumEnsemble<GeodeticDatum> copy(DefaultDatumEnsemble<? extends GeodeticDatum> object) {
return new Geodetic(object);
}
@@ -916,7 +751,7 @@
new Factory<VerticalDatum>(VerticalDatum.class) {
@Override
- DefaultDatumEnsemble<VerticalDatum> copy(DatumEnsemble<? extends VerticalDatum> object) {
+ DefaultDatumEnsemble<VerticalDatum> copy(DefaultDatumEnsemble<? extends VerticalDatum> object) {
return new Vertical(object);
}
@@ -930,7 +765,7 @@
new Factory<TemporalDatum>(TemporalDatum.class) {
@Override
- DefaultDatumEnsemble<TemporalDatum> copy(DatumEnsemble<? extends TemporalDatum> object) {
+ DefaultDatumEnsemble<TemporalDatum> copy(DefaultDatumEnsemble<? extends TemporalDatum> object) {
return new Time(object);
}
@@ -942,23 +777,9 @@
}
},
- new Factory<ParametricDatum>(ParametricDatum.class) {
- @Override
- DefaultDatumEnsemble<ParametricDatum> copy(DatumEnsemble<? extends ParametricDatum> object) {
- return new Parametric(object);
- }
-
- @Override
- DefaultDatumEnsemble<ParametricDatum> create(Map<String,?> properties,
- List<? extends ParametricDatum> members, PositionalAccuracy accuracy)
- {
- return new Parametric(properties, members, accuracy);
- }
- },
-
new Factory<EngineeringDatum>(EngineeringDatum.class) {
@Override
- DefaultDatumEnsemble<EngineeringDatum> copy(DatumEnsemble<? extends EngineeringDatum> object) {
+ DefaultDatumEnsemble<EngineeringDatum> copy(DefaultDatumEnsemble<? extends EngineeringDatum> object) {
return new Engineering(object);
}
@@ -972,7 +793,7 @@
new Factory<Datum>(Datum.class) {
@Override
- DefaultDatumEnsemble<Datum> copy(DatumEnsemble<? extends Datum> object) {
+ DefaultDatumEnsemble<Datum> copy(DefaultDatumEnsemble<? extends Datum> object) {
return new DefaultDatumEnsemble<>(object, Datum.class);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
index 4f8a8ae..f346ca0 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
@@ -45,8 +45,8 @@
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -174,7 +174,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -182,7 +182,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
index 5e161c9..6cb7955 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
@@ -25,8 +25,8 @@
import org.apache.sis.referencing.privy.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -69,7 +69,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -77,22 +77,22 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
index d1393fe..23b9754 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
@@ -52,9 +52,9 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNullElement;
import static org.apache.sis.referencing.privy.WKTUtilities.toFormattable;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.datum.DynamicReferenceFrame;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.pending.geoapi.referencing.DynamicReferenceFrame;
/**
@@ -213,7 +213,7 @@
* <th colspan="3" class="hsep">Defined in parent classes (reminder)</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -221,22 +221,22 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
@@ -512,7 +512,6 @@
* If this datum is dynamic, the frame reference epoch is used.
* Otherwise, a time is computed from the temporal area of interest.
*
- * @see DynamicReferenceFrame#getFrameReferenceEpoch()
* @see BursaWolfParameters#getPositionVectorTransformation(Temporal)
*/
private Matrix createTransformation(final BursaWolfParameters bursaWolf, final Extent areaOfInterest) {
@@ -536,6 +535,10 @@
* The parameter values are valid at the time given by the
* {@linkplain #getFrameReferenceEpoch() frame reference epoch}.
*
+ * <div class="note"><b>Upcoming API change:</b>
+ * this class may implement a {@code DynamicReferenceFrame} interface from the GeoAPI standard
+ * after the next GeoAPI release. In the meantime, {@code DynamicReferenceFrame} is not a public API.</div>
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
* @since 1.5
@@ -570,7 +573,7 @@
* Creates a new datum with the same values as the specified datum, which must be dynamic.
*
* @param datum the datum to copy.
- * @throws ClassCastException if the given datum is not an instance of {@link DynamicReferenceFrame}.
+ * @throws ClassCastException if the given datum is not an instance of {@code DynamicReferenceFrame}.
*
* @see #castOrCopy(GeodeticDatum)
*/
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
index 473697a..daf17df 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
@@ -33,8 +33,8 @@
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.datum.ImageDatum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -91,7 +91,7 @@
* </tr>
* <tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -99,22 +99,22 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultParametricDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultParametricDatum.java
index 1037b5b..cc63fdb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultParametricDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultParametricDatum.java
@@ -22,9 +22,6 @@
import org.apache.sis.referencing.privy.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.ParametricDatum;
-
/**
* Defines the origin of a parametric coordinate reference system.
@@ -35,7 +32,7 @@
*
* <ol>
* <li>Create a {@code ParametricDatum} from an identifier in a database by invoking
- * {@link org.opengis.referencing.datum.DatumAuthorityFactory#createParametricDatum(String)}.</li>
+ * {@code DatumAuthorityFactory.createParametricDatum(String)}.</li>
* <li>Create a {@code ParametricDatum} by invoking the {@code DatumFactory.createParametricDatum(…)} method,
* (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
* <li>Create a {@code DefaultParametricDatum} by invoking the
@@ -58,7 +55,7 @@
*/
@XmlType(name = "ParametricDatumType")
@XmlRootElement(name = "ParametricDatum")
-public class DefaultParametricDatum extends AbstractDatum implements ParametricDatum {
+public class DefaultParametricDatum extends AbstractDatum {
/**
* Serial number for inter-operability with different versions.
*/
@@ -88,19 +85,19 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
@@ -121,47 +118,17 @@
*
* <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
*
- * @param datum the datum to copy.
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter type may be changed
+ * to {@code org.opengis.referencing.datum.ParametricDatum}. This change is pending GeoAPI revision.</div>
*
- * @see #castOrCopy(ParametricDatum)
+ * @param datum the datum to copy.
*/
- protected DefaultParametricDatum(final ParametricDatum datum) {
+ protected DefaultParametricDatum(final DefaultParametricDatum datum) {
super(datum);
}
/**
- * Returns a SIS datum implementation with the same values as the given arbitrary implementation.
- * If the given object is {@code null}, then this method returns {@code null}.
- * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
- * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
- *
- * @param object the object to get as a SIS implementation, or {@code null} if none.
- * @return a SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultParametricDatum castOrCopy(final ParametricDatum object) {
- return (object == null) || (object instanceof DefaultParametricDatum) ?
- (DefaultParametricDatum) object : new DefaultParametricDatum(object);
- }
-
- /**
- * Returns the GeoAPI interface implemented by this class.
- * The SIS implementation returns {@code ParametricDatum.class}.
- *
- * <h4>Note for implementers</h4>
- * Subclasses usually do not need to override this method since GeoAPI does not define {@code TemporalDatum}
- * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their
- * own set of interfaces.
- *
- * @return {@code ParametricDatum.class} or a user-defined sub-interface.
- */
- @Override
- public Class<? extends ParametricDatum> getInterface() {
- return ParametricDatum.class;
- }
-
- /**
- * Formats this datum as a <i>Well Known Text</i> {@code ParametricDatum[…]} element.
+ * Formats this datum as a <cite>Well Known Text</cite> {@code ParametricDatum[…]} element.
*
* <h4>Compatibility note</h4>
* {@code ParametricDatum} is defined in the WKT 2 specification only.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
index a82b375..2d41215 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
@@ -43,8 +43,8 @@
// 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.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -129,7 +129,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -137,7 +137,7 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -332,7 +332,6 @@
*
* @see org.apache.sis.referencing.crs.AbstractCRS#isBaseCRS(Formatter)
*/
- @SuppressWarnings("deprecation")
private static boolean isElementOfBaseCRS(final Formatter formatter) {
return formatter.getEnclosingElement(2) instanceof GeneralDerivedCRS;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
index e3faacf..bb71f31 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
@@ -37,8 +37,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -117,7 +117,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -125,22 +125,22 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
@@ -149,7 +149,7 @@
* @param properties the properties to be given to the identified object.
* @param origin the date and time origin of this temporal datum.
*
- * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createTemporalDatum(Map, Temporal)
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createTemporalDatum(Map, Date)
*
* @since 1.5
*/
@@ -159,6 +159,19 @@
}
/**
+ * Creates a temporal datum from the given properties.
+ *
+ * @param properties the properties to be given to the identified object.
+ * @param origin the date and time origin of this temporal datum.
+ *
+ * @deprecated Use {@link #DefaultTemporalDatum(Map, Temporal)} instead.
+ */
+ @Deprecated(since="1.5")
+ public DefaultTemporalDatum(final Map<String,?> properties, final Date origin) {
+ this(properties, TemporalDate.toTemporal(origin));
+ }
+
+ /**
* Creates a new datum with the same values as the specified one.
* This copy constructor provides a way to convert an arbitrary implementation into a SIS one
* or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
index 8ba7eb1..5318757 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
@@ -36,11 +36,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.VerticalDatumType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import org.opengis.referencing.datum.DynamicReferenceFrame;
-import org.opengis.referencing.datum.RealizationMethod;
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.pending.geoapi.referencing.DynamicReferenceFrame;
/**
@@ -63,7 +61,7 @@
* <li>Create a {@code VerticalDatum} by invoking the {@code DatumFactory.createVerticalDatum(…)} method
* (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
* <li>Create a {@code DefaultVerticalDatum} by invoking the
- * {@linkplain #DefaultVerticalDatum(Map, RealizationMethod) constructor}.</li>
+ * {@linkplain #DefaultVerticalDatum(Map, VerticalDatumType) constructor}.</li>
* </ol>
*
* <b>Example:</b> the following code gets a vertical datum for height above the geoid:
@@ -96,18 +94,12 @@
private static final long serialVersionUID = 380347456670516572L;
/**
- * The realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified.
- *
- * @see #getRealizationMethod()
- */
- private RealizationMethod method;
-
- /**
* The type of this vertical datum.
+ * If {@code null}, a value will be inferred from the name by {@link #type()}.
*
+ * @see #type()
* @see #getVerticalDatumType()
*/
- @SuppressWarnings("deprecation")
private VerticalDatumType type;
/**
@@ -123,7 +115,7 @@
* <th>Returned by</th>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
- * <td>{@link Identifier} or {@link String}</td>
+ * <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
@@ -131,52 +123,35 @@
* <td>{@link #getAlias()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
- * <td>{@link Identifier} (optionally as array)</td>
+ * <td>{@link ReferenceIdentifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getRemarks()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link #getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@code "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link #getAnchorEpoch()}</td>
* </tr>
* </table>
*
* @param properties the properties to be given to the identified object.
- * @param method the realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified.
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- @SuppressWarnings("this-escape")
- public DefaultVerticalDatum(final Map<String,?> properties, final RealizationMethod method) {
- super(properties);
- this.method = method;
- type = VerticalDatumTypes.fromMethod(method);
- }
-
- /**
- * Creates a vertical datum from the given properties.
- *
- * @param properties the properties to be given to the identified object.
* @param type the type of this vertical datum.
*
- * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}.
+ * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createVerticalDatum(Map, VerticalDatumType)
*/
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public DefaultVerticalDatum(final Map<String,?> properties, final VerticalDatumType type) {
super(properties);
this.type = Objects.requireNonNull(type);
- method = VerticalDatumTypes.toMethod(type);
}
/**
@@ -190,10 +165,8 @@
*
* @see #castOrCopy(VerticalDatum)
*/
- @SuppressWarnings("deprecation")
protected DefaultVerticalDatum(final VerticalDatum datum) {
super(datum);
- method = datum.getRealizationMethod().orElse(null);
type = datum.getVerticalDatumType();
}
@@ -229,15 +202,25 @@
}
/**
- * Returns the method through which this vertical reference frame is realized.
+ * Returns the type of this datum, or infers the type from the datum name if no type were specified.
+ * The latter case occurs after unmarshalling, since GML 3.2 does not contain any attribute for the datum type.
+ * It may also happen if the datum were created using reflection.
*
- * @return method through which this vertical reference frame is realized.
+ * <p>This method uses heuristic rules and may be changed in any future SIS version.</p>
*
- * @since 2.0 (temporary version number until this branch is released)
+ * <p>No synchronization needed; this is not a problem if this value is computed twice.
+ * This method returns only existing immutable instances.</p>
+ *
+ * @see #getVerticalDatumType()
+ * @see #getTypeElement()
*/
- @Override
- public Optional<RealizationMethod> getRealizationMethod() {
- return Optional.ofNullable(method);
+ private VerticalDatumType type() {
+ VerticalDatumType t = type;
+ if (t == null) {
+ final ReferenceIdentifier name = super.getName();
+ type = t = VerticalDatumTypes.fromDatum(name != null ? name.getCode() : null, super.getAlias(), null);
+ }
+ return t;
}
/**
@@ -250,13 +233,10 @@
* but in a programmatic way more suitable to coordinate transformation engines.
*
* @return the type of this vertical datum.
- *
- * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}.
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public VerticalDatumType getVerticalDatumType() {
- return type;
+ return type();
}
/**
@@ -264,6 +244,10 @@
* The parameter values are valid at the time given by the
* {@linkplain #getFrameReferenceEpoch() frame reference epoch}.
*
+ * <div class="note"><b>Upcoming API change:</b>
+ * this class may implement a {@code DynamicReferenceFrame} interface from the GeoAPI standard
+ * after the next GeoAPI release. In the meantime, {@code DynamicReferenceFrame} is not a public API.</div>
+ *
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
* @since 1.5
@@ -285,27 +269,9 @@
* See super-class constructor for more information.
*
* @param properties the properties to be given to the identified object.
- * @param method the realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified.
- * @param epoch the epoch to which the definition of the dynamic reference frame is referenced.
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- public Dynamic(Map<String,?> properties, RealizationMethod method, Temporal epoch) {
- super(properties, method);
- frameReferenceEpoch = Objects.requireNonNull(epoch);
- }
-
- /**
- * Creates a dynamic reference frame from the given properties.
- * See super-class constructor for more information.
- *
- * @param properties the properties to be given to the identified object.
* @param type the type of this vertical datum.
* @param epoch the epoch to which the definition of the dynamic reference frame is referenced.
- *
- * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}.
*/
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public Dynamic(Map<String,?> properties, VerticalDatumType type, Temporal epoch) {
super(properties, type);
frameReferenceEpoch = Objects.requireNonNull(epoch);
@@ -315,7 +281,7 @@
* Creates a new datum with the same values as the specified datum, which must be dynamic.
*
* @param datum the datum to copy.
- * @throws ClassCastException if the given datum is not an instance of {@link DynamicReferenceFrame}.
+ * @throws ClassCastException if the given datum is not an instance of {@code DynamicReferenceFrame}.
*
* @see #castOrCopy(VerticalDatum)
*/
@@ -370,7 +336,6 @@
* @hidden because nothing new to said.
*/
@Override
- @SuppressWarnings("deprecation")
public boolean equals(final Object object, final ComparisonMode mode) {
if (object == this) {
return true; // Slight optimization.
@@ -381,16 +346,15 @@
switch (mode) {
case STRICT: {
final var other = (DefaultVerticalDatum) object;
- return Objects.equals(method, other.method) && Objects.equals(type, other.type);
+ return type().equals(other.type());
}
case BY_CONTRACT: {
final var other = (VerticalDatum) object;
- return Objects.equals(getRealizationMethod(), other.getRealizationMethod()) &&
- Objects.equals(getVerticalDatumType(), other.getVerticalDatumType());
+ return Objects.equals(getVerticalDatumType(), other.getVerticalDatumType());
}
default: {
/*
- * RealizationMethod is considered as metadata because it is related to the anchor definition,
+ * VerticalDatumType is considered as metadata because it is related to the anchor definition,
* which is itself considered as metadata. Furthermore, GeodeticObjectParser and EPSGDataAccess
* do not always set this property to the same value, because of historical changes in the WKT.
*/
@@ -410,7 +374,7 @@
*/
@Override
protected long computeHashCode() {
- return super.computeHashCode() + 37 * Objects.hashCode(method);
+ return super.computeHashCode() + type().hashCode();
}
/**
@@ -420,7 +384,7 @@
* OGC 01-009 defined numerical codes for various vertical datum types, for example 2005 for geoidal height.
* Such codes were formatted for all {@code Datum} subtypes in WKT 1. Datum types became specified only for
* vertical datum in the ISO 19111:2003 standard, then removed completely in the ISO 19111:2007 standard.
- * They were reintroduced in a different form ({@link RealizationMethod}) in the ISO 19111:2019 standard.
+ * They were reintroduced in a different form ({@code RealizationMethod}) in the ISO 19111:2019 standard.
*
* @return {@code "VerticalDatum"} (WKT 2) or {@code "Vert_Datum"} (WKT 1).
*
@@ -430,7 +394,7 @@
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
if (formatter.getConvention().majorVersion() == 1) {
- formatter.append(VerticalDatumTypes.toLegacyCode(getVerticalDatumType()));
+ formatter.append(VerticalDatumTypes.toLegacyCode(type()));
return WKTKeywords.Vert_Datum;
}
return formatter.shortOrLong(WKTKeywords.VDatum, WKTKeywords.VerticalDatum);
@@ -466,7 +430,6 @@
*
* @see <a href="http://issues.apache.org/jira/browse/SIS-160">SIS-160: Need XSLT between GML 3.1 and 3.2</a>
*/
- @SuppressWarnings("deprecation")
@XmlElement(name = "verticalDatumType")
private VerticalDatumType getTypeElement() {
return Context.isGMLVersion(Context.current(), LegacyNamespaces.VERSION_3_2) ? null : getVerticalDatumType();
@@ -475,11 +438,9 @@
/**
* Invoked by JAXB only. The vertical datum type is set only if it has not already been specified.
*/
- @SuppressWarnings("deprecation")
- private void setTypeElement(final VerticalDatumType value) {
+ private void setTypeElement(final VerticalDatumType t) {
if (type == null) {
- type = value;
- method = VerticalDatumTypes.toMethod(value);
+ type = t;
} else {
ImplementationHelper.propertyAlreadySet(DefaultVerticalDatum.class, "setTypeElement", "verticalDatumType");
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
index 68cfaac..20f5dfb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
@@ -32,6 +32,9 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.privy.Strings;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+
/**
* Delegates object creations to one of the {@code create} methods in a backing {@code AuthorityFactory}.
@@ -177,9 +180,12 @@
*/
static final AuthorityFactoryProxy<InternationalString> description(final Class<? extends IdentifiedObject> classe) {
return new AuthorityFactoryProxy<InternationalString>(InternationalString.class, AuthorityFactoryIdentifier.Type.ANY) {
- @Override InternationalString createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
+ @Override InternationalString create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
return factory.getDescriptionText(classe, code).orElse(null);
}
+ @Override InternationalString createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
+ return factory.getDescriptionText(code);
+ }
@Override AuthorityFactoryProxy<InternationalString> specialize(String typeName) {
return this;
}
@@ -189,7 +195,6 @@
/**
* The proxy for the {@link GeodeticAuthorityFactory#createObject(String)} method.
*/
- @SuppressWarnings("removal")
static final AuthorityFactoryProxy<IdentifiedObject> OBJECT =
new AuthorityFactoryProxy<IdentifiedObject>(IdentifiedObject.class, AuthorityFactoryIdentifier.Type.ANY) {
@Override IdentifiedObject createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
@@ -198,13 +203,16 @@
};
@SuppressWarnings("unchecked")
- static final AuthorityFactoryProxy<DatumEnsemble<?>> ENSEMBLE =
- new AuthorityFactoryProxy<DatumEnsemble<?>>((Class) DatumEnsemble.class, AuthorityFactoryIdentifier.Type.DATUM) {
- @Override DatumEnsemble<?> create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
+ static final AuthorityFactoryProxy<DefaultDatumEnsemble<?>> ENSEMBLE =
+ new AuthorityFactoryProxy<DefaultDatumEnsemble<?>>((Class) DefaultDatumEnsemble.class, AuthorityFactoryIdentifier.Type.DATUM) {
+ @Override DefaultDatumEnsemble<?> create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
return factory.createDatumEnsemble(code);
}
- @Override DatumEnsemble<?> createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
- return datumFactory(factory).createDatumEnsemble(code);
+ @Override DefaultDatumEnsemble<?> createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
+ if (factory instanceof GeodeticAuthorityFactory) {
+ return ((GeodeticAuthorityFactory) factory).createDatumEnsemble(code);
+ }
+ throw new FactoryException("Unsupported factory.");
}
};
@@ -239,16 +247,6 @@
}
};
- static final AuthorityFactoryProxy<ParametricDatum> PARAMETRIC_DATUM =
- new AuthorityFactoryProxy<ParametricDatum>(ParametricDatum.class, AuthorityFactoryIdentifier.Type.DATUM) {
- @Override ParametricDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
- return factory.createParametricDatum(code);
- }
- @Override ParametricDatum createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
- return datumFactory(factory).createParametricDatum(code);
- }
- };
-
static final AuthorityFactoryProxy<VerticalDatum> VERTICAL_DATUM =
new AuthorityFactoryProxy<VerticalDatum>(VerticalDatum.class, AuthorityFactoryIdentifier.Type.DATUM) {
@Override VerticalDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
@@ -389,16 +387,6 @@
}
};
- static final AuthorityFactoryProxy<ParametricCS> PARAMETRIC_CS =
- new AuthorityFactoryProxy<ParametricCS>(ParametricCS.class, AuthorityFactoryIdentifier.Type.CS) {
- @Override ParametricCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
- return factory.createParametricCS(code);
- }
- @Override ParametricCS createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
- return csFactory(factory).createParametricCS(code);
- }
- };
-
static final AuthorityFactoryProxy<CoordinateSystemAxis> AXIS =
new AuthorityFactoryProxy<CoordinateSystemAxis>(CoordinateSystemAxis.class, AuthorityFactoryIdentifier.Type.CS) {
@Override CoordinateSystemAxis create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
@@ -470,7 +458,6 @@
}
};
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
static final AuthorityFactoryProxy<GeocentricCRS> GEOCENTRIC_CRS =
new AuthorityFactoryProxy<GeocentricCRS>(GeocentricCRS.class, AuthorityFactoryIdentifier.Type.CRS) {
@Override GeocentricCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
@@ -481,16 +468,6 @@
}
};
- static final AuthorityFactoryProxy<GeodeticCRS> GEODETIC_CRS =
- new AuthorityFactoryProxy<GeodeticCRS>(GeodeticCRS.class, AuthorityFactoryIdentifier.Type.CRS) {
- @Override GeodeticCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
- return factory.createGeodeticCRS(code);
- }
- @Override GeodeticCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
- return crsFactory(factory).createGeodeticCRS(code);
- }
- };
-
@SuppressWarnings("deprecation")
static final AuthorityFactoryProxy<ImageCRS> IMAGE_CRS =
new AuthorityFactoryProxy<ImageCRS>(ImageCRS.class, AuthorityFactoryIdentifier.Type.CRS) {
@@ -532,16 +509,6 @@
}
};
- static final AuthorityFactoryProxy<ParametricCRS> PARAMETRIC_CRS =
- new AuthorityFactoryProxy<ParametricCRS>(ParametricCRS.class, AuthorityFactoryIdentifier.Type.CRS) {
- @Override ParametricCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
- return factory.createParametricCRS(code);
- }
- @Override ParametricCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
- return crsFactory(factory).createParametricCRS(code);
- }
- };
-
@SuppressWarnings("rawtypes")
static final AuthorityFactoryProxy<ParameterDescriptor> PARAMETER =
new AuthorityFactoryProxy<ParameterDescriptor>(ParameterDescriptor.class, AuthorityFactoryIdentifier.Type.GEODETIC) {
@@ -578,12 +545,10 @@
* with a preference for those who are more likely to be requested.
* This field can be declared only after all the above constants.
*/
- @SuppressWarnings("deprecation")
static final AuthorityFactoryProxy<?>[] PROXIES = new AuthorityFactoryProxy<?>[] {
PROJECTED_CRS, // Special kind of GeneralDerivedCRS.
GEOGRAPHIC_CRS, // Special kind of GeodeticCRS.
GEOCENTRIC_CRS, // Special kind of GeodeticCRS.
- GEODETIC_CRS,
VERTICAL_CRS,
TEMPORAL_CRS,
IMAGE_CRS, // Can be seen as a special kind of EngineeringCRS (even if not shown in hierarchy).
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/CommonAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
index 089d027..6650570 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
@@ -456,7 +456,6 @@
* @throws FactoryException if the object creation failed.
*/
@Override
- @SuppressWarnings("removal")
public IdentifiedObject createObject(final String code) throws FactoryException {
return createCoordinateReferenceSystem(code);
}
@@ -686,8 +685,8 @@
* @return an exception initialized with an error message built from the specified information.
*/
private static NoSuchAuthorityCodeException noSuchAuthorityCode(String localCode, String code, Exception cause) {
- return new NoSuchAuthorityCodeException(Resources.format(Resources.Keys.NoSuchAuthorityCode_3,
+ return (NoSuchAuthorityCodeException) new NoSuchAuthorityCodeException(Resources.format(Resources.Keys.NoSuchAuthorityCode_3,
Constants.OGC, CoordinateReferenceSystem.class, localCode),
- Constants.OGC, localCode, code, cause);
+ Constants.OGC, localCode, code).initCause(cause);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
index 955389f..2649aa6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
@@ -65,6 +65,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.util.collection.BackingStoreException;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+
/**
* A concurrent authority factory that caches all objects created by another factory.
@@ -858,7 +861,6 @@
* @throws FactoryException if the object creation failed.
*/
@Override
- @SuppressWarnings("removal")
public IdentifiedObject createObject(final String code) throws FactoryException {
return create(AuthorityFactoryProxy.OBJECT, code);
}
@@ -914,37 +916,21 @@
* The default implementation performs the following steps:
* <ul>
* <li>Return the cached instance for the given code if such instance already exists.</li>
- * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createGeodeticCRS(String)}
+ * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createGeocentricCRS(String)}
* method, invoke that method and cache the result for future use.</li>
- * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createGeodeticCRS(String)}
+ * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createGeocentricCRS(String)}
* method in the parent class. This allows to check if the more generic
* {@link #createCoordinateReferenceSystem(String)} method cached a value before to try that method.</li>
* </ul>
*
- * @return the coordinate reference system for the given code.
- * @throws FactoryException if the object creation failed.
- *
- * @since 1.5
- */
- @Override
- public GeodeticCRS createGeodeticCRS(final String code) throws FactoryException {
- if (isDefault(GeodeticCRS.class)) {
- return super.createGeodeticCRS(code);
- }
- return create(AuthorityFactoryProxy.GEODETIC_CRS, code);
- }
-
- /**
- * Returns a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
*
* @return the coordinate reference system for the given code.
* @throws FactoryException if the object creation failed.
- *
- * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS.
- * Use {@link #createGeodeticCRS(String)} instead.
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public GeocentricCRS createGeocentricCRS(final String code) throws FactoryException {
if (isDefault(GeocentricCRS.class)) {
return super.createGeocentricCRS(code);
@@ -1022,31 +1008,6 @@
}
/**
- * Returns a 1-dimensional coordinate reference system which uses parameter values or functions.
- * The default implementation performs the following steps:
- * <ul>
- * <li>Return the cached instance for the given code if such instance already exists.</li>
- * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createParametricCRS(String)}
- * method, invoke that method and cache the result for future use.</li>
- * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createParametricCRS(String)}
- * method in the parent class. This allows to check if the more generic
- * {@link #createCoordinateReferenceSystem(String)} method cached a value before to try that method.</li>
- * </ul>
- *
- * @return the coordinate reference system for the given code.
- * @throws FactoryException if the object creation failed.
- *
- * @since 1.4
- */
- @Override
- public ParametricCRS createParametricCRS(final String code) throws FactoryException {
- if (isDefault(ParametricCRS.class)) {
- return super.createParametricCRS(code);
- }
- return create(AuthorityFactoryProxy.PARAMETRIC_CRS, code);
- }
-
- /**
* Returns a CRS describing the position of points through two or more independent coordinate reference systems.
* The default implementation performs the following steps:
* <ul>
@@ -1154,14 +1115,18 @@
* {@link #createObject(String)} method cached a value before to try that method.</li>
* </ul>
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code DatumEnsemble} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).</div>
+ *
* @return the datum for the given code.
* @throws FactoryException if the object creation failed.
*
* @since 1.5
*/
@Override
- public DatumEnsemble<?> createDatumEnsemble(final String code) throws FactoryException {
- if (isDefault(DatumEnsemble.class)) {
+ public DefaultDatumEnsemble<?> createDatumEnsemble(final String code) throws FactoryException {
+ if (isDefault(DefaultDatumEnsemble.class)) {
return super.createDatumEnsemble(code);
}
return create(AuthorityFactoryProxy.ENSEMBLE, code);
@@ -1261,31 +1226,6 @@
}
/**
- * Returns an identification of a reference surface used as the origin of a parametric coordinate system.
- * The default implementation performs the following steps:
- * <ul>
- * <li>Return the cached instance for the given code if such instance already exists.</li>
- * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createParametricDatum(String)}
- * method, invoke that method and cache the result for future use.</li>
- * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createParametricDatum(String)}
- * method in the parent class. This allows to check if the more generic
- * {@link #createDatum(String)} method cached a value before to try that method.</li>
- * </ul>
- *
- * @return the datum for the given code.
- * @throws FactoryException if the object creation failed.
- *
- * @since 1.4
- */
- @Override
- public ParametricDatum createParametricDatum(final String code) throws FactoryException {
- if (isDefault(ParametricDatum.class)) {
- return super.createParametricDatum(code);
- }
- return create(AuthorityFactoryProxy.PARAMETRIC_DATUM, code);
- }
-
- /**
* Returns a datum defining the origin of an engineering coordinate reference system.
* The default implementation performs the following steps:
* <ul>
@@ -1496,31 +1436,6 @@
}
/**
- * Returns a 1-dimensional coordinate system containing a single axis.
- * The default implementation performs the following steps:
- * <ul>
- * <li>Return the cached instance for the given code if such instance already exists.</li>
- * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createParametricCS(String)}
- * method, invoke that method and cache the result for future use.</li>
- * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createParametricCS(String)}
- * method in the parent class. This allows to check if the more generic
- * {@link #createCoordinateSystem(String)} method cached a value before to try that method.</li>
- * </ul>
- *
- * @return the coordinate system for the given code.
- * @throws FactoryException if the object creation failed.
- *
- * @since 1.4
- */
- @Override
- public ParametricCS createParametricCS(final String code) throws FactoryException {
- if (isDefault(ParametricCS.class)) {
- return super.createParametricCS(code);
- }
- return create(AuthorityFactoryProxy.PARAMETRIC_CS, code);
- }
-
- /**
* Returns a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
* The default implementation performs the following steps:
* <ul>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
index c684889..dec2641 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
@@ -42,6 +42,12 @@
import org.apache.sis.util.iso.AbstractFactory;
import org.apache.sis.util.resources.Errors;
+// Specific to the main branch:
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.crs.DefaultParametricCRS;
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+
/**
* Creates geodetic objects from codes defined by an authority.
@@ -166,7 +172,6 @@
*
* @since 1.5
*/
- @Override
public Optional<InternationalString> getDescriptionText(Class<? extends IdentifiedObject> type, String code)
throws FactoryException
{
@@ -174,6 +179,24 @@
}
/**
+ * Returns a description of the object corresponding to a code.
+ *
+ * @param code value allocated by authority.
+ * @return a description of the object, or {@code null} if the object
+ * corresponding to the specified {@code code} has no description.
+ * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
+ * @throws FactoryException if the query failed for some other reason.
+ *
+ * @deprecated This method is ambiguous because the EPSG geodetic registry may allocate
+ * the same code to different kinds of object.
+ */
+ @Override
+ @Deprecated(since = "1.5")
+ public InternationalString getDescriptionText(final String code) throws FactoryException {
+ return getDescriptionText(IdentifiedObject.class, code).orElse(null);
+ }
+
+ /**
* Returns an object of the specified type from a code. This implementation forwards
* the method call to the most specialized methods determined by the given type.
* For example, a call to {@code createObject(GeodeticCRS.class, code)} delegates
@@ -215,7 +238,6 @@
* @see org.apache.sis.referencing.AbstractIdentifiedObject
*/
@Override
- @SuppressWarnings("removal")
public abstract IdentifiedObject createObject(String code) throws NoSuchAuthorityCodeException, FactoryException;
/**
@@ -326,6 +348,10 @@
* <tr><td>EPSG:4984</td> <td>World Geodetic System 1972</td></tr>
* </table>
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
+ *
* <h4>Default implementation</h4>
* The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
* If the result cannot be cast, then a {@link NoSuchAuthorityCodeException} is thrown.
@@ -337,25 +363,7 @@
*
* @see org.apache.sis.referencing.crs.DefaultGeocentricCRS
* @see org.apache.sis.referencing.CommonCRS#geocentric()
- *
- * @since 1.5
*/
- public GeodeticCRS createGeodeticCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
- return cast(GeodeticCRS.class, createCoordinateReferenceSystem(code), code);
- }
-
- /**
- * Creates a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
- *
- * @param code value allocated by authority.
- * @return the coordinate reference system for the given code.
- * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
- * @throws FactoryException if the object creation failed.
- *
- * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS.
- * Use {@link #createGeodeticCRS(String)} instead.
- */
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public GeocentricCRS createGeocentricCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
return cast(GeocentricCRS.class, createCoordinateReferenceSystem(code), code);
}
@@ -454,6 +462,9 @@
* The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
* If the result cannot be cast, then a {@link NoSuchAuthorityCodeException} is thrown.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may be changed
+ * to {@code org.opengis.referencing.crs.ParametricCRS}. This change is pending GeoAPI revision.</div>
+ *
* @param code value allocated by authority.
* @return the coordinate reference system for the given code.
* @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
@@ -461,8 +472,8 @@
*
* @see org.apache.sis.referencing.crs.DefaultParametricCRS
*/
- public ParametricCRS createParametricCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
- return cast(ParametricCRS.class, createCoordinateReferenceSystem(code), code);
+ public DefaultParametricCRS createParametricCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
+ return cast(DefaultParametricCRS.class, createCoordinateReferenceSystem(code), code);
}
/**
@@ -594,6 +605,10 @@
* of Apache <abbr>SIS</abbr> and for the structure of the <abbr>EPSG</abbr> geodetic dataset,
* which uses the same {@code "Datum"} table for storing the properties of the two kinds of object.</p>
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code DatumEnsemble} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).</div>
+ *
* @param code value allocated by authority.
* @return the datum ensemble for the given code.
* @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
@@ -603,8 +618,8 @@
*
* @since 1.5
*/
- public DatumEnsemble<?> createDatumEnsemble(final String code) throws NoSuchAuthorityCodeException, FactoryException {
- return cast(DatumEnsemble.class, createDatum(code), code);
+ public DefaultDatumEnsemble<?> createDatumEnsemble(final String code) throws NoSuchAuthorityCodeException, FactoryException {
+ return cast(DefaultDatumEnsemble.class, createDatum(code), code);
}
/**
@@ -748,6 +763,9 @@
* The default implementation delegates to {@link #createDatum(String)} and casts the result.
* If the result cannot be cast, then a {@link NoSuchAuthorityCodeException} is thrown.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may be changed
+ * to {@code org.opengis.referencing.datum.ParametricDatum}. This change is pending GeoAPI revision.</div>
+ *
* @param code value allocated by authority.
* @return the datum for the given code.
* @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
@@ -755,8 +773,8 @@
*
* @see org.apache.sis.referencing.datum.DefaultParametricDatum
*/
- public ParametricDatum createParametricDatum(final String code) throws NoSuchAuthorityCodeException, FactoryException {
- return cast(ParametricDatum.class, createDatum(code), code);
+ public DefaultParametricDatum createParametricDatum(final String code) throws NoSuchAuthorityCodeException, FactoryException {
+ return cast(DefaultParametricDatum.class, createDatum(code), code);
}
/**
@@ -1038,6 +1056,9 @@
* The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
* If the result cannot be cast, then a {@link NoSuchAuthorityCodeException} is thrown.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may be changed
+ * to {@code org.opengis.referencing.cs.ParametricCS}. This change is pending GeoAPI revision.</div>
+ *
* @param code value allocated by authority.
* @return the coordinate system for the given code.
* @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
@@ -1045,8 +1066,8 @@
*
* @see org.apache.sis.referencing.cs.DefaultParametricCS
*/
- public ParametricCS createParametricCS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
- return cast(ParametricCS.class, createCoordinateSystem(code), code);
+ public DefaultParametricCS createParametricCS(final String code) throws NoSuchAuthorityCodeException, FactoryException {
+ return cast(DefaultParametricCS.class, createCoordinateSystem(code), code);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
index 9d7ef47..0797fab 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
@@ -25,8 +25,8 @@
import java.util.logging.Logger;
import java.util.logging.LogRecord;
import java.util.concurrent.atomic.AtomicReference;
-import java.lang.reflect.Constructor;
import java.time.temporal.Temporal;
+import java.lang.reflect.Constructor;
import jakarta.xml.bind.JAXBException;
import javax.measure.Unit;
import javax.measure.quantity.Angle;
@@ -64,6 +64,9 @@
import org.apache.sis.io.wkt.Parser;
import org.apache.sis.xml.XML;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DefaultDatumEnsemble;
+
/**
* Creates Coordinate Reference System (CRS) implementations, with their Coordinate System (CS) and Datum components.
@@ -111,15 +114,15 @@
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getCode()} on the {@linkplain AbstractIdentifiedObject#getName() name}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#CODESPACE_KEY}</td>
+ * <td>"codespace"</td>
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getCodeSpace()} on the {@linkplain AbstractIdentifiedObject#getName() name}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#VERSION_KEY}</td>
+ * <td>"version"</td>
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getVersion()} on the {@linkplain AbstractIdentifiedObject#getName() name}</td>
* </tr><tr>
- * <td>{@value org.opengis.metadata.Identifier#DESCRIPTION_KEY}</td>
+ * <td>"description"</td>
* <td>{@link String}</td>
* <td>{@link NamedIdentifier#getDescription()} on the {@linkplain AbstractIdentifiedObject#getName() name}</td>
* </tr><tr>
@@ -131,23 +134,23 @@
* <td>{@link Identifier} (optionally as array)</td>
* <td>{@link AbstractIdentifiedObject#getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link AbstractIdentifiedObject#getDomains()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#SCOPE_KEY}</td>
+ * <td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td>
* <td>{@link String} or {@link InternationalString}</td>
- * <td>{@link DefaultObjectDomain#getScope()}</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getScope()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_DEFINITION_KEY}</td>
+ * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_POINT_KEY}</td>
* <td>{@link InternationalString} or {@link String}</td>
* <td>{@link AbstractDatum#getAnchorDefinition()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.datum.Datum#ANCHOR_EPOCH_KEY}</td>
+ * <td>{@value "anchorEpoch"}</td>
* <td>{@link java.time.temporal.Temporal}</td>
* <td>{@link AbstractDatum#getAnchorEpoch()}</td>
* </tr><tr>
@@ -318,9 +321,13 @@
/**
* Creates a geocentric coordinate reference system from a Cartesian coordinate system.
* Geocentric CRS have their origin at the approximate centre of mass of the earth.
- * An {@linkplain #createGeodeticCRS(Map, GeodeticDatum, SphericalCS) alternate method} allows creation of the
+ * An {@linkplain #createGeocentricCRS(Map, GeodeticDatum, SphericalCS) alternate method} allows creation of the
* same kind of CRS with spherical coordinate system instead of a Cartesian one.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
+ *
* <h4>Dependencies</h4>
* The components needed by this method can be created by the following methods:
* <ol>
@@ -345,15 +352,14 @@
* @param cs the three-dimensional Cartesian coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, DatumEnsemble, CartesianCS)
+ * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, DefaultDatumEnsemble, CartesianCS)
* @see GeodeticAuthorityFactory#createGeodeticCRS(String)
*
* @since 1.5
*/
- @Override
public GeodeticCRS createGeodeticCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final CartesianCS cs)
throws FactoryException
{
@@ -374,11 +380,10 @@
* @param cs the three-dimensional Cartesian coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS.
- * Use {@link #createGeodeticCRS(Map, GeodeticDatum, CartesianCS)} instead.
+ * @see GeodeticAuthorityFactory#createGeocentricCRS(String)
+ * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, CartesianCS)
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public GeocentricCRS createGeocentricCRS(final Map<String,?> properties,
final GeodeticDatum datum, final CartesianCS cs) throws FactoryException
{
@@ -431,9 +436,13 @@
/**
* Creates a geocentric coordinate reference system from a spherical coordinate system.
* Geocentric CRS have their origin at the approximate centre of mass of the earth.
- * An {@linkplain #createGeodeticCRS(Map, GeodeticDatum, CartesianCS) alternate method} allows creation of the
+ * An {@linkplain #createGeocentricCRS(Map, GeodeticDatum, CartesianCS) alternate method} allows creation of the
* same kind of CRS with Cartesian coordinate system instead of a spherical one.
*
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
+ *
* <h4>Dependencies</h4>
* The components needed by this method can be created by the following methods:
* <ol>
@@ -458,15 +467,14 @@
* @param cs the spherical coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, DatumEnsemble, SphericalCS)
+ * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, DefaultDatumEnsemble, SphericalCS)
* @see GeodeticAuthorityFactory#createGeodeticCRS(String)
*
* @since 1.5
*/
- @Override
public GeodeticCRS createGeodeticCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final SphericalCS cs)
throws FactoryException
{
@@ -491,7 +499,7 @@
* Use {@link #createGeodeticCRS(Map, GeodeticDatum, SphericalCS)} instead.
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
+ @Deprecated
public GeocentricCRS createGeocentricCRS(final Map<String,?> properties,
final GeodeticDatum datum, final SphericalCS cs) throws FactoryException
{
@@ -562,7 +570,6 @@
*
* @since 1.4
*/
- @Override
public SphericalCS createSphericalCS(final Map<String,?> properties,
final CoordinateSystemAxis axis0,
final CoordinateSystemAxis axis1)
@@ -608,15 +615,14 @@
* @param cs the two- or three-dimensional ellipsoidal coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultGeographicCRS#DefaultGeographicCRS(Map, GeodeticDatum, DatumEnsemble, EllipsoidalCS)
+ * @see DefaultGeographicCRS#DefaultGeographicCRS(Map, GeodeticDatum, DefaultDatumEnsemble, EllipsoidalCS)
* @see GeodeticAuthorityFactory#createGeographicCRS(String)
*
* @since 1.5
*/
- @Override
public GeographicCRS createGeographicCRS(final Map<String,?> properties,
final GeodeticDatum datum,
- final DatumEnsemble<GeodeticDatum> ensemble,
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble,
final EllipsoidalCS cs)
throws FactoryException
{
@@ -630,8 +636,31 @@
}
/**
+ * Creates a geographic <abbr>CRS</abbr> from a reference frame.
+ * This is a shortcut for the {@linkplain #createGeographicCRS(Map, GeodeticDatum, DefaultDatumEnsemble, EllipsoidalCS)
+ * more generic method} without datum ensemble.
+ *
+ * @param properties name and other properties to give to the new object.
+ * Available properties are {@linkplain ObjectFactory listed there}.
+ * @param datum geodetic reference frame to use in created CRS.
+ * @param cs the ellipsoidal coordinate system for the created CRS.
+ * @return the coordinate reference system for the given properties.
+ * @throws FactoryException if the object creation failed.
+ */
+ @Override
+ public GeographicCRS createGeographicCRS(Map<String, ?> properties, GeodeticDatum datum, EllipsoidalCS cs)
+ throws FactoryException
+ {
+ return createGeographicCRS(properties, datum, null, cs);
+ }
+
+ /**
* Creates a datum ensemble from a collection of members and an ensemble accuracy.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code DatumEnsemble} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).</div>
+ *
* @param <D> the type of datum contained in the ensemble.
* @param properties name and other properties to give to the new object.
* @param members datum or reference frames which are members of the datum ensemble.
@@ -641,8 +670,7 @@
*
* @since 1.5
*/
- @Override
- public <D extends Datum> DatumEnsemble<D> createDatumEnsemble(final Map<String,?> properties,
+ public <D extends Datum> DefaultDatumEnsemble<D> createDatumEnsemble(final Map<String,?> properties,
final Collection<? extends D> members,
final PositionalAccuracy accuracy)
throws FactoryException
@@ -700,7 +728,6 @@
* Creates a dynamic geodetic reference frame from ellipsoid and frame reference epoch.
* The arguments are the same as for the {@linkplain #createGeodeticDatum(Map, Ellipsoid,
* PrimeMeridian) static datum}, with the addition of a mandatory frame reference epoch.
- * The returned object implements the {@link DynamicReferenceFrame} interface.
*
* @param properties name and other properties to give to the new object.
* @param ellipsoid the ellipsoid to use in new geodetic reference frame.
@@ -713,7 +740,6 @@
*
* @since 1.5
*/
- @Override
public GeodeticDatum createGeodeticDatum(final Map<String,?> properties,
final Ellipsoid ellipsoid,
final PrimeMeridian primeMeridian,
@@ -1041,7 +1067,7 @@
* <ol>
* <li>{@link #createCoordinateSystemAxis(Map, String, AxisDirection, Unit)}</li>
* <li>{@link #createVerticalCS(Map, CoordinateSystemAxis)}</li>
- * <li>{@link #createVerticalDatum(Map, RealizationMethod)}</li>
+ * <li>{@link #createVerticalDatum(Map, VerticalDatumType)}</li>
* <li>{@link #createDatumEnsemble(Map, Collection, PositionalAccuracy)} (optional)</li>
* </ol>
*
@@ -1055,15 +1081,14 @@
* @param cs the vertical coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultVerticalCRS#DefaultVerticalCRS(Map, VerticalDatum, DatumEnsemble, VerticalCS)
+ * @see DefaultVerticalCRS#DefaultVerticalCRS(Map, VerticalDatum, DefaultDatumEnsemble, VerticalCS)
* @see GeodeticAuthorityFactory#createVerticalCRS(String)
*
* @since 1.5
*/
- @Override
public VerticalCRS createVerticalCRS(final Map<String,?> properties,
final VerticalDatum datum,
- final DatumEnsemble<VerticalDatum> ensemble,
+ final DefaultDatumEnsemble<VerticalDatum> ensemble,
final VerticalCS cs)
throws FactoryException
{
@@ -1081,26 +1106,17 @@
* The default implementation creates a {@link DefaultVerticalDatum} instance.
*
* @param properties name and other properties to give to the new object.
- * @param method the realization method of the vertical datum, or {@code null} if none.
+ * Available properties are {@linkplain ObjectFactory listed there}.
+ * @param datum vertical datum to use in created CRS.
+ * @param cs the vertical coordinate system for the created CRS.
+ * @return the coordinate reference system for the given properties.
* @throws FactoryException if the object creation failed.
- *
- * @see DefaultVerticalDatum#DefaultVerticalDatum(Map, RealizationMethod)
- * @see GeodeticAuthorityFactory#createVerticalDatum(String)
- *
- * @since 2.0 (temporary version number until this branch is released)
*/
@Override
- public VerticalDatum createVerticalDatum(final Map<String,?> properties,
- final RealizationMethod method)
+ public VerticalCRS createVerticalCRS(Map<String, ?> properties, VerticalDatum datum, VerticalCS cs)
throws FactoryException
{
- final DefaultVerticalDatum datum;
- try {
- datum = new DefaultVerticalDatum(complete(properties), method);
- } catch (IllegalArgumentException exception) {
- throw new InvalidGeodeticParameterException(exception);
- }
- return unique("createVerticalDatum", datum);
+ return createVerticalCRS(properties, datum, null, cs);
}
/**
@@ -1113,11 +1129,8 @@
*
* @see DefaultVerticalDatum#DefaultVerticalDatum(Map, VerticalDatumType)
* @see GeodeticAuthorityFactory#createVerticalDatum(String)
- *
- * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}.
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public VerticalDatum createVerticalDatum(final Map<String,?> properties,
final VerticalDatumType type) throws FactoryException
{
@@ -1131,37 +1144,6 @@
}
/**
- * Creates a dynamic vertical datum from a realization method and a frame reference epoch.
- * The arguments are the same as for the {@linkplain #createVerticalDatum(Map, RealizationMethod)
- * static datum}, with the addition of a mandatory frame reference epoch.
- * The returned object implements the {@link DynamicReferenceFrame} interface.
- *
- * @param properties name and other properties to give to the new object.
- * @param method the realization method of the vertical datum, or {@code null} if none.
- * @param epoch the epoch to which the definition of the dynamic reference frame is referenced.
- * @throws FactoryException if the object creation failed.
- *
- * @see DefaultVerticalDatum.Dynamic#Dynamic(Map, RealizationMethod, Temporal)
- * @see GeodeticAuthorityFactory#createVerticalDatum(String)
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- @Override
- public VerticalDatum createVerticalDatum(final Map<String,?> properties,
- final RealizationMethod method,
- final Temporal epoch)
- throws FactoryException
- {
- final DefaultVerticalDatum datum;
- try {
- datum = new DefaultVerticalDatum.Dynamic(complete(properties), method, epoch);
- } catch (IllegalArgumentException exception) {
- throw new InvalidGeodeticParameterException(exception);
- }
- return unique("createVerticalDatum", datum);
- }
-
- /**
* Creates a dynamic vertical datum from an enumerated type value and a frame reference epoch.
* The arguments are the same as for the {@linkplain #createVerticalDatum(Map, VerticalDatumType)
* static datum}, with the addition of a mandatory frame reference epoch.
@@ -1175,10 +1157,7 @@
* @see GeodeticAuthorityFactory#createVerticalDatum(String)
*
* @since 1.5
- *
- * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}.
*/
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public VerticalDatum createVerticalDatum(final Map<String,?> properties,
final VerticalDatumType type,
final Temporal epoch)
@@ -1248,15 +1227,14 @@
* @param cs the temporal coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultTemporalCRS#DefaultTemporalCRS(Map, TemporalDatum, DatumEnsemble, TimeCS)
+ * @see DefaultTemporalCRS#DefaultTemporalCRS(Map, TemporalDatum, DefaultDatumEnsemble, TimeCS)
* @see GeodeticAuthorityFactory#createTemporalCRS(String)
*
* @since 1.5
*/
- @Override
public TemporalCRS createTemporalCRS(final Map<String,?> properties,
final TemporalDatum datum,
- final DatumEnsemble<TemporalDatum> ensemble,
+ final DefaultDatumEnsemble<TemporalDatum> ensemble,
final TimeCS cs) throws FactoryException
{
final DefaultTemporalCRS crs;
@@ -1269,6 +1247,25 @@
}
/**
+ * Creates a temporal <abbr>CRS</abbr> from a datum.
+ * This is a shortcut for the {@linkplain #createTemporalCRS(Map, TemporalDatum, DefaultDatumEnsemble, TimeCS)
+ * more generic method} without datum ensemble.
+ *
+ * @param properties name and other properties to give to the new object.
+ * Available properties are {@linkplain ObjectFactory listed there}.
+ * @param datum temporal datum to use in created CRS.
+ * @param cs the temporal coordinate system for the created CRS.
+ * @return the coordinate reference system for the given properties.
+ * @throws FactoryException if the object creation failed.
+ */
+ @Override
+ public TemporalCRS createTemporalCRS(Map<String, ?> properties, TemporalDatum datum, TimeCS cs)
+ throws FactoryException
+ {
+ return createTemporalCRS(properties, datum, null, cs);
+ }
+
+ /**
* Creates a temporal datum from an enumerated type value.
* The default implementation creates a {@link DefaultTemporalDatum} instance.
*
@@ -1281,7 +1278,7 @@
*/
@Override
public TemporalDatum createTemporalDatum(final Map<String,?> properties,
- final Temporal origin)
+ final Date origin)
throws FactoryException
{
final DefaultTemporalDatum datum;
@@ -1343,6 +1340,11 @@
* At least one of the {@code datum} and {@code ensemble} arguments shall be non-null.
* The default implementation creates a {@link DefaultParametricCRS} instance.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter types may be changed to
+ * {@code org.opengis.referencing.datum.ParametricDatum} and {@code org.opengis.referencing.cs.ParametricCS},
+ * and the return type may be changed to {@code org.opengis.referencing.crs.ParametricCRS}.
+ * Those change are pending GeoAPI revision.</div>
+ *
* @param properties name and other properties to give to the new object.
* @param datum parametric datum, or {@code null} if the CRS is associated only to a datum ensemble.
* @param ensemble collection of datum which for low accuracy requirements may be considered to be
@@ -1350,16 +1352,15 @@
* @param cs the parametric coordinate system for the created CRS.
* @throws FactoryException if the object creation failed.
*
- * @see DefaultParametricCRS#DefaultParametricCRS(Map, ParametricDatum, DatumEnsemble, ParametricCS)
+ * @see DefaultParametricCRS#DefaultParametricCRS(Map, DefaultParametricDatum, DefaultDatumEnsemble, ParametricCS)
* @see GeodeticAuthorityFactory#createParametricCRS(String)
*
* @since 1.5
*/
- @Override
- public ParametricCRS createParametricCRS(final Map<String,?> properties,
- final ParametricDatum datum,
- final DatumEnsemble<ParametricDatum> ensemble,
- final ParametricCS cs)
+ public DefaultParametricCRS createParametricCRS(final Map<String,?> properties,
+ final DefaultParametricDatum datum,
+ final DefaultDatumEnsemble<DefaultParametricDatum> ensemble,
+ final DefaultParametricCS cs)
throws FactoryException
{
final DefaultParametricCRS crs;
@@ -1372,17 +1373,39 @@
}
/**
+ * Creates a parametric <abbr>CRS</abbr> from a datum.
+ * This is a shortcut for the {@linkplain #createParametricCRS(Map, ParametricDatum, DefaultDatumEnsemble, ParametricCS)
+ * more generic method} without datum ensemble.
+ *
+ * @param properties name and other properties to give to the new object.
+ * Available properties are {@linkplain ObjectFactory listed there}.
+ * @param datum temporal datum to use in created CRS.
+ * @param cs the temporal coordinate system for the created CRS.
+ * @return the coordinate reference system for the given properties.
+ * @throws FactoryException if the object creation failed.
+ */
+ public DefaultParametricCRS createParametricCRS(final Map<String,?> properties,
+ final DefaultParametricDatum datum,
+ final DefaultParametricCS cs)
+ throws FactoryException
+ {
+ return createParametricCRS(properties, datum, null, cs);
+ }
+
+ /**
* Creates a parametric datum.
* The default implementation creates a {@link DefaultParametricDatum} instance.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may be changed
+ * to {@code org.opengis.referencing.datum.ParametricDatum}. This change is pending GeoAPI revision.</div>
+ *
* @param properties name and other properties to give to the new object.
* @throws FactoryException if the object creation failed.
*
* @see DefaultParametricDatum#DefaultParametricDatum(Map)
* @see GeodeticAuthorityFactory#createParametricDatum(String)
*/
- @Override
- public ParametricDatum createParametricDatum(final Map<String,?> properties)
+ public DefaultParametricDatum createParametricDatum(final Map<String,?> properties)
throws FactoryException
{
final DefaultParametricDatum datum;
@@ -1406,6 +1429,9 @@
*
* The default implementation creates a {@link DefaultParametricCS} instance.
*
+ * <div class="warning"><b>Warning:</b> in a future SIS version, the return type may be changed
+ * to {@code org.opengis.referencing.cs.ParametricCS}. This change is pending GeoAPI revision.</div>
+ *
* @param properties name and other properties to give to the new object.
* @param axis the single axis.
* @throws FactoryException if the object creation failed.
@@ -1413,8 +1439,7 @@
* @see DefaultParametricCS#DefaultParametricCS(Map, CoordinateSystemAxis)
* @see GeodeticAuthorityFactory#createParametricCS(String)
*/
- @Override
- public ParametricCS createParametricCS(final Map<String, ?> properties,
+ public DefaultParametricCS createParametricCS(final Map<String, ?> properties,
final CoordinateSystemAxis axis)
throws FactoryException
{
@@ -1586,10 +1611,9 @@
*
* @since 1.5
*/
- @Override
public EngineeringCRS createEngineeringCRS(final Map<String,?> properties,
final EngineeringDatum datum,
- final DatumEnsemble<EngineeringDatum> ensemble,
+ final DefaultDatumEnsemble<EngineeringDatum> ensemble,
final CoordinateSystem cs)
throws FactoryException
{
@@ -1603,6 +1627,25 @@
}
/**
+ * Creates a engineering <abbr>CRS</abbr> from a datum.
+ * This is a shortcut for the {@linkplain #createEngineeringCRS(Map, EngineeringDatum, DefaultDatumEnsemble, CoordinateSystem)
+ * more generic method} without datum ensemble.
+ *
+ * @param properties name and other properties to give to the new object.
+ * Available properties are {@linkplain ObjectFactory listed there}.
+ * @param datum engineering datum to use in created CRS.
+ * @param cs the coordinate system for the created CRS.
+ * @return the coordinate reference system for the given properties.
+ * @throws FactoryException if the object creation failed.
+ */
+ @Override
+ public EngineeringCRS createEngineeringCRS(Map<String, ?> properties, EngineeringDatum datum, CoordinateSystem cs)
+ throws FactoryException
+ {
+ return createEngineeringCRS(properties, datum, null, cs);
+ }
+
+ /**
* Creates an engineering datum.
* The default implementation creates a {@link DefaultEngineeringDatum} instance.
*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
index 872885d..f367263 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
@@ -918,7 +918,6 @@
* @throws FactoryException if the object creation failed.
*/
@Override
- @SuppressWarnings("removal")
public IdentifiedObject createObject(final String code) throws FactoryException {
return create(AuthorityFactoryProxy.OBJECT, code);
}
@@ -972,27 +971,14 @@
* <li>{@code http://www.opengis.net/gml/srs/}<var>authority</var>{@code .xml#}<var>code</var></li>
* </ul>
*
- * @return the coordinate reference system for the given code.
- * @throws FactoryException if the object creation failed.
- *
- * @since 1.5
- */
- @Override
- public GeodeticCRS createGeodeticCRS(final String code) throws FactoryException {
- return create(AuthorityFactoryProxy.GEODETIC_CRS, code);
- }
-
- /**
- * Creates a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
+ * <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to the
+ * {@link GeodeticCRS} parent interface. This is because ISO 19111 does not defines specific interface
+ * for the geocentric case. Users should assign the return value to a {@code GeodeticCRS} type.</div>
*
* @return the coordinate reference system for the given code.
* @throws FactoryException if the object creation failed.
- *
- * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS.
- * Use {@link #createGeodeticCRS(String)} instead.
*/
@Override
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
public GeocentricCRS createGeocentricCRS(final String code) throws FactoryException {
return create(AuthorityFactoryProxy.GEOCENTRIC_CRS, code);
}
@@ -1756,7 +1742,7 @@
if (cs instanceof EllipsoidalCS) {
return factory.createGeographicCRS(properties, datum, (EllipsoidalCS) cs);
} else if (cs instanceof SphericalCS) {
- return factory.createGeodeticCRS(properties, datum, null, (SphericalCS) cs);
+ return factory.createGeocentricCRS(properties, datum, (SphericalCS) cs);
}
}
return null;
@@ -1772,7 +1758,7 @@
* @return the combined CRS, or {@code null} if the given information are not sufficient.
* @throws FactoryException if an error occurred while creating the combined CRS.
*/
- private static DerivedCRS combine(final CoordinateReferenceSystem baseCRS, final Conversion fromBase,
+ private static GeneralDerivedCRS combine(final CoordinateReferenceSystem baseCRS, final Conversion fromBase,
final CoordinateSystem cs) throws FactoryException
{
if (baseCRS != null && fromBase.getSourceCRS() == null && fromBase.getTargetCRS() == null) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
index be28e30..72fca57 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
@@ -113,7 +113,6 @@
* Creates a coordinate operation for the specified <abbr>EPSG</abbr> code.
*/
@Override
- @SuppressWarnings("deprecation")
protected CoordinateOperation createObject(final String code) throws FactoryException {
final Integer base = projections.get(code);
if (base != null) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index cf8ecff..8034b0b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -91,7 +91,6 @@
import org.apache.sis.referencing.internal.SignReversalComment;
import org.apache.sis.referencing.internal.VerticalDatumTypes;
import org.apache.sis.referencing.internal.Resources;
-import org.apache.sis.referencing.internal.ServicesForMetadata;
import org.apache.sis.parameter.DefaultParameterDescriptor;
import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
import org.apache.sis.system.Loggers;
@@ -125,9 +124,14 @@
import org.apache.sis.measure.Units;
import org.apache.sis.pending.jdk.JDK16;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.referencing.ObjectFactory;
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.datum.AbstractDatum;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.referencing.internal.ServicesForMetadata;
+import org.apache.sis.temporal.TemporalDate;
/**
@@ -1277,13 +1281,13 @@
* We have to create the extents outside the `while` loop for
* the same reason as above for `extent`.
*/
- ObjectDomain[] domains = null;
+ DefaultObjectDomain[] domains = null;
if (translator.isUsageTableFound()) {
final var extents = new ArrayList<String>();
final var scopes = new ArrayList<Integer>();
getUsages(actualTable, code, extents, scopes);
if (!extents.isEmpty()) {
- domains = new ObjectDomain[extents.size()];
+ domains = new DefaultObjectDomain[extents.size()];
for (int i=0; i<domains.length; i++) {
domains[i] = new DefaultObjectDomain(
getScope(scopes.get(i)),
@@ -1380,13 +1384,13 @@
properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
properties.put(ReferencingFactoryContainer.MT_FACTORY, owner.mtFactory);
if (domains != null) {
- properties.put(IdentifiedObject.DOMAINS_KEY, domains);
+ properties.put(AbstractIdentifiedObject.DOMAINS_KEY, domains);
}
if (scope != null && !scope.equals(UNKNOWN_SCOPE)) { // Should be always NULL since EPSG version 10.
- properties.put(ObjectDomain.SCOPE_KEY, scope);
+ properties.put(Datum.SCOPE_KEY, scope);
}
if (extent != null) { // Should be always NULL since EPSG version 10.
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, extent);
+ properties.put(Datum.DOMAIN_OF_VALIDITY_KEY, extent);
}
return properties;
}
@@ -1531,6 +1535,15 @@
}
/**
+ * Returns the geodetic factory to use by casting the given one if possible.
+ */
+ private static GeodeticObjectFactory extended(final ObjectFactory factory) {
+ return (factory instanceof GeodeticObjectFactory)
+ ? (GeodeticObjectFactory) factory
+ : GeodeticObjectFactory.provider();
+ }
+
+ /**
* Creates an arbitrary coordinate reference system from a code.
* The returned object will typically be an instance of {@link GeographicCRS}, {@link ProjectedCRS},
* {@link VerticalCRS} or {@link CompoundCRS}.
@@ -1612,14 +1625,18 @@
final String datumCode = getString(code, result, 9);
final CoordinateSystem cs = owner.createCoordinateSystem(csCode); // Do not inline the `getString(…)` calls.
final GeodeticDatum datumOrEnsemble = owner.createGeodeticDatum(datumCode);
- final DatumEnsemble<GeodeticDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, GeodeticDatum.class);
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, GeodeticDatum.class);
final GeodeticDatum datum = (ensemble == null) ? datumOrEnsemble : null;
if (cs instanceof CartesianCS) {
final var c = (CartesianCS) cs;
- constructor = (factory, metadata) -> factory.createGeodeticCRS(metadata, datum, ensemble, c);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createGeodeticCRS(metadata, datum, ensemble, c)
+ : factory.createGeocentricCRS(metadata, datum, c);
} else if (cs instanceof SphericalCS) {
final var c = (SphericalCS) cs;
- constructor = (factory, metadata) -> factory.createGeodeticCRS(metadata, datum, ensemble, c);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createGeodeticCRS(metadata, datum, ensemble, c)
+ : factory.createGeocentricCRS(metadata, datum, c);
} else {
throw new FactoryDataException(error().getString(
Errors.Keys.IllegalCoordinateSystem_1, cs.getName()));
@@ -1644,9 +1661,11 @@
csCode = replaceDeprecatedCS(csCode);
}
final EllipsoidalCS cs = owner.createEllipsoidalCS(csCode.toString());
- final DatumEnsemble<GeodeticDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, GeodeticDatum.class);
+ final DefaultDatumEnsemble<GeodeticDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, GeodeticDatum.class);
final GeodeticDatum datum = (ensemble == null) ? datumOrEnsemble : null;
- constructor = (factory, metadata) -> factory.createGeographicCRS(metadata, datum, ensemble, cs);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createGeographicCRS(metadata, datum, ensemble, cs)
+ : factory.createGeographicCRS(metadata, datum, cs);
break;
}
/* ──────────────────────────────────────────────────────────────────────
@@ -1734,9 +1753,11 @@
final String datumCode = getString(code, result, 9);
final VerticalCS cs = owner.createVerticalCS(csCode); // Do not inline the `getString(…)` calls.
final VerticalDatum datumOrEnsemble = owner.createVerticalDatum(datumCode);
- final DatumEnsemble<VerticalDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, VerticalDatum.class);
+ final DefaultDatumEnsemble<VerticalDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, VerticalDatum.class);
final VerticalDatum datum = (ensemble == null) ? datumOrEnsemble : null;
- constructor = (factory, metadata) -> factory.createVerticalCRS(metadata, datum, ensemble, cs);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createVerticalCRS(metadata, datum, ensemble, cs)
+ : factory.createVerticalCRS(metadata, datum, cs);
break;
}
/* ──────────────────────────────────────────────────────────────────────
@@ -1751,9 +1772,11 @@
final String datumCode = getString(code, result, 9);
final TimeCS cs = owner.createTimeCS(csCode); // Do not inline the `getString(…)` calls.
final TemporalDatum datumOrEnsemble = owner.createTemporalDatum(datumCode);
- final DatumEnsemble<TemporalDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, TemporalDatum.class);
+ final DefaultDatumEnsemble<TemporalDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, TemporalDatum.class);
final TemporalDatum datum = (ensemble == null) ? datumOrEnsemble : null;
- constructor = (factory, metadata) -> factory.createTemporalCRS(metadata, datum, ensemble, cs);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createTemporalCRS(metadata, datum, ensemble, cs)
+ : factory.createTemporalCRS(metadata, datum, cs);
break;
}
/* ──────────────────────────────────────────────────────────────────────
@@ -1764,9 +1787,11 @@
final String datumCode = getString(code, result, 9);
final CoordinateSystem cs = owner.createCoordinateSystem(csCode); // Do not inline the `getString(…)` calls.
final EngineeringDatum datumOrEnsemble = owner.createEngineeringDatum(datumCode);
- final DatumEnsemble<EngineeringDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, EngineeringDatum.class);
+ final DefaultDatumEnsemble<EngineeringDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, EngineeringDatum.class);
final EngineeringDatum datum = (ensemble == null) ? datumOrEnsemble : null;
- constructor = (factory, metadata) -> factory.createEngineeringCRS(metadata, datum, ensemble, cs);
+ constructor = (factory, metadata) ->
+ (ensemble != null) ? extended(factory).createEngineeringCRS(metadata, datum, ensemble, cs)
+ : factory.createEngineeringCRS(metadata, datum, cs);
break;
}
/* ──────────────────────────────────────────────────────────────────────
@@ -1775,11 +1800,11 @@
case "parametric": {
final String csCode = getString(code, result, 8);
final String datumCode = getString(code, result, 9);
- final ParametricCS cs = owner.createParametricCS(csCode); // Do not inline the `getString(…)` calls.
- final ParametricDatum datumOrEnsemble = owner.createParametricDatum(datumCode);
- final DatumEnsemble<ParametricDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, ParametricDatum.class);
- final ParametricDatum datum = (ensemble == null) ? datumOrEnsemble : null;
- constructor = (factory, metadata) -> factory.createParametricCRS(metadata, datum, ensemble, cs);
+ final DefaultParametricCS cs = owner.createParametricCS(csCode); // Do not inline the `getString(…)` calls.
+ final DefaultParametricDatum datumOrEnsemble = owner.createParametricDatum(datumCode);
+ final DefaultDatumEnsemble<DefaultParametricDatum> ensemble = wasDatumEnsemble(datumOrEnsemble, DefaultParametricDatum.class);
+ final DefaultParametricDatum datum = (ensemble == null) ? datumOrEnsemble : null;
+ constructor = (factory, metadata) -> extended(factory).createParametricCRS(metadata, datum, ensemble, cs);
break;
}
/* ──────────────────────────────────────────────────────────────────────
@@ -1843,9 +1868,9 @@
* @return the given datum as an ensemble if it should be considered as such, or {@code null} otherwise.
* @throws ClassCastException if at least one member is not an instance of the specified type.
*/
- private static <D extends Datum> DatumEnsemble<D> wasDatumEnsemble(final D datum, final Class<D> memberType) {
- if (datum instanceof DatumEnsemble<?>) {
- return DefaultDatumEnsemble.castOrCopy((DatumEnsemble<?>) datum).cast(memberType);
+ private static <D extends Datum> DefaultDatumEnsemble<D> wasDatumEnsemble(final D datum, final Class<D> memberType) {
+ if (datum instanceof DefaultDatumEnsemble<?>) {
+ return ((DefaultDatumEnsemble<?>) datum).cast(memberType);
}
return null;
}
@@ -1930,14 +1955,14 @@
final Ellipsoid ellipsoid = owner.createEllipsoid(ellipsoidCode); // Do not inline the `getString(…)` calls.
final PrimeMeridian meridian = owner.createPrimeMeridian(meridianCode);
constructor = (factory, metadata) ->
- (dynamic != null) ? factory.createGeodeticDatum(metadata, ellipsoid, meridian, dynamic)
+ (dynamic != null) ? extended(factory).createGeodeticDatum(metadata, ellipsoid, meridian, dynamic)
: factory.createGeodeticDatum(metadata, ellipsoid, meridian);
break;
}
case "vertical": {
- final RealizationMethod method = getRealizationMethod(getOptionalInteger(result, 14));
+ final VerticalDatumType method = getRealizationMethod(getOptionalInteger(result, 14));
constructor = (factory, metadata) ->
- (dynamic != null) ? factory.createVerticalDatum(metadata, method, dynamic)
+ (dynamic != null) ? extended(factory).createVerticalDatum(metadata, method, dynamic)
: factory.createVerticalDatum(metadata, method);
break;
}
@@ -1955,14 +1980,14 @@
} catch (RuntimeException e) {
throw new FactoryDataException(resources().getString(Resources.Keys.DatumOriginShallBeDate), e);
}
- constructor = (factory, metadata) -> factory.createTemporalDatum(metadata, originDate);
+ constructor = (factory, metadata) -> factory.createTemporalDatum(metadata, TemporalDate.toDate(originDate));
break;
}
/*
* Straightforward cases.
*/
case "engineering": constructor = DatumFactory::createEngineeringDatum; break;
- case "parametric": constructor = DatumFactory::createParametricDatum; break;
+ case "parametric": constructor = (factory, metadata) -> extended(factory).createParametricDatum(metadata); break;
case "ensemble": constructor = createDatumEnsemble(epsg); break;
default: throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
}
@@ -1974,10 +1999,10 @@
@SuppressWarnings("LocalVariableHidesMemberVariable")
final Map<String,Object> properties = createProperties(
"Datum", epsg, name, null, area, scope, remarks, deprecated);
- properties.put(Datum.ANCHOR_DEFINITION_KEY, anchor);
- properties.put(Datum.ANCHOR_EPOCH_KEY, epoch);
- properties.put(Datum.PUBLICATION_DATE_KEY, publish);
- properties.put(Datum.CONVENTIONAL_RS_KEY, conventionalRS);
+ properties.put(AbstractDatum.ANCHOR_DEFINITION_KEY, anchor);
+ properties.put(AbstractDatum.ANCHOR_EPOCH_KEY, epoch);
+ properties.put(AbstractDatum.PUBLICATION_DATE_KEY, publish);
+ properties.put(AbstractDatum.CONVENTIONAL_RS_KEY, conventionalRS);
properties.values().removeIf(Objects::isNull);
final Datum datum = constructor.create(owner.datumFactory, properties);
returnValue = ensureSingleton(datum, returnValue, code);
@@ -2031,7 +2056,7 @@
+ " FROM \"DatumEnsembleMember\""
+ " WHERE DATUM_ENSEMBLE_CODE = ?"
+ " ORDER BY DATUM_SEQUENCE", code);
- return (factory, metadata) -> DefaultDatumEnsemble.castOrCopy(factory.createDatumEnsemble(metadata, members, accuracy));
+ return (factory, metadata) -> extended(factory).createDatumEnsemble(metadata, members, accuracy);
}
/**
@@ -2529,7 +2554,7 @@
}
case WKTKeywords.spherical: {
switch (dimension) {
- case 2: cs = csFactory.createSphericalCS(properties, axes[0], axes[1]); break;
+ case 2: cs = extended(csFactory).createSphericalCS(properties, axes[0], axes[1]); break;
case 3: cs = csFactory.createSphericalCS(properties, axes[0], axes[1], axes[2]); break;
}
break;
@@ -2550,7 +2575,7 @@
}
case WKTKeywords.parametric: {
switch (dimension) {
- case 1: cs = csFactory.createParametricCS(properties, axes[0]); break;
+ case 1: cs = extended(csFactory).createParametricCS(properties, axes[0]); break;
}
break;
}
@@ -2711,17 +2736,19 @@
/**
* Returns the realization method for the specified code.
+ * Returned as the legacy {@link VerticalDatumType} because
+ * {@code RealizationMethod} did not existed in GeoAPI 3.0.
*
* @param code code of the realization method, or {@code null} if none.
- * @return realization method, or {@code null} if the given code was null.
+ * @return realization method, or {@code GEOIDAL} if the given code was null.
*/
- private RealizationMethod getRealizationMethod(final Integer code) throws FactoryException, SQLException {
+ private VerticalDatumType getRealizationMethod(final Integer code) throws FactoryException, SQLException {
assert Thread.holdsLock(this);
if (code == null) {
- return null;
+ return VerticalDatumType.GEOIDAL;
}
final Long cacheKey = cacheKey(2, code);
- var returnValue = (RealizationMethod) localCache.get(cacheKey);
+ var returnValue = (VerticalDatumType) localCache.get(cacheKey);
if (returnValue == null && code != null) {
try (ResultSet result = executeQueryForCodes(
"DatumRealizationMethod",
@@ -2735,7 +2762,7 @@
}
}
if (returnValue == null) {
- throw noSuchAuthorityCode(RealizationMethod.class, String.valueOf(code));
+ throw noSuchAuthorityCode(VerticalDatumType.class, String.valueOf(code));
}
localCache.put(cacheKey, returnValue);
}
@@ -2980,7 +3007,7 @@
@SuppressWarnings("LocalVariableHidesMemberVariable")
final Map<String,Object> properties = createProperties(
"Coordinate_Operation Parameter", epsg, name, null, null, null, isReversible, deprecated);
- properties.put(Identifier.DESCRIPTION_KEY, description);
+ properties.put(ImmutableIdentifier.DESCRIPTION_KEY, description);
final var descriptor = new DefaultParameterDescriptor<>(properties, 1, 1, type, valueDomain, null, null);
returnValue = ensureSingleton(descriptor, returnValue, code);
if (result.isClosed()) break; // See createProperties(…) for explanation.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
index 4ffdbd4..26c7006 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
@@ -27,6 +27,11 @@
import org.apache.sis.referencing.privy.WKTKeywords;
import org.apache.sis.util.CharSequences;
+// Specific to the main branch:
+import org.apache.sis.referencing.crs.DefaultParametricCRS;
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+
/**
* Information about a specific table. This class uses the mixed-case variant of the <abbr>EPSG</abbr> table names.
@@ -63,7 +68,6 @@
*
* The order is significant: it is the key for a {@code switch} statement.
*/
- @SuppressWarnings("deprecation")
static final TableInfo[] EPSG = {
CRS = new TableInfo(CoordinateReferenceSystem.class,
"\"Coordinate Reference System\"",
@@ -72,7 +76,7 @@
"COORD_REF_SYS_KIND",
new Class<?>[] { ProjectedCRS.class, GeographicCRS.class, GeocentricCRS.class,
VerticalCRS.class, CompoundCRS.class, EngineeringCRS.class,
- DerivedCRS.class, TemporalCRS.class, ParametricCRS.class}, // See comment below
+ DerivedCRS.class, TemporalCRS.class, DefaultParametricCRS.class}, // See comment below
new String[] {"projected", "geographic", "geocentric",
"vertical", "compound", "engineering",
"derived", "temporal", "parametric"}, // See comment below
@@ -91,7 +95,7 @@
"COORD_SYS_TYPE",
new Class<?>[] {CartesianCS.class, EllipsoidalCS.class, VerticalCS.class, LinearCS.class,
SphericalCS.class, PolarCS.class, CylindricalCS.class,
- TimeCS.class, ParametricCS.class, AffineCS.class},
+ TimeCS.class, DefaultParametricCS.class, AffineCS.class},
new String[] {WKTKeywords.Cartesian, WKTKeywords.ellipsoidal, WKTKeywords.vertical, WKTKeywords.linear,
WKTKeywords.spherical, WKTKeywords.polar, WKTKeywords.cylindrical,
WKTKeywords.temporal, WKTKeywords.parametric, WKTKeywords.affine}, // Same comment as in the CRS case above.
@@ -110,7 +114,7 @@
"DATUM_NAME",
"DATUM_TYPE",
new Class<?>[] { GeodeticDatum.class, VerticalDatum.class, EngineeringDatum.class,
- TemporalDatum.class, ParametricDatum.class},
+ TemporalDatum.class, DefaultParametricDatum.class},
new String[] {"geodetic", "vertical", "engineering",
"temporal", "parametric"}, // Same comment as in the CRS case above.
null, true),
@@ -278,7 +282,6 @@
* @param object the object to search in the database.
* @param buffer where to append the {@code WHERE} clause.
*/
- @SuppressWarnings("deprecation")
final void where(final IdentifiedObject object, final StringBuilder buffer) {
Class<?> userType = object.getClass();
if (object instanceof GeodeticCRS) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxy.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxy.java
index 4115c99..57ac4b1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxy.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxy.java
@@ -26,9 +26,6 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.referencing.GeodeticException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-
/**
* A factory that redirect all method to another factory. This factory is normally useless and not used by Apache SIS.
@@ -63,14 +60,11 @@
}
@Override
- public final Optional<InternationalString> getDescriptionText(Class<? extends IdentifiedObject> type, String code)
- throws FactoryException
- {
- return factory().getDescriptionText(type, code);
+ public final InternationalString getDescriptionText(String code) throws FactoryException {
+ return factory().getDescriptionText(code);
}
@Override
- @SuppressWarnings("removal")
public final IdentifiedObject createObject(String code) throws FactoryException {
return factory().createObject(code);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java
index a4498bb..9d3962d 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java
@@ -32,10 +32,6 @@
import org.opengis.referencing.crs.GeocentricCRS;
import org.opengis.referencing.crs.ImageCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.crs.GeodeticCRS;
-import org.opengis.referencing.crs.ParametricCRS;
-
/**
* A factory that redirect all method to another factory. This factory is normally useless and not used by Apache SIS.
@@ -82,17 +78,12 @@
return factory().createGeographicCRS(code);
}
- @Deprecated(since = "2.0") // Temporary version number until this branch is released.
+ @Override
public GeocentricCRS createGeocentricCRS(String code) throws FactoryException {
return factory().createGeocentricCRS(code);
}
@Override
- public GeodeticCRS createGeodeticCRS(String code) throws FactoryException {
- return factory().createGeodeticCRS(code);
- }
-
- @Override
@Deprecated(since = "1.5")
public ImageCRS createImageCRS(String code) throws FactoryException {
return factory().createImageCRS(code);
@@ -112,9 +103,4 @@
public VerticalCRS createVerticalCRS(String code) throws FactoryException {
return factory().createVerticalCRS(code);
}
-
- @Override
- public ParametricCRS createParametricCRS(String code) throws FactoryException {
- return factory().createParametricCRS(code);
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCS.java
index d9ce915..3f76550 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCS.java
@@ -30,9 +30,6 @@
import org.opengis.referencing.cs.VerticalCS;
import org.apache.sis.referencing.CRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.cs.ParametricCS;
-
/**
* Same as {@link EPSGFactoryProxyCRS} but for coordinate systems.
@@ -93,11 +90,6 @@
}
@Override
- public ParametricCS createParametricCS(String code) throws FactoryException {
- return factory().createParametricCS(code);
- }
-
- @Override
public CoordinateSystemAxis createCoordinateSystemAxis(String code) throws FactoryException {
return factory().createCoordinateSystemAxis(code);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyDatum.java
index 33dc34e..fba7aef 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyDatum.java
@@ -30,9 +30,6 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.ImageDatum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.ParametricDatum;
-
/**
* Same as {@link EPSGFactoryProxyCRS} but for datum.
@@ -92,9 +89,4 @@
public VerticalDatum createVerticalDatum(String code) throws FactoryException {
return factory().createVerticalDatum(code);
}
-
- @Override
- public ParametricDatum createParametricDatum(String code) throws FactoryException {
- return factory().createParametricDatum(code);
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
index ca37336..d121506 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
@@ -29,6 +29,31 @@
import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
import org.apache.sis.referencing.privy.ReferencingUtilities;
+// Specific to the main branch:
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Collection;
+import java.time.Instant;
+import java.time.Year;
+import java.time.YearMonth;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import java.time.ZoneOffset;
+import java.time.LocalTime;
+import java.time.OffsetTime;
+import java.time.temporal.Temporal;
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.IdentifiedObject;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.operation.CoordinateOperation;
+import org.apache.sis.referencing.DefaultObjectDomain;
+import org.apache.sis.referencing.AbstractIdentifiedObject;
+
/**
* Utilities related to version 1 of Well Known Text format, or to ISO 19111:2007.
@@ -63,7 +88,6 @@
* the ISO 19111's ones (ISO names are "Geocentric X", "Geocentric Y" and "Geocentric Z"). This constant uses
* the invalid names and directions for WKT 1 parsing/formatting purposes.
*/
- @SuppressWarnings("deprecation")
private static final CartesianCS GEOCENTRIC = new DefaultCartesianCS(Map.of(NAME_KEY, "Legacy geocentric"),
new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "X"), "X", AxisDirection.OTHER, Units.METRE),
new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "Y"), "Y", AxisDirection.EAST, Units.METRE),
@@ -124,4 +148,96 @@
}
return cs;
}
+
+ /**
+ * Temporary getter method used as a workaround for the lack of this method in GeoAPI 3.0 interface.
+ *
+ * @param object the object from which to get the domain.
+ * @return domain of the given object.
+ */
+ public static Collection<DefaultObjectDomain> getDomains(final IdentifiedObject object) {
+ if (object instanceof AbstractIdentifiedObject) {
+ return ((AbstractIdentifiedObject) object).getDomains();
+ }
+ final Extent domainOfValidity;
+ final InternationalString scope;
+ if (object instanceof ReferenceSystem) {
+ final var c = (ReferenceSystem) object;
+ scope = c.getScope();
+ domainOfValidity = c.getDomainOfValidity();
+ } else if (object instanceof Datum) {
+ final var c = (Datum) object;
+ scope = c.getScope();
+ domainOfValidity = c.getDomainOfValidity();
+ } else if (object instanceof CoordinateOperation) {
+ final var c = (CoordinateOperation) object;
+ scope = c.getScope();
+ domainOfValidity = c.getDomainOfValidity();
+ } else {
+ return null;
+ }
+ if (scope == null && domainOfValidity == null) {
+ return null;
+ }
+ return List.of(new DefaultObjectDomain(scope, domainOfValidity));
+ }
+
+ /**
+ * Returns the first non-null scope found in the given collection.
+ *
+ * @param domains the value of {@link AbstractIdentifiedObject#getDomains()}.
+ * @return a description of domain of usage, or {@code null} if none.
+ */
+ public static InternationalString getScope(final Collection<DefaultObjectDomain> domains) {
+ return domains.stream().map(DefaultObjectDomain::getScope).filter(Objects::nonNull).findFirst().orElse(null);
+ }
+
+ /**
+ * Returns the first non-null domain of validity found in the given collection.
+ *
+ * @param domains the value of {@link AbstractIdentifiedObject#getDomains()}.
+ * @return the valid domain, or {@code null} if not available.
+ */
+ public static Extent getDomainOfValidity(final Collection<DefaultObjectDomain> domains) {
+ return domains.stream().map(DefaultObjectDomain::getDomainOfValidity).filter(Objects::nonNull).findFirst().orElse(null);
+ }
+
+ /**
+ * Converts a {@link java.time} object to a legacy {@link Date} object.
+ * If the time zone is not specified, UTC is assumed.
+ *
+ * @param t the date to convert.
+ * @return the given temporal object as a date, or {@code null} if the method doesn't know how to convert.
+ * @throws ArithmeticException if numeric overflow occurs.
+ */
+ public static Date toDate(final Temporal t) {
+ final Instant instant;
+ if (t instanceof Instant) {
+ instant = (Instant) t;
+ } else {
+ final OffsetDateTime odt;
+ if (t instanceof OffsetDateTime) {
+ odt = (OffsetDateTime) t;
+ } else if (t instanceof ZonedDateTime) {
+ odt = ((ZonedDateTime) t).toOffsetDateTime();
+ } else if (t instanceof LocalDateTime) {
+ odt = ((LocalDateTime) t).atOffset(ZoneOffset.UTC);
+ } else {
+ final LocalDate date;
+ if (t instanceof LocalDate) {
+ date = (LocalDate) t;
+ } else if (t instanceof YearMonth) {
+ date = ((YearMonth) t).atDay(1);
+ } else if (t instanceof Year) {
+ date = ((Year) t).atDay(1);
+ } else {
+ return null;
+ }
+ odt = date.atTime(OffsetTime.of(LocalTime.MIDNIGHT, ZoneOffset.UTC));
+ }
+ instant = odt.toInstant();
+ }
+ // Do not use `Date.from(Instant)` because we want the `ArithmeticException` in case of overflow.
+ return new Date(instant.toEpochMilli());
+ }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java
index c49f2c0..fdddd32 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java
@@ -69,9 +69,6 @@
import org.apache.sis.parameter.Parameters;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.UnimplementedServiceException;
-
/**
* Builder of a parameterized math transform identified by a name or code.
@@ -662,7 +659,7 @@
} catch (IllegalArgumentException | IllegalStateException exception) {
throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
} else {
- throw new UnimplementedServiceException(Errors.format(
+ throw new FactoryException(Errors.format(
Errors.Keys.UnsupportedImplementation_1, Classes.getClass(provider)));
}
if (provider instanceof AbstractProvider) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
index 25866b0..914cb6b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
@@ -30,9 +30,8 @@
import org.apache.sis.geometry.GeneralDirectPosition;
import org.apache.sis.util.Utilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.RegisterOperations;
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -40,7 +39,7 @@
* This class caches the last transform used in order to improve performance when
* {@linkplain CoordinateOperation#getSourceCRS() source} and
* {@linkplain CoordinateOperation#getTargetCRS() target} CRS do not change often.
- * Using this class is faster than invoking <code>{@linkplain RegisterOperations#findCoordinateOperations
+ * Using this class is faster than invoking <code>{@linkplain MultiRegisterOperations#findCoordinateOperations
* RegisterOperations.findCoordinateOperations}(lastCRS, targetCRS)</code> for every points.
*
* <ul class="verbose">
@@ -88,7 +87,7 @@
/**
* The factory to use for creating new coordinate operation.
*/
- private final RegisterOperations factory;
+ private final MultiRegisterOperations factory;
/**
* The default CRS to assume when {@link #transform(DirectPosition)} has been invoked without associated CRS.
@@ -127,7 +126,7 @@
* @param factory the factory to use for creating coordinate operations, or {@code null} for the default.
*/
public PositionTransformer(final CoordinateReferenceSystem defaultCRS, final CoordinateReferenceSystem targetCRS,
- final RegisterOperations factory)
+ final MultiRegisterOperations factory)
{
super(targetCRS);
this.defaultCRS = (defaultCRS != null) ? defaultCRS : targetCRS;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionalAccuracyConstant.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionalAccuracyConstant.java
index 50307e1..1143a75 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionalAccuracyConstant.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionalAccuracyConstant.java
@@ -288,7 +288,7 @@
if (Units.isLinear(unit)) {
final Unit<Length> unitOfLength = unit.asType(Length.class);
for (final Record record : records) {
- for (final Object value : record.getFields().values()) {
+ for (final Object value : record.getAttributes().values()) {
if (value instanceof Number) {
double v = ((Number) value).doubleValue();
v = unitOfLength.getConverterTo(Units.METRE).convert(v);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java
index 8c6fc20..15366f3 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java
@@ -46,6 +46,7 @@
import org.apache.sis.geometry.AbstractEnvelope;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.geometry.CoordinateFormat;
+import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.IdentifiedObjects;
@@ -58,7 +59,6 @@
import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
import org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
-import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Longitude;
import org.apache.sis.system.Modules;
@@ -72,8 +72,20 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import java.util.Map;
+import org.opengis.util.TypeName;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.crs.CRSFactory;
+import org.opengis.referencing.cs.CSFactory;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.datum.DatumFactory;
+import org.apache.sis.referencing.cs.DefaultParametricCS;
+import org.apache.sis.referencing.datum.DefaultParametricDatum;
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
/**
@@ -432,7 +444,7 @@
* If above code did not found an EPSG code, discard EPSG codes that
* we may find in the loop below because they are probably invalid.
*/
- for (final Identifier id : object.getIdentifiers()) {
+ for (final ReferenceIdentifier id : object.getIdentifiers()) {
if (!Constants.EPSG.equalsIgnoreCase(id.getCodeSpace())) {
return IdentifiedObjects.toString(id);
}
@@ -450,6 +462,15 @@
// ╚═════════════════════════════════════════════════════════════════════════════╝
/**
+ * Returns the name of the type of values.
+ */
+ @Override
+ public TypeName getValueType(final ParameterDescriptor<?> parameter) {
+ return (parameter instanceof DefaultParameterDescriptor<?>)
+ ? ((DefaultParameterDescriptor<?>) parameter).getValueType() : null;
+ }
+
+ /**
* Returns a fully implemented parameter descriptor.
*
* @param <T> the type of values.
@@ -462,6 +483,80 @@
}
/**
+ * Creates a parametric CS. This method requires the SIS factory
+ * since parametric CRS were not available in GeoAPI 3.0.
+ *
+ * <p>This method is actually not needed anymore for {@code sis-metadata} module,
+ * but is still defined here for historical reason. This method is removed on SIS
+ * branches using a GeoAPI versions more recent than 3.0.</p>
+ *
+ * @param properties the coordinate system name, and optionally other properties.
+ * @param axis the axis of the parametric coordinate system.
+ * @param factory the factory to use for creating the coordinate system.
+ * @return a parametric coordinate system using the given axes.
+ * @throws FactoryException if the parametric object creation failed.
+ */
+ public static CoordinateSystem createParametricCS(final Map<String,?> properties, final CoordinateSystemAxis axis,
+ CSFactory factory) throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = GeodeticObjectFactory.provider();
+ }
+ return ((GeodeticObjectFactory) factory).createParametricCS(properties, axis);
+ }
+
+ /**
+ * Creates a parametric datum. This method requires the SIS factory
+ * since parametric CRS were not available in GeoAPI 3.0.
+ *
+ * <p>This method is actually not needed anymore for {@code sis-metadata} module,
+ * but is still defined here for historical reason. This method is removed on SIS
+ * branches using a GeoAPI versions more recent than 3.0.</p>
+ *
+ * @param properties the datum name, and optionally other properties.
+ * @param factory the factory to use for creating the datum.
+ * @return a parametric datum using the given name.
+ * @throws FactoryException if the parametric object creation failed.
+ */
+ public static Datum createParametricDatum(final Map<String,?> properties, DatumFactory factory)
+ throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = GeodeticObjectFactory.provider();
+ }
+ return ((GeodeticObjectFactory) factory).createParametricDatum(properties);
+ }
+
+ /**
+ * Creates a parametric CRS. This method requires the SIS factory
+ * since parametric CRS were not available in GeoAPI 3.0.
+ *
+ * <p>This method is actually not needed anymore for {@code sis-metadata} module,
+ * but is still defined here for historical reason. This method is removed on SIS
+ * branches using a GeoAPI versions more recent than 3.0.</p>
+ *
+ * @param properties the coordinate reference system name, and optionally other properties.
+ * @param datum the parametric datum.
+ * @param cs the parametric coordinate system.
+ * @param factory the factory to use for creating the coordinate reference system.
+ * @return a parametric coordinate system using the given axes.
+ * @throws FactoryException if the parametric object creation failed.
+ */
+ public static SingleCRS createParametricCRS(final Map<String,?> properties, final Datum datum,
+ final CoordinateSystem cs, CRSFactory factory) throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = GeodeticObjectFactory.provider();
+ }
+ try {
+ return ((GeodeticObjectFactory) factory).createParametricCRS(properties,
+ (DefaultParametricDatum) datum, (DefaultParametricCS) cs);
+ } catch (ClassCastException e) {
+ throw new InvalidGeodeticParameterException(e.toString(), e);
+ }
+ }
+
+ /**
* Creates a format for {@link DirectPosition} instances.
*
* @param locale the locale for the new {@code Format}, or {@code null} for {@code Locale.ROOT}.
@@ -514,9 +609,9 @@
final String msg = Exceptions.getLocalizedMessage(e, locale);
return (msg != null) ? msg : Classes.getShortClassName(e);
}
- if (authority != null) {
+ if (authority instanceof DefaultCitation) {
final OnLineFunction f = OnLineFunction.valueOf(CONNECTION);
- for (final OnlineResource res : authority.getOnlineResources()) {
+ for (final OnlineResource res : ((DefaultCitation) authority).getOnlineResources()) {
if (f.equals(res.getFunction())) {
final InternationalString i18n = res.getDescription();
if (i18n != null) return i18n.toString(locale);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
index 8eef785..2b754a9 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
@@ -24,25 +24,29 @@
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.util.Characters;
import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.privy.CodeLists;
import org.apache.sis.measure.Units;
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.VerticalDatumType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import java.util.function.Predicate;
+import org.opengis.util.CodeList;
+import org.apache.sis.util.StringBuilders;
+import org.apache.sis.util.privy.CodeLists;
/**
- * Extensions to the standard set of {@link RealizationMethod}.
- * Some of those constants are derived from a legacy {@link VerticalDatumType} code list.
+ * Extensions to the standard set of {@link VerticalDatumType}.
* Those constants are not in public API because they were intentionally omitted from ISO 19111,
* and the ISO experts said that they should really not be public.
*
+ * <p>This class implements {@link Predicate} for opportunist reasons.
+ * This implementation convenience may change in any future SIS version.</p>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
*/
-public final class VerticalDatumTypes {
+public final class VerticalDatumTypes implements Predicate<CodeList<?>> {
/**
* A pseudo-realization method for ellipsoidal heights that are measured along
* the normal to the ellipsoid used in the definition of horizontal datum.
@@ -83,25 +87,19 @@
static final String LOCAL = "LOCAL";
/**
- * Do not allow instantiation of this class.
- */
- private VerticalDatumTypes() {
- }
-
- /**
* Returns a pseudo-realization method for ellipsoidal heights.
* <strong>The use of this method is deprecated</strong> as ellipsoidal height
* should never be separated from the horizontal components according ISO 19111.
*
* <h4>Maintenance note</h4>
- * If the implementation of this method is modified, search for {@code RealizationMethod.valueOf}
+ * If the implementation of this method is modified, search for {@code VerticalDatumType.valueOf}
* at least in {@link org.apache.sis.referencing.CommonCRS.Vertical#datum()} and make sure that
* the code is equivalent.
*
* @return the ellipsoidal pseudo-realization method.
*/
- public static RealizationMethod ellipsoidal() {
- return RealizationMethod.valueOf(ELLIPSOIDAL);
+ public static VerticalDatumType ellipsoidal() {
+ return VerticalDatumType.valueOf(ELLIPSOIDAL);
}
/**
@@ -110,7 +108,7 @@
* @param method the method to test, or {@code null}.
* @return whether the given method is the ellipsoidal pseudo-realization method.
*/
- public static boolean ellipsoidal(final RealizationMethod method) {
+ public static boolean ellipsoidal(final VerticalDatumType method) {
return (method != null) && ELLIPSOIDAL.equalsIgnoreCase(method.name());
}
@@ -122,14 +120,14 @@
* @param code the legacy vertical datum code.
* @return the vertical datum type, or {@code null} if none.
*/
- public static RealizationMethod fromLegacyCode(final int code) {
+ public static VerticalDatumType fromLegacyCode(final int code) {
switch (code) {
// case 2000: return null; // CS_VD_Other
- case 2001: return RealizationMethod.valueOf(ORTHOMETRIC); // CS_VD_Orthometric
+ case 2001: return VerticalDatumType.valueOf(ORTHOMETRIC); // CS_VD_Orthometric
case 2002: return ellipsoidal(); // CS_VD_Ellipsoidal
- case 2003: return RealizationMethod.valueOf(BAROMETRIC); // CS_VD_AltitudeBarometric
- case 2005: return RealizationMethod.GEOID; // CS_VD_GeoidModelDerived
- case 2006: return RealizationMethod.TIDAL; // CS_VD_Depth
+ case 2003: return VerticalDatumType.BAROMETRIC; // CS_VD_AltitudeBarometric
+ case 2005: return VerticalDatumType.GEOIDAL; // CS_VD_GeoidModelDerived
+ case 2006: return VerticalDatumType.DEPTH; // CS_VD_Depth
default: return null;
}
}
@@ -141,7 +139,6 @@
* @param method the vertical datum type, or {@code null} if unknown.
* @return the legacy code for the given datum type, or 0 if unknown.
*/
- @SuppressWarnings("deprecation")
public static int toLegacyCode(final VerticalDatumType method) {
if (method != null) {
switch (method.name().toUpperCase(Locale.US)) {
@@ -156,58 +153,6 @@
}
/**
- * Returns the vertical datum type from a realization method.
- * If the given method cannot be mapped to a legacy type, then this method returns "other surface".
- * This is because the vertical datum type was a mandatory property in legacy OGC/ISO standards.
- * This method is used for writing GML documents older than GML 3.2.
- *
- * <p>Note: this is renamed {@code toLegacyName(RealizationMethod)} on the GeoAPI 4.0 branch.</p>
- *
- * @param method the realization method, or {@code null}.
- * @return the vertical datum type (never null).
- */
- @SuppressWarnings("deprecation")
- public static VerticalDatumType fromMethod(final RealizationMethod method) {
- if (method == RealizationMethod.GEOID) return VerticalDatumType.GEOIDAL;
- if (method == RealizationMethod.TIDAL) return VerticalDatumType.DEPTH;
- if (method != null) {
- return VerticalDatumType.valueOf(method.name().toUpperCase(Locale.US));
- }
- return VerticalDatumType.OTHER_SURFACE;
- }
-
- /**
- * Returns the realization method from a vertical datum type.
- * This method is used for reading GML documents older than GML 3.2.
- *
- * <p>Note: this is renamed {@code fromLegacyName(String)} on the GeoAPI 4.0 branch.</p>
- *
- * @param type the vertical datum type, or {@code null}.
- * @return the realization method, or {@code null} if none.
- */
- @SuppressWarnings("deprecation")
- public static RealizationMethod toMethod(final VerticalDatumType type) {
- return (type != null) ? fromLegacyName(type.name()) : null;
- }
-
- /**
- * Returns the realization method from a vertical datum type.
- * This method is used for reading GML documents older than GML 3.2.
- *
- * @param type the vertical datum type, or {@code null}.
- * @return the realization method, or {@code null} if none.
- */
- public static RealizationMethod fromLegacyName(final String type) {
- if ("geoidal" .equalsIgnoreCase(type)) return RealizationMethod.GEOID;
- if ("depth" .equalsIgnoreCase(type)) return RealizationMethod.TIDAL;
- if (LOCAL .equalsIgnoreCase(type)) return RealizationMethod.valueOf(LOCAL);
- if (BAROMETRIC .equalsIgnoreCase(type)) return RealizationMethod.valueOf(BAROMETRIC);
- if (ORTHOMETRIC.equalsIgnoreCase(type)) return RealizationMethod.valueOf(ORTHOMETRIC);
- if (ELLIPSOIDAL.equalsIgnoreCase(type)) return ellipsoidal();
- return null;
- }
-
- /**
* Returns the realization method from heuristic rules applied on the name.
*
* <p>Note: this is {@code fromMethod(String)} on the GeoAPI 4.0 branch.</p>
@@ -215,15 +160,15 @@
* @param name the realization method name, or {@code null}.
* @return the realization method, or {@code null} if the given name was null.
*/
- public static RealizationMethod fromMethod(final String name) {
- RealizationMethod method = fromLegacyName(name);
+ public static VerticalDatumType fromMethod(final String name) {
+ VerticalDatumType method = fromDatum(name);
if (method == null && name != null && !name.isBlank()) {
final int s = name.lastIndexOf('-');
if (s >= 0 && name.substring(s+1).strip().equalsIgnoreCase("based")) {
- method = CodeLists.forCodeName(RealizationMethod.class, name.substring(0, s));
+ method = fromDatum(name.substring(0, s));
}
if (method == null) {
- method = RealizationMethod.valueOf(name);
+ method = VerticalDatumType.valueOf(name);
}
}
return method;
@@ -239,12 +184,12 @@
* @param name the name of the datum for which to guess a type, or {@code null} if unknown.
* @param aliases the aliases of the datum for which to guess a type, or {@code null} if unknown.
* @param axis the vertical axis for which to guess a type, or {@code null} if unknown.
- * @return a datum type, or {@code null} if none can be guessed.
+ * @return a datum type, or {@link VerticalDatumType#OTHER_SURFACE} if none can be guessed.
*/
- public static RealizationMethod fromDatum(final String name, final Collection<? extends GenericName> aliases,
+ public static VerticalDatumType fromDatum(final String name, final Collection<? extends GenericName> aliases,
final CoordinateSystemAxis axis)
{
- RealizationMethod method = fromDatum(name);
+ VerticalDatumType method = fromDatum(name);
if (method != null) {
return method;
}
@@ -264,19 +209,19 @@
AxisDirection dir = AxisDirection.UP; // Expected direction for accepting the type.
switch (abbreviation.charAt(0)) {
case 'h': method = ellipsoidal(); break;
- case 'H': method = RealizationMethod.GEOID; break;
- case 'D': method = RealizationMethod.TIDAL; dir = AxisDirection.DOWN; break;
- default: return null;
+ case 'H': method = VerticalDatumType.GEOIDAL; break;
+ case 'D': method = VerticalDatumType.DEPTH; dir = AxisDirection.DOWN; break;
+ default: return VerticalDatumType.OTHER_SURFACE;
}
if (dir.equals(axis.getDirection())) {
return method;
}
}
} else if (Units.isPressure(unit)) {
- return RealizationMethod.valueOf(BAROMETRIC);
+ return VerticalDatumType.BAROMETRIC;
}
}
- return null;
+ return VerticalDatumType.OTHER_SURFACE;
}
/**
@@ -286,15 +231,65 @@
* @param name name of the datum for which to guess a realization method, or {@code null}.
* @return a realization method, or {@code null} if none can be guessed.
*/
- private static RealizationMethod fromDatum(final String name) {
+ private static VerticalDatumType fromDatum(final String name) {
if (name != null) {
if (CharSequences.equalsFiltered("Mean Sea Level", name, Characters.Filter.LETTERS_AND_DIGITS, true)) {
- return RealizationMethod.TIDAL;
+ return VerticalDatumType.GEOIDAL;
}
- if (name.contains("geoid")) {
- return RealizationMethod.GEOID;
+ if (name.regionMatches(true, 0, "geoid", 0, 5)) {
+ return VerticalDatumType.GEOIDAL;
+ }
+ if (name.equalsIgnoreCase("Tidal")) {
+ return VerticalDatumType.DEPTH;
+ }
+ for (int i=0; i<name.length();) {
+ final int c = name.codePointAt(i);
+ if (Character.isLetter(c)) {
+ return CodeLists.find(VerticalDatumType.class, new VerticalDatumTypes(name));
+ }
+ i += Character.charCount(c);
}
}
return null;
}
+
+ /**
+ * The name of a datum to compare against the list of datum types,
+ * in upper-case and (if possible) using US-ASCII characters.
+ */
+ private final StringBuilder datum;
+
+ /**
+ * Creates a new {@code CodeList.Filter} which will compare the given datum name against the list of datum types.
+ * The comparison is case-insensitive and ignores some non-ASCII characters. The exact algorithm applied here is
+ * implementation dependent and may change in any future version.
+ *
+ * @param name the datum name.
+ */
+ private VerticalDatumTypes(final String name) {
+ final int length = name.length();
+ datum = new StringBuilder(length);
+ for (int i=0; i<length;) {
+ final int c = name.codePointAt(i);
+ datum.appendCodePoint(Character.toUpperCase(c));
+ i += Character.charCount(c);
+ }
+ StringBuilders.toASCII(datum);
+ }
+
+ /**
+ * Returns {@code true} if the name of the given code is the prefix of a word in the datum name.
+ * We do not test the characters following the prefix because the word may be incomplete
+ * (e.g. {@code "geoid"} versus {@code "geoidal"}).
+ *
+ * <p>This method is public as an implementation side-effect and should be ignored.</p>
+ *
+ * @param code the code to test.
+ * @return {@code true} if the code matches the criterion.
+ */
+ @Override
+ public boolean test(final CodeList<?> code) {
+ final int i = datum.indexOf(code.name());
+ return (i == 0) || (i >= 0 && Character.isWhitespace(datum.codePointBefore(i)));
+ }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
index 58c1cfb..1872b0b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
@@ -77,9 +77,14 @@
// 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.crs.DerivedCRS;
-import org.opengis.coordinate.CoordinateSet;
+// Specific to the main branch:
+import java.time.temporal.Temporal;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19111;
+import org.opengis.metadata.extent.Extent;
+import org.apache.sis.referencing.internal.Legacy;
+import org.apache.sis.coordinate.AbstractCoordinateSet;
/**
@@ -291,8 +296,8 @@
* <td>{@link Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.IdentifiedObject#DOMAINS_KEY}</td>
- * <td>{@link org.opengis.referencing.ObjectDomain} (optionally as array)</td>
+ * <td>"domains"</td>
+ * <td>{@link org.apache.sis.referencing.DefaultObjectDomain} (optionally as array)</td>
* <td>{@link #getDomains()}</td>
* </tr><tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
@@ -422,7 +427,7 @@
super(operation);
sourceCRS = operation.getSourceCRS();
targetCRS = operation.getTargetCRS();
- interpolationCRS = operation.getInterpolationCRS().orElse(null);
+ interpolationCRS = getInterpolationCRS(operation);
operationVersion = operation.getOperationVersion();
coordinateOperationAccuracy = operation.getCoordinateOperationAccuracy();
transform = operation.getMathTransform();
@@ -486,20 +491,19 @@
* But SIS supports also defining conversions with non-null CRS provided that:
*
* <ul>
- * <li>{@link DerivedCRS#getBaseCRS()} is the {@linkplain #getSourceCRS() source CRS} of this operation, and</li>
- * <li>{@link DerivedCRS#getConversionFromBase()} is this operation instance.</li>
+ * <li>{@link GeneralDerivedCRS#getBaseCRS()} is the {@linkplain #getSourceCRS() source CRS} of this operation, and</li>
+ * <li>{@link GeneralDerivedCRS#getConversionFromBase()} is this operation instance.</li>
* </ul>
*
* When this method returns {@code true}, the source and target CRS are not marshalled in XML documents.
*
* @return {@code true} if this coordinate operation is for the definition of a derived or projected CRS.
*/
- @SuppressWarnings("deprecation")
public boolean isDefiningConversion() {
/*
* Trick: we do not need to verify if (this instanceof Conversion) because:
* - Only DefaultConversion constructor accepts null source and target CRS.
- * - DerivedCRS.getConversionFromBase() return type is Conversion.
+ * - GeneralDerivedCRS.getConversionFromBase() return type is Conversion.
*/
return (sourceCRS == null && targetCRS == null)
|| ((targetCRS instanceof GeneralDerivedCRS)
@@ -546,12 +550,45 @@
*
* @return the <abbr>CRS</abbr> required for interpolating the values.
*/
- @Override
public Optional<CoordinateReferenceSystem> getInterpolationCRS() {
return Optional.ofNullable(interpolationCRS);
}
/**
+ * Returns the interpolation CRS of the given coordinate operation, or {@code null} if none.
+ */
+ static CoordinateReferenceSystem getInterpolationCRS(final CoordinateOperation operation) {
+ return (operation instanceof AbstractCoordinateOperation)
+ ? ((AbstractCoordinateOperation) operation).getInterpolationCRS().orElse(null) : null;
+ }
+
+ /**
+ * Returns the date at which source coordinate tuples are valid.
+ * This is mandatory if the <abbr>CRS</abbr> is dynamic.
+ *
+ * @return epoch at which source coordinate tuples are valid.
+ *
+ * @since 1.5
+ */
+ @UML(identifier="sourceCoordinateEpoch", obligation=CONDITIONAL, specification=ISO_19111)
+ public Optional<Temporal> getSourceEpoch() {
+ return Optional.empty();
+ }
+
+ /**
+ * Returns the date at which target coordinate tuples are valid.
+ * This is mandatory if the <abbr>CRS</abbr> is dynamic.
+ *
+ * @return epoch at which target coordinate tuples are valid.
+ *
+ * @since 1.5
+ */
+ @UML(identifier="targetCoordinateEpoch", obligation=CONDITIONAL, specification=ISO_19111)
+ public Optional<Temporal> getTargetEpoch() {
+ return Optional.empty();
+ }
+
+ /**
* Returns the version of the coordinate operation. Different versions of a coordinate
* {@linkplain DefaultTransformation transformation} may exist because of the stochastic
* nature of the parameters. In principle this property is irrelevant to coordinate
@@ -622,6 +659,32 @@
}
/**
+ * Returns the area or region or timeframe in which this coordinate operation is valid.
+ *
+ * @return the coordinate operation valid domain, or {@code null} if not available.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public Extent getDomainOfValidity() {
+ return Legacy.getDomainOfValidity(getDomains());
+ }
+
+ /**
+ * Returns a description of domain of usage, or limitations of usage, for which this operation is valid.
+ *
+ * @return a description of domain of usage, or {@code null} if none.
+ *
+ * @deprecated Replaced by {@link #getDomains()} as of ISO 19111:2019.
+ */
+ @Override
+ @Deprecated(since = "1.4")
+ public InternationalString getScope() {
+ return Legacy.getScope(getDomains());
+ }
+
+ /**
* Returns the object for transforming coordinates in the source CRS to coordinates in the target CRS.
* The transform may be {@code null} if this coordinate operation is a defining conversion.
*
@@ -645,7 +708,7 @@
* <li>If the <abbr>CRS</abbr> and/or epoch of the given data are not equivalent to the source <abbr>CRS</abbr> and/or
* epoch of this coordinate operation, this method will automatically prepend an additional operation step.</li>
* <li>The coordinate tuples are not transformed immediately, but instead will be computed on-the-fly
- * in the stream returned by {@link CoordinateSet#stream()}.</li>
+ * in the stream returned by {@link AbstractCoordinateSet#stream()}.</li>
* <li>If a {@link TransformException} occurs during on-the-fly coordinate operation, it will be wrapped
* in an unchecked {@link org.apache.sis.util.collection.BackingStoreException}.</li>
* <li>The returned coordinate set is serializable if the given data and the math transform are also serializable.</li>
@@ -659,8 +722,7 @@
*
* @since 1.5
*/
- @Override
- public CoordinateSet transform(final CoordinateSet data) throws TransformException {
+ public AbstractCoordinateSet transform(final AbstractCoordinateSet data) throws TransformException {
return new TransformedCoordinateSet(this, data);
}
@@ -768,8 +830,8 @@
* corresponding wraparound axis in the source CRS because the <em>easting</em> axis in projected CRS does not
* have a wraparound range meaning. We could argue that
* {@linkplain org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getDirection() axis directions} match,
- * but such matching is not guaranteed to exist since {@code ProjectedCRS} is a special case of {@code DerivedCRS}
- * and derived CRS can have rotations.
+ * but such matching is not guaranteed to exist since {@code ProjectedCRS} is a special case of
+ * {@code GeneralDerivedCRS} and derived CRS can have rotations.
*
* <h4>Default implementation</h4>
* The default implementation infers this set by inspecting the source and target coordinate system axes.
@@ -861,7 +923,7 @@
final CoordinateOperation that = (CoordinateOperation) object;
if ((mode.isIgnoringMetadata() ||
(deepEquals(getCoordinateOperationAccuracy(), that.getCoordinateOperationAccuracy(), mode))) &&
- deepEquals(getInterpolationCRS(), that.getInterpolationCRS(), mode))
+ deepEquals(getInterpolationCRS().orElse(null), getInterpolationCRS(that), mode))
{
/*
* At this point all metadata match or can be ignored. First, compare the targetCRS.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
index 1bd5e38..bbbd212 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
@@ -233,7 +233,6 @@
* @since 1.0
*/
@Override
- @SuppressWarnings("deprecation")
public List<CoordinateOperation> createOperations(final CoordinateReferenceSystem sourceCRS,
final CoordinateReferenceSystem targetCRS)
throws FactoryException
@@ -362,7 +361,7 @@
/**
* Creates operations from an arbitrary single CRS to a derived coordinate reference system.
* Conversions from {@code GeographicCRS} to {@code ProjectedCRS} are also handled by this method,
- * since projected CRS are a special kind of {@code DerivedCRS}.
+ * since projected CRS are a special kind of {@code GeneralDerivedCRS}.
*
* <p>The default implementation constructs the following operation chain:</p>
* <blockquote><code>sourceCRS → {@linkplain DerivedCRS#getBaseCRS() baseCRS} → targetCRS</code></blockquote>
@@ -379,7 +378,6 @@
* @return coordinate operations from {@code sourceCRS} to {@code targetCRS}.
* @throws FactoryException if the operation cannot be constructed.
*/
- @SuppressWarnings("deprecation")
protected List<CoordinateOperation> createOperationStep(final SingleCRS sourceCRS,
final GeneralDerivedCRS targetCRS)
throws FactoryException
@@ -399,7 +397,7 @@
/**
* Creates an operation from a derived CRS to an arbitrary single coordinate reference system.
* Conversions from {@code ProjectedCRS} to {@code GeographicCRS} are also handled by this method,
- * since projected CRS are a special kind of {@code DerivedCRS}.
+ * since projected CRS are a special kind of {@code GeneralDerivedCRS}.
*
* <p>The default implementation constructs the following operation chain:</p>
* <blockquote><code>sourceCRS → {@linkplain DerivedCRS#getBaseCRS() baseCRS} → targetCRS</code></blockquote>
@@ -416,7 +414,6 @@
* @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}.
* @throws FactoryException if the operation cannot be constructed.
*/
- @SuppressWarnings("deprecation")
protected List<CoordinateOperation> createOperationStep(final GeneralDerivedCRS sourceCRS,
final SingleCRS targetCRS)
throws FactoryException
@@ -459,7 +456,6 @@
* @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}.
* @throws FactoryException if the operation cannot be constructed.
*/
- @SuppressWarnings("deprecation")
protected List<CoordinateOperation> createOperationStep(final GeneralDerivedCRS sourceCRS,
final GeneralDerivedCRS targetCRS)
throws FactoryException
@@ -533,7 +529,7 @@
*/
final boolean isGeographic = (sourceCS instanceof EllipsoidalCS);
identifier = isGeographic != (targetCS instanceof EllipsoidalCS) ? GEOCENTRIC_CONVERSION : AXIS_CHANGES;
- final var builder = factorySIS.getMathTransformFactory().builder(Constants.COORDINATE_SYSTEM_CONVERSION);
+ final var builder = CoordinateOperations.builder(factorySIS.getMathTransformFactory(), Constants.COORDINATE_SYSTEM_CONVERSION);
final var ellipsoid = (isGeographic ? sourceDatum : targetDatum).getEllipsoid();
builder.setSourceAxes(sourceCS, ellipsoid);
builder.setTargetAxes(targetCS, ellipsoid);
@@ -635,7 +631,7 @@
final EllipsoidalCS cs = CommonCRS.WGS84.geographic3D().getCoordinateSystem();
if (!Utilities.equalsIgnoreMetadata(interpolationCS, cs)) {
final GeographicCRS stepCRS = factorySIS.crsFactory
- .createGeographicCRS(derivedFrom(sourceCRS), sourceCRS.getDatum(), sourceCRS.getDatumEnsemble(), cs);
+ .createGeographicCRS(derivedFrom(sourceCRS), DatumOrEnsemble.asDatum(sourceCRS), cs);
step1 = createOperation(sourceCRS, toAuthorityDefinition(GeographicCRS.class, stepCRS));
interpolationCRS = step1.getTargetCRS();
interpolationCS = interpolationCRS.getCoordinateSystem();
@@ -1206,7 +1202,6 @@
* @param crs the CRS having a conversion that cannot be inverted.
* @return a default error message.
*/
- @SuppressWarnings("deprecation")
private String canNotInvert(final GeneralDerivedCRS crs) {
return resources().getString(Resources.Keys.NonInvertibleOperation_1, label(crs.getConversionFromBase()));
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
index 8544706..8060d6b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
@@ -84,6 +84,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.crs.GeneralDerivedCRS;
+// Specific to the main branch:
+import org.apache.sis.referencing.operation.transform.MathTransformBuilder;
+
/**
* Base class of code that search for coordinate operation, either by looking in a registry maintained by an authority
@@ -436,7 +439,6 @@
* axis order, we want to check also the coordinate operations using (latitude, longitude) axis order
* because they may be the only ones available.</p>
*/
- @SuppressWarnings("deprecation")
private static boolean isEasySearch(final CoordinateReferenceSystem crs) {
if (crs instanceof GeneralDerivedCRS) {
return false;
@@ -1009,7 +1011,7 @@
}
}
return factorySIS.createSingleOperation(properties, sourceCRS, targetCRS,
- operation.getInterpolationCRS().orElse(null), method, transform);
+ AbstractCoordinateOperation.getInterpolationCRS(operation), method, transform);
}
/**
@@ -1149,7 +1151,7 @@
if (SubTypes.isSingleOperation(op)) {
if (forward) sourceCRS = toGeodetic3D(sourceCRS, source3D);
else targetCRS = toGeodetic3D(targetCRS, target3D);
- final MathTransform.Builder builder;
+ final MathTransformBuilder builder;
final MathTransform mt;
try {
final var parameters = ((SingleOperation) op).getParameterValues();
@@ -1277,7 +1279,7 @@
* @return the parameterized transform.
* @throws FactoryException if the transform cannot be created.
*/
- private MathTransform.Builder createTransformBuilder(
+ private MathTransformBuilder createTransformBuilder(
final ParameterValueGroup parameters,
final CoordinateReferenceSystem sourceCRS,
final CoordinateReferenceSystem targetCRS) throws FactoryException
@@ -1373,7 +1375,7 @@
method = CoordinateOperations.findMethod(factorySIS.getMathTransformFactory(), descriptor);
} catch (NoSuchIdentifierException e) {
recoverableException("createFromMathTransform", e);
- method = factory.createOperationMethod(properties, descriptor);
+ method = factorySIS.createOperationMethod(properties, descriptor);
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
index bb3e1b3..ad25a5e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
@@ -175,7 +175,7 @@
if (targetCRS == null) {
targetCRS = crs;
} else if (mtFactory != null) {
- var builder = mtFactory.builder(Constants.COORDINATE_SYSTEM_CONVERSION);
+ var builder = CoordinateOperations.builder(mtFactory, Constants.COORDINATE_SYSTEM_CONVERSION);
builder.setSourceAxes(crs.getCoordinateSystem(), DatumOrEnsemble.getEllipsoid(crs).orElse(null));
builder.setTargetAxes(targetCRS.getCoordinateSystem(), null);
transform = mtFactory.createConcatenatedTransform(transform, builder.create());
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
index f4141c8..1b63584 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
@@ -50,6 +50,9 @@
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.ProjectedCRS;
+// Specific to the main branch:
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
+
/**
* A parameterized mathematical operation that converts coordinates to another CRS without any change of
@@ -119,7 +122,7 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link #getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr>
@@ -228,7 +231,6 @@
* @param target the new target CRS.
* @param factory the factory to use for creating a transform from the parameters or for performing axis changes.
*/
- @SuppressWarnings("deprecation")
DefaultConversion(final Conversion definition,
final CoordinateReferenceSystem source,
final CoordinateReferenceSystem target,
@@ -365,7 +367,6 @@
*
* @since 1.5
*/
- @SuppressWarnings("deprecation")
public Conversion specialize(final CoordinateReferenceSystem sourceCRS,
final CoordinateReferenceSystem targetCRS,
MathTransformFactory factory) throws FactoryException
@@ -430,8 +431,8 @@
if (datum != null) {
other = crs2.getDatum();
} else {
- datum = crs1.getDatumEnsemble();
- other = crs2.getDatumEnsemble();
+ datum = getDatumEnsemble(crs1);
+ other = getDatumEnsemble(crs2);
}
if (datum != null && other != null && !Utilities.equalsIgnoreMetadata(datum, other)) {
throw new MismatchedDatumException(Resources.format(
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
index 9a01510..93ea647 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
@@ -317,7 +317,6 @@
*
* @since 1.4
*/
- @Override
public OperationMethod createOperationMethod(final Map<String,?> properties,
final ParameterDescriptorGroup parameters) throws FactoryException
{
@@ -331,17 +330,6 @@
}
/**
- * @deprecated The dimensions attributes have been removed in ISO 19111:2019 revision.
- */
- @Deprecated(since="1.4", forRemoval=true)
- public OperationMethod createOperationMethod(final Map<String,?> properties,
- final Integer sourceDimensions, final Integer targetDimensions,
- ParameterDescriptorGroup parameters) throws FactoryException
- {
- return createOperationMethod(properties, parameters);
- }
-
- /**
* Creates a defining conversion from the given operation parameters.
* This conversion has no source and target CRS since those elements are usually unknown at this stage.
* The source and target CRS will become known later, at the
@@ -369,7 +357,7 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link DefaultConversion#getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr>
@@ -452,7 +440,7 @@
* <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
* <td>{@link DefaultConversion#getIdentifiers()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
index 05f765e..ca4f77e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
@@ -517,7 +517,6 @@
* @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#118">WKT 2 specification §17.2.3</a>
*/
@Override
- @SuppressWarnings("deprecation")
protected String formatTo(final Formatter formatter) {
final boolean isWKT1 = formatter.getConvention().majorVersion() == 1;
/*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java
index d3bdca7..058f194 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java
@@ -87,7 +87,7 @@
* <td>{@link org.opengis.metadata.quality.PositionalAccuracy} (optionally as array)</td>
* <td>{@link #getCoordinateOperationAccuracy()}</td>
* </tr><tr>
- * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
* <td>{@link org.opengis.metadata.extent.Extent}</td>
* <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td>
* </tr>
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java
index b0a7591..ba7d05f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java
@@ -40,8 +40,9 @@
import org.apache.sis.util.Deprecable;
import org.apache.sis.util.collection.Containers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.apache.sis.referencing.DefaultObjectDomain;
+import org.apache.sis.referencing.internal.Legacy;
/**
@@ -138,7 +139,7 @@
* @param target where to store the properties of the inverse operation.
*/
static void properties(final SingleOperation source, final Map<String,Object> target) {
- target.put(SingleOperation.DOMAINS_KEY, source.getDomains().toArray(ObjectDomain[]::new));
+ target.put("domains", Legacy.getDomains(source).toArray(DefaultObjectDomain[]::new));
final Collection<PositionalAccuracy> accuracy = source.getCoordinateOperationAccuracy();
if (!Containers.isNullOrEmpty(accuracy)) {
target.put(SingleOperation.COORDINATE_OPERATION_ACCURACY_KEY,
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MathTransformContext.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MathTransformContext.java
index 1e8f153..c610643 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MathTransformContext.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MathTransformContext.java
@@ -42,8 +42,8 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.UnimplementedServiceException;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.CoordinateOperations;
/**
@@ -115,7 +115,7 @@
final Ellipsoid ellipsoid)
throws FactoryException
{
- final var builder = factory.builder(Constants.COORDINATE_SYSTEM_CONVERSION);
+ final var builder = CoordinateOperations.builder(factory, Constants.COORDINATE_SYSTEM_CONVERSION);
builder.setSourceAxes(source, ellipsoid);
builder.setTargetAxes(target, ellipsoid);
return builder.create();
@@ -220,7 +220,7 @@
}
matrix = cm;
} else {
- throw new UnimplementedServiceException(Errors.format(Errors.Keys.UnsupportedCoordinateSystem_1, userCS.getName()));
+ throw new FactoryException(Errors.format(Errors.Keys.UnsupportedCoordinateSystem_1, userCS.getName()));
}
}
return matrix;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MismatchedDatumException.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MismatchedDatumException.java
index 6e8666c..bc5abc2 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MismatchedDatumException.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/MismatchedDatumException.java
@@ -36,8 +36,7 @@
* @author Martin Desruisseaux (Geomatys)
* @version 0.6
*
- * @see org.opengis.coordinate.MismatchedCoordinateMetadataException
- * @see org.opengis.coordinate.MismatchedDimensionException
+ * @see org.opengis.geometry.MismatchedDimensionException
* @see org.apache.sis.referencing.operation.matrix.MismatchedMatrixSizeException
*
* @since 0.6
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java
index e670e5c..9f1776e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java
@@ -29,6 +29,9 @@
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.referencing.operation.transform.MathTransforms;
+// Specific to the main branch:
+import org.apache.sis.referencing.crs.DefaultParametricCRS;
+
/**
* Information about the operation from a source component to a target component in {@code CompoundCRS} instances.
@@ -55,12 +58,11 @@
* {@link ProjectedCRS} and {@link DerivedCRS} are not in this list because we rather use their base CRS
* as the criterion for determining their type.
*/
- @SuppressWarnings("deprecation")
private static final Class<?>[][] COMPATIBLE_TYPES = {
{GeodeticCRS.class},
{VerticalCRS.class, GeodeticCRS.class},
{TemporalCRS.class},
- {ParametricCRS.class},
+ {DefaultParametricCRS.class},
{EngineeringCRS.class},
{ImageCRS.class}
};
@@ -69,7 +71,6 @@
* Returns the class of the given CRS after unwrapping derived and projected CRS.
* The returned type is for use with {@link #COMPATIBLE_TYPES}.
*/
- @SuppressWarnings("deprecation")
private static Class<?> type(SingleCRS crs) {
while (crs instanceof GeneralDerivedCRS) {
crs = (SingleCRS) ((GeneralDerivedCRS) crs).getBaseCRS();
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/TransformedCoordinateSet.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/TransformedCoordinateSet.java
index e51b222..68ff144 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/TransformedCoordinateSet.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/TransformedCoordinateSet.java
@@ -33,10 +33,8 @@
import org.apache.sis.coordinate.DefaultCoordinateMetadata;
import org.apache.sis.coordinate.AbstractCoordinateSet;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coordinate.CoordinateSet;
-import org.opengis.coordinate.CoordinateMetadata;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -50,13 +48,12 @@
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -6533100977777070895L;
+ private static final long serialVersionUID = -6533100977777070894L;
/**
* The data to transform.
*/
- @SuppressWarnings("serial") // Apache SIS implementations of this interface are serializable.
- private final CoordinateSet data;
+ private final AbstractCoordinateSet data;
/**
* The transform to apply on coordinate tuples.
@@ -74,14 +71,16 @@
* @param data the coordinate tuples to transform.
* @throws TransformException if the transform cannot be prepared.
*/
- TransformedCoordinateSet(final AbstractCoordinateOperation op, final CoordinateSet data) throws TransformException {
+ TransformedCoordinateSet(final AbstractCoordinateOperation op, final AbstractCoordinateSet data)
+ throws TransformException
+ {
super(new DefaultCoordinateMetadata(op.getTargetCRS(), op.getTargetEpoch().orElse(null)));
@SuppressWarnings("LocalVariableHidesMemberVariable")
MathTransform transform = op.getMathTransform();
if (transform == null) {
throw new TransformException(Resources.format(Resources.Keys.OperationHasNoTransform_2, op.getClass(), op.getName()));
}
- final CoordinateMetadata metadata = data.getCoordinateMetadata();
+ final DefaultCoordinateMetadata metadata = data.getCoordinateMetadata();
if (metadata != null) try {
GeographicBoundingBox aoi = CRS.getGeographicBoundingBox(op);
final var step = new DefaultCoordinateMetadata(op.getSourceCRS(), op.getSourceEpoch().orElse(null));
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
index 354fcbd..3816006 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
@@ -60,8 +60,9 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.geometry.coordinate.Position;
/**
@@ -368,7 +369,7 @@
int offset = 0;
for (int i = gridSize.length; i != 0;) {
final int size = gridSize[--i];
- final double coordinate = source.getCoordinate(i);
+ final double coordinate = source.getOrdinate(i);
final int index = (int) coordinate;
if (index != coordinate) {
throw new IllegalArgumentException(Errors.format(Errors.Keys.NotAnInteger_1, coordinate));
@@ -411,8 +412,7 @@
return;
}
if (actual != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3, "source", expected, actual));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3, "source", expected, actual));
}
}
@@ -422,9 +422,8 @@
* with {@link #numPoints} the index of the next point that we failed to add.
*/
private MismatchedDimensionException mismatchedDimension(final String name, final int expected, final int actual) {
- return new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3,
- Strings.toIndexed(name, numPoints), expected, actual));
+ return new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3,
+ Strings.toIndexed(name, numPoints), expected, actual));
}
/**
@@ -554,6 +553,13 @@
}
/**
+ * Returns the direct position of the given position, or {@code null} if none.
+ */
+ private static DirectPosition position(final Position p) {
+ return (p != null) ? p.getDirectPosition() : null;
+ }
+
+ /**
* Sets all control point (source, target) pairs, overwriting any previous setting.
* The source positions are all integer coordinates in a rectangle from (0, 0, …) inclusive
* to {@code gridSize} exclusive where {@code gridSize} is an {@code int[]} array specified
@@ -573,7 +579,7 @@
}
final int srcDim = gridToCRS.getSourceDimensions();
if (srcDim != gridSize.length) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedTransformDimension_4, "gridToCRS", 0, gridSize.length, srcDim));
}
final int tgtDim = gridToCRS.getTargetDimensions();
@@ -635,7 +641,7 @@
*
* @since 0.8
*/
- public void setControlPoints(final Map<? extends DirectPosition, ? extends DirectPosition> sourceToTarget)
+ public void setControlPoints(final Map<? extends Position, ? extends Position> sourceToTarget)
throws MismatchedDimensionException
{
ensureModifiable();
@@ -644,9 +650,9 @@
numPoints = 0;
int srcDim = 0;
int tgtDim = 0;
- for (final Map.Entry<? extends DirectPosition, ? extends DirectPosition> entry : sourceToTarget.entrySet()) {
- final DirectPosition src = entry.getKey(); if (src == null) continue;
- final DirectPosition tgt = entry.getValue(); if (tgt == null) continue;
+ for (final Map.Entry<? extends Position, ? extends Position> entry : sourceToTarget.entrySet()) {
+ final DirectPosition src = position(entry.getKey()); if (src == null) continue;
+ final DirectPosition tgt = position(entry.getValue()); if (tgt == null) continue;
/*
* The first time that we get a non-null source and target coordinate, allocate the arrays.
* The sources arrays are allocated only if the source coordinates are randomly distributed.
@@ -684,11 +690,11 @@
} else {
index = numPoints;
for (int i=0; i<srcDim; i++) {
- isValid &= Double.isFinite(sources[i][index] = src.getCoordinate(i));
+ isValid &= Double.isFinite(sources[i][index] = src.getOrdinate(i));
}
}
for (int i=0; i<tgtDim; i++) {
- isValid &= Double.isFinite(targets[i][index] = tgt.getCoordinate(i));
+ isValid &= Double.isFinite(targets[i][index] = tgt.getOrdinate(i));
}
/*
* If the point contains some NaN or infinite coordinate values, it is okay to leave it as-is
@@ -789,7 +795,7 @@
*/
@Override
public final boolean containsValue(final Object value) {
- return (value instanceof DirectPosition) && search(targets, ((DirectPosition) value).getCoordinates()) >= 0;
+ return (value instanceof Position) && search(targets, ((Position) value).getDirectPosition().getCoordinate()) >= 0;
}
/**
@@ -798,7 +804,7 @@
*/
@Override
public final boolean containsKey(final Object key) {
- return (key instanceof DirectPosition) && flatIndex((DirectPosition) key) >= 0;
+ return (key instanceof Position) && flatIndex(((Position) key).getDirectPosition()) >= 0;
}
/**
@@ -807,8 +813,8 @@
*/
@Override
public final DirectPosition get(final Object key) {
- if (key instanceof DirectPosition) {
- final int index = flatIndex((DirectPosition) key);
+ if (key instanceof Position) {
+ final int index = flatIndex(((Position) key).getDirectPosition());
if (index >= 0) return position(targets, index);
}
return null;
@@ -833,7 +839,7 @@
int offset = 0;
while (i != 0) {
final int size = gridSize[--i];
- final double coordinate = source.getCoordinate(i);
+ final double coordinate = source.getOrdinate(i);
final int index = (int) coordinate;
if (index < 0 || index >= size || index != coordinate) {
return -1;
@@ -928,7 +934,7 @@
* in the flattened array. In non-gridded case, this operation requires linear scan.
*/
@Override int flatIndex(final DirectPosition source) {
- return search(sources, source.getCoordinates());
+ return search(sources, source.getCoordinate());
}
/**
@@ -971,7 +977,7 @@
verifySourceDimension(source.length);
final int tgtDim = target.length;
if (targets != null && tgtDim != targets.length) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, "target", targets.length, tgtDim));
}
int index;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java
index fba1687..935ecfd 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java
@@ -51,8 +51,8 @@
import org.apache.sis.math.Vector;
import static org.apache.sis.referencing.operation.builder.ResidualGrid.SOURCE_DIMENSION;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -383,9 +383,8 @@
return;
}
}
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedTransformDimension_4,
- "sourceToGrid", isTarget, SOURCE_DIMENSION, dim));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedTransformDimension_4,
+ "sourceToGrid", isTarget, SOURCE_DIMENSION, dim));
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/ResidualGrid.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/ResidualGrid.java
index ee77693..83d8695 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/ResidualGrid.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/builder/ResidualGrid.java
@@ -309,11 +309,12 @@
}
@SuppressWarnings({"CloneInNonCloneableClass", "CloneDoesntCallSuperClone"})
- @Override public Matrix clone() {return this;}
- @Override public boolean isIdentity() {return false;}
- @Override public int getNumCol() {return getGridSize(0);}
- @Override public int getNumRow() {return getGridSize(1);}
- @Override public Number apply(int[] p) {return getElement(p[1], p[0]);}
+ @Override public Matrix clone() {return this;}
+ @Override public boolean isIdentity() {return false;}
+ @Override public int getNumCol() {return getGridSize(0);}
+ @Override public int getNumRow() {return getGridSize(1);}
+ @Override public Number apply (int[] p) {return getElement(p[1], p[0]);}
+ @Override public void setElement(int y, int x, double v) {throw new UnsupportedOperationException();}
/** Computes the matrix element in the given row and column. */
@Override public double getElement(final int y, final int x) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
index 3283878..4645cce 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
@@ -40,8 +40,8 @@
import org.apache.sis.referencing.internal.Arithmetic;
import org.apache.sis.referencing.operation.transform.MathTransforms; // For javadoc
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -302,8 +302,8 @@
if (!same) {
scale = scale.negate();
}
- translate = scale.multiply((same ? srcCorner : srcOppositeCorner).getCoordinate(srcIndex), decimal);
- translate = DoubleDouble.of(dstCorner.getCoordinate(dstIndex), decimal).subtract(translate);
+ translate = scale.multiply((same ? srcCorner : srcOppositeCorner).getOrdinate(srcIndex), decimal);
+ translate = DoubleDouble.of(dstCorner.getOrdinate(dstIndex), decimal).subtract(translate);
matrix.setNumber(dstIndex, srcIndex, scale);
matrix.setNumber(dstIndex, srcAxes.length, translate);
@@ -335,7 +335,7 @@
* </ul>
*
* This method ignores the {@linkplain Envelope#getCoordinateReferenceSystem() envelope CRS}, which may be null.
- * Actually this method is used more often for {@linkplain org.opengis.coverage.grid.GridEnvelope grid envelopes}
+ * Actually this method is used more often for grid envelopes
* (which have no CRS) than geodetic envelopes.
*
* <h4>Crossing the anti-meridian of a Geographic CRS</h4>
@@ -394,7 +394,7 @@
* anti-meridian.
*/
final double scale = dstEnvelope.getSpan(i) / srcEnvelope.getSpan(i);
- final double translate = dstCorner.getCoordinate(i) - srcCorner.getCoordinate(i)*scale;
+ final double translate = dstCorner.getOrdinate(i) - srcCorner.getOrdinate(i)*scale;
matrix.setElement(i, i, scale);
matrix.setElement(i, srcDim, translate);
}
@@ -473,7 +473,7 @@
* </ul>
*
* This method ignores the {@linkplain Envelope#getCoordinateReferenceSystem() envelope CRS}, which may be null.
- * Actually this method is used more often for {@linkplain org.opengis.coverage.grid.GridEnvelope grid envelopes}
+ * Actually this method is used more often for grid envelopes
* (which have no CRS) than geodetic envelopes.
*
* <h4>Crossing the anti-meridian of a Geographic CRS</h4>
@@ -754,7 +754,7 @@
}
if (translation != null) {
for (int j=0; j<numRow; j++) {
- matrix.setElement(j, numCol, translation.getCoordinate(j));
+ matrix.setElement(j, numCol, translation.getOrdinate(j));
}
}
return matrix;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java
index 7c2775b..ae4b6a9 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java
@@ -16,8 +16,8 @@
*/
package org.apache.sis.referencing.operation.matrix;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -31,7 +31,6 @@
* @author Martin Desruisseaux (Geomatys)
* @version 0.4
*
- * @see org.opengis.coordinate.MismatchedCoordinateMetadataException
* @see org.apache.sis.referencing.operation.MismatchedDatumException
*
* @since 0.4
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
index 4bffd74..976c105 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
@@ -53,8 +53,8 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.privy.Numerics;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -470,7 +470,7 @@
for (final V variant : variants) {
final String identifier = variant.getIdentifier();
if (identifier != null) {
- for (final Identifier id : method.getIdentifiers()) {
+ for (final ReferenceIdentifier id : method.getIdentifiers()) {
if (Constants.EPSG.equals(id.getCodeSpace()) && identifier.equals(id.getCode())) {
return variant;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
index bd8a52a..0fc47ce 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
@@ -48,8 +48,8 @@
import org.apache.sis.util.OptionalCandidate;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -189,7 +189,7 @@
* @throws TransformException if the domain cannot be estimated.
*
* @see MathTransforms#getDomain(MathTransform)
- * @see org.opengis.referencing.ObjectDomain#getDomainOfValidity()
+ * @see org.opengis.referencing.operation.CoordinateOperation#getDomainOfValidity()
*
* @since 1.3
*/
@@ -286,8 +286,7 @@
* @param dimension the wrong dimension.
*/
static MismatchedDimensionException mismatchedDimension(final String argument, final int expected, final int dimension) {
- return new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3, argument, expected, dimension));
+ return new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3, argument, expected, dimension));
}
/**
@@ -323,16 +322,16 @@
*/
final double[] array;
if (dimSource >= dimTarget) {
- array = ptSrc.getCoordinates();
+ array = ptSrc.getCoordinate();
} else {
array = new double[dimTarget];
for (int i=dimSource; --i>=0;) {
- array[i] = ptSrc.getCoordinate(i);
+ array[i] = ptSrc.getOrdinate(i);
}
}
transform(array, 0, array, 0, false);
for (int i=0; i<dimTarget; i++) {
- ptDst.setCoordinate(i, array[i]);
+ ptDst.setOrdinate(i, array[i]);
}
} else {
/*
@@ -344,10 +343,10 @@
if (dimSource <= dimTarget) {
source = destination.coordinates;
for (int i=0; i<dimSource; i++) {
- source[i] = ptSrc.getCoordinate(i);
+ source[i] = ptSrc.getOrdinate(i);
}
} else {
- source = ptSrc.getCoordinates();
+ source = ptSrc.getCoordinate();
}
transform(source, 0, destination.coordinates, 0, false);
ptDst = destination;
@@ -814,7 +813,7 @@
@Override
public Matrix derivative(final DirectPosition point) throws TransformException {
final int dimSource = getSourceDimensions();
- final double[] coordinates = point.getCoordinates();
+ final double[] coordinates = point.getCoordinate();
if (coordinates.length != dimSource) {
throw mismatchedDimension("point", dimSource, coordinates.length);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java
index fef35f5..e0f30ca 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java
@@ -24,8 +24,8 @@
import org.apache.sis.referencing.operation.matrix.Matrix1;
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -148,7 +148,7 @@
coordinate = Double.NaN;
} else {
ensureDimensionMatches("point", DIMENSION, point);
- coordinate = point.getCoordinate(0);
+ coordinate = point.getOrdinate(0);
}
return new Matrix1(derivative(coordinate));
}
@@ -227,7 +227,7 @@
coordinate = Double.NaN;
} else {
ensureDimensionMatches("point", DIMENSION, point);
- coordinate = point.getCoordinate(0);
+ coordinate = point.getOrdinate(0);
}
return new Matrix1(derivative(coordinate));
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
index 82a6d02..225b068 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
@@ -45,6 +45,9 @@
import org.apache.sis.referencing.privy.WKTUtilities;
import org.apache.sis.util.resources.Errors;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.CoordinateOperations;
+
/**
* Builder of transforms between coordinate systems.
@@ -276,14 +279,14 @@
return addOrRemoveVertical(stepSource, stepTarget, Geographic2Dto3D.NAME, Geographic3Dto2D.NAME);
}
if ((stepTarget instanceof CartesianCS || stepTarget instanceof SphericalCS)) {
- final var context = factory.builder(GeographicToGeocentric.NAME);
+ final var context = CoordinateOperations.builder(factory, GeographicToGeocentric.NAME);
context.setSourceAxes(stepSource, ellipsoid);
context.setTargetAxes(stepTarget, null);
return delegate(context);
}
} else if (stepTarget instanceof EllipsoidalCS) {
if ((stepSource instanceof CartesianCS || stepSource instanceof SphericalCS)) {
- final var context = factory.builder(GeocentricToGeographic.NAME);
+ final var context = CoordinateOperations.builder(factory, GeocentricToGeographic.NAME);
context.setSourceAxes(stepSource, null);
context.setTargetAxes(stepTarget, ellipsoid);
return delegate(context);
@@ -375,7 +378,7 @@
final int change = stepTarget.getDimension() - stepSource.getDimension();
if (change != 0) {
final String method = change < 0 ? remove : add;
- final var context = factory.builder(method);
+ final var context = CoordinateOperations.builder(factory, method);
context.setSourceAxes(stepSource, ellipsoid);
context.setTargetAxes(stepTarget, ellipsoid);
return delegate(context);
@@ -393,7 +396,7 @@
* @return result of {@code context.create()}.
* @throws FactoryException if the given context cannot create the transform.
*/
- private MathTransform delegate(final MathTransform.Builder context) throws FactoryException {
+ private MathTransform delegate(final MathTransformBuilder context) throws FactoryException {
final MathTransform step = context.create();
setParameters(step, context.getMethod().orElse(null), context.parameters());
return step;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
index d86fac6..042c6a2 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
@@ -58,9 +58,6 @@
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.referencing.operation.matrix.Matrices;
-
/**
* Low level factory for creating {@linkplain AbstractMathTransform math transforms}.
@@ -483,6 +480,10 @@
* or anything else related to datum. Datum changes have dedicated {@link OperationMethod},
* for example <q>Longitude rotation</q> (EPSG:9601) for changing the prime meridian.
*
+ * <div class="warning"><b>Upcoming API generalization:</b>
+ * the return type of this method may be changed to a new {@code MathTransform.Builder} interface
+ * in a future Apache SIS version. This is pending GeoAPI 3.1 release, if approved by OGC.</div>
+ *
* @param method the case insensitive name or identifier of the desired coordinate operation method.
* @return a builder for a meth transform implementing the formulas identified by the given method.
* @throws NoSuchIdentifierException if there is no supported method for the given name or identifier.
@@ -490,8 +491,7 @@
* @see #getAvailableMethods(Class)
* @since 1.5
*/
- @Override
- public MathTransform.Builder builder(final String method) throws NoSuchIdentifierException {
+ public MathTransformBuilder builder(final String method) throws NoSuchIdentifierException {
if (method.replace('_', ' ').equalsIgnoreCase(Constants.COORDINATE_SYSTEM_CONVERSION)) {
return new CoordinateSystemTransformBuilder(this);
}
@@ -575,7 +575,7 @@
* The source ellipsoid is unconditionally set to {@code null}.
*
* @param cs the coordinate system to set as the source (can be {@code null}).
- * @deprecated Replaced by {@link MathTransform.Builder#setSourceAxes(CoordinateSystem, Ellipsoid)}.
+ * @deprecated Replaced by {@link MathTransformBuilder#setSourceAxes(CoordinateSystem, Ellipsoid)}.
*/
@Deprecated(since="1.5", forRemoval=true)
public void setSource(final CoordinateSystem cs) {
@@ -596,7 +596,7 @@
* @param crs the coordinate system and ellipsoid to set as the source, or {@code null}.
*
* @since 1.3
- * @deprecated Replaced by {@link MathTransform.Builder#setSourceAxes(CoordinateSystem, Ellipsoid)}.
+ * @deprecated Replaced by {@link MathTransformBuilder#setSourceAxes(CoordinateSystem, Ellipsoid)}.
*/
@Deprecated(since="1.5", forRemoval=true)
public void setSource(final GeodeticCRS crs) {
@@ -615,7 +615,7 @@
* The target ellipsoid is unconditionally set to {@code null}.
*
* @param cs the coordinate system to set as the target (can be {@code null}).
- * @deprecated Replaced by {@link MathTransform.Builder#setTargetAxes(CoordinateSystem, Ellipsoid)}.
+ * @deprecated Replaced by {@link MathTransformBuilder#setTargetAxes(CoordinateSystem, Ellipsoid)}.
*/
@Deprecated(since="1.5", forRemoval=true)
public void setTarget(final CoordinateSystem cs) {
@@ -636,7 +636,7 @@
* @param crs the coordinate system and ellipsoid to set as the target, or {@code null}.
*
* @since 1.3
- * @deprecated Replaced by {@link MathTransform.Builder#setTargetAxes(CoordinateSystem, Ellipsoid)}.
+ * @deprecated Replaced by {@link MathTransformBuilder#setTargetAxes(CoordinateSystem, Ellipsoid)}.
*/
@Deprecated(since="1.5", forRemoval=true)
public void setTarget(final GeodeticCRS crs) {
@@ -749,7 +749,7 @@
* @throws IllegalStateException if {@link #createParameterizedTransform(ParameterValueGroup, Context)}
* has not yet been invoked.
*
- * @deprecated Replaced by {@link MathTransform.Builder#getMethod()}.
+ * @deprecated Replaced by {@link MathTransformBuilder#getMethod()}.
*
* @since 1.3
*/
@@ -1048,22 +1048,6 @@
}
/**
- * Creates a modifiable matrix of size {@code numRow} × {@code numCol}.
- * Elements on the diagonal (<var>j</var> == <var>i</var>) are set to 1.
- *
- * @param numRow number of rows.
- * @param numCol number of columns.
- * @return a new matrix of the given size.
- * @throws FactoryException if the matrix creation failed.
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- @Override
- public Matrix createMatrix(int numRow, int numCol) throws FactoryException {
- return Matrices.createDiagonal(numRow, numCol);
- }
-
- /**
* Creates a transform by concatenating two existing transforms.
* A concatenated transform acts in the same way as applying two transforms, one after the other.
*
@@ -1225,7 +1209,7 @@
*
* @see #createParameterizedTransform(ParameterValueGroup)
*
- * @deprecated Replaced by {@link MathTransform.Builder#getMethod()}.
+ * @deprecated Replaced by {@link MathTransformBuilder#getMethod()}.
*/
@Override
@Deprecated(since = "1.5")
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DomainDefinition.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DomainDefinition.java
index 244f76b..614fc12 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DomainDefinition.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DomainDefinition.java
@@ -60,7 +60,7 @@
*
* @see MathTransforms#getDomain(MathTransform)
* @see AbstractMathTransform#getDomain(DomainDefinition)
- * @see org.opengis.referencing.operation.CoordinateOperation#getDomains()
+ * @see org.opengis.referencing.operation.CoordinateOperation#getDomainOfValidity()
*
* @since 1.3
*/
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
index bcda590..2bfb003 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
@@ -631,10 +631,10 @@
final double h;
switch (dim) {
default: throw mismatchedDimension("point", getSourceDimensions(), dim);
- case 3: wh = true; h = point.getCoordinate(VERTICAL_DIM); break;
+ case 3: wh = true; h = point.getOrdinate(VERTICAL_DIM); break;
case 2: wh = false; h = 0; break;
}
- return transform(point.getCoordinate(0), point.getCoordinate(1), h, null, 0, true, wh);
+ return transform(point.getOrdinate(0), point.getOrdinate(1), h, null, 0, true, wh);
}
/**
@@ -1027,7 +1027,7 @@
*/
@Override
public Matrix derivative(final DirectPosition point) throws TransformException {
- final double[] coordinates = point.getCoordinates();
+ final double[] coordinates = point.getCoordinate();
ArgumentChecks.ensureDimensionMatches("point", NUM_CENTRIC_DIM, coordinates);
return this.transform(coordinates, 0, coordinates, 0, true);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/IdentityTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/IdentityTransform.java
index e7521d3..62f3c52 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/IdentityTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/IdentityTransform.java
@@ -155,7 +155,7 @@
}
ArgumentChecks.ensureDimensionMatches("ptDst", dimension, ptDst);
for (int i=0; i<dimension; i++) {
- ptDst.setCoordinate(i, ptSrc.getCoordinate(i));
+ ptDst.setOrdinate(i, ptSrc.getOrdinate(i));
}
return ptDst;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformBuilder.java
index 0602b67..1b15e02 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformBuilder.java
@@ -25,6 +25,12 @@
import org.apache.sis.util.Classes;
import org.apache.sis.util.privy.Strings;
+// Specific to the main branch:
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.parameter.ParameterValueGroup;
+
/**
* Builder of a parameterized math transform using a method identified by a name or code.
@@ -38,7 +44,7 @@
* @version 1.5
* @since 1.5
*/
-public abstract class MathTransformBuilder implements MathTransform.Builder {
+public abstract class MathTransformBuilder {
/**
* The factory to use for building the transform.
*/
@@ -73,12 +79,91 @@
*
* @return the operation method used for creating the math transform from the parameter values.
*/
- @Override
public final Optional<OperationMethod> getMethod() {
return Optional.ofNullable(provider);
}
/**
+ * Returns the parameter values of the transform to create.
+ * Those parameters are initialized to default values, which may be implementation or method depend.
+ * User-supplied values should be set directly in the returned instance with codes like
+ * <code>parameter(</code><var>name</var><code>).setValue(</code><var>value</var><code>)</code>.
+ *
+ * @return the parameter values of the transform to create. Values should be set in-place.
+ */
+ public abstract ParameterValueGroup parameters();
+
+ /**
+ * Gives hints about axis lengths and their orientations in input coordinates.
+ * The action performed by this call depends on the {@linkplain #getMethod() operation method}.
+ * For map projections, the action may include something equivalent to the following code:
+ *
+ * {@snippet lang="java" :
+ * parameters().parameter("semi_major").setValue(ellipsoid.getSemiMajorAxis(), ellipsoid.getAxisUnit());
+ * parameters().parameter("semi_minor").setValue(ellipsoid.getSemiMinorAxis(), ellipsoid.getAxisUnit());
+ * }
+ *
+ * For geodetic datum shifts, the action may be similar to above code but with different parameter names:
+ * {@code "src_semi_major"} and {@code "src_semi_minor"}. Other operation methods may ignore the arguments.
+ *
+ * <h4>Axis order, units and direction</h4>
+ * By default, the source axes of a parameterized transform are normalized to <var>east</var>,
+ * <var>north</var>, <var>up</var> (if applicable) directions with units in degrees and meters.
+ * If this requirement is ambiguous, for example because the operation method uses incompatible
+ * axis directions or units, then the {@code cs} argument should be non-null for allowing the
+ * implementation to resolve that ambiguity.
+ *
+ * @param cs the coordinate system defining source axis order and units, or {@code null} if none.
+ * @param ellipsoid the ellipsoid providing source semi-axis lengths, or {@code null} if none.
+ */
+ public void setSourceAxes(CoordinateSystem cs, Ellipsoid ellipsoid) {
+ }
+
+ /**
+ * Gives hints about axis lengths and their orientations in output coordinates.
+ * The action performed by this call depends on the {@linkplain #getMethod() operation method}.
+ * For datum shifts, the action may include something equivalent to the following code:
+ *
+ * {@snippet lang="java" :
+ * parameters().parameter("tgt_semi_major").setValue(ellipsoid.getSemiMajorAxis(), ellipsoid.getAxisUnit());
+ * parameters().parameter("tgt_semi_minor").setValue(ellipsoid.getSemiMinorAxis(), ellipsoid.getAxisUnit());
+ * }
+ *
+ * <h4>Axis order, units and direction</h4>
+ * By default, the target axes of a parameterized transform are normalized to <var>east</var>,
+ * <var>north</var>, <var>up</var> (if applicable) directions with units in degrees and meters.
+ * If this requirement is ambiguous, for example because the operation method uses incompatible
+ * axis directions or units, then the {@code cs} argument should be non-null for allowing the
+ * implementation to resolve that ambiguity.
+ *
+ * @param cs the coordinate system defining target axis order and units, or {@code null} if none.
+ * @param ellipsoid the ellipsoid providing target semi-axis lengths, or {@code null} if none.
+ */
+ public void setTargetAxes(CoordinateSystem cs, Ellipsoid ellipsoid) {
+ }
+
+ /**
+ * Creates the parameterized transform. The operation method is given by {@link #getMethod()}
+ * and the parameter values should have been set on the group returned by {@link #parameters()}
+ * before to invoke this constructor.
+ * Example:
+ *
+ * {@snippet lang="java" :
+ * MathTransformFactory factory = ...;
+ * MathTransformBuilder builder = factory.builder("Transverse_Mercator");
+ * ParameterValueGroup pg = builder.parameters();
+ * pg.parameter("semi_major").setValue(6378137.000);
+ * pg.parameter("semi_minor").setValue(6356752.314);
+ * MathTransform mt = builder.create();
+ * }
+ *
+ * @return the parameterized transform.
+ * @throws FactoryException if the transform creation failed.
+ * This exception is thrown if some required parameters have not been supplied, or have illegal values.
+ */
+ public abstract MathTransform create() throws FactoryException;
+
+ /**
* Eventually replaces the given transform by a unique instance. The replacement is done
* only if the {@linkplain #factory} is an instance of {@link DefaultMathTransformFactory}
* and {@linkplain DefaultMathTransformFactory#caching(boolean) caching} is enabled.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
index 26b85b0..0564d0c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
@@ -43,8 +43,8 @@
import org.apache.sis.util.Static;
import org.apache.sis.util.privy.DoubleDouble;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -297,8 +297,6 @@
* @throws IllegalArgumentException if {@code preimage} is non-null and the sequence of values is not monotonic.
* @return the <i>y=f(x)</i> function.
*
- * @see org.opengis.coverage.InterpolationMethod
- *
* @since 0.7
*/
public static MathTransform1D interpolate(final double[] preimage, final double[] values) {
@@ -737,7 +735,7 @@
final int tgtDim = toApproximate.getTargetDimensions();
double[] coordinates = new double[Math.max(tgtDim, srcDim + 1)];
for (int i=0; i<srcDim; i++) {
- coordinates[i] = tangentPoint.getCoordinate(i);
+ coordinates[i] = tangentPoint.getOrdinate(i);
}
final Matrix derivative = derivativeAndTransform(toApproximate, coordinates, 0, coordinates, 0);
final MatrixSIS m = Matrices.createAffine(derivative, new DirectPositionView.Double(coordinates, 0, tgtDim));
@@ -748,7 +746,7 @@
*/
coordinates = ArraysExt.resize(coordinates, srcDim + 1);
for (int i=0; i<srcDim; i++) {
- coordinates[i] = -tangentPoint.getCoordinate(i);
+ coordinates[i] = -tangentPoint.getOrdinate(i);
}
coordinates[srcDim] = 1;
m.translate(coordinates);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/OnewayLinearTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/OnewayLinearTransform.java
index 3a72184..08e43d6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/OnewayLinearTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/OnewayLinearTransform.java
@@ -24,10 +24,6 @@
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-
/**
* A transform which is linear in the forward direction, but non-linear in the inverse direction.
@@ -191,24 +187,4 @@
public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException {
delegate.transform(srcPts, srcOff, dstPts, dstOff, numPts);
}
-
- @Override
- public int transform(DoubleBuffer source, DoubleBuffer target) throws TransformException {
- return delegate.transform(source, target);
- }
-
- @Override
- public int transform(FloatBuffer source, FloatBuffer target) throws TransformException {
- return delegate.transform(source, target);
- }
-
- @Override
- public int transform(FloatBuffer source, DoubleBuffer target) throws TransformException {
- return delegate.transform(source, target);
- }
-
- @Override
- public int transform(DoubleBuffer source, FloatBuffer target) throws TransformException {
- return delegate.transform(source, target);
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
index 1a46d3b..85a909a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
@@ -42,8 +42,8 @@
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -260,9 +260,8 @@
final int subDim = subTransform.getSourceDimensions();
final int actual = modifiedCoordinates.cardinality();
if (actual != subDim) {
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3,
- "modifiedCoordinates", subDim, actual));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3,
+ "modifiedCoordinates", subDim, actual));
}
final var sep = new TransformSeparator(subTransform, factory);
MathTransform result = MathTransforms.identity(resultDim);
@@ -595,7 +594,7 @@
ArgumentChecks.ensureDimensionMatches("point", transDim + nSkipped, point);
final GeneralDirectPosition subPoint = new GeneralDirectPosition(transDim);
for (int i=0; i<transDim; i++) {
- subPoint.coordinates[i] = point.getCoordinate(i + firstAffectedCoordinate);
+ subPoint.coordinates[i] = point.getOrdinate(i + firstAffectedCoordinate);
}
return expand(MatrixSIS.castOrCopy(subTransform.derivative(subPoint)),
firstAffectedCoordinate, numTrailingCoordinates, 0);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
index 79940a6..998c0ed 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
@@ -615,7 +615,7 @@
for (int i=0; i<srcDim; i++) {
final double e = elt[mix++];
if (e != 0) { // For avoiding NullPointerException if affine.
- w += point.getCoordinate(i) * e;
+ w += point.getOrdinate(i) * e;
}
}
/*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
index 6472b6f..28cefb5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
@@ -561,7 +561,7 @@
*/
@Override
public final DirectPosition transform(final DirectPosition ptSrc, DirectPosition ptDst) throws TransformException {
- final double[] source = ptSrc.getCoordinates(); // Needs to be first in case ptDst overwrites ptSrc.
+ final double[] source = ptSrc.getCoordinate(); // Needs to be first in case ptDst overwrites ptSrc.
ptDst = global.transform(ptSrc, ptDst);
final SubArea domain = forward.locate(ptDst);
if (domain != null) {
@@ -576,7 +576,7 @@
*/
@Override
public final Matrix derivative(final DirectPosition point) throws TransformException {
- return transform(point.getCoordinates(), 0, null, 0, true);
+ return transform(point.getCoordinate(), 0, null, 0, true);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AffineTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AffineTransform2D.java
index 5610890..7aafb68 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AffineTransform2D.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AffineTransform2D.java
@@ -277,14 +277,14 @@
}
} else {
if (ptDst == null) {
- final var point = new DirectPosition2D(ptSrc.getCoordinate(0), ptSrc.getCoordinate(1));
+ final var point = new DirectPosition2D(ptSrc.getOrdinate(0), ptSrc.getOrdinate(1));
super.transform(point, point);
return point;
}
ArgumentChecks.ensureDimensionMatches("ptDst", DIMENSION, ptDst);
if (ptDst instanceof Point2D) {
final var point = (Point2D) ptDst;
- point.setLocation(ptSrc.getCoordinate(0), ptSrc.getCoordinate(1));
+ point.setLocation(ptSrc.getOrdinate(0), ptSrc.getOrdinate(1));
super.transform(point, point);
return ptDst;
}
@@ -292,10 +292,10 @@
/*
* At this point, we have no choice to create a temporary Point2D.
*/
- final var point = new Point2D.Double(ptSrc.getCoordinate(0), ptSrc.getCoordinate(1));
+ final var point = new Point2D.Double(ptSrc.getOrdinate(0), ptSrc.getOrdinate(1));
super.transform(point, point);
- ptDst.setCoordinate(0, point.x);
- ptDst.setCoordinate(1, point.y);
+ ptDst.setOrdinate(0, point.x);
+ ptDst.setOrdinate(1, point.y);
return ptDst;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
index b68cbed..bd8d066 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
@@ -34,6 +34,12 @@
import org.apache.sis.measure.Units;
import static org.apache.sis.util.CharSequences.*;
+// Specific to the main branch:
+import java.util.HashMap;
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19111;
+
/**
* Utilities methods related to {@link AxisDirection}.
@@ -65,12 +71,102 @@
*
* @see #isUserDefined(AxisDirection)
*/
- private static final int LAST_ORDINAL = UNSPECIFIED.ordinal();
+ private static final int LAST_ORDINAL = DISPLAY_DOWN.ordinal();
+
+ /**
+ * Forward direction.
+ * For an observer at the centre of the object this is will be towards its front, bow or nose.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="forward", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection FORWARD = AxisDirection.valueOf("FORWARD");
+
+ /**
+ * Starboard direction.
+ * For an observer at the centre of the object this will be towards its right.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="starboard", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection STARBOARD = AxisDirection.valueOf("STARBOARD");
+
+ /**
+ * Port direction.
+ * For an observer at the centre of the object this will be towards its left.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="port", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection PORT = AxisDirection.valueOf("PORT");
+
+ /**
+ * Direction of geographic angles (bearing).
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="clockwise", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection CLOCKWISE = AxisDirection.valueOf("CLOCKWISE");
+
+ /**
+ * Direction of arithmetic angles. Used in polar coordinate systems.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="counterClockwise", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection COUNTER_CLOCKWISE = AxisDirection.valueOf("COUNTER_CLOCKWISE");
+
+ /**
+ * Distance from the origin in a polar coordinate system.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="awayFrom", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection AWAY_FROM = AxisDirection.valueOf("AWAY_FROM");
+
+ /**
+ * Distance toward the origin.
+ * Added in ISO 19111:2019 (was not in ISO 19111:2007).
+ */
+ @UML(identifier="towards", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection TOWARDS = AxisDirection.valueOf("TOWARDS");
+
+ /**
+ * Axis positive direction is unspecified.
+ */
+ @UML(identifier="unspecified", obligation=CONDITIONAL, specification=ISO_19111)
+ public static final AxisDirection UNSPECIFIED = AxisDirection.valueOf("UNSPECIFIED");
+
+ /**
+ * For each direction, the opposite direction.
+ * This map shall be immutable after construction.
+ */
+ private static final Map<AxisDirection,AxisDirection> OPPOSITES = new HashMap<>(24);
+ static {
+ put(UNSPECIFIED, UNSPECIFIED);
+ put(NORTH, SOUTH);
+ put(NORTH_NORTH_EAST, SOUTH_SOUTH_WEST);
+ put(NORTH_EAST, SOUTH_WEST);
+ put(EAST_NORTH_EAST, WEST_SOUTH_WEST);
+ put(EAST, WEST);
+ put(EAST_SOUTH_EAST, WEST_NORTH_WEST);
+ put(SOUTH_EAST, NORTH_WEST);
+ put(SOUTH_SOUTH_EAST, NORTH_NORTH_WEST);
+ put(UP, DOWN);
+ put(FUTURE, PAST);
+ put(COLUMN_POSITIVE, COLUMN_NEGATIVE);
+ put(ROW_POSITIVE, ROW_NEGATIVE);
+ put(DISPLAY_RIGHT, DISPLAY_LEFT);
+ put(DISPLAY_UP, DISPLAY_DOWN);
+ put(COUNTER_CLOCKWISE, CLOCKWISE);
+ put(AWAY_FROM, TOWARDS);
+ }
+
+ /**
+ * Stores the given directions in the {@link #OPPOSITES} array.
+ */
+ private static void put(final AxisDirection dir, final AxisDirection opposite) {
+ OPPOSITES.put(dir, opposite);
+ OPPOSITES.put(opposite, dir);
+ }
/**
* Proposed abbreviations for some axis directions.
*/
- @SuppressWarnings("deprecation")
private static final Map<AxisDirection,String> ABBREVIATIONS = Map.of(
FUTURE, "t",
COLUMN_POSITIVE, "i",
@@ -140,7 +236,7 @@
* @return the opposite direction, or {@code null} if none or unknown.
*/
public static AxisDirection opposite(AxisDirection dir) {
- return (dir != null) ? dir.opposite().orElse(null) : null;
+ return OPPOSITES.get(dir);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java
index 89a68ce..7ff1df4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java
@@ -57,6 +57,12 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.crs.GeneralDerivedCRS;
+// Specific to the main branch:
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.MathTransform;
+import org.apache.sis.referencing.operation.transform.MathTransformBuilder;
+import org.apache.sis.referencing.internal.ParameterizedTransformBuilder;
+
/**
* Utility methods related to coordinate operations.
@@ -269,6 +275,33 @@
}
/**
+ * Returns the transform builder for the specified method name, using user-overrideable method if possible.
+ * If the given factory is an instance of {@link DefaultMathTransformFactory}, then this method delegates to it.
+ *
+ * @param mtFactory the factory to use for a builder.
+ * @param method the name of the operation method to fetch.
+ * @return the transform builder for the operation method of the given name.
+ * @throws NoSuchIdentifierException if the requested operation method cannot be found.
+ */
+ public static MathTransformBuilder builder(final MathTransformFactory mtFactory, final String method)
+ throws NoSuchIdentifierException
+ {
+ if (mtFactory instanceof DefaultMathTransformFactory) {
+ return ((DefaultMathTransformFactory) mtFactory).builder(method);
+ } else {
+ final var m = findMethod(mtFactory.getAvailableMethods(SingleOperation.class), method);
+ return new ParameterizedTransformBuilder(mtFactory, m) {
+ @Override public MathTransform create() throws FactoryException {
+ if (sourceCS == null && targetCS == null && sourceEllipsoid == null && targetEllipsoid == null) {
+ return swapAndScaleAxes(factory.createParameterizedTransform(parameters()));
+ }
+ return super.create();
+ }
+ };
+ }
+ }
+
+ /**
* Returns {@code true} if the given transform factory is the default instances used by Apache SIS.
*
* @param mtFactory the factory to test. May be null.
@@ -336,7 +369,6 @@
* @param target the target of the coordinate operation.
* @return target dimensions where "wrap around" may happen, or an empty set if none.
*/
- @SuppressWarnings("deprecation")
public static Set<Integer> wrapAroundChanges(CoordinateReferenceSystem source, final CoordinateSystem target) {
long changes = changes(source.getCoordinateSystem(), target);
while (source instanceof GeneralDerivedCRS) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java
index ae75b10..801897b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java
@@ -309,7 +309,6 @@
* The returned value is one of {@link #METHOD}, {@link #CONVERSION}, {@link #CS}, {@link #PRIME_MERIDIAN},
* {@link #ELLIPSOID}, {@link #DATUM} or {@link #OTHER} constants.
*/
- @SuppressWarnings("deprecation")
private static int diffCode(final Iterator<SingleCRS> authoritative, final Iterator<SingleCRS> given) {
while (authoritative.hasNext() && given.hasNext()) {
final SingleCRS crsA = authoritative.next();
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java
index d4e81e9..b851a18 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java
@@ -40,9 +40,6 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ArraysExt;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* A class in charges of combining two-dimensional geographic or projected CRS with an ellipsoidal height into a
@@ -147,7 +144,7 @@
final var geod = (GeodeticCRS) crs;
final EllipsoidalCS cs3D;
cs3D = factories.getCSFactory() .createEllipsoidalCS(csProps, axes[0], axes[1], axes[2]);
- crs = factories.getCRSFactory().createGeographicCRS(crsProps, geod.getDatum(), geod.getDatumEnsemble(), cs3D);
+ crs = factories.getCRSFactory().createGeographicCRS(crsProps, DatumOrEnsemble.asDatum(geod), cs3D);
} else {
final ProjectedCRS proj = (ProjectedCRS) crs;
GeographicCRS base = proj.getBaseCRS();
@@ -224,13 +221,11 @@
ArgumentChecks.ensureNonNullElement("components", i, crs);
if (i != 0) name.append(" + ");
name.append(crs.getName().getCode());
- for (ObjectDomain obj : crs.getDomains()) {
- domain = Extents.intersection(domain, obj.getDomainOfValidity());
- }
+ domain = Extents.intersection(domain, crs.getDomainOfValidity());
}
final var properties = new HashMap<String,Object>(4);
properties.put(CoordinateReferenceSystem.NAME_KEY, name.toString());
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, domain);
+ properties.put(CoordinateReferenceSystem.DOMAIN_OF_VALIDITY_KEY, domain);
return properties;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ExtendedPrecisionMatrix.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ExtendedPrecisionMatrix.java
index a353489..07f7c25 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ExtendedPrecisionMatrix.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ExtendedPrecisionMatrix.java
@@ -78,6 +78,7 @@
@Override public int getNumCol() {return m.getNumCol();}
@Override public String toString() {return m.toString();}
@Override public Matrix clone() {return m.clone();}
+ @Override public boolean isIdentity() {return m.isIdentity();}
};
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/Formulas.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/Formulas.java
index a1fb1be..d11d380 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/Formulas.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/Formulas.java
@@ -99,7 +99,7 @@
* but come at a high cost on older machines without hardware support.
*/
@Configuration
- public static final boolean USE_FMA = true;
+ public static final boolean USE_FMA = false;
/**
* Do not allow instantiation of this class.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java
index df58dc1..f67dfd1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java
@@ -61,10 +61,10 @@
import org.apache.sis.referencing.internal.Resources;
import org.apache.sis.parameter.Parameters;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.referencing.datum.DatumEnsemble;
-import org.opengis.referencing.operation.MathTransform;
+// Specific to the main branch:
+import org.apache.sis.temporal.TemporalDate;
+import org.apache.sis.referencing.datum.DatumOrEnsemble;
+import org.apache.sis.referencing.operation.transform.MathTransformBuilder;
/**
@@ -87,13 +87,6 @@
private GeodeticDatum datum;
/**
- * The datum ensemble, or {@code null} if none.
- *
- * @see #getDatumOrEnsemble()
- */
- private DatumEnsemble<GeodeticDatum> ensemble;
-
- /**
* The name of the conversion to use for creating a {@code ProjectedCRS} or {@code DerivedCRS}.
* This name is for information purpose; its value does not impact the numerical results of coordinate operations.
*
@@ -197,7 +190,7 @@
}
if (description != null || bbox != null) {
final DefaultExtent extent = new DefaultExtent(description, bbox, null, null);
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, extent);
+ properties.put(CoordinateReferenceSystem.DOMAIN_OF_VALIDITY_KEY, extent);
}
return this;
}
@@ -270,7 +263,7 @@
* @return {@code this}, for method calls chaining.
* @throws FactoryException if the operation method cannot be obtained.
*/
- public GeodeticObjectBuilder setConversion(final MathTransform.Builder builder) throws FactoryException {
+ public GeodeticObjectBuilder setConversion(final MathTransformBuilder builder) throws FactoryException {
method = builder.getMethod().orElseThrow(() -> new FactoryException());
parameters = builder.parameters(); // Set only if above line succeed.
return this;
@@ -367,8 +360,7 @@
conversionName = c.getName().getCode();
method = c.getMethod();
parameters = c.getParameterValues();
- datum = crs.getDatum();
- ensemble = crs.getDatumEnsemble();
+ datum = DatumOrEnsemble.asDatum(crs.getBaseCRS());
properties.putAll(IdentifiedObjects.getProperties(crs, ProjectedCRS.IDENTIFIERS_KEY));
return this;
}
@@ -519,7 +511,7 @@
GeographicCRS crs = getBaseCRS();
final IdentifiedObject id = getDatumOrEnsemble();
if (id != null) {
- crs = factories.getCRSFactory().createGeographicCRS(name(id), datum, ensemble, crs.getCoordinateSystem());
+ crs = factories.getCRSFactory().createGeographicCRS(name(id), datum, crs.getCoordinateSystem());
}
return createProjectedCRS(crs, factories.getStandardProjectedCS());
}
@@ -529,7 +521,7 @@
* Both of them may be {@code null}.
*/
private IdentifiedObject getDatumOrEnsemble() {
- return (datum != null) ? datum : ensemble;
+ return datum; // There is more code in the GeoAPI 3.1/4.0 branches.
}
/**
@@ -553,7 +545,7 @@
if (id != null) {
properties.putIfAbsent(GeographicCRS.NAME_KEY, id.getName());
}
- return factories.getCRSFactory().createGeographicCRS(properties, datum, ensemble, crs.getCoordinateSystem());
+ return factories.getCRSFactory().createGeographicCRS(properties, datum, crs.getCoordinateSystem());
}
/**
@@ -609,7 +601,7 @@
if (td == null) {
final Object remarks = properties.remove(TemporalCRS.REMARKS_KEY);
final Object identifier = properties.remove(TemporalCRS.IDENTIFIERS_KEY);
- td = factories.getDatumFactory().createTemporalDatum(properties, origin);
+ td = factories.getDatumFactory().createTemporalDatum(properties, TemporalDate.toDate(origin));
properties.put(TemporalCRS.IDENTIFIERS_KEY, identifier);
properties.put(TemporalCRS.REMARKS_KEY, remarks);
properties.put(TemporalCRS.NAME_KEY, td.getName()); // Share the Identifier instance.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/IntervalRectangle.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/IntervalRectangle.java
index 6145a60..f1693ab 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/IntervalRectangle.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/IntervalRectangle.java
@@ -117,10 +117,10 @@
* @see Envelope#getUpperCorner()
*/
public IntervalRectangle(final DirectPosition lower, final DirectPosition upper) {
- xmin = lower.getCoordinate(0);
- xmax = upper.getCoordinate(0);
- ymin = lower.getCoordinate(1);
- ymax = upper.getCoordinate(1);
+ xmin = lower.getOrdinate(0);
+ xmax = upper.getOrdinate(0);
+ ymin = lower.getOrdinate(1);
+ ymax = upper.getOrdinate(1);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java
index b048979..0c3a931 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java
@@ -26,6 +26,13 @@
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.util.InternationalString;
+// Specific to the main branch:
+import java.util.Set;
+import java.util.Collection;
+import org.opengis.util.GenericName;
+import org.opengis.metadata.extent.Extent;
+import org.apache.sis.io.wkt.UnformattableObjectException;
+
/**
* A referencing object for which every methods return {@code null} or a neutral value.
@@ -83,4 +90,20 @@
public InternationalString getScope() {
return null;
}
+
+ @Override public Collection<GenericName> getAlias() {return null;}
+ @Override public Set<ReferenceIdentifier> getIdentifiers() {return null;}
+ @Override public InternationalString getRemarks() {return null;}
+ @Override public Extent getDomainOfValidity() {return null;}
+
+ /**
+ * Throws the exception in all cases.
+ *
+ * @return never return.
+ * @throws UnformattableObjectException always thrown.
+ */
+ @Override
+ public String toWKT() throws UnformattableObjectException {
+ throw new UnformattableObjectException();
+ }
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingFactoryContainer.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingFactoryContainer.java
index effa230..12a8fe2 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingFactoryContainer.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingFactoryContainer.java
@@ -43,8 +43,8 @@
import org.apache.sis.util.iso.DefaultNameFactory;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.Factory;
+// Specific to the main branch:
+import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
/**
@@ -127,7 +127,7 @@
* Factory for fetching operation methods and creating defining conversions.
* This is needed only for user-defined projected coordinate reference system.
*/
- private CoordinateOperationFactory operationFactory;
+ private DefaultCoordinateOperationFactory operationFactory;
/**
* The {@linkplain org.opengis.referencing.operation.MathTransform math transform} factory.
@@ -160,7 +160,7 @@
datumFactory = (DatumFactory) properties.get(DATUM_FACTORY);
csFactory = (CSFactory) properties.get(CS_FACTORY);
crsFactory = (CRSFactory) properties.get(CRS_FACTORY);
- operationFactory = (CoordinateOperationFactory) properties.get(OPERATION_FACTORY);
+ operationFactory = (DefaultCoordinateOperationFactory) properties.get(OPERATION_FACTORY);
mtFactory = (MathTransformFactory) properties.get(MT_FACTORY);
}
@@ -186,7 +186,7 @@
this.crsFactory = crsFactory;
this.csFactory = csFactory;
this.datumFactory = datumFactory;
- this.operationFactory = operationFactory;
+ this.operationFactory = (DefaultCoordinateOperationFactory) operationFactory; // Because of GeoAPI 3.0 limitation.
this.mtFactory = mtFactory;
}
@@ -212,12 +212,12 @@
* @return {@code true} if the factory changed as a result of this method call.
* @throws IllegalArgumentException if the {@code type} argument is not one of the valid values.
*/
- public final <T extends Factory> boolean setFactory(final Class<T> type, final T factory) {
+ public final <T> boolean setFactory(final Class<T> type, final T factory) {
if (type == NameFactory.class) return nameFactory != (nameFactory = (NameFactory) factory);
if (type == DatumFactory.class) return datumFactory != (datumFactory = (DatumFactory) factory);
if (type == CSFactory.class) return csFactory != (csFactory = (CSFactory) factory);
if (type == CRSFactory.class) return crsFactory != (crsFactory = (CRSFactory) factory);
- if (type == CoordinateOperationFactory.class) return operationFactory != (operationFactory = (CoordinateOperationFactory) factory);
+ if (type == CoordinateOperationFactory.class) return operationFactory != (operationFactory = (DefaultCoordinateOperationFactory) factory);
if (type == MathTransformFactory.class) return mtFactory != (mtFactory = (MathTransformFactory) factory);
throw new IllegalArgumentException(Errors.forLocale(getLocale()).getString(Errors.Keys.IllegalArgumentValue_2, "type", type));
}
@@ -243,8 +243,8 @@
* @return the factory for the given type.
* @throws IllegalArgumentException if the {@code type} argument is not one of the valid values.
*/
- public final <T extends Factory> T getFactory(final Class<T> type) {
- final Factory f;
+ public final <T> T getFactory(final Class<T> type) {
+ final Object f;
if (type == NameFactory.class) f = getNameFactory();
else if (type == DatumFactory.class) f = getDatumFactory();
else if (type == CSFactory.class) f = getCSFactory();
@@ -313,10 +313,15 @@
*
* @return the Coordinate Operation factory (never {@code null}).
*/
- public final CoordinateOperationFactory getCoordinateOperationFactory() {
+ public final DefaultCoordinateOperationFactory getCoordinateOperationFactory() {
if (operationFactory == null) {
- operationFactory = CoordinateOperations.getCoordinateOperationFactory(defaultProperties, mtFactory, crsFactory, csFactory);
+ CoordinateOperationFactory op = CoordinateOperations.getCoordinateOperationFactory(defaultProperties, mtFactory, crsFactory, csFactory);
defaultProperties = null; // Not needed anymore.
+ if (op instanceof DefaultCoordinateOperationFactory) {
+ operationFactory = (DefaultCoordinateOperationFactory) op;
+ } else {
+ operationFactory = DefaultCoordinateOperationFactory.provider();
+ }
}
return operationFactory;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java
index 659a3af..0815726 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java
@@ -51,6 +51,14 @@
import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+// Specific to the main branch:
+import java.util.Collection;
+import java.util.NoSuchElementException;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.pending.geoapi.referencing.MissingMethods;
+import org.apache.sis.metadata.privy.Identifiers;
+import org.apache.sis.xml.NilObject;
+
/**
* A set of static methods working on GeoAPI referencing objects.
@@ -202,6 +210,51 @@
}
/**
+ * Copies all {@link SingleCRS} components from the given source to the given collection.
+ * For each {@link CompoundCRS} element found in the iteration, this method replaces the
+ * {@code CompoundCRS} by its {@linkplain CompoundCRS#getComponents() components}, which
+ * may themselves have other {@code CompoundCRS}. Those replacements are performed recursively
+ * until we obtain a flat view of CRS components.
+ *
+ * @param source the collection of single or compound CRS.
+ * @param addTo where to add the single CRS in order to obtain a flat view of {@code source}.
+ * @return {@code true} if this method found only single CRS in {@code source}, in which case {@code addTo}
+ * got the same content (assuming that {@code addTo} was empty prior this method call).
+ * @throws NoSuchElementException if a CRS component is missing.
+ * @throws ClassCastException if a CRS is neither a {@link SingleCRS} or a {@link CompoundCRS}.
+ *
+ * @see org.apache.sis.referencing.CRS#getSingleComponents(CoordinateReferenceSystem)
+ */
+ public static boolean getSingleComponents(final Iterable<? extends CoordinateReferenceSystem> source,
+ final Collection<? super SingleCRS> addTo) throws ClassCastException
+ {
+ boolean sameContent = true;
+ for (final CoordinateReferenceSystem candidate : source) {
+ if (candidate instanceof CompoundCRS) {
+ getSingleComponents(((CompoundCRS) candidate).getComponents(), addTo);
+ sameContent = false;
+ } else if (candidate instanceof SingleCRS) {
+ addTo.add((SingleCRS) candidate);
+ } else {
+ /*
+ * Illegal class. Try to provide a better error message, in particular when the CRS component
+ * is nil because it is an unresolved xlink in a GML document. Nil objects are proxies, which
+ * have hard to understand class names.
+ */
+ final String message;
+ if (candidate instanceof NilObject) {
+ message = Errors.format(Errors.Keys.NilObject_1, Identifiers.getNilReason((NilObject) candidate));
+ throw new NoSuchElementException(message);
+ } else {
+ message = Errors.format(Errors.Keys.NestedElementNotAllowed_1, getInterface(candidate));
+ throw new ClassCastException(message);
+ }
+ }
+ }
+ return sameContent;
+ }
+
+ /**
* Returns {@code true} if the type of the given datum is ellipsoidal. A vertical datum is not allowed
* to be ellipsoidal according ISO 19111, but Apache SIS relaxes this restriction in some limited cases,
* for example when parsing a string in the legacy WKT 1 format. Apache SIS should not expose those
@@ -215,7 +268,7 @@
*/
public static boolean isEllipsoidalHeight(final VerticalDatum datum) {
if (datum != null) {
- return datum.getRealizationMethod().map(VerticalDatumTypes::ellipsoidal).orElse(false);
+ return VerticalDatumTypes.ellipsoidal(datum.getVerticalDatumType());
}
return false;
}
@@ -232,7 +285,6 @@
* @param allow3D whether this method is allowed to return three-dimensional CRS (with ellipsoidal height).
* @return a two-dimensional geographic CRS with standard axes, or {@code null} if none.
*/
- @SuppressWarnings("deprecation")
public static GeographicCRS toNormalizedGeographicCRS(CoordinateReferenceSystem crs, final boolean latlon, final boolean allow3D) {
/*
* ProjectedCRS instances always have a GeographicCRS as their base.
@@ -277,7 +329,7 @@
final var source = (GeodeticCRS) crs;
return new DefaultGeographicCRS(
Map.of(DefaultGeographicCRS.NAME_KEY, NilReferencingObject.UNNAMED),
- source.getDatum(), source.getDatumEnsemble(), normalizedCS);
+ source.getDatum(), MissingMethods.getDatumEnsemble(source), normalizedCS);
}
if (crs instanceof CompoundCRS) {
for (final CoordinateReferenceSystem e : ((CompoundCRS) crs).getComponents()) {
@@ -316,7 +368,7 @@
*/
public static Map<String,?> getPropertiesWithoutIdentifiers(final IdentifiedObject object, final Map<String,?> overwrite) {
final Map<String,?> properties = IdentifiedObjects.getProperties(object, IdentifiedObject.IDENTIFIERS_KEY);
- final Identifier name = object.getName();
+ final ReferenceIdentifier name = object.getName();
final boolean keepName = name.getCodeSpace() == null && name.getAuthority() == null;
if (keepName && overwrite == null) {
return properties;
@@ -484,7 +536,7 @@
*/
public static ParameterDescriptorGroup rename(final ParameterDescriptorGroup parameters, final String code) {
if (parameters != null) {
- Identifier name = parameters.getName();
+ ReferenceIdentifier name = parameters.getName();
if (!code.equals(name.getCode())) {
name = new ImmutableIdentifier(name.getAuthority(), name.getCodeSpace(), code);
return new DefaultParameterDescriptorGroup(Map.of(ParameterDescriptorGroup.NAME_KEY, name), parameters);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java
index 5e5f127..2026d1b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java
@@ -279,7 +279,7 @@
addType(org.opengis.referencing.cs.CoordinateSystemAxis.class, Axis);
addType(org.apache.sis.referencing.datum.BursaWolfParameters.class, ToWGS84);
addType(org.opengis.referencing.operation.MathTransform.class, Param_MT, Concat_MT, Inverse_MT, PassThrough_MT);
- addType(org.opengis.coordinate.CoordinateMetadata.class, CoordinateMetadata);
+ addType(org.apache.sis.coordinate.DefaultCoordinateMetadata.class, CoordinateMetadata);
addType(org.opengis.geometry.DirectPosition.class, Point);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTUtilities.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTUtilities.java
index ae07909..21ce4b1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTUtilities.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTUtilities.java
@@ -63,8 +63,8 @@
import org.apache.sis.math.Statistics;
import org.apache.sis.math.Vector;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -343,7 +343,7 @@
*/
public static boolean isEPSG(final GeneralParameterDescriptor descriptor, final boolean ifUndefined) {
if (descriptor != null) {
- final Identifier id = descriptor.getName();
+ final ReferenceIdentifier id = descriptor.getName();
if (id != null) {
final String cs = id.getCodeSpace();
if (cs != null) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WraparoundApplicator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WraparoundApplicator.java
index c6d85d5..cdd40ea 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WraparoundApplicator.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WraparoundApplicator.java
@@ -144,7 +144,7 @@
final CoordinateSystemAxis axis = targetCS.getAxis(wraparoundDimension);
m = (axis.getMinimumValue() + axis.getMaximumValue()) / 2;
} else {
- m = targetMedian.getCoordinate(wraparoundDimension);
+ m = targetMedian.getOrdinate(wraparoundDimension);
}
if (!Double.isFinite(m)) {
if (targetMedian != null) {
@@ -158,7 +158,7 @@
*/
m = 0;
}
- sm = (sourceMedian != null) ? sourceMedian.getCoordinate(wraparoundDimension) : Double.NaN;
+ sm = (sourceMedian != null) ? sourceMedian.getOrdinate(wraparoundDimension) : Double.NaN;
} catch (BackingStoreException e) {
// Some `DirectPosition` implementations compute coordinates only when first needed.
throw e.unwrapOrRethrow(TransformException.class);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_GeneralOperationParameter.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_GeneralOperationParameter.java
index 9a08fba..2f4ccb9 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_GeneralOperationParameter.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_GeneralOperationParameter.java
@@ -479,8 +479,8 @@
private static NamedIdentifier toNamedIdentifier(final Object name) {
if (name == null || name.getClass() == NamedIdentifier.class) {
return (NamedIdentifier) name;
- } else if (name instanceof Identifier) {
- return new NamedIdentifier((Identifier) name);
+ } else if (name instanceof ReferenceIdentifier) {
+ return new NamedIdentifier((ReferenceIdentifier) name);
} else {
return new NamedIdentifier((GenericName) name);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_ParametricDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_ParametricDatum.java
index 036cdc1..74eb82f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_ParametricDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_ParametricDatum.java
@@ -20,9 +20,6 @@
import org.apache.sis.xml.bind.gco.PropertyType;
import org.apache.sis.referencing.datum.DefaultParametricDatum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.ParametricDatum;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -31,7 +28,7 @@
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class CD_ParametricDatum extends PropertyType<CD_ParametricDatum, ParametricDatum> {
+public final class CD_ParametricDatum extends PropertyType<CD_ParametricDatum, DefaultParametricDatum> {
/**
* Empty constructor for JAXB only.
*/
@@ -46,14 +43,14 @@
* @return {@code ParametricDatum.class}
*/
@Override
- protected Class<ParametricDatum> getBoundType() {
- return ParametricDatum.class;
+ protected Class<DefaultParametricDatum> getBoundType() {
+ return DefaultParametricDatum.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private CD_ParametricDatum(final ParametricDatum datum) {
+ private CD_ParametricDatum(final DefaultParametricDatum datum) {
super(datum);
}
@@ -65,7 +62,7 @@
* @return a {@code PropertyType} wrapping the given the element.
*/
@Override
- protected CD_ParametricDatum wrap(final ParametricDatum datum) {
+ protected CD_ParametricDatum wrap(final DefaultParametricDatum datum) {
return new CD_ParametricDatum(datum);
}
@@ -78,7 +75,7 @@
*/
@XmlElement(name = "ParametricDatum")
public DefaultParametricDatum getElement() {
- return DefaultParametricDatum.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java
index a6eeffe..619e4f5 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java
@@ -25,7 +25,6 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-@SuppressWarnings("deprecation")
public final class CD_VerticalDatumType extends CodeListAdapter<VerticalDatumType> {
/**
* Empty constructor for JAXB only.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_ParametricCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_ParametricCS.java
index 201b786..3f43cfd 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_ParametricCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_ParametricCS.java
@@ -20,9 +20,6 @@
import org.apache.sis.referencing.cs.DefaultParametricCS;
import org.apache.sis.xml.bind.gco.PropertyType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.cs.ParametricCS;
-
/**
* JAXB adapter mapping implementing class to the GeoAPI interface. See
@@ -30,7 +27,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class CS_ParametricCS extends PropertyType<CS_ParametricCS, ParametricCS> {
+public final class CS_ParametricCS extends PropertyType<CS_ParametricCS, DefaultParametricCS> {
/**
* Empty constructor for JAXB only.
*/
@@ -45,14 +42,14 @@
* @return {@code ParametricCS.class}
*/
@Override
- protected Class<ParametricCS> getBoundType() {
- return ParametricCS.class;
+ protected Class<DefaultParametricCS> getBoundType() {
+ return DefaultParametricCS.class;
}
/**
* Constructor for the {@link #wrap} method only.
*/
- private CS_ParametricCS(final ParametricCS cs) {
+ private CS_ParametricCS(final DefaultParametricCS cs) {
super(cs);
}
@@ -64,7 +61,7 @@
* @return a {@code PropertyType} wrapping the given the element.
*/
@Override
- protected CS_ParametricCS wrap(final ParametricCS cs) {
+ protected CS_ParametricCS wrap(final DefaultParametricCS cs) {
return new CS_ParametricCS(cs);
}
@@ -77,7 +74,7 @@
*/
@XmlElement(name = "ParametricCS")
public DefaultParametricCS getElement() {
- return DefaultParametricCS.castOrCopy(metadata);
+ return metadata;
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java
index c1022ef..9312025 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java
@@ -30,7 +30,6 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-@SuppressWarnings("deprecation")
public final class CS_UserDefinedCS extends PropertyType<CS_UserDefinedCS, UserDefinedCS> {
/**
* Empty constructor for JAXB only.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/Code.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/Code.java
index f7cb318..eb9e21f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/Code.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/Code.java
@@ -73,7 +73,7 @@
*
* @param identifier the identifier from which to get the values.
*/
- Code(final Identifier identifier) {
+ Code(final ReferenceIdentifier identifier) {
code = identifier.getCode();
codeSpace = identifier.getCodeSpace();
String version = identifier.getVersion();
@@ -162,12 +162,12 @@
* @param identifiers the object identifiers, or {@code null} if none.
* @return the {@code <gml:identifier>} as a {@code Code} instance, or {@code null} if none.
*/
- public static Code forIdentifiedObject(final Class<?> type, final Iterable<? extends Identifier> identifiers) {
+ public static Code forIdentifiedObject(final Class<?> type, final Iterable<? extends ReferenceIdentifier> identifiers) {
if (identifiers != null) {
boolean isHTTP = false;
boolean isEPSG = false;
- Identifier fallback = null;
- for (final Identifier identifier : identifiers) {
+ ReferenceIdentifier fallback = null;
+ for (final ReferenceIdentifier identifier : identifiers) {
final String code = identifier.getCode();
if (code == null) continue; // Paranoiac check.
if (code.regionMatches(true, 0, "urn:", 0, 4)) {
@@ -229,10 +229,12 @@
if (authority != null) {
for (final Identifier id : authority.getIdentifiers()) {
if (Constants.EPSG.equalsIgnoreCase(id.getCode())) {
- final String cs = id.getCodeSpace();
- if (cs != null) {
- code.codeSpace = cs;
- break;
+ if (id instanceof ReferenceIdentifier) {
+ final String cs = ((ReferenceIdentifier) id).getCodeSpace();
+ if (cs != null) {
+ code.codeSpace = cs;
+ break;
+ }
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/RS_Identifier.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/RS_Identifier.java
index a9e8649..cd5e35c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/RS_Identifier.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/RS_Identifier.java
@@ -19,6 +19,9 @@
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* JAXB adapter mapping the GeoAPI {@link Identifier} to an implementation class that can be marshalled.
@@ -36,7 +39,7 @@
* <gml:identifier codeSpace="EPSG">4326</gml:identifier>
* }
*
- * If the {@code Identifier} to marshal contains a {@linkplain Identifier#getVersion() version},
+ * If the {@code Identifier} to marshal contains a {@linkplain ReferenceIdentifier#getVersion() version},
* then this adapter concatenates the version to the codespace in a "URI-like" way like below:
*
* {@snippet lang="xml" :
@@ -58,7 +61,7 @@
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class RS_Identifier extends XmlAdapter<Code, Identifier> {
+public final class RS_Identifier extends XmlAdapter<Code, ReferenceIdentifier> {
/**
* Empty constructor for JAXB.
*/
@@ -73,7 +76,7 @@
* @return an identifier which represents the value.
*/
@Override
- public Identifier unmarshal(final Code value) {
+ public ReferenceIdentifier unmarshal(final Code value) {
return (value != null) ? value.getIdentifier() : null;
}
@@ -85,7 +88,7 @@
* @return the adapter for the given metadata.
*/
@Override
- public Code marshal(final Identifier value) {
+ public Code marshal(final ReferenceIdentifier value) {
return (value != null) ? new Code(value) : null;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
index 5049ee0..9d278bf 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
@@ -30,6 +30,9 @@
import static org.apache.sis.referencing.Assertions.assertDisjoint;
import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
+
/**
* Tests the methods defined in the {@link AbstractEnvelope} class.
@@ -90,7 +93,7 @@
}
default: throw new IllegalArgumentException(String.valueOf(type));
}
- if (type != RECTANGLE) {
+ if (PENDING_NEXT_GEOAPI_RELEASE) {
validate(envelope);
}
return envelope;
@@ -195,9 +198,9 @@
assertEquals( 50, envelope.getMaximum (1), label);
assertEquals( 40, envelope.getMedian (1), label);
assertEquals( 20, envelope.getSpan (1), label);
- assertEquals( 12, lower .getCoordinate(0), label);
+ assertEquals( 12, lower .getOrdinate (0), label);
assertEquals(-180, envelope.getMinimum (0), label);
- assertEquals( -4, upper .getCoordinate(0), label);
+ assertEquals( -4, upper .getOrdinate (0), label);
assertEquals(+180, envelope.getMaximum (0), label);
assertEquals(-176, envelope.getMedian (0), label);
assertEquals( 344, envelope.getSpan (0), label); // 360° - testSimpleEnvelope()
@@ -256,9 +259,9 @@
assertEquals( 50, envelope.getMaximum (1), label);
assertEquals( 40, envelope.getMedian (1), label);
assertEquals( 20, envelope.getSpan (1), label);
- assertEquals( 12, lower .getCoordinate(0), label);
+ assertEquals( 12, lower .getOrdinate (0), label);
assertEquals(-180, envelope.getMinimum (0), label);
- assertEquals(-364, upper .getCoordinate(0), label);
+ assertEquals(-364, upper .getOrdinate (0), label);
assertEquals(+180, envelope.getMaximum (0), label);
assertEquals( 4, envelope.getMedian (0), label); // Note the alternance with the previous test methods.
assertEquals( NaN, envelope.getSpan (0), label); // testCrossingAntiMeridian() + 360°.
@@ -309,9 +312,9 @@
assertEquals( 50, envelope.getMaximum (1), label);
assertEquals( 40, envelope.getMedian (1), label);
assertEquals( 20, envelope.getSpan (1), label);
- assertEquals( 372, lower .getCoordinate(0), label);
+ assertEquals( 372, lower .getOrdinate (0), label);
assertEquals(-180, envelope.getMinimum (0), label);
- assertEquals(-364, upper .getCoordinate(0), label);
+ assertEquals(-364, upper .getOrdinate (0), label);
assertEquals(+180, envelope.getMaximum (0), label);
assertEquals(-176, envelope.getMedian (0), label); // Note the alternance with the previous test methods.
assertEquals( NaN, envelope.getSpan (0), label); // testCrossingAntiMeridianTwice() + 360°.
@@ -413,9 +416,9 @@
assertEquals( 50, envelope.getMaximum (1), label);
assertEquals( 40, envelope.getMedian (1), label);
assertEquals( 20, envelope.getSpan (1), label);
- assertEquals( 0.0, lower .getCoordinate(0), label);
+ assertEquals( 0.0, lower .getOrdinate (0), label);
assertEquals(-180, envelope.getMinimum (0), label);
- assertEquals(-0.0, upper .getCoordinate(0), label);
+ assertEquals(-0.0, upper .getOrdinate (0), label);
assertEquals(+180, envelope.getMaximum (0), label);
assertEquals( 180, envelope.getMedian (0), label);
assertEquals( 360, envelope.getSpan (0), label);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
index 373939f..cd0de51 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
@@ -56,7 +56,7 @@
*/
private static void assertPositionEquals(final DirectPosition expected, final DirectPosition actual) {
assertNotSame(expected, actual);
- assertArrayEquals(expected.getCoordinates(), actual.getCoordinates());
+ assertArrayEquals(expected.getCoordinate(), actual.getCoordinate());
}
/**
@@ -93,7 +93,7 @@
final var format = new CoordinateFormat(null, null);
final var charPos = new ParsePosition(0);
DirectPosition position = format.parse("23.78 -12.74 127.9 3.25", charPos);
- assertArrayEquals(new double[] {23.78, -12.74, 127.9, 3.25}, position.getCoordinates());
+ assertArrayEquals(new double[] {23.78, -12.74, 127.9, 3.25}, position.getCoordinate());
assertEquals(-1, charPos.getErrorIndex());
assertEquals(23, charPos.getIndex());
/*
@@ -102,7 +102,7 @@
*/
charPos.setIndex(0);
position = format.parse("4.64 10.25 -3.12", charPos);
- assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinates());
+ assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinate());
assertEquals(-1, charPos.getErrorIndex());
assertEquals(16, charPos.getIndex());
/*
@@ -113,7 +113,7 @@
assertEquals("; ", format.getSeparator());
charPos.setIndex(0);
position = format.parse("4.64;10.25 ; -3.12", charPos);
- assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinates());
+ assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinate());
assertEquals(-1, charPos.getErrorIndex());
assertEquals(19, charPos.getIndex());
}
@@ -157,9 +157,9 @@
final var format = new CoordinateFormat(Locale.US, null);
format.setDefaultCRS(HardCodedConversions.mercator());
DirectPosition pos = format.parse("100 m W 300 m N", new ParsePosition(0));
- assertArrayEquals(new double[] {-100, 300}, pos.getCoordinates());
+ assertArrayEquals(new double[] {-100, 300}, pos.getCoordinate());
pos = format.parse("200 m E 100 m S", new ParsePosition(0));
- assertArrayEquals(new double[] {200, -100}, pos.getCoordinates());
+ assertArrayEquals(new double[] {200, -100}, pos.getCoordinate());
}
/**
@@ -213,7 +213,7 @@
format.setDefaultCRS(HardCodedCRS.GEOID_4D);
final ParsePosition charPos = new ParsePosition(11);
final DirectPosition pos = format.parse("(to skip); 23°46,8′E 12°44,4′S 127,9 m 22-09-2006 07:00 (ignore)", charPos);
- assertArrayEquals(new double[] {23.78, -12.74, 127.90, 54000.25}, pos.getCoordinates());
+ assertArrayEquals(new double[] {23.78, -12.74, 127.90, 54000.25}, pos.getCoordinate());
assertEquals(-1, charPos.getErrorIndex());
assertEquals(55, charPos.getIndex());
/*
@@ -248,7 +248,7 @@
DirectPosition position = format.parse(buffer, charPos);
assertEquals(buffer.length(), charPos.getIndex(), "Should have parsed the whole text.");
assertEquals(2, position.getDimension(), "DirectPosition.getDimension()");
- assertArrayEquals(new double[] {-3, 4}, position.getCoordinates());
+ assertArrayEquals(new double[] {-3, 4}, position.getCoordinate());
}
/**
@@ -264,7 +264,7 @@
DirectPosition position = coordinateFormat.parse("[skip] 12", charPos);
assertEquals(9, charPos.getIndex(), "Should have parsed the whole text.");
assertEquals(1, position.getDimension(), "DirectPosition.getDimension()");
- assertArrayEquals(new double[] {12}, position.getCoordinates());
+ assertArrayEquals(new double[] {12}, position.getCoordinate());
}
/**
@@ -337,7 +337,7 @@
assertEquals("40°07′N 9°52′35,6″E ± 3 km", format.format(pos));
final DirectPosition p = format.parseObject("40°07′N 9°52′35,6″E ± 3 km");
- assertArrayEquals(new double[] {40.1166, 9.8765}, p.getCoordinates(), 0.0001);
+ assertArrayEquals(new double[] {40.1166, 9.8765}, p.getCoordinate(), 0.0001);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition1DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition1DTest.java
index cf0ae60..de99257 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition1DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition1DTest.java
@@ -73,7 +73,7 @@
assertTrue(p2.equals(p1));
assertEquals(p2.hashCode(), p1.hashCode());
- p1.setCoordinate(0, p1.getCoordinate(0) + 1);
+ p1.setOrdinate(0, p1.getOrdinate(0) + 1);
assertFalse(p1.equals(p2));
assertFalse(p2.equals(p1));
assertNotEquals(p2.hashCode(), p1.hashCode());
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition2DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition2DTest.java
index 6f83218..fd419a3 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition2DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/DirectPosition2DTest.java
@@ -73,7 +73,7 @@
assertTrue(p2.equals(p1));
assertEquals(p2.hashCode(), p1.hashCode());
- p1.setCoordinate(0, p1.getCoordinate(0) + 1);
+ p1.setOrdinate(0, p1.getOrdinate(0) + 1);
assertFalse(p1.equals(p2));
assertFalse(p2.equals(p1));
assertNotEquals(p2.hashCode(), p1.hashCode());
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
index 91ecdf5..e11f746 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
@@ -36,6 +36,9 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
+
/**
* Tests the {@link GeneralEnvelope} class. The {@link Envelope2D} class will also be tested as a
@@ -57,7 +60,7 @@
* This is set to {@code true} only when we intentionally want to create an invalid envelope,
* for example in order to test normalization.
*/
- boolean skipValidation;
+ boolean skipValidation = !PENDING_NEXT_GEOAPI_RELEASE;
/**
* Creates a new test case.
@@ -115,14 +118,14 @@
}
final DirectPosition lower = test.getLowerCorner();
final DirectPosition upper = test.getUpperCorner();
- assertEquals(xLower, lower.getCoordinate(0), "lower");
- assertEquals(xUpper, upper.getCoordinate(0), "upper");
+ assertEquals(xLower, lower.getOrdinate (0), "lower");
+ assertEquals(xUpper, upper.getOrdinate (0), "upper");
assertEquals(xmin, test .getMinimum (0), "xmin");
assertEquals(xmax, test .getMaximum (0), "xmax");
assertEquals(ymin, test .getMinimum (1), "ymin");
assertEquals(ymax, test .getMaximum (1), "ymax");
- assertEquals(ymin, lower.getCoordinate(1), "ymin");
- assertEquals(ymax, upper.getCoordinate(1), "ymax");
+ assertEquals(ymin, lower.getOrdinate (1), "ymin");
+ assertEquals(ymax, upper.getOrdinate (1), "ymax");
if (test instanceof Envelope2D ri) {
assertEquals(xmin, ri.getMinX(), "xmin");
assertEquals(xmax, ri.getMaxX(), "xmax");
@@ -615,8 +618,8 @@
@Test
public void testCornerModifications() {
final GeneralEnvelope e = create(2, -4, 3, -3);
- e.getLowerCorner().setCoordinate(0, 1);
- e.getUpperCorner().setCoordinate(1, -1);
+ e.getLowerCorner().setOrdinate(0, 1);
+ e.getUpperCorner().setOrdinate(1, -1);
assertEquals( 1, e.getLower(0));
assertEquals(-4, e.getLower(1));
assertEquals( 3, e.getUpper(0));
@@ -662,8 +665,8 @@
envelope.setTimeRange(Instant.parse("2015-04-10T06:00:00Z"),
Instant.parse("2018-12-29T12:00:00Z"));
- assertArrayEquals(new double[] {-20, -30, 57122.25}, envelope.getLowerCorner().getCoordinates());
- assertArrayEquals(new double[] { 25, 12, 58481.50}, envelope.getUpperCorner().getCoordinates());
+ assertArrayEquals(new double[] {-20, -30, 57122.25}, envelope.getLowerCorner().getCoordinate());
+ assertArrayEquals(new double[] { 25, 12, 58481.50}, envelope.getUpperCorner().getCoordinate());
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/WraparoundAdjustmentTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/WraparoundAdjustmentTest.java
index d044168..f4ccf20 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/WraparoundAdjustmentTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/WraparoundAdjustmentTest.java
@@ -230,7 +230,7 @@
final WraparoundAdjustment wa = new WraparoundAdjustment(domainOfValidity, HardCodedConversions.mercator());
DirectPosition actual = wa.shift(pointOfInterest);
- assertEquals(-6679169, actual.getCoordinate(0), 1);
- assertEquals( 221194, actual.getCoordinate(1), 1);
+ assertEquals(-6679169, actual.getOrdinate(0), 1);
+ assertEquals( 221194, actual.getOrdinate(1), 1);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
deleted file mode 100644
index 07f34b9..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * 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.io.wkt;
-
-import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.crs.VerticalCRS;
-import org.opengis.util.FactoryException;
-import org.opengis.referencing.datum.RealizationMethod;
-import org.apache.sis.metadata.privy.AxisNames;
-import org.apache.sis.referencing.factory.GeodeticObjectFactory;
-import org.apache.sis.system.Loggers;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.opengis.test.referencing.WKTParserTest;
-import org.apache.sis.test.LoggingWatcher;
-import org.apache.sis.test.FailureDetailsReporter;
-import org.apache.sis.referencing.EPSGDependentTestCase;
-
-
-/**
- * Tests Well-Known Text parser using the tests defined in GeoAPI. Those tests use the
- * {@link org.apache.sis.referencing.factory.GeodeticObjectFactory#createFromWKT(String)} method.
- *
- * @author Martin Desruisseaux (IRD, Geomatys)
- */
-@ExtendWith(FailureDetailsReporter.class)
-public final class CRSParserTest extends WKTParserTest {
- /**
- * A JUnit extension for listening to log events.
- */
- @RegisterExtension
- public final LoggingWatcher loggings;
-
- /**
- * Whether the test should replace the curly quotation marks “ and ” by the straight quotation mark ".
- * The ISO 19162 specification uses only straight quotation marks, but SIS supports both.
- * Curly quotation marks are convenient for identifying bugs, so we test them first.
- */
- private boolean useStraightQuotes;
-
- /**
- * Creates a new test case using the default {@code CRSFactory} implementation.
- */
- public CRSParserTest() {
- super(GeodeticObjectFactory.provider());
- loggings = new LoggingWatcher(Loggers.WKT);
- }
-
- /**
- * Forces the check of whether of EPSG database exists before to start any tests.
- * This is done for avoiding race conditions logging the same message many times.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- EPSGDependentTestCase.forceCheckForEPSG();
- }
-
- /**
- * Pre-process the WKT string before parsing. This method may replace curly quotation marks
- * ({@code “} and {@code ”}) by straight quotation marks ({@code "}).
- * The Apache SIS parser should understand both forms transparently.
- *
- * @param wkt the Well-Known Text to pre-process.
- * @return the Well-Known Text to parse.
- */
- @Override
- protected String preprocessWKT(String wkt) {
- if (useStraightQuotes) {
- wkt = super.preprocessWKT(wkt);
- }
- return wkt;
- }
-
- /**
- * Verifies the axis names of a geographic CRS. This method is invoked when the parsed object is
- * expected to have <q>Geodetic latitude</q> and <q>Geodetic longitude</q> names.
- */
- @SuppressWarnings("fallthrough")
- private void verifyEllipsoidalCS() {
- final CoordinateSystem cs = object.getCoordinateSystem();
- switch (cs.getDimension()) {
- default: assertEquals(AxisNames.ELLIPSOIDAL_HEIGHT, cs.getAxis(2).getName().getCode(), "name");
- case 2: assertEquals(AxisNames.GEODETIC_LONGITUDE, cs.getAxis(1).getName().getCode(), "name");
- case 1: assertEquals(AxisNames.GEODETIC_LATITUDE, cs.getAxis(0).getName().getCode(), "name");
- case 0: break;
- }
- switch (cs.getDimension()) {
- default: assertEquals("h", cs.getAxis(2).getAbbreviation(), "abbreviation");
- case 2: assertEquals("λ", cs.getAxis(1).getAbbreviation(), "abbreviation");
- case 1: assertEquals("φ", cs.getAxis(0).getAbbreviation(), "abbreviation");
- case 0: break;
- }
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODCRS[“WGS 84”,
- * DATUM[“World Geodetic System 1984”,
- * ELLIPSOID[“WGS 84”, 6378137, 298.257223563,
- * LENGTHUNIT[“metre”,1.0]]],
- * CS[ellipsoidal,3],
- * AXIS[“(lat)”,north,ANGLEUNIT[“degree”,0.0174532925199433]],
- * AXIS[“(lon)”,east,ANGLEUNIT[“degree”,0.0174532925199433]],
- * AXIS[“ellipsoidal height (h)”,up,LENGTHUNIT[“metre”,1.0]]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testGeographic3D() throws FactoryException {
- super.testGeographic3D();
- verifyEllipsoidalCS();
- useStraightQuotes = true;
- super.testGeographic3D(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODCRS[“S-95”,
- * DATUM[“Pulkovo 1995”,
- * ELLIPSOID[“Krassowsky 1940”, 6378245, 298.3,
- * LENGTHUNIT[“metre”,1.0]]],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north,ORDER[1]],
- * AXIS[“longitude”,east,ORDER[2]],
- * ANGLEUNIT[“degree”,0.0174532925199433],
- * REMARK[“Система Геодеэических Координвт года 1995(СК-95)”]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testGeographicWithUnicode() throws FactoryException {
- super.testGeographicWithUnicode();
- verifyEllipsoidalCS();
- useStraightQuotes = true;
- super.testGeographicWithUnicode(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODCRS[“NAD83”,
- * DATUM[“North American Datum 1983”,
- * ELLIPSOID[“GRS 1980”, 6378137, 298.257222101, LENGTHUNIT[“metre”,1.0]]],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north],
- * AXIS[“longitude”,east],
- * ANGLEUNIT[“degree”,0.017453292519943],
- * ID[“EPSG”,4269],
- * REMARK[“1986 realisation”]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testGeographicWithIdentifier() throws FactoryException {
- super.testGeographicWithIdentifier();
- verifyEllipsoidalCS();
- useStraightQuotes = true;
- super.testGeographicWithIdentifier(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODCRS[“NTF (Paris)”,
- * DATUM[“Nouvelle Triangulation Francaise”,
- * ELLIPSOID[“Clarke 1880 (IGN)”, 6378249.2, 293.4660213]],
- * PRIMEM[“Paris”,2.5969213],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north,ORDER[1]],
- * AXIS[“longitude”,east,ORDER[2]],
- * ANGLEUNIT[“grad”,0.015707963267949],
- * REMARK[“Nouvelle Triangulation Française”]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testGeographicWithGradUnits() throws FactoryException {
- super.testGeographicWithGradUnits();
- verifyEllipsoidalCS();
- useStraightQuotes = true;
- super.testGeographicWithGradUnits(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODETICCRS[“JGD2000”,
- * DATUM[“Japanese Geodetic Datum 2000”,
- * ELLIPSOID[“GRS 1980”, 6378137, 298.257222101]],
- * CS[Cartesian,3],
- * AXIS[“(X)”,geocentricX],
- * AXIS[“(Y)”,geocentricY],
- * AXIS[“(Z)”,geocentricZ],
- * LENGTHUNIT[“metre”,1.0],
- * SCOPE[“Geodesy, topographic mapping and cadastre”],
- * AREA[“Japan”],
- * BBOX[17.09,122.38,46.05,157.64],
- * TIMEEXTENT[2002-04-01,2011-10-21],
- * ID[“EPSG”,4946,URI[“urn:ogc:def:crs:EPSG::4946”]],
- * REMARK[“注:JGD2000ジオセントリックは現在JGD2011に代わりました。”]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testGeocentric() throws FactoryException {
- super.testGeocentric();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.GEOCENTRIC_X, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.GEOCENTRIC_Y, cs.getAxis(1).getName().getCode(), "name");
- assertEquals(AxisNames.GEOCENTRIC_Z, cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testGeocentric(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Ignored for now, because the Lambert Azimuthal Equal Area projection method is not yet implemented.
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- @Disabled("Lambert Azimuthal Equal Area projection method not yet implemented.")
- public void testProjectedYX() throws FactoryException {
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * PROJCRS[“NAD27 / Texas South Central”,
- * BASEGEODCRS[“NAD27”,
- * DATUM[“North American Datum 1927”,
- * ELLIPSOID[“Clarke 1866”, 20925832.164, 294.97869821,
- * LENGTHUNIT[“US survey foot”,0.304800609601219]]]],
- * CONVERSION[“Texas South Central SPCS27”,
- * METHOD[“Lambert Conic Conformal (2SP)”,ID[“EPSG”,9802]],
- * PARAMETER[“Latitude of false origin”,27.83333333333333,
- * ANGLEUNIT[“degree”,0.0174532925199433],ID[“EPSG”,8821]],
- * PARAMETER[“Longitude of false origin”,-99.0,
- * ANGLEUNIT[“degree”,0.0174532925199433],ID[“EPSG”,8822]],
- * PARAMETER[“Latitude of 1st standard parallel”,28.383333333333,
- * ANGLEUNIT[“degree”,0.0174532925199433],ID[“EPSG”,8823]],
- * PARAMETER[“Latitude of 2nd standard parallel”,30.283333333333,
- * ANGLEUNIT[“degree”,0.0174532925199433],ID[“EPSG”,8824]],
- * PARAMETER[“Easting at false origin”,2000000.0,
- * LENGTHUNIT[“US survey foot”,0.304800609601219],ID[“EPSG”,8826]],
- * PARAMETER[“Northing at false origin”,0.0,
- * LENGTHUNIT[“US survey foot”,0.304800609601219],ID[“EPSG”,8827]]],
- * CS[Cartesian,2],
- * AXIS[“(x)”,east],
- * AXIS[“(y)”,north],
- * LENGTHUNIT[“US survey foot”,0.304800609601219],
- * REMARK[“Fundamental point: Meade’s Ranch KS, latitude 39°13'26.686"N, longitude 98°32'30.506"W.”]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testProjectedWithFootUnits() throws FactoryException {
- super.testProjectedWithFootUnits();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.EASTING, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.NORTHING, cs.getAxis(1).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testProjectedWithFootUnits(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters and the line feed in {@code REMARK}):
- *
- * <blockquote><pre>PROJCRS[“NAD83 UTM 10”,
- * BASEGEODCRS[“NAD83(86)”,
- * DATUM[“North American Datum 1983”,
- * ELLIPSOID[“GRS 1980”,6378137,298.257222101]],
- * ANGLEUNIT[“degree”,0.0174532925199433],
- * PRIMEM[“Greenwich”,0]],
- * CONVERSION[“UTM zone 10N”,ID[“EPSG”,16010],
- * METHOD[“Transverse Mercator”],
- * PARAMETER[“Latitude of natural origin”,0.0],
- * PARAMETER[“Longitude of natural origin”,-123.0],
- * PARAMETER[“Scale factor”,0.9996],
- * PARAMETER[“False easting”,500000.0],
- * PARAMETER[“False northing”,0.0]],
- * CS[Cartesian,2],
- * AXIS[“(E)”,east,ORDER[1]],
- * AXIS[“(N)”,north,ORDER[2]],
- * LENGTHUNIT[“metre”,1.0],
- * REMARK[“In this example units are implied. This is allowed for backward compatibility.
- * It is recommended that units are explicitly given in the string,
- * as in the previous two examples.”]]</pre></blockquote>
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testProjectedWithImplicitParameterUnits() throws FactoryException {
- super.testProjectedWithImplicitParameterUnits();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.EASTING, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.NORTHING, cs.getAxis(1).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testProjectedWithImplicitParameterUnits(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis name and vertical datum type.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * VERTCRS[“NAVD88”,
- * VDATUM[“North American Vertical Datum 1988”],
- * CS[vertical,1],
- * AXIS[“gravity-related height (H)”,up],LENGTHUNIT[“metre”,1.0]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testVertical() throws FactoryException {
- super.testVertical();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.GRAVITY_RELATED_HEIGHT, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(RealizationMethod.GEOID, ((VerticalCRS) object).getDatum().getRealizationMethod().orElse(null));
-
- useStraightQuotes = true;
- super.testVertical(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis name.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * TIMECRS[“GPS Time”,
- * TDATUM[“Time origin”,TIMEORIGIN[1980-01-01T00:00:00.0Z]],
- * CS[temporal,1],AXIS[“time”,future],TIMEUNIT[“day”,86400.0]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testTemporal() throws FactoryException {
- super.testTemporal();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.TIME, cs.getAxis(0).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testTemporal(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis name.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * PARAMETRICCRS[“WMO standard atmosphere layer 0”,
- * PDATUM[“Mean Sea Level”,ANCHOR[“1013.25 hPa at 15°C”]],
- * CS[parametric,1],
- * AXIS[“pressure (hPa)”,up],
- * PARAMETRICUNIT[“hPa”,100.0]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testParametric() throws FactoryException {
- super.testParametric();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals("pressure", cs.getAxis(0).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testParametric(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * ENGINEERINGCRS[“Astra Minas Grid”,
- * ENGINEERINGDATUM[“Astra Minas”],
- * CS[Cartesian,2],
- * AXIS[“northing (X)”,north,ORDER[1]],
- * AXIS[“westing (Y)”,west,ORDER[2]],
- * LENGTHUNIT[“metre”,1.0],
- * ID[“EPSG”,5800]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testEngineering() throws FactoryException {
- super.testEngineering();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.NORTHING, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.WESTING, cs.getAxis(1).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testEngineering(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * ENGCRS[“A construction site CRS”,
- * EDATUM[“P1”,ANCHOR[“Peg in south corner”]],
- * CS[Cartesian,2],
- * AXIS[“site east”,southWest,ORDER[1]],
- * AXIS[“site north”,southEast,ORDER[2]],
- * LENGTHUNIT[“metre”,1.0],
- * TIMEEXTENT[“date/time t1”,“date/time t2”]]
- * }
- *
- * In current Apache SIS version, this test produces a logs a warning saying
- * that the {@code TimeExtent[…]} element is not yet supported.
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testEngineeringRotated() throws FactoryException {
- super.testEngineeringRotated();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals("site east", cs.getAxis(0).getName().getCode(), "name");
- assertEquals("site north", cs.getAxis(1).getName().getCode(), "name");
- loggings.assertNextLogContains("A construction site CRS", "TimeExtent[String,String]");
-
- useStraightQuotes = true;
- super.testEngineeringRotated(); // Test again with “ and ” replaced by ".
- loggings.assertNextLogContains("A construction site CRS", "TimeExtent[String,String]");
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * ENGCRS[“A ship-centred CRS”,
- * EDATUM[“Ship reference point”,ANCHOR[“Centre of buoyancy”]],
- * CS[Cartesian,3],
- * AXIS[“(x)”,forward],
- * AXIS[“(y)”,starboard],
- * AXIS[“(z)”,down],
- * LENGTHUNIT[“metre”,1.0]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testEngineeringForShip() throws FactoryException {
- super.testEngineeringForShip();
- final CoordinateSystem cs = object.getCoordinateSystem();
- /*
- * In this case we had no axis names, so Apache SIS reused the abbreviations.
- * This could change in any future SIS version if we update Transliterator.
- */
- assertEquals("x", cs.getAxis(0).getName().getCode(), "name");
- assertEquals("y", cs.getAxis(1).getName().getCode(), "name");
- assertEquals("z", cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testEngineeringForShip(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * GEODCRS[“ETRS89 Lambert Azimuthal Equal Area CRS”,
- * BASEGEODCRS[“WGS 84”,
- * DATUM[“WGS 84”,
- * ELLIPSOID[“WGS 84”,6378137,298.2572236,LENGTHUNIT[“metre”,1.0]]]],
- * DERIVINGCONVERSION[“Atlantic pole”,
- * METHOD[“Pole rotation”,ID[“Authority”,1234]],
- * PARAMETER[“Latitude of rotated pole”,52.0,
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * PARAMETER[“Longitude of rotated pole”,-30.0,
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * PARAMETER[“Axis rotation”,-25.0,
- * ANGLEUNIT[“degree”,0.0174532925199433]]],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north,ORDER[1]],
- * AXIS[“longitude”,east,ORDER[2]],
- * ANGLEUNIT[“degree”,0.0174532925199433]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testDerivedGeodetic() throws FactoryException {
- super.testDerivedGeodetic();
- verifyEllipsoidalCS();
- useStraightQuotes = true;
- super.testDerivedGeodetic(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * ENGCRS[“Topocentric example A”,
- * BASEGEODCRS[“WGS 84”,
- * DATUM[“WGS 84”,
- * ELLIPSOID[“WGS 84”, 6378137, 298.2572236, LENGTHUNIT[“metre”,1.0]]]],
- * DERIVINGCONVERSION[“Topocentric example A”,
- * METHOD[“Geographic/topocentric conversions”,ID[“EPSG”,9837]],
- * PARAMETER[“Latitude of topocentric origin”,55.0,
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * PARAMETER[“Longitude of topocentric origin”,5.0,
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * PARAMETER[“Ellipsoidal height of topocentric origin”,0.0,
- * LENGTHUNIT[“metre”,1.0]]],
- * CS[Cartesian,3],
- * AXIS[“Topocentric East (U)”,east,ORDER[1]],
- * AXIS[“Topocentric North (V)”,north,ORDER[2]],
- * AXIS[“Topocentric height (W)”,up,ORDER[3]],
- * LENGTHUNIT[“metre”,1.0]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testDerivedEngineeringFromGeodetic() throws FactoryException {
- super.testDerivedEngineeringFromGeodetic();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals("Topocentric East", cs.getAxis(0).getName().getCode(), "name");
- assertEquals("Topocentric North", cs.getAxis(1).getName().getCode(), "name");
- assertEquals("Topocentric height", cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testDerivedEngineeringFromGeodetic(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- *
- * @see org.apache.sis.referencing.operation.provider.SeismicBinGridMock
- */
- @Test
- @Override
- @Disabled("Pending implementation of EPSG:1049 — Seismic bin grid.")
- public void testDerivedEngineeringFromProjected() throws FactoryException {
- super.testDerivedEngineeringFromProjected();
- final CoordinateSystem cs = object.getCoordinateSystem();
- /*
- * In this case we had no axis names, so Apache SIS reused the abbreviations.
- * This could change in any future SIS version if we update Transliterator.
- */
- assertEquals("I", cs.getAxis(0).getName().getCode(), "name");
- assertEquals("J", cs.getAxis(1).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testDerivedEngineeringFromProjected(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * COMPOUNDCRS[“NAD83 + NAVD88”,
- * GEODCRS[“NAD83”,
- * DATUM[“North American Datum 1983”,
- * ELLIPSOID[“GRS 1980”,6378137,298.257222101,
- * LENGTHUNIT[“metre”,1.0]]],
- * PRIMEMERIDIAN[“Greenwich”,0],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north,ORDER[1]],
- * AXIS[“longitude”,east,ORDER[2]],
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * VERTCRS[“NAVD88”,
- * VDATUM[“North American Vertical Datum 1988”],
- * CS[vertical,1],
- * AXIS[“gravity-related height (H)”,up],
- * LENGTHUNIT[“metre”,1]]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testCompoundWithVertical() throws FactoryException {
- super.testCompoundWithVertical();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.GEODETIC_LATITUDE, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.GEODETIC_LONGITUDE, cs.getAxis(1).getName().getCode(), "name");
- assertEquals(AxisNames.GRAVITY_RELATED_HEIGHT, cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testCompoundWithVertical(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * COMPOUNDCRS[“GPS position and time”,
- * GEODCRS[“WGS 84”,
- * DATUM[“World Geodetic System 1984”,
- * ELLIPSOID[“WGS 84”,6378137,298.257223563]],
- * CS[ellipsoidal,2],
- * AXIS[“(lat)”,north,ORDER[1]],
- * AXIS[“(lon)”,east,ORDER[2]],
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * TIMECRS[“GPS Time”,
- * TIMEDATUM[“Time origin”,TIMEORIGIN[1980-01-01]],
- * CS[temporal,1],
- * AXIS[“time (T)”,future],
- * TIMEUNIT[“day”,86400]]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testCompoundWithTime() throws FactoryException {
- super.testCompoundWithTime();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.GEODETIC_LATITUDE, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.GEODETIC_LONGITUDE, cs.getAxis(1).getName().getCode(), "name");
- assertEquals(AxisNames.TIME, cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testCompoundWithTime(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-
- /**
- * Completes the GeoAPI tests with a check of axis names.
- * The WKT parsed by this test is (except for quote characters):
- *
- * {@snippet lang="wkt" :
- * COMPOUNDCRS[“ICAO layer 0”,
- * GEODETICCRS[“WGS 84”,
- * DATUM[“World Geodetic System 1984”,
- * ELLIPSOID[“WGS 84”,6378137,298.257223563,
- * LENGTHUNIT[“metre”,1.0]]],
- * CS[ellipsoidal,2],
- * AXIS[“latitude”,north,ORDER[1]],
- * AXIS[“longitude”,east,ORDER[2]],
- * ANGLEUNIT[“degree”,0.0174532925199433]],
- * PARAMETRICCRS[“WMO standard atmosphere”,
- * PARAMETRICDATUM[“Mean Sea Level”,
- * ANCHOR[“Mean Sea Level = 1013.25 hPa”]],
- * CS[parametric,1],
- * AXIS[“pressure (P)”,unspecified],
- * PARAMETRICUNIT[“hPa”,100]]]
- * }
- *
- * @throws FactoryException if an error occurred during the WKT parsing.
- */
- @Test
- @Override
- public void testCompoundWithParametric() throws FactoryException {
- super.testCompoundWithParametric();
- final CoordinateSystem cs = object.getCoordinateSystem();
- assertEquals(AxisNames.GEODETIC_LATITUDE, cs.getAxis(0).getName().getCode(), "name");
- assertEquals(AxisNames.GEODETIC_LONGITUDE, cs.getAxis(1).getName().getCode(), "name");
- assertEquals("pressure", cs.getAxis(2).getName().getCode(), "name");
-
- useStraightQuotes = true;
- super.testCompoundWithParametric(); // Test again with “ and ” replaced by ".
- loggings.assertNoUnexpectedLog();
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/FormatterTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/FormatterTest.java
index 913f4bb..6c4f5c0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/FormatterTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/FormatterTest.java
@@ -100,7 +100,7 @@
}
/**
- * Tests (indirectly) {@link Formatter#append(ControlledVocabulary)}.
+ * Tests (indirectly) {@code Formatter.append(ControlledVocabulary)}.
*/
@Test
public void testAppendCodeList() {
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
index 73826a2..a239849 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
@@ -226,7 +226,7 @@
" ANCHOR[“Tananarive observatory”]]");
assertNameAndIdentifierEqual("Tananarive 1925", 0, datum);
- assertEquals("Tananarive observatory", datum.getAnchorDefinition().get().toString());
+ assertEquals("Tananarive observatory", datum.getAnchorPoint().toString());
final Ellipsoid ellipsoid = datum.getEllipsoid();
assertNameAndIdentifierEqual("International 1924", 0, ellipsoid);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/MathTransformParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/MathTransformParserTest.java
index b2c6a84..9a8d8b0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/MathTransformParserTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/MathTransformParserTest.java
@@ -30,8 +30,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
index 3ba62d8..aaf43b9 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
@@ -28,6 +28,9 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.test.mock.CoordinateSystemAxisMock;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.AxisDirections;
+
/**
* Tests the {@link Transliterator} class.
@@ -101,7 +104,7 @@
assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal", AxisDirection.NORTH, "P"), "P");
assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal", AxisDirection.NORTH, "B"), "B");
assertEquals("λ", t.toUnicodeAbbreviation("ellipsoidal", AxisDirection.EAST, "L"), "L");
- assertEquals("θ", t.toUnicodeAbbreviation("polar", AxisDirection.CLOCKWISE, "U"), "U");
+ assertEquals("θ", t.toUnicodeAbbreviation("polar", AxisDirections.CLOCKWISE,"U"), "U");
assertEquals("Ω", t.toUnicodeAbbreviation("spherical", AxisDirection.NORTH, "U"), "U");
assertEquals("θ", t.toUnicodeAbbreviation("spherical", AxisDirection.EAST, "V"), "V");
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
index 8d7e4eb..575775f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
@@ -46,9 +46,9 @@
import static org.apache.sis.test.Assertions.assertSetEquals;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -381,7 +381,7 @@
* for checking precedence.
*/
GeographicCRS crs = factory.createGeographicCRS("2C");
- Identifier id = TestUtilities.getSingleton(crs.getIdentifiers());
+ ReferenceIdentifier id = TestUtilities.getSingleton(crs.getIdentifiers());
assertEquals("TEST", id.getCodeSpace());
assertEquals("21", id.getCode());
assertSame(crs, factory.createGeographicCRS("2C")); // Test caching.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
index c78574b..45a81ce 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
@@ -34,9 +34,6 @@
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.parameter.ParameterDirection;
-
/**
* Tests the {@link DefaultParameterDescriptorGroup} class.
@@ -105,7 +102,6 @@
*/
@Test
public void validateTestObjects() {
- assertEquals(ParameterDirection.IN, M1_M1_O1_O2.getDirection());
for (final GeneralParameterDescriptor descriptor : M1_M1_O1_O2.descriptors()) {
AssertionError error = null;
try {
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterValueTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterValueTest.java
index ae70183..315c247 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterValueTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterValueTest.java
@@ -377,8 +377,8 @@
final AxisDirection[] directions = {
AxisDirection.NORTH,
AxisDirection.SOUTH,
- AxisDirection.DISPLAY_LEFT,
- AxisDirection.PAST
+ AxisDirection.PAST,
+ AxisDirection.DISPLAY_LEFT
};
final ParameterDescriptor<AxisDirection> descriptor = DefaultParameterDescriptorTest.create(
"Direction", AxisDirection.class, directions, AxisDirection.NORTH);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/ParametersTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/ParametersTest.java
index 4f7a912..08a8580 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/ParametersTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/ParametersTest.java
@@ -40,11 +40,6 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.ReferenceIdentifier;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import org.opengis.parameter.ParameterDirection;
-import org.opengis.util.TypeName;
-
/**
* Tests the static methods in the {@link Parameters} class.
@@ -114,11 +109,8 @@
@Override public Collection<GenericName> getAlias() {return descriptor.getAlias();}
@Override public Set<ReferenceIdentifier> getIdentifiers() {return descriptor.getIdentifiers();}
@Override public InternationalString getRemarks() {return descriptor.getRemarks();}
- @Override public Optional<InternationalString> getDescription() {return descriptor.getDescription();}
- @Override public ParameterDirection getDirection() {return descriptor.getDirection();}
@Override public int getMinimumOccurs() {return descriptor.getMinimumOccurs();}
@Override public int getMaximumOccurs() {return descriptor.getMaximumOccurs();}
- @Override public TypeName getValueType() {return descriptor.getValueType();}
@Override public Class<T> getValueClass() {return descriptor.getValueClass();}
@Override public Set<T> getValidValues() {return descriptor.getValidValues();}
@Override public Comparable<T> getMinimumValue() {return descriptor.getMinimumValue();}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorParametersTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorParametersTest.java
index ad1d665..c91054f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorParametersTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorParametersTest.java
@@ -34,9 +34,6 @@
import static org.apache.sis.referencing.Assertions.assertEpsgIdentifierEquals;
import static org.apache.sis.referencing.Assertions.assertAliasTipEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Validators.validate;
-
/**
* Tests the {@link TensorParameters} class.
@@ -281,7 +278,6 @@
}
final ParameterValueGroup group = param.createValueGroup(
Map.of(ParameterDescriptor.NAME_KEY, "Test"), matrix);
- validate(group);
assertEquals(numRow, group.parameter(NUM_ROW).intValue());
assertEquals(numCol, group.parameter(NUM_COL).intValue());
assertEquals(matrix, param.toMatrix(group));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java
index c6eb2e5..9f2d2be 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java
@@ -39,9 +39,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.referencing.Assertions.assertRemarksEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.referencing.IdentifiedObject.*;
-import static org.opengis.referencing.ObjectDomain.*;
+// Specific to the main branch:
+import static org.opengis.referencing.ReferenceSystem.*;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/Assertions.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/Assertions.java
index 360d535..d7a85f0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/Assertions.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/Assertions.java
@@ -54,6 +54,9 @@
import org.apache.sis.test.TestUtilities;
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Assertion methods used by the {@code org.apache.sis.referencing} module in addition of the ones inherited
@@ -88,7 +91,7 @@
* @param expected the expected identifier code.
* @param actual the identifier to verify.
*/
- public static void assertOgcIdentifierEquals(final String expected, final Identifier actual) {
+ public static void assertOgcIdentifierEquals(final String expected, final ReferenceIdentifier actual) {
assertNotNull(actual);
assertEquals(expected, actual.getCode(), "code");
assertEquals(Constants.OGC, actual.getCodeSpace(), "codeSpace");
@@ -106,7 +109,7 @@
public static void assertEpsgIdentifierEquals(final String expected, final Identifier actual) {
assertNotNull(actual);
assertEquals(expected, actual.getCode(), "code");
- assertEquals(Constants.EPSG, actual.getCodeSpace(), "codeSpace");
+ assertEquals(Constants.EPSG, (actual instanceof ReferenceIdentifier) ? ((ReferenceIdentifier) actual).getCodeSpace() : null, "codeSpace");
assertEquals(Constants.EPSG, Citations.toCodeSpace(actual.getAuthority()), "authority");
assertEquals(Constants.EPSG + Constants.DEFAULT_SEPARATOR + expected, IdentifiedObjects.toString(actual), "identifier");
}
@@ -308,8 +311,8 @@
if (i < tolerances.length) {
tolerance = tolerances[i];
}
- if (abs(expectedLower.getCoordinate(i) - actualLower.getCoordinate(i)) > tolerance ||
- abs(expectedUpper.getCoordinate(i) - actualUpper.getCoordinate(i)) > tolerance)
+ if (abs(expectedLower.getOrdinate(i) - actualLower.getOrdinate(i)) > tolerance ||
+ abs(expectedUpper.getOrdinate(i) - actualUpper.getOrdinate(i)) > tolerance)
{
fail("Envelopes are not equal in dimension " + i + ":\n"
+ "expected " + Envelopes.toString(expected) + "\n"
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/BuilderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/BuilderTest.java
index e075067..2e19fc5 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/BuilderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/BuilderTest.java
@@ -35,6 +35,9 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.TestCase;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Tests {@link Builder}.
@@ -79,17 +82,17 @@
/*
* The failed attempt to set a new codespace shall not have modified builder state.
*/
- assertEquals("EPSG", builder.properties.get(Identifier.CODESPACE_KEY));
+ assertEquals("EPSG", builder.properties.get(ReferenceIdentifier.CODESPACE_KEY));
assertSame (Citations.EPSG, builder.properties.get(Identifier.AUTHORITY_KEY));
/*
* After a cleanup (normally after a createXXX(…) method call), user shall be allowed to
* set a new codespace again. Note that the cleanup operation shall not clear the codespace.
*/
builder.onCreate(true);
- assertEquals("EPSG", builder.properties.get(Identifier.CODESPACE_KEY));
+ assertEquals("EPSG", builder.properties.get(ReferenceIdentifier.CODESPACE_KEY));
assertSame (Citations.EPSG, builder.properties.get(Identifier.AUTHORITY_KEY));
builder.setCodeSpace(IOGP, "EPSG");
- assertEquals("EPSG", builder.properties.get(Identifier.CODESPACE_KEY));
+ assertEquals("EPSG", builder.properties.get(ReferenceIdentifier.CODESPACE_KEY));
assertSame ( IOGP, builder.properties.get(Identifier.AUTHORITY_KEY));
}
@@ -212,7 +215,7 @@
assertSame(Citations.EPSG, value); // Authority and codespace shall be unchanged.
break;
}
- case Identifier.CODESPACE_KEY: {
+ case ReferenceIdentifier.CODESPACE_KEY: {
assertEquals("EPSG", value); // Authority and codespace shall be unchanged.
break;
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
index 72fc601..8e52101 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
@@ -48,9 +48,6 @@
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* Tests the {@link CRS} class.
@@ -256,7 +253,7 @@
default: throw new AssertionError(i);
}
properties.put(DefaultProjectedCRS.NAME_KEY, "CRS #" + i);
- properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent(
+ properties.put(DefaultProjectedCRS.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent(
null, new DefaultGeographicBoundingBox(-1, +1, ymin, ymax), null, null));
crs[i] = new DefaultProjectedCRS(properties, baseCRS.geographic(), HardCodedConversions.MERCATOR, cs);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java
index 7b7b243..991376a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java
@@ -53,9 +53,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -215,24 +215,23 @@
* Verifies the vertical datum enumeration.
*/
@Test
- @SuppressWarnings("deprecation")
public void testVertical() {
for (final CommonCRS.Vertical e : CommonCRS.Vertical.values()) {
- final RealizationMethod method;
+ final VerticalDatumType method;
final String axisName, datumName;
switch (e) {
- case NAVD88: axisName = AxisNames.GRAVITY_RELATED_HEIGHT; datumName = "North American Vertical Datum 1988"; method = RealizationMethod. GEOID; break;
- case BAROMETRIC: axisName = "Barometric altitude"; datumName = "Constant pressure surface"; method = RealizationMethod.valueOf("BAROMETRIC"); break;
- case MEAN_SEA_LEVEL: axisName = AxisNames.GRAVITY_RELATED_HEIGHT; datumName = "Mean Sea Level"; method = RealizationMethod. TIDAL; break;
- case DEPTH: axisName = AxisNames.DEPTH; datumName = "Mean Sea Level"; method = RealizationMethod. TIDAL; break;
+ case NAVD88: axisName = AxisNames.GRAVITY_RELATED_HEIGHT; datumName = "North American Vertical Datum 1988"; method = VerticalDatumType. GEOIDAL; break;
+ case BAROMETRIC: axisName = "Barometric altitude"; datumName = "Constant pressure surface"; method = VerticalDatumType. BAROMETRIC; break;
+ case MEAN_SEA_LEVEL: axisName = AxisNames.GRAVITY_RELATED_HEIGHT; datumName = "Mean Sea Level"; method = VerticalDatumType. GEOIDAL; break;
+ case DEPTH: axisName = AxisNames.DEPTH; datumName = "Mean Sea Level"; method = VerticalDatumType. GEOIDAL; break;
case ELLIPSOIDAL: axisName = AxisNames.ELLIPSOIDAL_HEIGHT; datumName = "Ellipsoid"; method = VerticalDatumTypes.ellipsoidal(); break;
- case OTHER_SURFACE: axisName = "Height"; datumName = "Other surface"; method = null; break;
+ case OTHER_SURFACE: axisName = "Height"; datumName = "Other surface"; method = VerticalDatumType. OTHER_SURFACE; break;
default: throw new AssertionError(e);
}
final String name = e.name();
final VerticalDatum datum = e.datum();
final VerticalCRS crs = e.crs();
- if (e.isEPSG) {
+ if (e.isEPSG && !name.startsWith("NAV")) {
/*
* BAROMETRIC and ELLIPSOIDAL uses an axis named "Height", which is not a valid
* axis name according ISO 19111. We skip the validation test for those enums.
@@ -242,10 +241,8 @@
assertSame(datum, e.datum(), name); // Datum before CRS creation.
assertSame(crs.getDatum(), e.datum(), name); // Datum after CRS creation.
assertEquals(datumName, datum.getName().getCode(), name);
+ assertEquals(method, datum.getVerticalDatumType(), name);
assertEquals(axisName, crs.getCoordinateSystem().getAxis(0).getName().getCode(), name);
- if (!e.isEPSG) { // Because the information is not in EPSG database 9.x.
- assertEquals(method, datum.getRealizationMethod().orElse(null), name);
- }
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
index d7eb42a..341b33c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
@@ -44,6 +44,11 @@
*/
public final class GeodesicsOnEllipsoidTest extends GeodeticCalculatorTest {
/**
+ * Tolerance threshold for comparison of floating point numbers.
+ */
+ private static final double STRICT = 0;
+
+ /**
* The {@link GeodesicsOnEllipsoid} instance to be tested.
* A specialized type is used for tracking locale variables.
*/
@@ -315,8 +320,8 @@
* λ₂ — end point longitude. Shifted by 10° compared to Karney because of λ₁ = 10°.
* α₂ — azimuth at end point.
*/
- assertEquals( 41.79331020506, endPoint.getCoordinate(1), 1E-11, "φ₂");
- assertEquals(147.84490004377, endPoint.getCoordinate(0), 1E-11, "λ₂");
+ assertEquals( 41.79331020506, endPoint.getOrdinate(1), 1E-11, "φ₂");
+ assertEquals(147.84490004377, endPoint.getOrdinate(0), 1E-11, "λ₂");
assertEquals(149.09016931807, testedEarth.getEndingAzimuth(), 1E-11, "α₂");
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java
index 8b1c9bc..5d48afe 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java
@@ -29,9 +29,9 @@
import net.sf.geographiclib.Geodesic;
import net.sf.geographiclib.GeodesicData;
import org.opengis.geometry.DirectPosition;
+import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
-import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.referencing.privy.Formulas;
import org.apache.sis.referencing.privy.ShapeUtilitiesExt;
import org.apache.sis.geometry.DirectPosition2D;
@@ -50,9 +50,9 @@
import org.apache.sis.test.widget.VisualCheck;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertBetween;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -83,8 +83,8 @@
* @param ε the tolerance threshold.
*/
static void assertPositionEquals(final double φ, final double λ, final DirectPosition p, final double ε) {
- assertEquals(φ, p.getCoordinate(0), ε, "φ");
- assertEquals(λ, p.getCoordinate(1), ε, "λ");
+ assertEquals(φ, p.getOrdinate(0), ε, "φ");
+ assertEquals(λ, p.getOrdinate(1), ε, "λ");
}
/**
@@ -411,8 +411,8 @@
aErrors.accept(abs(c.getStartingAzimuth() - azimuth));
c.setStartingAzimuth(azimuth);
DirectPosition endPoint = c.getEndPoint();
- final double φ = endPoint.getCoordinate(0);
- final double λ = endPoint.getCoordinate(1);
+ final double φ = endPoint.getOrdinate(0);
+ final double λ = endPoint.getOrdinate(1);
double dy = (buffer[0] - φ) * toMetres;
double dx = IEEEremainder(buffer[1] - λ, 360) * toMetres * cos(toRadians(φ));
yError.accept(abs(dy) / resolution);
@@ -523,11 +523,11 @@
final DirectPosition start = c.getStartPoint();
final DirectPosition end = c.getEndPoint();
try {
- assertEquals(expected[COLUMN_φ1], start.getCoordinate(0), Formulas.ANGULAR_TOLERANCE, "φ₁");
- assertEquals(expected[COLUMN_λ1], start.getCoordinate(1), Formulas.ANGULAR_TOLERANCE, "λ₁");
+ assertEquals(expected[COLUMN_φ1], start.getOrdinate(0), Formulas.ANGULAR_TOLERANCE, "φ₁");
+ assertEquals(expected[COLUMN_λ1], start.getOrdinate(1), Formulas.ANGULAR_TOLERANCE, "λ₁");
assertEquals(expected[COLUMN_α1], c.getStartingAzimuth(), azimuthTolerance / cosφ1, "α₁");
- assertEquals(expected[COLUMN_φ2], end.getCoordinate(0), latitudeTolerance, "φ₂");
- assertEquals(expected[COLUMN_λ2], end.getCoordinate(1), longitudeTolerance, "λ₂");
+ assertEquals(expected[COLUMN_φ2], end.getOrdinate(0), latitudeTolerance, "φ₂");
+ assertEquals(expected[COLUMN_λ2], end.getOrdinate(1), longitudeTolerance, "λ₂");
assertEquals(expected[COLUMN_α2], c.getEndingAzimuth(), azimuthTolerance / cosφ2, "α₂");
assertEquals(expected[COLUMN_Δs], c.getGeodesicDistance(), linearTolerance * relaxIfConfirmed(potentialProblem), "∆s");
clear();
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java
index dec5d99..04536e6 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java
@@ -38,8 +38,10 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.operation.CoordinateOperation;
/**
@@ -64,11 +66,17 @@
* @param isMandatory {@code true} if an absence of world extent is a failure.
*/
private static void assertIsWorld(final IdentifiedObject object, boolean isMandatory) {
- for (ObjectDomain domain : object.getDomains()) {
- assertIsWorld(domain.getDomainOfValidity(), isMandatory);
- isMandatory = false;
+ final Extent extent;
+ if (object instanceof ReferenceSystem) {
+ extent = ((ReferenceSystem) object).getDomainOfValidity();
+ } else if (object instanceof Datum) {
+ extent = ((Datum) object).getDomainOfValidity();
+ } else if (object instanceof CoordinateOperation) {
+ extent = ((CoordinateOperation) object).getDomainOfValidity();
+ } else {
+ extent = null;
}
- assertFalse(isMandatory, "Expected a world extent element.");
+ assertIsWorld(extent, isMandatory);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/ImmutableIdentifierTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/ImmutableIdentifierTest.java
index 13211c7..0a9825f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/ImmutableIdentifierTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/ImmutableIdentifierTest.java
@@ -40,8 +40,8 @@
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.metadata.Identifier.*;
+// Specific to the main branch:
+import static org.opengis.referencing.ReferenceIdentifier.*;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/NamedIdentifierTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/NamedIdentifierTest.java
index 9f3eaea..4766e88 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/NamedIdentifierTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/NamedIdentifierTest.java
@@ -32,8 +32,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -55,7 +55,7 @@
@Test
public void testCreateFromCode() {
final NamedIdentifier identifier = new NamedIdentifier(Citations.EPSG, "EPSG", "4326", "8.3", null);
- Validators.validate((Identifier) identifier);
+ Validators.validate((ReferenceIdentifier) identifier);
Validators.validate((GenericName) identifier);
// ImmutableIdentifier properties
@@ -81,7 +81,7 @@
final NameFactory factory = DefaultNameFactory.provider();
final NameSpace scope = factory.createNameSpace(factory.createLocalName(null, "IOGP"), null);
final NamedIdentifier identifier = new NamedIdentifier(factory.createGenericName(scope, "EPSG", "4326"));
- Validators.validate((Identifier) identifier);
+ Validators.validate((ReferenceIdentifier) identifier);
Validators.validate((GenericName) identifier);
// ImmutableIdentifier properties
@@ -118,7 +118,7 @@
@Test
public void testCreateFromInternationalString() {
final NamedIdentifier identifier = createI18N();
- Validators.validate((Identifier) identifier);
+ Validators.validate((ReferenceIdentifier) identifier);
Validators.validate((GenericName) identifier);
// ImmutableIdentifier properties
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
index c1cae87..755ac94 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
@@ -41,8 +41,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
index 84b99e3..10840b6 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
@@ -41,9 +41,9 @@
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -133,7 +133,7 @@
@Test
public void testConstruction() {
final DefaultDerivedCRS crs = createLongitudeRotation();
- Validators.validate(crs);
+// Validators.validate(crs);
assertEquals("Back to Greenwich", crs.getName().getCode());
assertEquals("NTF (Paris)", crs.getBaseCRS().getName().getCode());
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
index 76c6258..0dcd64a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
@@ -34,8 +34,8 @@
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
index 7030e97..05bdb0c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
@@ -32,8 +32,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -94,7 +94,7 @@
@Test
public void testIdentifiers() {
GeographicCRS crs = CommonCRS.WGS72.geographic();
- Identifier identifier = getSingleton(crs.getIdentifiers());
+ ReferenceIdentifier identifier = getSingleton(crs.getIdentifiers());
assertEquals("EPSG", identifier.getCodeSpace());
assertEquals("4322", identifier.getCode());
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultImageCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
index 6bf4332..05f712d 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
@@ -39,8 +39,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.PixelInCell;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
index c5a4988..8abe73c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
@@ -46,8 +46,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRS.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRS.java
index fe0a120..d4464b3 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRS.java
@@ -32,8 +32,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.PixelInCell;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.referencing.ObjectDomain.DOMAIN_OF_VALIDITY_KEY;
+// Specific to the main branch:
+import static org.opengis.referencing.ReferenceSystem.DOMAIN_OF_VALIDITY_KEY;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRSTest.java
index 3694edf..c3be229 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/HardCodedCRSTest.java
@@ -47,8 +47,8 @@
public void validate() {
final ValidatorContainer validators = new ValidatorContainer();
validators.validate(WGS84);
- validators.validate(WGS84_3D); validators.crs.enforceStandardNames = false;
- validators.validate(ELLIPSOIDAL_HEIGHT); validators.crs.enforceStandardNames = true;
+ validators.validate(WGS84_3D);
+ validators.validate(ELLIPSOIDAL_HEIGHT);
validators.validate(GRAVITY_RELATED_HEIGHT);
validators.validate(TIME);
validators.validate(SPHERICAL);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/CoordinateSystemsTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
index fd9296c..05dbe0e 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
@@ -42,8 +42,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
index 0b44ba6..ec240fd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
@@ -26,8 +26,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.AxisDirections;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -52,8 +53,8 @@
final DefaultCylindricalCS normalized = cs.forConvention(AxesConvention.DISPLAY_ORIENTED);
assertNotSame(cs, normalized);
assertAxisDirectionsEqual(normalized,
- AxisDirection.AWAY_FROM,
- AxisDirection.COUNTER_CLOCKWISE,
+ AxisDirections.AWAY_FROM,
+ AxisDirections.COUNTER_CLOCKWISE,
AxisDirection.UP);
}
@@ -75,7 +76,7 @@
DefaultCylindricalCS normalized = cs.forConvention(AxesConvention.RIGHT_HANDED);
assertNotSame(cs, normalized);
assertAxisDirectionsEqual(normalized,
- AxisDirection.CLOCKWISE, // Interchanged (r,θ) order for making right handed.
+ AxisDirections.CLOCKWISE, // Interchanged (r,θ) order for making right handed.
AxisDirection.SOUTH,
AxisDirection.UP);
@@ -83,7 +84,7 @@
assertNotSame(cs, normalized);
assertAxisDirectionsEqual(normalized,
AxisDirection.SOUTH, // Not modified to North because radius cannot be negative.
- AxisDirection.COUNTER_CLOCKWISE,
+ AxisDirections.COUNTER_CLOCKWISE,
AxisDirection.UP);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultPolarCSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultPolarCSTest.java
index bb21729..17c96d7 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultPolarCSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultPolarCSTest.java
@@ -26,8 +26,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.AxisDirections;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -52,8 +53,8 @@
final DefaultPolarCS normalized = cs.forConvention(AxesConvention.DISPLAY_ORIENTED);
assertNotSame(cs, normalized);
assertAxisDirectionsEqual(normalized,
- AxisDirection.AWAY_FROM,
- AxisDirection.COUNTER_CLOCKWISE);
+ AxisDirections.AWAY_FROM,
+ AxisDirections.COUNTER_CLOCKWISE);
}
/**
@@ -72,7 +73,7 @@
DefaultPolarCS normalized = cs.forConvention(AxesConvention.RIGHT_HANDED);
assertAxisDirectionsEqual(normalized,
- AxisDirection.CLOCKWISE,
+ AxisDirections.CLOCKWISE,
AxisDirection.SOUTH);
assertSame(cs, normalized);
@@ -80,6 +81,6 @@
assertNotSame(cs, normalized);
assertAxisDirectionsEqual(normalized,
AxisDirection.SOUTH, // Not modified to North because radius cannot be negative.
- AxisDirection.COUNTER_CLOCKWISE);
+ AxisDirections.COUNTER_CLOCKWISE);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
index 4aadf4b..0022abe 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
@@ -24,8 +24,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.AxisDirections;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -90,8 +91,8 @@
final DefaultSphericalCS normalized = cs.forConvention(AxesConvention.NORMALIZED);
assertNotSame(cs, normalized); // Should create a new CoordinateSystem.
assertAxisDirectionsEqual(normalized,
- AxisDirection.COUNTER_CLOCKWISE,
+ AxisDirections.COUNTER_CLOCKWISE,
AxisDirection.UP,
- AxisDirection.AWAY_FROM);
+ AxisDirections.AWAY_FROM);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
index b7b43a9..bffb391 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
@@ -23,6 +23,9 @@
import org.apache.sis.metadata.privy.AxisNames;
import org.apache.sis.measure.Units;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.AxisDirections;
+
/**
* Collection of axes for testing purpose.
@@ -398,7 +401,7 @@
* @see #GEOCENTRIC_RADIUS
*/
public static final DefaultCoordinateSystemAxis DISTANCE = create("Distance", "r",
- AxisDirection.AWAY_FROM, Units.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
+ AxisDirections.AWAY_FROM, Units.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
/**
* An axis with clockwise orientation.
@@ -406,7 +409,7 @@
* (not to be confused with geodetic spherical coordinate system).
*/
public static final DefaultCoordinateSystemAxis BEARING = create("Bearing", "θ",
- AxisDirection.CLOCKWISE, Units.DEGREE, -180, +180, RangeMeaning.WRAPAROUND);
+ AxisDirections.CLOCKWISE, Units.DEGREE, -180, +180, RangeMeaning.WRAPAROUND);
/**
* An axis with for elevation angle.
@@ -469,7 +472,7 @@
* for axes that were not properly defined.
*/
public static final DefaultCoordinateSystemAxis UNDEFINED = create("Undefined", "m",
- AxisDirection.UNSPECIFIED, Units.UNITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
+ AxisDirections.UNSPECIFIED, Units.UNITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
* Creates a new axis of the given name, abbreviation, direction and unit.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
index 4b8a95d..3a6b058 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
@@ -113,7 +113,6 @@
* with axes of legacy (WKT 1) axes.
*/
@Test
- @SuppressWarnings("deprecation")
public void testSortWKT1() {
assertOrdered(new AxisDirection[] {
AxisDirection.OTHER,
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/BursaWolfParametersTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
index 7a1f3d3..a97e6cd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
@@ -31,8 +31,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
index 374c984..e457d99 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
@@ -48,8 +48,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.referencing.Assertions.assertRemarksEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
index dc6845d..96a022b 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
@@ -37,10 +37,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.referencing.ObjectDomain.*;
-import static org.opengis.referencing.IdentifiedObject.*;
-import static org.opengis.test.Assertions.assertIdentifierEquals;
+// Specific to the main branch:
+import static org.opengis.referencing.ReferenceSystem.*;
+import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
index 5a2241f..ae7c354 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
@@ -38,8 +38,9 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.referencing.Assertions.assertRemarksEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import java.lang.reflect.Field;
+import org.opengis.referencing.datum.VerticalDatumType;
/**
@@ -47,7 +48,6 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-@SuppressWarnings("deprecation")
public final class DefaultVerticalDatumTest extends TestCase {
/**
* Creates a new test case.
@@ -69,12 +69,40 @@
}
/**
+ * Tests the {@link DefaultVerticalDatum#getVerticalDatumType()} method in a state
+ * simulating unmarshalling of GML 3.2 document.
+ *
+ * @throws NoSuchFieldException Should never happen.
+ * @throws IllegalAccessException Should never happen.
+ */
+ @Test
+ public void testAfterUnmarshal() throws NoSuchFieldException, IllegalAccessException {
+ final Field typeField = DefaultVerticalDatum.class.getDeclaredField("type");
+ typeField.setAccessible(true);
+ assertEquals(VerticalDatumType .GEOIDAL, typeForName(typeField, "Geoidal height"));
+ assertEquals(VerticalDatumType .DEPTH, typeForName(typeField, "Some depth measurement"));
+ assertEquals(VerticalDatumTypes.ellipsoidal(), typeForName(typeField, "Ellipsoidal height"));
+ assertEquals(VerticalDatumType .OTHER_SURFACE, typeForName(typeField, "NotADepth"));
+ }
+
+ /**
+ * Returns the vertical datum type inferred by {@link DefaultVerticalDatum} for the given name.
+ */
+ private static VerticalDatumType typeForName(final Field typeField, final String name) throws IllegalAccessException {
+ final var datum = new DefaultVerticalDatum(
+ Map.of(DefaultVerticalDatum.NAME_KEY, name),
+ VerticalDatumType.OTHER_SURFACE);
+ typeField.set(datum, null);
+ return datum.getVerticalDatumType();
+ }
+
+ /**
* Tests {@link DefaultVerticalDatum#toWKT()}.
*/
@Test
public void testToWKT() {
DefaultVerticalDatum datum;
- datum = new DefaultVerticalDatum(Map.of(DefaultVerticalDatum.NAME_KEY, "Geoidal"), RealizationMethod.GEOID);
+ datum = new DefaultVerticalDatum(Map.of(DefaultVerticalDatum.NAME_KEY, "Geoidal"), VerticalDatumType.GEOIDAL);
assertWktEquals(Convention.WKT1, "VERT_DATUM[“Geoidal”, 2005]", datum);
assertWktEquals(Convention.WKT2, "VDATUM[“Geoidal”]", datum);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "VerticalDatum[“Geoidal”]", datum);
@@ -94,7 +122,11 @@
public void testXML() throws JAXBException {
final DefaultVerticalDatum datum = unmarshalFile(DefaultVerticalDatum.class, openTestFile(false));
assertIsMeanSeaLevel(datum, true);
- assertTrue(datum.getRealizationMethod().isEmpty());
+ /*
+ * Following attribute does not exist in GML 3.2, so it has been inferred.
+ * Our datum name is "Mean Sea Level", which is mapped to the geoidal type.
+ */
+ assertEquals(VerticalDatumType.GEOIDAL, datum.getVerticalDatumType());
/*
* Values in the following tests are specific to our XML file.
* The actual texts in the EPSG database are more descriptive.
@@ -126,7 +158,7 @@
/*
* Following attribute exists in GML 3.1 only.
*/
- assertEquals(RealizationMethod.GEOID, datum.getRealizationMethod().orElse(null));
+ assertEquals(VerticalDatumType.GEOIDAL, datum.getVerticalDatumType());
/*
* The name, anchor definition and domain of validity are lost because
* those property does not have the same XML element name (SIS-160).
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/GeodeticDatumMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/GeodeticDatumMock.java
index ba97fe6..b837b89 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/GeodeticDatumMock.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/GeodeticDatumMock.java
@@ -27,6 +27,11 @@
// Test dependencies
import org.apache.sis.test.mock.IdentifiedObjectMock;
+// Specific to the main branch:
+import java.util.Date;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.extent.Extent;
+
/**
* A dummy implementation of {@link GeodeticDatum}, which is also its own ellipsoid.
@@ -120,12 +125,16 @@
return new Object[] {getCode(), alias, semiMajorAxis, semiMinorAxis, inverseFlattening, isIvfDefinitive};
}
- @Override public PrimeMeridian getPrimeMeridian() {return PrimeMeridianMock.GREENWICH;}
- @Override public Ellipsoid getEllipsoid() {return this;}
- @Override public Unit<Length> getAxisUnit() {return Units.METRE;}
- @Override public double getSemiMajorAxis() {return semiMajorAxis;}
- @Override public double getSemiMinorAxis() {return semiMinorAxis;}
- @Override public double getInverseFlattening() {return inverseFlattening;}
- @Override public boolean isSphere() {return semiMajorAxis == semiMinorAxis;}
- @Override public boolean isIvfDefinitive() {return isIvfDefinitive;}
+ @Override public PrimeMeridian getPrimeMeridian() {return PrimeMeridianMock.GREENWICH;}
+ @Override public Ellipsoid getEllipsoid() {return this;}
+ @Override public Unit<Length> getAxisUnit() {return Units.METRE;}
+ @Override public double getSemiMajorAxis() {return semiMajorAxis;}
+ @Override public double getSemiMinorAxis() {return semiMinorAxis;}
+ @Override public double getInverseFlattening() {return inverseFlattening;}
+ @Override public boolean isSphere() {return semiMajorAxis == semiMinorAxis;}
+ @Override public boolean isIvfDefinitive() {return isIvfDefinitive;}
+ @Override public InternationalString getAnchorPoint() {return null;}
+ @Override public Date getRealizationEpoch() {return null;}
+ @Override public Extent getDomainOfValidity() {return null;}
+ @Override public InternationalString getScope() {return null;}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java
index 182f209..add1c0f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java
@@ -30,10 +30,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.PixelInCell;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
-import static org.opengis.referencing.IdentifiedObject.*;
-import static org.opengis.referencing.ObjectDomain.*;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
+import static org.opengis.referencing.datum.Datum.*;
/**
@@ -128,10 +127,9 @@
/**
* Mean sea level, which can be used as an approximation of geoid.
*/
- @SuppressWarnings("deprecation")
public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum(
properties("Mean Sea Level", "5100", "Hydrography."),
- RealizationMethod.GEOID);
+ VerticalDatumType.GEOIDAL);
/**
* Default datum for time measured since January 1st, 1970 at 00:00 UTC.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/TimeDependentBWPTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
index 662d942..9aca865 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
@@ -30,8 +30,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
index d913f06..0720e17 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
@@ -129,7 +129,6 @@
* @throws FactoryException if the creation failed for another reason.
*/
@Override
- @SuppressWarnings("removal")
public IdentifiedObject createObject(final String code) throws FactoryException {
assertFalse(isClosed());
final int n;
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
index 2a258c9..516817a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
@@ -53,8 +53,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEqualsRegex;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -403,7 +403,7 @@
"\\E(?: SCOPE\\[“.+”\\],\n)?\\Q" + // Ignore SCOPE[…] if present.
" AREA[“World\\E.*\\Q”],\n" +
" BBOX[-90.00, -180.00, 90.00, 180.00],\n" +
- " ID[“CRS”, 84, CITATION[“OGC:WMS”], URI[“urn:ogc:def:crs:OGC:1.3:CRS84”]]" +
+ " ID[“CRS”, 84, CITATION[“WMS”], URI[“urn:ogc:def:crs:OGC:1.3:CRS84”]]" +
"\\E(?:,\n REMARK\\[“.+”\\])?\\]", // Ignore trailing REMARK[…] if present.
crs);
/*
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
deleted file mode 100644
index 762cad6..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.referencing.factory;
-
-import java.util.Map;
-import javax.measure.Unit;
-import javax.measure.quantity.Angle;
-import javax.measure.quantity.Length;
-import org.opengis.util.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.cs.CSFactory;
-import org.opengis.referencing.cs.CartesianCS;
-import org.opengis.referencing.cs.EllipsoidalCS;
-import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.crs.CRSFactory;
-import org.opengis.referencing.crs.GeodeticCRS;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.crs.ProjectedCRS;
-import org.opengis.referencing.datum.DatumFactory;
-import org.opengis.referencing.datum.Ellipsoid;
-import org.opengis.referencing.datum.PrimeMeridian;
-import org.opengis.referencing.datum.GeodeticDatum;
-import org.opengis.referencing.operation.OperationMethod;
-import org.opengis.referencing.operation.Conversion;
-import org.opengis.parameter.ParameterValueGroup;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.referencing.MultiRegisterOperations;
-import org.apache.sis.referencing.operation.DefaultConversion;
-import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
-import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.measure.Units;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.opengis.test.referencing.ObjectFactoryTest;
-import org.apache.sis.test.FailureDetailsReporter;
-import static org.apache.sis.referencing.Assertions.assertWktEquals;
-import static org.apache.sis.test.Assertions.assertMessageContains;
-
-
-/**
- * Tests {@link GeodeticObjectFactory} using the suite of tests provided in the GeoAPI project.
- * Note that this does not include authority factories tests or GIGS tests.
- *
- * @author Cédric Briançon (Geomatys)
- */
-@ExtendWith(FailureDetailsReporter.class)
-public final class GeodeticObjectFactoryTest extends ObjectFactoryTest {
- /**
- * Creates a new test suite using the singleton factory instance.
- */
- public GeodeticObjectFactoryTest() {
- super(MultiRegisterOperations.provider());
- }
-
- /**
- * Tests {@link GeodeticObjectFactory#createFromWKT(String)}. We test only a very small WKT here because
- * it is not the purpose of this class to test the parser. The main purpose of this test is to verify
- * that {@link GeodeticObjectFactory} has been able to instantiate the parser.
- *
- * @throws FactoryException if the parsing failed.
- */
- @Test
- public void testCreateFromWKT() throws FactoryException {
- final CRSFactory crsFactory = factories.getFactory(CRSFactory.class).orElseThrow();
- final GeodeticCRS crs = (GeodeticCRS) crsFactory.createFromWKT(
- "GEOGCS[“WGS 84”,\n" +
- " DATUM[“World Geodetic System 1984”,\n" +
- " SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
- " PRIMEM[“Greenwich”, 0.0],\n" +
- " UNIT[“degree”, 0.017453292519943295]]");
-
- assertEquals("WGS 84", crs.getName().getCode());
- assertEquals("World Geodetic System 1984", crs.getDatum().getName().getCode());
- }
-
- /**
- * Tests {@link GeodeticObjectFactory#createFromWKT(String)} with an erroneous projection parameter name.
- * The intent is to verify that the expected exception is thrown.
- *
- * @throws FactoryException if the parsing failed for another reason than the expected one.
- */
- @Test
- public void testInvalidParameterInWKT() throws FactoryException {
- final CRSFactory crsFactory = factories.getFactory(CRSFactory.class).orElseThrow();
- var e = assertThrows(InvalidGeodeticParameterException.class,
- () -> crsFactory.createFromWKT(
- "PROJCRS[“Custom”,\n" +
- " BASEGEODCRS[“North American 1983”,\n" +
- " DATUM[“North American 1983”,\n" +
- " ELLIPSOID[“GRS 1980”, 6378137, 298.257222101]]],\n" +
- " CONVERSION[“Custom”,\n" +
- " METHOD[“Lambert Conformal Conic”],\n" +
- " PARAMETER[“Standard parallel 1”, 43.0],\n" +
- " PARAMETER[“Standard parallel 2”, 45.5],\n" +
- " PARAMETER[“Central parallel”, 41.75]],\n" + // Wrong parameter.
- " CS[Cartesian, 2],\n" +
- " AXIS[“(Y)”, north],\n" +
- " AXIS[“(X)”, east]]"),
- "Should not have parsed a WKT with wrong projection parameter.");
- assertMessageContains(e, "Central parallel");
- }
-
- /**
- * Convenience method creating a map with only the "{@code name"} property.
- * This is the only mandatory property for object creation.
- */
- private static Map<String,?> name(final String name) {
- return Map.of(IdentifiedObject.NAME_KEY, name);
- }
-
- /**
- * Tests step-by-step the creation of a new projected coordinate reference systems.
- * This test creates every objects itself and compares with expected WKT 1 after each step.
- *
- * <p>Note that practical applications may use existing constants declared in the
- * {@link CommonCRS} class instead of creating everything like this test does.</p>
- *
- * @throws FactoryException if the creation of a geodetic component failed.
- */
- @Test
- public void testStepByStepCreation() throws FactoryException {
- final CRSFactory crsFactory = factories.getFactory(CRSFactory.class).orElseThrow();
- final CSFactory csFactory = factories.getFactory(CSFactory.class).orElseThrow();
- final DatumFactory datumFactory = factories.getFactory(DatumFactory.class).orElseThrow();
- /*
- * List of all objects to be created in this test.
- */
- final Unit<Length> linearUnit;
- final Unit<Angle> angularUnit;
- final Ellipsoid ellipsoid;
- final PrimeMeridian meridian;
- final GeodeticDatum datum;
- final CoordinateSystemAxis longitude, latitude, easting, northing;
- final EllipsoidalCS geographicCS;
- final GeographicCRS geographicCRS;
- final OperationMethod method;
- final ParameterValueGroup parameters;
- final Conversion projection;
- final CartesianCS projectedCS;
- final ProjectedCRS projectedCRS;
- /*
- * Prime meridian
- */
- angularUnit = Units.DEGREE;
- meridian = datumFactory.createPrimeMeridian(name("Greenwich"), 0, angularUnit);
- assertWktEquals(Convention.WKT1,
- "PRIMEM[“Greenwich”, 0.0]", meridian);
- /*
- * Ellipsoid
- */
- linearUnit = Units.METRE;
- ellipsoid = datumFactory.createEllipsoid(name("Airy1830"), 6377563.396, 6356256.910, linearUnit);
- assertWktEquals(Convention.WKT1,
- "SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]", ellipsoid);
- /*
- * Geodetic reference frame
- */
- datum = datumFactory.createGeodeticDatum(name("Airy1830"), ellipsoid, meridian);
- assertWktEquals(Convention.WKT1,
- "DATUM[“Airy1830”,\n" +
- " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]]", datum);
- /*
- * Base coordinate reference system
- */
- longitude = csFactory.createCoordinateSystemAxis(name("Longitude"), "long", AxisDirection.EAST, angularUnit);
- latitude = csFactory.createCoordinateSystemAxis(name("Latitude"), "lat", AxisDirection.NORTH, angularUnit);
- geographicCS = csFactory.createEllipsoidalCS(name("Ellipsoidal"), longitude, latitude);
- geographicCRS = crsFactory.createGeographicCRS(name("Airy1830"), datum, geographicCS);
- assertWktEquals(Convention.WKT1,
- "GEOGCS[“Airy1830”,\n" +
- " DATUM[“Airy1830”,\n" +
- " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]],\n" +
- " PRIMEM[“Greenwich”, 0.0],\n" +
- " UNIT[“degree”, 0.017453292519943295],\n" +
- " AXIS[“Longitude”, EAST],\n" +
- " AXIS[“Latitude”, NORTH]]", geographicCRS);
- /*
- * Defining conversion
- */
- method = DefaultMathTransformFactory.provider().getOperationMethod("Transverse_Mercator");
- parameters = method.getParameters().createValue();
- parameters.parameter("semi_major") .setValue(ellipsoid.getSemiMajorAxis());
- parameters.parameter("semi_minor") .setValue(ellipsoid.getSemiMinorAxis());
- parameters.parameter("central_meridian") .setValue( 49);
- parameters.parameter("latitude_of_origin").setValue( -2);
- parameters.parameter("false_easting") .setValue( 400000);
- parameters.parameter("false_northing") .setValue(-100000);
- projection = new DefaultConversion(name("GBN grid"), method, null, parameters);
- /*
- * Projected coordinate reference system
- */
- easting = csFactory.createCoordinateSystemAxis(name("Easting"), "x", AxisDirection.EAST, linearUnit);
- northing = csFactory.createCoordinateSystemAxis(name("Northing"), "y", AxisDirection.NORTH, linearUnit);
- projectedCS = csFactory.createCartesianCS(name("Cartesian"), easting, northing);
- projectedCRS = crsFactory.createProjectedCRS(name("Great_Britian_National_Grid"), geographicCRS, projection, projectedCS);
- assertWktEquals(Convention.WKT1,
- "PROJCS[“Great_Britian_National_Grid”,\n" +
- " GEOGCS[“Airy1830”,\n" +
- " DATUM[“Airy1830”,\n" +
- " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]],\n" +
- " PRIMEM[“Greenwich”, 0.0],\n" +
- " UNIT[“degree”, 0.017453292519943295],\n" +
- " AXIS[“Longitude”, EAST],\n" +
- " AXIS[“Latitude”, NORTH]],\n" +
- " PROJECTION[“Transverse_Mercator”, AUTHORITY[“EPSG”, “9807”]],\n" +
- " PARAMETER[“latitude_of_origin”, -2.0],\n" +
- " PARAMETER[“central_meridian”, 49.0],\n" +
- " PARAMETER[“scale_factor”, 1.0],\n" +
- " PARAMETER[“false_easting”, 400000.0],\n" +
- " PARAMETER[“false_northing”, -100000.0],\n" +
- " UNIT[“metre”, 1],\n" +
- " AXIS[“Easting”, EAST],\n" +
- " AXIS[“Northing”, NORTH]]", projectedCRS);
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
index eb7371b..a9e6519 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
@@ -30,6 +30,9 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
+// Specific to the main branch:
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
+
/**
* Tests {@link IdentifiedObjectFinder}.
@@ -75,7 +78,7 @@
*/
final CoordinateReferenceSystem search = new DefaultGeographicCRS(
Map.of(DefaultGeographicCRS.NAME_KEY, CRS84.getName()),
- CRS84.getDatum(), CRS84.getDatumEnsemble(), CRS84.getCoordinateSystem());
+ CRS84.getDatum(), getDatumEnsemble(CRS84), CRS84.getCoordinateSystem());
assertEqualsIgnoreMetadata(CRS84, search); // Required condition for next test.
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
index 3c090e0..6494590 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
@@ -29,8 +29,8 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertBetween;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
index 6543f29..03cb8f7 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
@@ -69,8 +69,8 @@
import static org.apache.sis.referencing.Assertions.assertAliasTipEquals;
import static org.apache.sis.test.TestCase.TAG_SLOW;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
@@ -167,7 +167,7 @@
@Test
public void testGeocentric() throws FactoryException {
final EPSGFactory factory = dataEPSG.factory();
- final GeodeticCRS crs = factory.createGeodeticCRS("epsg:4915");
+ final GeodeticCRS crs = factory.createGeocentricCRS("epsg:4915");
assertEpsgNameAndIdentifierEqual("ITRF93", 4915, crs);
assertEpsgNameAndIdentifierEqual("International Terrestrial Reference Frame 1993", 6652, crs.getDatum());
assertAxisDirectionsEqual(crs.getCoordinateSystem(), AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/AuthorityFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/AuthorityFactoryTest.java
deleted file mode 100644
index f86c126..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/AuthorityFactoryTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.referencing.geoapi;
-
-import org.opengis.util.FactoryException;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.MultiRegisterOperations;
-
-// Test dependencies
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.apache.sis.test.FailureDetailsReporter;
-
-
-/**
- * Runs the suite of transformation tests provided in the GeoAPI project.
- * The test suite uses the authority factory instance registered in {@link CRS}.
- * Some (not all) of those tests require the EPSG geodetic database to be installed.
- * If that database is not available, tests that cannot be executed will be automatically skipped.
- *
- * @author Cédric Briançon (Geomatys)
- * @author Martin Desruisseaux (Geomatys)
- * @version 1.4
- * @since 1.1
- */
-@ExtendWith(FailureDetailsReporter.class)
-public final class AuthorityFactoryTest extends org.opengis.test.referencing.AuthorityFactoryTest {
- /**
- * Creates a new test suite using the singleton factory instance.
- *
- * @throws FactoryException if no factory can be returned for the given authority.
- */
- public AuthorityFactoryTest() throws FactoryException {
- super(MultiRegisterOperations.provider());
- }
-
- /**
- * Skips for now the <cite>Krovak</cite> projection.
- */
- @Override
- @Disabled("Projection not yet implemented")
- public void testEPSG_2065() {
- }
-
- /**
- * Skips for now the <cite>Lambert Azimuthal Equal Area</cite> projection.
- */
- @Override
- @Disabled("Projection not yet implemented")
- public void testEPSG_3035() {
- }
-
- /**
- * Skips for now the <cite>Hyperbolic Cassini-Soldner</cite> projection
- * because projection derivative (Jacobian matrix) is not yet implemented.
- */
- @Override
- @Disabled("Derivative (Jacobian) not yet implemented")
- public void testEPSG_3139() {
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/ParameterizedTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/ParameterizedTransformTest.java
deleted file mode 100644
index a9c8a40..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/geoapi/ParameterizedTransformTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.referencing.geoapi;
-
-import org.opengis.util.FactoryException;
-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.DefaultMathTransformFactory;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.AfterEach;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.apache.sis.test.FailureDetailsReporter;
-
-
-/**
- * Runs a suite of tests provided in the GeoAPI project.
- *
- * @author Martin Desruisseaux (Geomatys)
- * @version 1.4
- * @since 1.1
- */
-@ExtendWith(FailureDetailsReporter.class)
-public final class ParameterizedTransformTest extends org.opengis.test.referencing.ParameterizedTransformTest {
- /**
- * Creates a new test suite using the singleton factory instance.
- */
- public ParameterizedTransformTest() {
- super(DefaultMathTransformFactory.provider());
- }
-
- /**
- * Every map projections shall be instances of {@link MathTransform2D}.
- * Note that some tests inherited from the parent class are not about
- * map projections.
- */
- @AfterEach
- public void ensureMathTransform2D() {
- final MathTransform tr = transform;
- if (tr != null && tr.getSourceDimensions() == 2 && tr.getTargetDimensions() == 2) {
- assertInstanceOf(MathTransform2D.class, tr);
- }
- }
-
- /**
- * Disables the derivative (Jacobian) tests because not yet implemented.
- *
- * @throws FactoryException if the math transform cannot be created.
- * @throws TransformException if the example point cannot be transformed.
- */
- @Test
- @Override
- public void testModifiedAzimuthalEquidistant() throws FactoryException, TransformException {
- isDerivativeSupported = false;
- super.testModifiedAzimuthalEquidistant();
- }
-
- /**
- * Disables the derivative (Jacobian) tests because not yet implemented.
- *
- * @throws FactoryException if the math transform cannot be created.
- * @throws TransformException if the example point cannot be transformed.
- */
- @Test
- @Override
- public void testHyperbolicCassiniSoldner() throws FactoryException, TransformException {
- isDerivativeSupported = false;
- super.testHyperbolicCassiniSoldner();
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/ParameterizedTransformBuilderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/ParameterizedTransformBuilderTest.java
index daa49c5..86ce08c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/ParameterizedTransformBuilderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/ParameterizedTransformBuilderTest.java
@@ -30,8 +30,8 @@
import org.apache.sis.referencing.cs.HardCodedCS;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
index 0a167b5..b0692cb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
@@ -27,16 +27,12 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.datum.VerticalDatumType;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.RealizationMethod;
-
/**
* Tests the {@link VerticalDatumTypes} class.
*
* @author Martin Desruisseaux (Geomatys)
*/
-@SuppressWarnings("deprecation")
public final class VerticalDatumTypesTest extends TestCase {
/**
* Creates a new test case.
@@ -47,7 +43,7 @@
/**
* Verifies name constraint with values defined in {@link org.apache.sis.referencing.CommonCRS.Vertical}.
* Some enumeration values must have the same names as the constants defined in {@link VerticalDatumTypes},
- * because the realization method is obtained by a call to {@link RealizationMethod#valueOf(String)}.
+ * because the realization method is obtained by a call to {@link VerticalDatumType#valueOf(String)}.
*/
@Test
public void verifyNameConstraint() {
@@ -61,8 +57,8 @@
@Test
public void testFromLegacyCode() {
assertEquals(VerticalDatumTypes.ellipsoidal(), VerticalDatumTypes.fromLegacyCode(2002));
- assertEquals(RealizationMethod .GEOID, VerticalDatumTypes.fromLegacyCode(2005));
- assertEquals(RealizationMethod .TIDAL, VerticalDatumTypes.fromLegacyCode(2006));
+ assertEquals(VerticalDatumType .GEOIDAL, VerticalDatumTypes.fromLegacyCode(2005));
+ assertEquals(VerticalDatumType .DEPTH, VerticalDatumTypes.fromLegacyCode(2006));
}
/**
@@ -82,10 +78,9 @@
*/
@Test
public void testFromMethod() {
- assertEquals(RealizationMethod .LEVELLING, VerticalDatumTypes.fromMethod("Levelling-based"));
- assertEquals(RealizationMethod .GEOID, VerticalDatumTypes.fromMethod("Geoid-based"));
- assertEquals(RealizationMethod .TIDAL, VerticalDatumTypes.fromMethod("Tidal"));
- assertEquals(VerticalDatumTypes.LOCAL, VerticalDatumTypes.fromMethod("Local").name());
+ assertEquals(VerticalDatumType.GEOIDAL, VerticalDatumTypes.fromMethod("Geoid-based"));
+ assertEquals(VerticalDatumType.DEPTH, VerticalDatumTypes.fromMethod("Tidal"));
+ assertTrue(VerticalDatumTypes.LOCAL.equalsIgnoreCase(VerticalDatumTypes.fromMethod("Local").name()));
}
/**
@@ -93,9 +88,9 @@
*/
@Test
public void verifyCodeList() {
- final RealizationMethod expected = VerticalDatumTypes.ellipsoidal(); // Must be first.
- final RealizationMethod[] types = RealizationMethod.values();
- assertEquals(RealizationMethod.LEVELLING, types[0]);
+ final VerticalDatumType expected = VerticalDatumTypes.ellipsoidal(); // Must be first.
+ final VerticalDatumType[] types = VerticalDatumType.values();
+ assertEquals(VerticalDatumType.OTHER_SURFACE, types[0]);
assertTrue(ArraysExt.contains(types, expected));
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
index 2961eb7..3f70ef2 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
@@ -74,8 +74,8 @@
import static org.apache.sis.test.Assertions.assertSetEquals;
import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
+// Specific to the main branch:
+import org.apache.sis.test.GeoapiAssert;
/**
@@ -161,7 +161,7 @@
* Verifies that the current transform is a linear transform with a matrix equals to the given one.
*/
private void assertMatrixEquals(final Matrix expected) {
- Assertions.assertMatrixEquals(expected,
+ GeoapiAssert.assertMatrixEquals(expected,
assertInstanceOf(LinearTransform.class, transform).getMatrix(),
STRICT, "transform.matrix");
}
@@ -299,6 +299,7 @@
if (targetCRS.getCoordinateSystem().getDimension() == 2) {
target = TestUtilities.dropLastDimensions(target, 3, 2);
}
+ tolerance = zTolerance; // Because GeoAPI 3.0 does not distinguish z axis from other axes (fixed in GeoAPI 3.1).
verifyTransform(source, target);
validate();
}
@@ -1011,7 +1012,7 @@
final var linear = assertInstanceOf(LinearTransform.class, transform);
assertEquals(3, linear.getSourceDimensions());
assertEquals(4, linear.getTargetDimensions());
- Assertions.assertMatrixEquals(Matrices.create(5, 4, new double[] {
+ GeoapiAssert.assertMatrixEquals(Matrices.create(5, 4, new double[] {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0, 0,
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
index d6c33c5..46c5143 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
@@ -46,8 +46,8 @@
import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -266,6 +266,7 @@
zTolerance = Formulas.LINEAR_TOLERANCE;
zDimension = new int[] {2};
λDimension = new int[] {1};
+ tolerance = zTolerance; // Because GeoAPI 3.0 does not distinguish z axis from other axes (fixed in GeoAPI 3.1).
verifyTransform(new double[] {54.271680278, 0.098269657, 20.00}, // in grads east of Paris
new double[] {48.844443528, 2.424952028, 63.15}); // in degrees east of Greenwich
validate();
@@ -300,6 +301,7 @@
zTolerance = Formulas.LINEAR_TOLERANCE;
zDimension = new int[] {2};
λDimension = new int[] {1};
+ tolerance = zTolerance; // Because GeoAPI 3.0 does not distinguish z axis from other axes (fixed in GeoAPI 3.1).
verifyTransform(new double[] {0.088442691, 48.844512250, 20.00}, // in degrees east of Paris
new double[] {2.424952028, 48.844443528, 63.15}); // in degrees east of Greenwich
validate();
@@ -355,7 +357,7 @@
private static void assertEpsgNameWithoutIdentifierEqual(final String name, final IdentifiedObject object) {
assertNotNull(object, name);
assertEquals(name, object.getName().getCode(), "name");
- for (final Identifier id : object.getIdentifiers()) {
+ for (final ReferenceIdentifier id : object.getIdentifiers()) {
assertFalse("EPSG".equalsIgnoreCase(id.getCodeSpace()), "EPSG identifier not allowed for modified objects.");
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
index 440eb63..17f016e 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
@@ -39,8 +39,8 @@
import static org.apache.sis.referencing.Assertions.assertWktEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertIdentifierEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
index 8f4124d..c1b5d8b 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
@@ -50,8 +50,9 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.pending.geoapi.referencing.MissingMethods.getDatumEnsemble;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -101,7 +102,7 @@
final var source = (GeodeticCRS) crs;
return new DefaultGeographicCRS(
Map.of(DefaultGeographicCRS.NAME_KEY, crs.getName()),
- source.getDatum(), source.getDatumEnsemble(), cs);
+ source.getDatum(), getDatumEnsemble(source), cs);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
index ddf0677..6891d1a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
@@ -37,6 +37,9 @@
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Tests {@link DefaultOperationMethod}.
@@ -64,7 +67,7 @@
{
final Map<String,Object> properties = new HashMap<>(8);
assertNull(properties.put(OperationMethod.NAME_KEY, method));
- assertNull(properties.put(Identifier.CODESPACE_KEY, "EPSG"));
+ assertNull(properties.put(ReferenceIdentifier.CODESPACE_KEY, "EPSG"));
assertNull(properties.put(Identifier.AUTHORITY_KEY, Citations.EPSG));
/*
* The parameter group for a Mercator projection is actually not empty, but it is not the purpose of
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java
index 5f2dda1..c99c4aa 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java
@@ -31,8 +31,8 @@
import org.apache.sis.xml.test.TestCase;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertIdentifierEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
index a7d05b2..1cc9107 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
@@ -51,9 +51,9 @@
import static org.apache.sis.test.TestUtilities.getDomainOfValidity;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertIdentifierEquals;
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -156,7 +156,7 @@
assertEquals("World Mercator", c.getName().getCode(), "name");
assertEquals("3395", getSingleton(c.getIdentifiers()).getCode(), "identifier");
assertEquals("Very small scale mapping.", getScope(c), "scope");
- assertNull(c.getOperationVersion(), "operationVersion");
+ assertNull (c.getOperationVersion(), "operationVersion");
final GeographicBoundingBox e = getDomainOfValidity(c);
assertEquals(+180, e.getEastBoundLongitude(), "eastBoundLongitude");
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java
index 37be602..56fb1b3 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java
@@ -37,8 +37,8 @@
import org.apache.sis.referencing.operation.HardCodedConversions;
import static org.apache.sis.test.Assertions.assertMapEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java
index 670ba90..de4f7c1 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java
@@ -29,8 +29,8 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.operation.HardCodedConversions;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -72,7 +72,7 @@
var expected = new Matrix3(111319, 0, 0,
0, 110662, -62,
0, 0, 1);
- Assertions.assertMatrixEquals(expected, linear.getMatrix(), 0.5, "linear");
+ assertMatrixEquals(expected, linear.getMatrix(), 0.5, "linear");
assertSame(points.create(null), linear, "Should have extracted the existing instance instead of computing a new one.");
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/ResidualGridTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/ResidualGridTest.java
index 856ab06..3c1d996 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/ResidualGridTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/ResidualGridTest.java
@@ -26,8 +26,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatricesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatricesTest.java
index 252ae88..693e837 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatricesTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatricesTest.java
@@ -35,8 +35,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/Matrix4Test.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
index e9a1bfe..9a4aa87 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
@@ -23,8 +23,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
index e94d7d1..504093a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
@@ -31,8 +31,8 @@
import org.apache.sis.test.TestUtilities;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
index bc37b79..5b280b7 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
@@ -25,8 +25,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
index 542d09c..a403a6a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
@@ -27,9 +27,6 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.ToleranceModifier;
-
/**
* Tests the {@link AlbersEqualArea} class. We test using various values of standard parallels.
@@ -74,7 +71,6 @@
final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres.
derivativeDeltas = new double[] {delta, delta};
- toleranceModifier = ToleranceModifier.PROJECTION;
tolerance = Formulas.LINEAR_TOLERANCE;
final AlbersEqualArea kernel = (AlbersEqualArea) getKernel();
assertTrue(isSpherical(kernel));
@@ -122,7 +118,6 @@
final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres.
derivativeDeltas = new double[] {delta, delta};
- toleranceModifier = ToleranceModifier.PROJECTION;
tolerance = Formulas.LINEAR_TOLERANCE;
final AlbersEqualArea kernel = (AlbersEqualArea) getKernel();
assertFalse(isSpherical(kernel));
@@ -161,7 +156,6 @@
*/
@Test
public void compareWithPROJ() throws FactoryException, TransformException {
- toleranceModifier = ToleranceModifier.PROJECTION;
tolerance = Formulas.LINEAR_TOLERANCE;
// Spherical case
@@ -212,7 +206,6 @@
0); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
verifyTransform(new double[] {0, 0,
0, +90,
0, -90},
@@ -242,7 +235,6 @@
200); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres.
derivativeDeltas = new double[] {delta, delta};
verifyInDomain(new double[] {-40, 10}, // Minimal input coordinate values
@@ -288,7 +280,6 @@
NaN); // False northing (none)
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
/*
* Skip inverse transform because the 176.003° become -183.997°. It is not the purpose
* of this test to verify longitude wraparound in reverse projection (we do not expect
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CassiniSoldnerTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CassiniSoldnerTest.java
index 9a89d60..289b922 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CassiniSoldnerTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CassiniSoldnerTest.java
@@ -189,32 +189,4 @@
verifyDerivative(toRadians(+3), toRadians(-10));
verifyDerivative(toRadians(-4), toRadians(+10));
}
-
- /**
- * Tests the <q>Cassini-Soldner</q> (EPSG:9806) projection method.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testCassiniSoldner()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(method(false)).testCassiniSoldner();
- }
-
- /**
- * Tests the <q>Hyperbolic Cassini-Soldner</q> (EPSG:9833) projection method.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testHyperbolicCassiniSoldner()
- */
- @Test
- public void runGeoapiHyperbolicTest() throws FactoryException, TransformException {
- createGeoApiTestNoDerivatives(method(true)).testHyperbolicCassiniSoldner();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
index 04bca36..72a16dd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
@@ -193,13 +193,6 @@
return projection.dy_dφ(sinφ, cos(φ)) * transform(φ);
}
};
- isInverseTransformSupported = false;
- derivativeDeltas = new double[] {2E-8};
- tolerance = 1E-7;
- verifyInDomain(new double[] {-89 * (PI/180)}, // Minimal value to test.
- new double[] {+89 * (PI/180)}, // Maximal value to test.
- new int[] {100}, // Number of points to test.
- TestUtilities.createRandomNumberGenerator());
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
index 6c81e7a..93aca82 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
@@ -28,9 +28,6 @@
// Test dependencies
import org.junit.jupiter.api.Test;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.ToleranceModifier;
-
/**
* Tests the {@link CylindricalEqualArea} class.
@@ -77,7 +74,6 @@
0, // False easting
0); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
final double λ = 2;
final double φ = 1;
final double x = 222638.98; // Test point from PROJ library.
@@ -106,7 +102,6 @@
0, // False easting
0); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
final double λ = 2;
final double φ = 1;
final double x = 222390.10; // Anti-regression values (not from an external source).
@@ -138,7 +133,6 @@
0, // False easting
0); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
final double λ = 2;
final double φ = 1;
final double x = 222390.10; // Anti-regression values (not from an external source).
@@ -169,7 +163,6 @@
200); // False northing
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres.
derivativeDeltas = new double[] {delta, delta};
verifyInDomain(CoordinateDomain.GEOGRAPHIC_SAFE, 0);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquidistantCylindricalTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquidistantCylindricalTest.java
index cf14b0a..8e02203 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquidistantCylindricalTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquidistantCylindricalTest.java
@@ -49,7 +49,6 @@
/**
* Tests the point given in EPSG example.
- * This is the same test as {@link #runGeoapiTest()} but is repeated here for easier debugging.
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
@@ -73,18 +72,4 @@
assertEquals(λ, p.x, Formulas.ANGULAR_TOLERANCE);
assertEquals(φ, p.y, Formulas.ANGULAR_TOLERANCE);
}
-
- /**
- * Tests the <q>Equidistant Cylindrical</q> (EPSG:1028) projection.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testEquidistantCylindrical()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(provider()).testEquidistantCylindrical();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertAzimuthalEqualAreaTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertAzimuthalEqualAreaTest.java
index bd44bff..fabb17c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertAzimuthalEqualAreaTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertAzimuthalEqualAreaTest.java
@@ -345,17 +345,4 @@
createProjection(false, 8, false);
verifyDerivative(toRadians(-6), toRadians(2));
}
-
- /**
- * Runs the test defined in the GeoAPI-conformance module.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testLambertAzimuthalEqualArea()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(provider(true)).testLambertAzimuthalEqualArea();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
index fae92fe..0efe429 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
@@ -37,8 +37,9 @@
import org.apache.sis.test.TestUtilities;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.referencing.operation.provider.LambertConformalMichigan;
+// Specific to the main branch:
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
/**
@@ -184,8 +185,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testLambertConicConformal1SP()
*/
@Test
public void testLambertConicConformal1SP() throws FactoryException, TransformException {
@@ -198,8 +197,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testLambertConicConformal1SP()
*/
@Test
public void testLambertConicConformal2SP() throws FactoryException, TransformException {
@@ -212,8 +209,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testLambertConicConformal1SP()
*/
@Test
public void testLambertConicConformalBelgium() throws FactoryException, TransformException {
@@ -226,12 +221,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testLambertConicConformalMichigan()
*/
@Test
public void testLambertConicConformalMichigan() throws FactoryException, TransformException {
- createGeoApiTest(new LambertConformalMichigan()).testLambertConicConformalMichigan();
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // Test not available in GeoAPI 3.0
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
index 2e91454..50b0ef7 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
@@ -40,9 +40,6 @@
import org.apache.sis.referencing.datum.GeodeticDatumMock;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.ParameterizedTransformTest;
-
/**
* Base class of map projection tests.
@@ -84,24 +81,8 @@
* @param provider the provider of the projection to test.
* @return the GeoAPI test class using the given provider.
*/
- static ParameterizedTransformTest createGeoApiTest(final MapProjection provider) {
- return new ParameterizedTransformTest(new MathTransformFactoryMock(provider));
- }
-
- /**
- * Instantiates the object to use for running GeoAPI test without derivative tests.
- *
- * @param provider the provider of the projection to test.
- * @return the GeoAPI test class using the given provider.
- */
- static ParameterizedTransformTest createGeoApiTestNoDerivatives(final MapProjection provider) {
- final class Tester extends ParameterizedTransformTest {
- Tester(final MapProjection provider) {
- super(new MathTransformFactoryMock(provider));
- isDerivativeSupported = false;
- }
- }
- return new Tester(provider);
+ static ParameterizedTransformTestMock createGeoApiTest(final MapProjection provider) {
+ return new ParameterizedTransformTestMock(new MathTransformFactoryMock(provider));
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java
index edf84fa..0de1b47 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java
@@ -37,10 +37,10 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.referencing.operation.transform.MathTransformFactoryMock;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.referencing.operation.provider.MercatorSpherical;
-import org.apache.sis.referencing.operation.provider.RegionalMercator;
-import static org.opengis.test.Assertions.assertBetween;
+// Specific to the main branch:
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
/**
@@ -185,8 +185,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercator1SP()
*/
@Test
public void testMercator1SP() throws FactoryException, TransformException {
@@ -199,8 +197,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercator2SP()
*/
@Test
public void testMercator2SP() throws FactoryException, TransformException {
@@ -213,12 +209,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercatorVariantC()
*/
@Test
public void testRegionalMercator() throws FactoryException, TransformException {
- createGeoApiTest(new RegionalMercator()).testMercatorVariantC();
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // Test not available in GeoAPI 3.0
}
/**
@@ -227,12 +221,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercatorSpherical()
*/
@Test
public void testMercatorSpherical() throws FactoryException, TransformException {
- createGeoApiTest(new MercatorSpherical()).testMercatorSpherical();
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // Test not available in GeoAPI 3.0
}
/**
@@ -241,8 +233,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testPseudoMercator()
*/
@Test
public void testPseudoMercator() throws FactoryException, TransformException {
@@ -255,8 +245,6 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testMiller()
*/
@Test
public void testMiller() throws FactoryException, TransformException {
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
index 5f27f61..c90b9cd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
@@ -74,20 +74,6 @@
}
/**
- * Tests the <q>Modified Azimuthal Equidistant</q> (EPSG:9832) projection method.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testModifiedAzimuthalEquidistant()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTestNoDerivatives(method()).testModifiedAzimuthalEquidistant();
- }
-
- /**
* Not yet supported.
*/
@Test
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/NormalizedProjectionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/NormalizedProjectionTest.java
index af16b32..323e947 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/NormalizedProjectionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/NormalizedProjectionTest.java
@@ -25,8 +25,8 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.apache.sis.test.FailureDetailsReporter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
+// Specific to the main branch:
+import org.apache.sis.referencing.operation.transform.TransformTestCase;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
index bbae27f..a77cb57 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
@@ -27,17 +27,12 @@
import org.junit.jupiter.api.Test;
import org.apache.sis.referencing.datum.HardCodedDatum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.FactoryException;
-import org.opengis.test.ToleranceModifier;
-
/**
* Tests the {@link ObliqueMercator} class.
*
* @author Martin Desruisseaux (Geomatys)
* @author Rémi Maréchal (Geomatys)
- * @author Emmanuel Giasson (Thales)
*/
public final class ObliqueMercatorTest extends MapProjectionTestCase {
/**
@@ -84,60 +79,4 @@
verifyDerivative(toRadians(15), toRadians(40));
verifyDerivative(toRadians(10), toRadians(60));
}
-
- /**
- * Tests with an azimuth of 90°.
- *
- * @throws TransformException if an error occurred while converting a point.
- */
- @Test
- public void testAzimuth90() throws TransformException {
- tolerance = 1E-9;
- transform = create(10, 20, 90);
- validate();
-
- final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres.
- derivativeDeltas = new double[] {delta, delta};
- verifyInverse(toRadians(15), toRadians(25));
- }
-
- /**
- * Tests with a latitude close to 90°.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while converting a point.
- *
- * <a href="https://issues.apache.org/jira/browse/SIS-532">SIS-532</a>
- */
- @Test
- public void testPole() throws TransformException, FactoryException {
- tolerance = 0.01;
- transform = create(179.8, 89.8, -174).createMapProjection(context(null, null));
- transform = transform.inverse();
- validate();
- /*
- * The projection of (180, 90) with SIS 1.1 is (+0.004715980030596256, 22338.795490272343).
- * Empirical cordinates shifted by 0.01 meter: (-0.005463426921067797, 22338.792057282844).
- * With those shifted coordinated, Apache SIS 1.1 was used to compute φ = NaN because the
- * U′ value in `ObliqueMercator.inverseTransform(…)` was slightly greater than 1.
- */
- isInverseTransformSupported = false;
- toleranceModifier = ToleranceModifier.GEOGRAPHIC;
- verifyTransform(new double[] {-0.005464, 22338.792057},
- new double[] {300, 90});
- }
-
- /**
- * Tests the <q>Hotine Oblique Mercator (variant B)</q> (EPSG:9815) projection method.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testHotineObliqueMercator()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(new ObliqueMercatorCenter()).testHotineObliqueMercator();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
index fb792d0..21ce377 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
@@ -31,8 +31,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.referencing.operation.matrix.Matrix2;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -220,20 +220,6 @@
}
/**
- * Tests the <cite>Oblique Stereographic</cite> case (EPSG:9809).
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testObliqueStereographic()
- */
- @Test
- public void testObliqueStereographic() throws FactoryException, TransformException {
- createGeoApiTest(new org.apache.sis.referencing.operation.provider.ObliqueStereographic()).testObliqueStereographic();
- }
-
- /**
* Tests consistency between forward and reverse projection using a point that was known to fail.
*
* @throws FactoryException if an error occurred while creating the map projection.
@@ -251,7 +237,7 @@
p.parameter("Longitude of natural origin").setValue(-70, Units.DEGREE);
createCompleteTransform(op, p);
tolerance = Formulas.ANGULAR_TOLERANCE;
- verifyInverse(30, 45);
+ verifyInverse(new double[] {30, 45});
}
/**
@@ -363,8 +349,7 @@
final Matrix derivative = spherical.transform(srcPts, 0, null, 0, true);
tolerance = 1E-12;
- assertMatrixEquals(reference, derivative, new Matrix2(tolerance, tolerance, tolerance, tolerance),
- "Spherical derivative");
+ assertMatrixEquals(reference, derivative, tolerance, "Spherical derivative");
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/OrthographicTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/OrthographicTest.java
index 3cbe5e5..2a658fd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/OrthographicTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/OrthographicTest.java
@@ -25,9 +25,6 @@
// Test dependencies
import org.junit.jupiter.api.Test;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.FactoryException;
-
/**
* Tests the {@link Orthographic} class.
@@ -149,18 +146,4 @@
verifyInDomain(CoordinateDomain.GEOGRAPHIC_RADIANS_SOUTH, 753524735);
verifyDerivative(toRadians(5), toRadians(-85));
}
-
- /**
- * Tests the <q>Orthographic</q> (EPSG:9840) projection method.
- * This test is defined in GeoAPI conformance test suite.
- *
- * @throws FactoryException if an error occurred while creating the map projection.
- * @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testOrthographic()
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(new org.apache.sis.referencing.operation.provider.Orthographic()).testOrthographic();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ParameterizedTransformTestMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ParameterizedTransformTestMock.java
new file mode 100644
index 0000000..ca6cdec
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ParameterizedTransformTestMock.java
@@ -0,0 +1,78 @@
+/*
+ * 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.referencing.operation.projection;
+
+import org.opengis.referencing.operation.MathTransformFactory;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
+
+
+/**
+ * Placeholder for a GeoAPI 3.1 method which was not available in GeoAPI 3.0.
+ * This placeholder does nothing. See Apache SIS JDK6 branch for a real test.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+final class ParameterizedTransformTestMock {
+ ParameterizedTransformTestMock(MathTransformFactory factory) {
+ // See GeoAPI 3.1 for real construction.
+ }
+
+ public void testMercator1SP() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testMercator2SP() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testPseudoMercator() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testMiller() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testLambertConicConformal1SP() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testLambertConicConformal2SP() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ public void testLambertConicConformalBelgium() {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
index 30707f9..90b68c1 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
@@ -120,12 +120,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testPolarStereographicA()
*/
@Test
public void testPolarStereographicA() throws FactoryException, TransformException {
- createGeoApiTest(new PolarStereographicA()).testPolarStereographicA();
+ new PolarStereographicA(); // Test creation only, as GeoAPI 3.0 did not yet had the test method.
}
/**
@@ -134,12 +132,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testPolarStereographicB()
*/
@Test
public void testPolarStereographicB() throws FactoryException, TransformException {
- createGeoApiTest(new PolarStereographicB()).testPolarStereographicB();
+ new PolarStereographicB(); // Test creation only, as GeoAPI 3.0 did not yet had the test method.
}
/**
@@ -148,12 +144,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testPolarStereographicC()
*/
@Test
public void testPolarStereographicC() throws FactoryException, TransformException {
- createGeoApiTest(new PolarStereographicC()).testPolarStereographicC();
+ new PolarStereographicC(); // Test creation only, as GeoAPI 3.0 did not yet had the test method.
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolyconicTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolyconicTest.java
index fbcba8d..c108ed5 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolyconicTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolyconicTest.java
@@ -140,15 +140,4 @@
verifyDerivative( -56, 50);
verifyDerivative( -20, 47);
}
-
- /**
- * Runs the test defined in the GeoAPI-conformance module.
- *
- * @throws FactoryException if the transform cannot be created.
- * @throws TransformException if an error occurred while projecting a point.
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(new org.apache.sis.referencing.operation.provider.Polyconic()).testPolyconic();
- }
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java
index 2683c54..25b0135 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java
@@ -91,16 +91,7 @@
* coordinate values. The transform results are between 0 and 1, while the inverse transform results
* are between -90° and 90°, which is an increase in magnitude close to ×100.
*/
- toleranceModifier = (tolerance, coordinate, mode) -> {
- switch (mode) {
- case INVERSE_TRANSFORM: {
- for (int i=0; i<tolerance.length; i++) {
- tolerance[i] *= 50;
- }
- break;
- }
- }
- };
+ tolerance *= 50; // Finer tolerance setting require GeoAPI 3.1.
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
index d79ee1f..254cae0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
@@ -36,9 +36,6 @@
import org.apache.sis.test.OptionalTestData;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.CalculationType;
-
/**
* Tests the {@link TransverseMercator} class.
@@ -112,12 +109,11 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testTransverseMercator()
*/
@Test
public void testTransverseMercator() throws FactoryException, TransformException {
- createGeoApiTest(new org.apache.sis.referencing.operation.provider.TransverseMercator()).testTransverseMercator();
+ // Test creation only, as GeoAPI 3.0 did not yet had the test method.
+ new org.apache.sis.referencing.operation.provider.TransverseMercator();
}
/**
@@ -126,12 +122,10 @@
*
* @throws FactoryException if an error occurred while creating the map projection.
* @throws TransformException if an error occurred while projecting a coordinate.
- *
- * @see org.opengis.test.referencing.ParameterizedTransformTest#testTransverseMercatorSouthOrientated()
*/
@Test
public void testTransverseMercatorSouthOrientated() throws FactoryException, TransformException {
- createGeoApiTest(new TransverseMercatorSouth()).testTransverseMercatorSouthOrientated();
+ new TransverseMercatorSouth(); // Test creation only, as GeoAPI 3.0 did not yet had the test method.
}
/**
@@ -269,7 +263,7 @@
else if (longitude <= 66) tolerance = 0.1;
else tolerance = 0.7;
transform.transform(source, 0, source, 0, 1);
- assertCoordinateEquals(target, source, reader.getLineNumber(), CalculationType.DIRECT_TRANSFORM, line);
+ assertCoordinateEquals(line, target, source, reader.getLineNumber(), false);
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/CoordinateFrameRotationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/CoordinateFrameRotationTest.java
index f1bf857..3de1417 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/CoordinateFrameRotationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/CoordinateFrameRotationTest.java
@@ -80,6 +80,7 @@
tolerance = Formulas.ANGULAR_TOLERANCE;
zTolerance = Formulas.LINEAR_TOLERANCE;
zDimension = new int[] {2};
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
createTransform(new CoordinateFrameRotation3D());
assertFalse(transform instanceof LinearTransform);
verifyTransform(PositionVector7ParamTest.samplePoint(1),
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
index 70c569b..bef2372 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
@@ -40,7 +40,6 @@
*
* @author Martin Desruisseaux (Geomatys)
*
- * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
* @see org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
*/
public final class FranceGeocentricInterpolationTest extends DatumShiftTestCase {
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
index 655045b..ff36fc3 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
@@ -38,10 +38,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Arrays;
-import org.opengis.test.ToleranceModifier;
-import org.apache.sis.referencing.datum.HardCodedDatum;
+// Specific to the main branch:
+import static org.apache.sis.referencing.privy.CoordinateOperations.builder;
/**
@@ -189,7 +187,7 @@
* @throws FactoryException if an error occurred while creating a transform.
*/
public static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory) throws FactoryException {
- final Parameters values = Parameters.castOrWrap(factory.builder("Geocentric translations (geog2D domain)").parameters());
+ final Parameters values = Parameters.castOrWrap(builder(factory, "Geocentric translations (geog2D domain)").parameters());
setTranslation(values);
setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid());
final MathTransform gt = new GeocentricTranslation().createMathTransform(factory, values);
@@ -227,6 +225,7 @@
*/
private void datumShift(final int sourceStep, final int targetStep) throws TransformException {
tolerance = precision(targetStep);
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
verifyTransform(samplePoint(sourceStep), samplePoint(targetStep));
validate();
}
@@ -259,43 +258,11 @@
derivativeDeltas = new double[] {delta, delta, 100}; // (Δλ, Δφ, Δh)
zTolerance = Formulas.LINEAR_TOLERANCE / 2; // Half the precision of h value given by EPSG
zDimension = new int[] {2}; // Dimension of h where to apply zTolerance
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
datumShift(1, 4);
}
/**
- * Tests the point used in {@link FranceGeocentricInterpolationTest}. We use this test for making sure
- * that we get the expected value when using the real geocentric translation method. This test will be
- * completed by an equivalent test in {@code MolodenskyTransformTest} for verifying the quality of our
- * approximation.
- *
- * @throws FactoryException if an error occurred while creating the transform.
- * @throws TransformException if transformation of a point failed.
- *
- * @see org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
- */
- @Test
- public void testFranceGeocentricInterpolationPoint() throws FactoryException, TransformException {
- transform = createDatumShiftForGeographic3D(DefaultMathTransformFactory.provider(),
- HardCodedDatum.NTF.getEllipsoid(),
- CommonCRS.ETRS89.ellipsoid(),
- -FranceGeocentricInterpolation.TX,
- -FranceGeocentricInterpolation.TY,
- -FranceGeocentricInterpolation.TZ);
-
- final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres
- derivativeDeltas = new double[] {delta, delta, 100}; // (Δλ, Δφ, Δh)
- tolerance = FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE;
- zTolerance = 0.005; // Half the precision of the target[2] value set below.
- zDimension = new int[] {2};
-
- final double[] source = Arrays.copyOf(FranceGeocentricInterpolationTest.samplePoint(1), 3);
- final double[] expected = Arrays.copyOf(FranceGeocentricInterpolationTest.samplePoint(2), 3);
- expected[2] = 43.15; // Anti-regression (this value is not provided in NTG_88 guidance note).
- verifyTransform(source, expected);
- validate();
- }
-
- /**
* Tests conversion of random points.
*
* @throws FactoryException if an error occurred while creating the transform.
@@ -305,7 +272,7 @@
public void testRandomPoints() throws FactoryException, TransformException {
testGeographicDomain(); // For creating the transform.
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.GEOGRAPHIC;
+// toleranceModifier = ToleranceModifier.GEOGRAPHIC;
verifyInDomain(CoordinateDomain.GEOGRAPHIC, 831342815);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java
index 93dfaa8..5ed6a89 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java
@@ -30,8 +30,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.referencing.privy.CoordinateOperations.builder;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -116,7 +117,7 @@
* Create a "Geographic to Geocentric" conversion with ellipsoid axis length units converted to metres
* (the unit implied by SRC_SEMI_MAJOR) because it is the unit of Bursa-Wolf parameters that we created above.
*/
- var builder = factory.builder(GeographicToGeocentric.NAME);
+ var builder = builder(factory, GeographicToGeocentric.NAME);
Parameters step = Parameters.castOrWrap(builder.parameters());
step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MAJOR));
step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MINOR));
@@ -124,7 +125,7 @@
assertEquals(3, toGeocentric.getSourceDimensions());
assertEquals(3, toGeocentric.getTargetDimensions());
- final MathTransform reduce = factory.builder("Geographic3D to 2D conversion").create();
+ final MathTransform reduce = builder(factory, "Geographic3D to 2D conversion").create();
assertEquals(3, reduce.getSourceDimensions());
assertEquals(2, reduce.getTargetDimensions());
try {
@@ -138,7 +139,7 @@
* Create a "Geocentric to Geographic" conversion with ellipsoid axis length units converted to metres
* because this is the unit of the Geocentric CRS used above.
*/
- builder = factory.builder(GeocentricToGeographic.NAME);
+ builder = builder(factory, GeocentricToGeographic.NAME);
step = Parameters.castOrWrap(builder.parameters());
step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MAJOR));
step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MINOR));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/LongitudeRotationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/LongitudeRotationTest.java
index 9500908..4077e35 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/LongitudeRotationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/LongitudeRotationTest.java
@@ -29,8 +29,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/MapProjectionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/MapProjectionTest.java
index ce32a37..5bcc419 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/MapProjectionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/MapProjectionTest.java
@@ -30,8 +30,8 @@
import static org.apache.sis.referencing.Assertions.assertOgcIdentifierEquals;
import static org.apache.sis.referencing.Assertions.assertEpsgIdentifierEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -131,7 +131,7 @@
assertEquals(isMandatory ? 1 : 0, actual.getMinimumOccurs());
if (epsgName != null) {
for (final GenericName alias : actual.getAlias()) {
- if (alias instanceof Identifier id && id.getAuthority() != Citations.EPSG) {
+ if (alias instanceof ReferenceIdentifier id && id.getAuthority() != Citations.EPSG) {
assertOgcIdentifierEquals(ogcName, id);
return;
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
index 4bca18b..3bb73e0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
@@ -37,8 +37,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
index 280e8af..09658eb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
@@ -47,8 +47,8 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.TestCase.TAG_SLOW;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -57,7 +57,6 @@
*
* @author Martin Desruisseaux (Geomatys)
*
- * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
* @see org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
*/
public final class NTv2Test extends DatumShiftTestCase {
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ParameterNameTableGenerator.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ParameterNameTableGenerator.java
deleted file mode 100644
index 26a2875..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ParameterNameTableGenerator.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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.referencing.operation.provider;
-
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.lang.reflect.Field;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Files;
-import java.nio.file.FileVisitResult;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import javax.measure.Unit;
-import org.opengis.util.GenericName;
-import org.opengis.metadata.Identifier;
-import org.apache.sis.referencing.NamedIdentifier;
-import org.apache.sis.parameter.DefaultParameterDescriptor;
-import org.apache.sis.measure.Angle;
-import org.apache.sis.measure.Latitude;
-import org.apache.sis.measure.Longitude;
-import org.apache.sis.measure.Range;
-import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.StringBuilders;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.ProjectDirectories;
-
-
-/**
- * Inserts comments with parameter names in the javadoc of parameters.
- * This class needs to be run explicitly; it is not part of JUnit tests.
- * After execution, files in the provider packages may be overwritten.
- * Developer should execute {@code "git diff"} and inspect the changes.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class ParameterNameTableGenerator extends SimpleFileVisitor<Path> {
- /**
- * Value as the kind of object expected in {@link DefaultParameterDescriptor}.
- */
- private static final Double ONE = 1d,
- POSITIVE_ZERO = +0d,
- NEGATIVE_ZERO = -0d,
- MIN_LONGITUDE = Longitude.MIN_VALUE,
- MAX_LONGITUDE = Longitude.MAX_VALUE,
- MIN_LATITUDE = Latitude.MIN_VALUE,
- MAX_LATITUDE = Latitude.MAX_VALUE;
-
- /**
- * The directory of Java source code to scan.
- */
- private final Path directory;
-
- /**
- * Pattern of the lines to search.
- */
- private final Pattern toSearch;
-
- /**
- * A temporary buffer for creating lines of comment.
- */
- private final StringBuilder buffer;
-
- /**
- * All lines in the file being processed.
- */
- private List<String> lines;
-
- /**
- * For {@link #main(String[])} only.
- */
- private ParameterNameTableGenerator() {
- directory = new ProjectDirectories(getClass()).getSourcesPackageDirectory("core/sis-referencing");
- toSearch = Pattern.compile(".*\\s+static\\s+.*ParameterDescriptor<\\w+>\\s*(\\w+)\\s*[=;].*");
- buffer = new StringBuilder();
- }
-
- /**
- * Launches the insertion of comment lines.
- *
- * @param args ignored.
- * @throws IOException if an error occurred while reading or writing a file.
- */
- public static void main(final String[] args) throws IOException {
- final ParameterNameTableGenerator cg = new ParameterNameTableGenerator();
- Files.walkFileTree(cg.directory, cg);
- }
-
- /**
- * Invoked before to enter in a sub-directory. This implementation skips all sub-directories.
- *
- * @param dir the directory in which to enter.
- * @param attrs ignored.
- * @return flag instructing whether to scan that directory or not.
- */
- @Override
- public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) {
- return dir.equals(directory) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
- }
-
- /**
- * Invoked for each file in the scanned directory. If the file is a Java file,
- * searches for {@code ParameterDescriptor} declarations. Otherwise ignore.
- *
- * @param file the file.
- * @param attrs ignored.
- * @return {@link FileVisitResult#CONTINUE}.
- * @throws IOException if an error occurred while reading or writing the given file.
- */
- @Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
- final String name = file.getFileName().toString();
- if (name.endsWith(".java")) {
- addCommentsToJavaFile(file);
- }
- return super.visitFile(file, attrs);
- }
-
- /**
- * Returns the class for the given Java source file.
- */
- private Class<?> getClass(final Path file) throws ClassNotFoundException {
- String name = file.getFileName().toString();
- name = name.substring(0, name.lastIndexOf('.')); // Remove the ".java" suffix.
- name = getClass().getPackageName() + '.' + name;
- return Class.forName(name);
- }
-
- /**
- * Finds the parameter descriptors in the given file, and add parameter names in comments.
- */
- private void addCommentsToJavaFile(final Path file) throws IOException {
- Class<?> classe = null;
- final Matcher matcher = toSearch.matcher("");
- lines = Files.readAllLines(file);
- for (int i=lines.size(); --i >= 0;) {
- final String line = lines.get(i);
- if (matcher.reset(line).matches()) {
- final String fieldName = matcher.group(1);
- final DefaultParameterDescriptor<?> descriptor;
- try {
- if (classe == null) {
- classe = getClass(file);
- }
- final Field field = classe.getDeclaredField(fieldName);
- field.setAccessible(true);
- descriptor = (DefaultParameterDescriptor<?>) field.get(null);
- } catch (ReflectiveOperationException e) {
- throw new AssertionError(e);
- }
- /*
- * Find the line where to insert comments. We detect if the comment to insert already exists
- * by looking for this class name (expected in a HTML comment) before the start of comments.
- * If we find that line, then we delete everything between it and the end of comments before
- * to regenerate them. Developer can execute "git diff" on the command line for checking if
- * any lines changed as a result.
- */
- int insertAt = i;
- String previous;
- do {
- previous = lines.get(--insertAt).trim();
- if (!previous.startsWith("*") && !previous.startsWith("@")) {
- fail("Unexpected content in " + file.getFileName() + " at line " + insertAt);
- }
- } while (!previous.equals("*/"));
- previous = lines.get(insertAt);
- buffer.setLength(0);
- buffer.append(previous, 0, previous.indexOf('*') + 1);
- for (int check = insertAt;;) {
- previous = lines.get(--check).trim();
- if (previous.equals("/**")) break;
- if (previous.contains("ParameterNameTableGenerator")) {
- lines.subList(check, insertAt).clear();
- insertAt = check;
- break;
- }
- }
- /*
- * Format a HTML table in the comment with the name and aliases of each parameter.
- */
- write(insertAt++, "<!-- Generated by ParameterNameTableGenerator -->");
- write(insertAt++, "<table class=\"sis\">");
- write(insertAt++, " <caption>Parameter names</caption>");
- write(insertAt++, descriptor.getName());
- for (final GenericName alias : descriptor.getAlias()) {
- write(insertAt++, (alias instanceof Identifier) ? (Identifier) alias : new NamedIdentifier(alias));
- }
- write(insertAt++, "</table>");
- /*
- * Format other information: default value, value domain, whether the value is mandatory, etc.
- * Default value of zero are omitted (i.e. unless otherwise specified, default values are zero
- * in the tables that we format). Range of values of [-90 … 90]° for latitude or [-180 … 180]°
- * for longitude are also omitted. In other words, we report only "unusual" things in the notes.
- */
- Object defaultValue = descriptor.getDefaultValue();
- Range<?> valueDomain = descriptor.getValueDomain();
- boolean isOptional = descriptor.getMinimumOccurs() == 0;
- boolean noDefault = (defaultValue == null);
- Object minValue = null;
- Object maxValue = null;
- if (valueDomain != null) {
- minValue = valueDomain.getMinValue();
- maxValue = valueDomain.getMaxValue();
- final boolean inclusive = valueDomain.isMinIncluded() && valueDomain.isMaxIncluded();
- if (fieldName.contains("LATITUDE") || fieldName.contains("PARALLEL")) {
- if (inclusive && MIN_LATITUDE.equals(minValue) && MAX_LATITUDE.equals(maxValue)) {
- valueDomain = null;
- }
- } else if (fieldName.contains("LONGITUDE") || fieldName.contains("MERIDIAN")) {
- if (inclusive && MIN_LONGITUDE.equals(minValue) && MAX_LONGITUDE.equals(maxValue)) {
- valueDomain = null;
- }
- } else if (fieldName.contains("SCALE")) {
- if (!inclusive && POSITIVE_ZERO.equals(minValue) && maxValue == null) {
- valueDomain = null;
- }
- } else if (minValue == null && maxValue == null) {
- valueDomain = null;
- }
- }
- if ((fieldName.contains("SCALE") ? ONE : POSITIVE_ZERO).equals(defaultValue)) {
- defaultValue = null;
- }
- if (defaultValue != null || valueDomain != null || isOptional || noDefault) {
- write(insertAt++, "<b>Notes:</b>");
- write(insertAt++, "<ul>");
- if (valueDomain != null) {
- final int p = buffer.length();
- buffer.append(" <li>");
- if ((minValue != null && minValue.equals(maxValue)) ||
- (NEGATIVE_ZERO.equals(minValue) && POSITIVE_ZERO.equals(maxValue)))
- {
- buffer.append("Value restricted to ").append(maxValue);
- StringBuilders.trimFractionalPart(buffer);
- } else {
- buffer.append("Value domain: ").append(valueDomain);
- }
- lines.add(insertAt++, buffer.append("</li>").toString());
- buffer.setLength(p);
- }
- if (defaultValue != null) {
- final int p = buffer.length();
- final boolean isText = !(defaultValue instanceof Number || defaultValue instanceof Angle);
- buffer.append(" <li>").append("Default value: ");
- if (isText) buffer.append("{@code ");
- buffer.append(defaultValue);
- if (isText) buffer.append('}');
- StringBuilders.trimFractionalPart(buffer);
- final Unit<?> unit = descriptor.getUnit();
- if (unit != null) {
- final String symbol = unit.getSymbol();
- if (!symbol.isEmpty()) {
- if (Character.isLetterOrDigit(symbol.charAt(0))) {
- buffer.append(' ');
- }
- buffer.append(symbol);
- }
- }
- lines.add(insertAt++, buffer.append("</li>").toString());
- buffer.setLength(p);
- } else if (noDefault) {
- write(insertAt++, " <li>No default value</li>");
- }
- if (isOptional) {
- write(insertAt++, " <li>Optional</li>");
- }
- write(insertAt++, "</ul>");
- }
- }
- }
- /*
- * If at least one table has been formatted, rewrite the file.
- */
- if (classe != null) {
- Files.write(file, lines);
- }
- lines = null;
- }
-
- /**
- * Appends the given line at the given position. This method writes the margin
- * (typically spaces followed by {@code '*'} and a single space) before the line.
- */
- private void write(final int insertAt, final String line) {
- final int p = buffer.length();
- if (!line.isEmpty()) {
- buffer.append(' ').append(line);
- }
- lines.add(insertAt, buffer.toString());
- buffer.setLength(p);
- }
-
- /**
- * Appends the given authority and name at the given position. This method writes the margin
- * (typically spaces followed by {@code '*'} and a single space) before the line.
- */
- private void write(final int insertAt, final Identifier id) {
- final int p = buffer.length();
- final String authority = id.getCodeSpace();
- buffer.append(" <tr><td> ").append(authority).append(':')
- .append(CharSequences.spaces(8 - authority.length()))
- .append("</td><td> ").append(id.getCode()).append(" </td></tr>");
- lines.add(insertAt, buffer.toString());
- buffer.setLength(p);
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/PositionVector7ParamTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/PositionVector7ParamTest.java
index 7ffcdbc..f7ac5b1 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/PositionVector7ParamTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/PositionVector7ParamTest.java
@@ -135,6 +135,7 @@
tolerance = Formulas.ANGULAR_TOLERANCE;
zTolerance = Formulas.LINEAR_TOLERANCE;
zDimension = new int[] {2};
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
createTransform(new PositionVector7Param3D());
assertFalse(transform instanceof LinearTransform);
verifyTransform(samplePoint(1), samplePoint(4));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProviderMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProviderMock.java
index 7ff33eb..f2904eb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProviderMock.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProviderMock.java
@@ -29,7 +29,7 @@
/**
* Base class of mock provider for coordinate operations not yet implemented in Apache SIS.
* This is used for operations needed for executing some Well Known Text (WKT) parsing tests
- * in the {@link org.apache.sis.io.wkt.CRSParserTest} class, without doing any real coordinate
+ * in the {@code org.apache.sis.io.wkt.CRSParserTest} class, without doing any real coordinate
* operations with the parsed objects.
*
* <p>Subclasses may be promoted to a real operation if we implement their formulas in a future Apache SIS version.</p>
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProvidersTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProvidersTest.java
index 09febc8..9ad9c35 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProvidersTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/ProvidersTest.java
@@ -30,8 +30,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertBetween;
+// Specific to the main branch:
+import org.apache.sis.parameter.DefaultParameterDescriptor;
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
/**
@@ -233,8 +234,8 @@
*/
@Test
public void testDescription() {
- assertNotEquals(0, SatelliteTracking.SATELLITE_ORBIT_INCLINATION.getDescription().orElseThrow().length());
- assertNotEquals(0, SatelliteTracking.SATELLITE_ORBITAL_PERIOD .getDescription().orElseThrow().length());
- assertNotEquals(0, SatelliteTracking.ASCENDING_NODE_PERIOD .getDescription().orElseThrow().length());
+ assertNotEquals(0, ((DefaultParameterDescriptor<Double>) SatelliteTracking.SATELLITE_ORBIT_INCLINATION).getDescription().orElseThrow().length());
+ assertNotEquals(0, ((DefaultParameterDescriptor<Double>) SatelliteTracking.SATELLITE_ORBITAL_PERIOD ).getDescription().orElseThrow().length());
+ assertNotEquals(0, ((DefaultParameterDescriptor<Double>) SatelliteTracking.ASCENDING_NODE_PERIOD ).getDescription().orElseThrow().length());
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/SeismicBinGridMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/SeismicBinGridMock.java
index 1ce7cc9..b025664 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/SeismicBinGridMock.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/SeismicBinGridMock.java
@@ -26,7 +26,7 @@
* The provider for <q>P6 (I = J-90°) seismic bin grid transformation</q> transformation (EPSG:1049).
*
* This conversion is not yet implemented in Apache SIS, but we need to at least accept the parameters
- * for a Well Known Text (WKT) parsing test in the {@link org.apache.sis.io.wkt.CRSParserTest} class.
+ * for a Well Known Text (WKT) parsing test in the {@code org.apache.sis.io.wkt.CRSParserTest} class.
*
* <p>This class may be promoted to a real operation if we implement the formulas in a future Apache SIS version.</p>
*
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransformTest.java
index 31916c6..7c3e87b 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransformTest.java
@@ -28,9 +28,6 @@
import org.apache.sis.referencing.datum.HardCodedDatum;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.CalculationType;
-
/**
* Tests {@link AbridgedMolodenskyTransform2D}. This class takes {@link MolodenskyTransform}
@@ -57,8 +54,6 @@
*
* @throws FactoryException if an error occurred while creating a transform step.
* @throws TransformException if a transformation failed.
- *
- * @see MolodenskyTransformTest#compareWithGeocentricTranslation()
*/
@Test
public void compareWithReferenceImplementation() throws FactoryException, TransformException {
@@ -74,7 +69,7 @@
for (int i=0; i<sources.length; i+=2) {
transform.transform(sources, i, targets, 0, 1); // Use the overridden method.
transform.transform(sources, i, expected, 0, false); // Use the MolodenskyTransform method.
- assertCoordinateEquals(expected, targets, 0, CalculationType.DIRECT_TRANSFORM, "transform");
+ assertCoordinateEquals("transform", expected, targets, 0, false);
}
}
@@ -109,7 +104,6 @@
public void testConsistency() throws FactoryException, TransformException {
transform = create();
validate();
- isDerivativeSupported = false;
isInverseTransformSupported = false;
verifyInDomain(CoordinateDomain.GEOGRAPHIC, -1941624852762631518L);
/*
@@ -118,7 +112,6 @@
* we are not completely sure that there is no bug in derivative formula).
*/
tolerance *= 10;
- isDerivativeSupported = true;
verifyInDomain(CoordinateDomain.GEOGRAPHIC, 4350796528249596132L);
}
@@ -133,7 +126,6 @@
public void testSerialization() throws FactoryException, TransformException {
transform = assertSerializedEquals(create());
validate();
- isDerivativeSupported = false;
isInverseTransformSupported = false;
verifyInDomain(CoordinateDomain.GEOGRAPHIC, 3534897149662911157L);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java
index f44d234..9c448e1 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java
@@ -25,9 +25,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Tests {@link CartesianToPolar}.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java
index 2688ab2..9cdc5eb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java
@@ -29,9 +29,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Tests {@link CartesianToSpherical}.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
index 8315b68..d118a1f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
@@ -34,8 +34,8 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -199,8 +199,8 @@
*/
after .m11 = -after .m11; after .m12 = 0;
before.m11 = -before.m11; before.m12 = 0;
- assertMatrixEquals(before, MathTransforms.getMatrix(steps.get(0)), null, "before");
- assertMatrixEquals(after, MathTransforms.getMatrix(steps.get(2)), null, "after");
+ assertMatrixEquals(before, MathTransforms.getMatrix(steps.get(0)), STRICT, "before");
+ assertMatrixEquals(after, MathTransforms.getMatrix(steps.get(2)), STRICT, "after");
}
/**
@@ -224,7 +224,7 @@
* Dropping a dimension is not a problem.
*/
final MathTransform c = MathTransforms.concatenate(tr1, tr2.inverse());
- Assertions.assertMatrixEquals(Matrices.create(3, 4, new double[] {
+ assertMatrixEquals(Matrices.create(3, 4, new double[] {
4, 0, 0, 0, // scale = 8/2
0, 2, 0, 0, // scale = 6/3
0, 0, 0, 1
@@ -236,7 +236,7 @@
* this concatenation was built from a transform which was putting value 5 in third dimension,
* we can complete the matrix as below with value 10 in third dimension.
*/
- Assertions.assertMatrixEquals(Matrices.create(4, 3, new double[] {
+ assertMatrixEquals(Matrices.create(4, 3, new double[] {
0.25, 0, 0,
0, 0.5, 0,
0, 0, 10, // Having value 10 instead of NaN is the main purpose of this test.
@@ -259,6 +259,6 @@
final MathTransform tr2 = MathTransforms.linear(new Matrix2(-1, 0, 0, 1));
final MathTransform c = MathTransforms.concatenate(tr1, tr2);
final Matrix m = ((LinearTransform) c).getMatrix();
- Assertions.assertMatrixEquals(new Matrix2(-4.9E-324, 5387, 0, 1), m, STRICT, "Concatenate");
+ assertMatrixEquals(new Matrix2(-4.9E-324, 5387, 0, 1), m, STRICT, "Concatenate");
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
index 6e9a8ab..bd3f7b3 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
@@ -33,8 +33,8 @@
import org.apache.sis.parameter.DefaultParameterDescriptorGroupTest;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
index c8fa84b..12816ae 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
@@ -49,8 +49,9 @@
import org.apache.sis.referencing.crs.HardCodedCRS;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.referencing.privy.CoordinateOperations.builder;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -216,7 +217,7 @@
continue;
}
final String classification = method.getName().getCode();
- final var builder = factory.builder(classification);
+ final var builder = builder(factory, classification);
ParameterValueGroup pg = builder.parameters();
pg.parameter("semi_major").setValue(6377563.396);
pg.parameter("semi_minor").setValue(6356256.909237285);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
index 2daae76..e3576ef 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
@@ -38,9 +38,6 @@
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import org.apache.sis.referencing.operation.provider.GeocentricTranslationTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.ToleranceModifier;
-
/**
* Tests {@link EllipsoidToCentricTransform} from geographic to geocentric coordinates.
@@ -144,6 +141,7 @@
tolerance = GeocentricTranslationTest.precision(1); // Required precision for (λ,φ)
zTolerance = Formulas.LINEAR_TOLERANCE / 2; // Required precision for h
zDimension = new int[] {2}; // Dimension of h where to apply zTolerance
+ tolerance = 1E-4; // Other SIS branches use a stricter threshold.
verifyTransform(GeocentricTranslationTest.samplePoint(2), // X = 3771793.968, Y = 140253.342, Z = 5124304.349 metres
GeocentricTranslationTest.samplePoint(1)); // 53°48'33.820"N, 02°07'46.380"E, 73.00 metres
}
@@ -159,7 +157,7 @@
final double delta = toRadians(100.0 / 60) / 1852; // Approximately 100 metres
derivativeDeltas = new double[] {delta, delta, 100}; // (Δλ, Δφ, Δh)
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
+// toleranceModifier = ToleranceModifier.PROJECTION;
createGeodeticConversion(HardCodedDatum.WGS84.getEllipsoid(), true);
verifyInDomain(CoordinateDomain.GEOGRAPHIC, 306954540);
}
@@ -181,8 +179,8 @@
final double delta = toRadians(100.0 / 60) / 1852;
derivativeDeltas = new double[] {delta, delta, 100};
tolerance = Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifier.PROJECTION;
- verifyInverse(40, 30, 10000);
+// toleranceModifier = ToleranceModifier.PROJECTION;
+ verifyInverse(new double[] {40, 30, 10000});
}
/**
@@ -205,7 +203,7 @@
toRadians(1.0 / 60) / 1852,
1
};
- verifyDerivative(point.getCoordinates());
+ verifyDerivative(point.getCoordinate());
/*
* Derivative of the inverse transform.
*/
@@ -213,7 +211,7 @@
transform = transform.inverse();
tolerance = 1E-8;
derivativeDeltas = new double[] {1,1,1}; // Approximately one metre.
- verifyDerivative(point.getCoordinates());
+ verifyDerivative(point.getCoordinate());
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToRadiusTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToRadiusTransformTest.java
index d4c6831..f8bf2f1 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToRadiusTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/EllipsoidToRadiusTransformTest.java
@@ -30,6 +30,9 @@
import org.apache.sis.referencing.datum.HardCodedDatum;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
+
/**
* Tests {@link EllipsoidToRadiusTransform}.
@@ -121,7 +124,7 @@
assertMatrixEquals(new Matrix3(
2, 0, -5,
0, 3, 0,
- 0, 0, 1), tr1, null, null);
+ 0, 0, 1), tr1, 0, null);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ExponentialTransform1DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ExponentialTransform1DTest.java
index 688a13c..9957d3e 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ExponentialTransform1DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ExponentialTransform1DTest.java
@@ -25,12 +25,6 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.referencing.Assertions.assertIsNotIdentity;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.EnumSet;
-import org.opengis.test.CalculationType;
-import org.opengis.test.ToleranceModifier;
-import org.opengis.test.ToleranceModifiers;
-
/**
* Tests the {@link ExponentialTransform1D} class. Note that this is closely related to
@@ -58,9 +52,8 @@
* Creates a new test case.
*/
public ExponentialTransform1DTest() {
- tolerance = 1E-14;
- toleranceModifier = ToleranceModifier.RELATIVE;
- derivativeDeltas = new double[] {0.001};
+ tolerance = 1E-5; // Tolerance is much smaller on other branches.
+// toleranceModifier = ToleranceModifier.RELATIVE; // Not available on GeoAPI 3.0.
}
/**
@@ -96,7 +89,6 @@
expected[i] = value;
}
verifyTransform(values, expected);
- verifyDerivative(2.5); // Test at a hard-coded point.
}
/**
@@ -130,13 +122,6 @@
private void testAffinePostConcatenation(final double base) throws TransformException {
transform = MathTransforms.concatenate(ExponentialTransform1D.create(base, SCALE),
LinearTransform1D.create(C1, C0));
- /*
- * The inverse transforms in this test case have high rounding errors.
- * Those errors are low for values close to zero, and increase fast for higher values.
- * We scale the default tolerance (1E-14) by 1E+8, which give us a tolerance of 1E-6.
- */
- toleranceModifier = ToleranceModifiers.concatenate(toleranceModifier,
- ToleranceModifiers.scale(EnumSet.of(CalculationType.INVERSE_TRANSFORM), 1E+8));
run(ConcatenatedTransformDirect1D.class, base, SCALE, false, true);
}
@@ -146,10 +131,6 @@
private void testAffineConcatenations(final double base) throws TransformException {
final LinearTransform1D linear = LinearTransform1D.create(C1, C0);
transform = MathTransforms.concatenate(linear, ExponentialTransform1D.create(base, SCALE), linear);
-
- // See testAffinePostConcatenation for an explanation about why we relax tolerance.
- toleranceModifier = ToleranceModifiers.concatenate(toleranceModifier,
- ToleranceModifiers.scale(EnumSet.of(CalculationType.INVERSE_TRANSFORM), 1E+8));
run(ConcatenatedTransformDirect1D.class, base, SCALE, true, true);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearInterpolator1DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearInterpolator1DTest.java
index 764a565..e2257e0 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearInterpolator1DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearInterpolator1DTest.java
@@ -28,9 +28,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Test {@link LinearInterpolator1D} class.
@@ -39,7 +36,7 @@
* @author Martin Desruisseaux (Geomatys).
*/
@ExtendWith(FailureDetailsReporter.class)
-public final class LinearInterpolator1DTest extends TransformTestCase {
+public final class LinearInterpolator1DTest extends MathTransformTestCase {
/**
* The values of the <i>y=f(x)</i> function to test.
*/
@@ -248,7 +245,6 @@
verifyTransform(new double[] {0, 1, 0.5, -0.5, -1, -2, 3, 3.5, 4, 5}, // Values to transform.
new double[] {5, 10, 7.5, 2.5, 0, -5, 250, 325, 400, 550}); // Expected results.
- verifyConsistency(0f, 1f, 0.5f, -0.5f, -1f, -2f, 3f, 3.5f, 4f, 5f);
verifyDerivative(0.25); // Interpolation (verified by safety)
verifyDerivative(-8); // Extrapolation
verifyDerivative( 8);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
index e0a9b70..f1da0a8 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
@@ -26,6 +26,9 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
+// Specific to the main branch:
+import org.junit.jupiter.api.Disabled;
+
/**
* Tests various implementation of the {@link LinearTransform} interface by inheriting the tests defined
@@ -64,6 +67,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testIdentity1D() throws FactoryException, TransformException {
super.testIdentity1D();
assertInstanceOf(IdentityTransform1D.class, transform, "Unexpected implementation.");
@@ -77,6 +81,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testIdentity2D() throws FactoryException, TransformException {
super.testIdentity2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -90,6 +95,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testIdentity3D() throws FactoryException, TransformException {
super.testIdentity3D();
assertInstanceOf(IdentityTransform.class, transform, "Unexpected implementation.");
@@ -103,6 +109,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testAxisSwapping2D() throws FactoryException, TransformException {
super.testAxisSwapping2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -116,6 +123,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testSouthOrientated2D() throws FactoryException, TransformException {
super.testSouthOrientated2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -129,6 +137,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testTranslatation2D() throws FactoryException, TransformException {
super.testTranslatation2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -142,6 +151,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testUniformScale2D() throws FactoryException, TransformException {
super.testUniformScale2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -155,6 +165,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testGenericScale2D() throws FactoryException, TransformException {
super.testGenericScale2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -168,6 +179,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testRotation2D() throws FactoryException, TransformException {
super.testRotation2D();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -181,6 +193,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testGeneral() throws FactoryException, TransformException {
super.testGeneral();
assertInstanceOf(AffineTransform2D.class, transform, "Unexpected implementation.");
@@ -194,6 +207,7 @@
*/
@Test
@Override
+ @Disabled(MESSAGE)
public void testDimensionReduction() throws FactoryException, TransformException {
super.testDimensionReduction();
assertInstanceOf(ProjectiveTransform.class, transform, "Unexpected implementation.");
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LogarithmicTransform1DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LogarithmicTransform1DTest.java
index 8e9731c..ffae3b7 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LogarithmicTransform1DTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/LogarithmicTransform1DTest.java
@@ -25,9 +25,6 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.referencing.Assertions.assertIsNotIdentity;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.ToleranceModifier;
-
/**
* Tests the {@link LogarithmicTransform1D} class. Note that this is closely related to
@@ -50,9 +47,8 @@
* Creates a new test case.
*/
public LogarithmicTransform1DTest() {
- tolerance = 2E-14;
- toleranceModifier = ToleranceModifier.RELATIVE;
- derivativeDeltas = new double[] {0.001};
+ tolerance = 1E-5; // Tolerance is much smaller on other branches.
+// toleranceModifier = ToleranceModifier.RELATIVE; // Not available on GeoAPI 3.0.
}
/**
@@ -90,7 +86,6 @@
expected[i] = value;
}
verifyTransform(values, expected);
- verifyDerivative(2.5); // Test at a hard-coded point.
}
/**
@@ -211,6 +206,5 @@
expected[i] = ExponentialTransform1DTest.SCALE * pow(10, log(value) / lnBase + C0);
}
verifyTransform(values, expected);
- verifyDerivative(2.5); // Test at a hard-coded point.
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java
index 0789a11..22d4a06 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java
@@ -29,6 +29,11 @@
// Test dependencies
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+// Specific to the main branch:
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
/**
* Skeleton for {@link MathTransformFactory} custom implementations.
@@ -60,21 +65,34 @@
return Set.of();
}
- /** Default implementation throws an exception. */
+ /** Default implementation unconditionally returns {@code null}. */
@Override
- public MathTransform.Builder builder(String code) throws NoSuchIdentifierException {
- throw new NoSuchIdentifierException(MESSAGE, code);
+ public OperationMethod getLastMethodUsed() {
+ return null;
}
/** Default implementation throws an exception. */
@Override
- public MathTransform createAffineTransform(Matrix matrix) throws FactoryException {
+ public ParameterValueGroup getDefaultParameters(String method) throws NoSuchIdentifierException {
+ throw new NoSuchIdentifierException(MESSAGE, method);
+ }
+
+ /** Default implementation throws an exception. */
+ @Override
+ @Deprecated
+ public MathTransform createBaseToDerived(CoordinateReferenceSystem baseCRS, ParameterValueGroup parameters, CoordinateSystem derivedCS) throws FactoryException {
throw new FactoryException(MESSAGE);
}
/** Default implementation throws an exception. */
@Override
- public Matrix createMatrix(int numRow, int numCol) throws FactoryException {
+ public MathTransform createParameterizedTransform(ParameterValueGroup parameters) throws FactoryException {
+ throw new FactoryException(MESSAGE);
+ }
+
+ /** Default implementation throws an exception. */
+ @Override
+ public MathTransform createAffineTransform(Matrix matrix) throws FactoryException {
throw new FactoryException(MESSAGE);
}
@@ -92,6 +110,13 @@
/** Default implementation throws an exception. */
@Override
+ @Deprecated
+ public MathTransform createFromXML(String xml) throws FactoryException {
+ throw new FactoryException(MESSAGE);
+ }
+
+ /** Default implementation throws an exception. */
+ @Override
public MathTransform createFromWKT(String wkt) throws FactoryException {
throw new FactoryException(MESSAGE);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java
index cefcc56..f11b949 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java
@@ -32,9 +32,9 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Optional;
-import org.apache.sis.referencing.operation.matrix.Matrices;
+// Specific to the main branch:
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.cs.CoordinateSystem;
/**
@@ -101,42 +101,11 @@
* @return the method given at construction time.
*/
@Override
- @Deprecated
public OperationMethod getLastMethodUsed() {
return method;
}
/**
- * Returns the builder for the operation method.
- *
- * @param name shall be the operation method name.
- * @return the builder.
- * @throws NoSuchIdentifierException if the given name is not the name
- * of the operation method known to this factory.
- */
- @Override
- public MathTransform.Builder builder(final String name) throws NoSuchIdentifierException {
- if (method.isHeuristicMatchForName(name)) {
- final ParameterValueGroup parameters = method.getParameters().createValue();
- return new MathTransform.Builder() {
- @Override public Optional<OperationMethod> getMethod() {
- return Optional.of(method);
- }
-
- @Override public ParameterValueGroup parameters() {
- return parameters;
- }
-
- @Override public MathTransform create() throws FactoryException {
- lastParameters = parameters;
- return method.createMathTransform(MathTransformFactoryMock.this, parameters);
- }
- };
- }
- throw new NoSuchIdentifierException(null, name);
- }
-
- /**
* Returns the parameters for the operation method.
*
* @param name shall be the operation method name.
@@ -145,7 +114,6 @@
* of the operation method known to this factory.
*/
@Override
- @Deprecated
public ParameterValueGroup getDefaultParameters(final String name) throws NoSuchIdentifierException {
if (method.isHeuristicMatchForName(name)) {
return method.getParameters().createValue();
@@ -161,7 +129,6 @@
* @throws FactoryException if the provider cannot create the transform.
*/
@Override
- @Deprecated
public MathTransform createParameterizedTransform(ParameterValueGroup parameters) throws FactoryException {
lastParameters = parameters;
return method.createMathTransform(this, parameters);
@@ -179,18 +146,6 @@
}
/**
- * Delegates to {@link Matrices}.
- *
- * @param numRow number of rows.
- * @param numCol number of columns.
- * @return a new matrix of the given size.
- */
- @Override
- public Matrix createMatrix(int numRow, int numCol) {
- return Matrices.createDiagonal(numRow, numCol);
- }
-
- /**
* Delegates to {@link MathTransforms}.
*
* @param transform1 first transform to concatenate.
@@ -218,6 +173,34 @@
/**
* Unimplemented method.
*
+ * @param baseCRS ignored.
+ * @param parameters ignored.
+ * @param derivedCS ignored.
+ * @return never returned.
+ */
+ @Override
+ @Deprecated
+ public MathTransform createBaseToDerived(CoordinateReferenceSystem baseCRS,
+ ParameterValueGroup parameters, CoordinateSystem derivedCS)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unimplemented method.
+ *
+ * @param xml ignored.
+ * @return never returned.
+ */
+ @Override
+ @Deprecated
+ public MathTransform createFromXML(String xml) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unimplemented method.
+ *
* @param wkt ignored.
* @return never returned.
*/
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
index c25f1a7..797ef01 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
@@ -44,12 +44,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.measure.Longitude;
-import org.opengis.test.CalculationType;
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Base class for tests of {@link AbstractMathTransform} implementations.
@@ -58,7 +52,6 @@
* <p>Various assertion methods:</p>
* <ul>
* <li>{@link #assertCoordinateEquals assertCoordinateEquals(…)} — from GeoAPI</li>
- * <li>{@link #assertMatrixEquals assertMatrixEquals(…)} — from GeoAPI</li>
* <li>{@link #assertParameterEquals assertParameterEquals(…)} — from Apache SIS</li>
* <li>{@link #assertWktEquals assertWktEquals(…)} — from Apache SIS</li>
* </ul>
@@ -120,17 +113,6 @@
* Creates a new test case.
*/
protected MathTransformTestCase() {
- /*
- * Use `zTolerance` threshold instead of `tolerance` when comparing vertical coordinate values.
- */
- toleranceModifier = (final double[] tolerances, final DirectPosition coordinates, final CalculationType mode) -> {
- if (mode != CalculationType.IDENTITY) {
- final int i = forComparison(zDimension, mode);
- if (i >= 0 && i < tolerances.length) {
- tolerances[i] = zTolerance;
- }
- }
- };
}
/**
@@ -148,41 +130,6 @@
zTolerance = 0;
tolerance = 0;
derivativeDeltas = null;
- configurationTip = null;
- }
-
- /**
- * Returns the value to use from the {@link #λDimension} or {@link #zDimension}
- * for the given comparison mode, or -1 if none.
- */
- @SuppressWarnings("fallthrough")
- private static int forComparison(final int[] config, final CalculationType mode) {
- if (config != null) {
- switch (mode) {
- case INVERSE_TRANSFORM: if (config.length >= 2) return config[1]; // Intentional fallthrough.
- case DIRECT_TRANSFORM: if (config.length >= 1) return config[0];
- }
- }
- return -1;
- }
-
- /**
- * Invoked by all {@code assertCoordinateEquals(…)} methods before two positions are compared.
- * The SIS implementation ensures that longitude values are contained in the ±180° range,
- * applying 360° shifts if needed.
- *
- * @param expected the expected coordinate values provided by the test case.
- * @param actual the coordinate values computed by the {@linkplain #transform transform} being tested.
- * @param mode indicates if the coordinates being compared are the result of a direct
- * or inverse transform, or if strict equality is requested.
- */
- @Override
- protected final void normalize(final DirectPosition expected, final DirectPosition actual, final CalculationType mode) {
- final int i = forComparison(λDimension, mode);
- if (i >= 0) {
- expected.setCoordinate(i, Longitude.normalize(expected.getCoordinate(i)));
- actual .setCoordinate(i, Longitude.normalize(actual .getCoordinate(i)));
- }
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
index 5128e48..471d97e 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
@@ -28,8 +28,8 @@
import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.io.wkt.UnformattableObjectException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformsTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
index 01af411..c4644fb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
@@ -35,8 +35,8 @@
import static org.apache.sis.test.TestCase.STRICT;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
index 699e340..72ee28d 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
@@ -39,22 +39,12 @@
import org.apache.sis.referencing.operation.provider.FranceGeocentricInterpolationTest;
import org.apache.sis.referencing.operation.provider.GeocentricTranslationTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.io.IOException;
-import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.referencing.operation.provider.AbridgedMolodensky;
-import org.apache.sis.math.StatisticsFormat;
-import org.apache.sis.math.Statistics;
-import static org.apache.sis.metadata.privy.ReferencingServices.NAUTICAL_MILE;
-import org.opengis.test.CalculationType;
-import org.opengis.test.ToleranceModifier;
-import org.opengis.test.ToleranceModifiers;
-import org.opengis.test.referencing.ParameterizedTransformTest;
-import org.apache.sis.test.TestCase;
+// Specific to the main branch:
+import static org.apache.sis.referencing.privy.CoordinateOperations.builder;
/**
- * Tests {@link MolodenskyTransform}. The {@link #compareWithGeocentricTranslation()}
+ * Tests {@link MolodenskyTransform}. The {@code compareWithGeocentricTranslation()}
* method uses {@link EllipsoidToCentricTransform} as a reference implementation.
* The errors compared to geocentric translations should not be greater than
* approximately 1 centimetre.
@@ -77,67 +67,6 @@
}
/**
- * Compares the Molodensky (non-abridged) transform with a geocentric translation.
- * Molodensky is an approximation of geocentric translation, so we test here how good this approximation is.
- * If {@link TestCase#VERBOSE} is {@code true}, then this method will print error statistics.
- *
- * @throws FactoryException if an error occurred while creating a transform step.
- * @throws TransformException if a transformation failed.
- * @throws IOException should never happen.
- *
- * @see #compareWithGeocentricTranslation()
- */
- @SuppressWarnings("fallthrough")
- private void compareWithGeocentricTranslation(
- final Ellipsoid source, final Ellipsoid target,
- final double tX, final double tY, final double tZ,
- final double xmin, final double ymin, final double zmin,
- final double xmax, final double ymax, final double zmax)
- throws FactoryException, TransformException, IOException
- {
- final MathTransform reference;
- final MathTransformFactory factory = DefaultMathTransformFactory.provider();
- transform = MolodenskyTransform.createGeodeticTransformation(factory, source, true, target, true, tX, tY, tZ, false);
- reference = GeocentricTranslationTest.createDatumShiftForGeographic3D(factory, source, target, tX, tY, tZ);
- final float[] srcPts = verifyInDomain(
- new double[] {xmin, ymin, zmin},
- new double[] {xmax, ymax, zmax},
- new int[] { 10, 10, 10},
- TestUtilities.createRandomNumberGenerator(103627524044558476L));
- /*
- * Transform the same input coordinates using Molodensky transform (actual) and using the reference
- * implementation (expected). If we were asked to print statistics, compute them before to test the
- * values since the statistics may be a useful information in case of problem.
- */
- final double[] actual = new double[srcPts.length];
- final double[] expected = new double[srcPts.length];
- transform.transform(srcPts, 0, actual, 0, srcPts.length / 3);
- reference.transform(srcPts, 0, expected, 0, srcPts.length / 3);
- if (TestCase.VERBOSE) {
- final Statistics[] stats = {
- new Statistics("|Δλ| (~cm)"),
- new Statistics("|Δφ| (~cm)"),
- new Statistics("|Δh| (cm)")
- };
- for (int i=0; i<srcPts.length; i++) {
- double Δ = actual[i] - expected[i];
- final int j = i % stats.length;
- switch (j) {
- case 0: Δ *= cos(toRadians(expected[i+1])); // Fall through
- case 1: Δ *= 60 * NAUTICAL_MILE; break; // Approximate conversion to metres
- }
- Δ *= 100; // Conversion to centimetres.
- stats[j].accept(abs(Δ));
- }
- StatisticsFormat.getInstance().format(stats, TestCase.out);
- }
- assertCoordinatesEqual(3, expected, 0,
- actual, 0, expected.length / 3,
- CalculationType.DIRECT_TRANSFORM,
- "Comparison of Molodensky and geocentric translation");
- }
-
- /**
* Creates a three-dimensional Molodensky transform for a datum shift from WGS84 to ED50.
* Tolerance thresholds are also initialized.
*
@@ -206,6 +135,7 @@
final double[] sample = GeocentricTranslationTest.samplePoint(1);
final double[] expected = GeocentricTranslationTest.samplePoint(5);
isInverseTransformSupported = false;
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
verifyTransform(sample, expected);
/*
* When testing the inverse transformation, we need to relax slightly
@@ -234,6 +164,7 @@
final double[] sample = GeocentricTranslationTest.samplePoint(1);
final double[] expected = GeocentricTranslationTest.samplePoint(4);
isInverseTransformSupported = false;
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
verifyTransform(sample, expected);
/*
* When testing the inverse transformation, we need to relax slightly
@@ -252,8 +183,6 @@
*
* @throws FactoryException if an error occurred while creating the transform.
* @throws TransformException if transformation of a point failed.
- *
- * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
*/
@Test
public void testFranceGeocentricInterpolationPoint() throws FactoryException, TransformException {
@@ -269,7 +198,7 @@
* Code below is a copy-and-paste of GeocentricTranslationTest.testFranceGeocentricInterpolationPoint(),
* but with the tolerance threshold increased. We do not let the error goes beyond 1 cm however.
*/
- tolerance = min(Formulas.ANGULAR_TOLERANCE, FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE * 6);
+ tolerance = Formulas.LINEAR_TOLERANCE; // Other SIS branches use a stricter threshold.
final double[] source = Arrays.copyOf(FranceGeocentricInterpolationTest.samplePoint(1), 3);
final double[] expected = Arrays.copyOf(FranceGeocentricInterpolationTest.samplePoint(2), 3);
expected[2] = 43.15; // Anti-regression (this value is not provided in NTG_88 guidance note).
@@ -278,46 +207,6 @@
}
/**
- * Compares the Molodensky (non-abridged) transforms with geocentric translations.
- * Molodensky is an approximation of geocentric translation, so we test here how good this
- * approximation is. This test performs the comparison for the following transformations:
- *
- * <ul>
- * <li>Transformation from NTF to RGF93. Those CRS are the source and target of <q>France geocentric
- * interpolation</q> (ESPG:9655). This test allows us to verify the accuracy documented in
- * {@link InterpolatedGeocentricTransform}.</li>
- * <li>(More areas may be added later).</li>
- * </ul>
- *
- * If {@link TestCase#VERBOSE} is {@code true}, then this method will print error statistics.
- *
- * @throws FactoryException if an error occurred while creating a transform step.
- * @throws TransformException if a transformation failed.
- * @throws IOException should never happen.
- *
- * @see #testFranceGeocentricInterpolationPoint()
- */
- @Test
- public void compareWithGeocentricTranslation() throws FactoryException, TransformException, IOException {
- /*
- * Disable the test for inverse transformations because they are not the purpose of this test.
- * Errors of inverse transformations are added to the error of forward transformations, which
- * would force us to double the tolerance threshold.
- */
- isInverseTransformSupported = false;
- tolerance = 3*Formulas.LINEAR_TOLERANCE; // To be converted in degrees by ToleranceModifier.GEOGRAPHIC
- zTolerance = 4*Formulas.LINEAR_TOLERANCE;
- toleranceModifier = ToleranceModifiers.concatenate(ToleranceModifier.GEOGRAPHIC, toleranceModifier);
- compareWithGeocentricTranslation(HardCodedDatum.NTF.getEllipsoid(), // Clarke 1880 (IGN)
- CommonCRS.ETRS89.ellipsoid(), // GRS 1980 ellipsoid
- FranceGeocentricInterpolation.TX,
- FranceGeocentricInterpolation.TY,
- FranceGeocentricInterpolation.TZ,
- -5.5, 41.0, -200, // Geographic area of GR2DF97A datum shift grid.
- 10.0, 52.0, +200);
- }
-
- /**
* Tests conversion of random points. The test is performed with the Molodensky transform,
* not the abridged one, because the errors caused by the abridged Molodensky method are
* too high for this test.
@@ -330,7 +219,7 @@
create(false);
tolerance = Formulas.LINEAR_TOLERANCE * 3; // To be converted in degrees by ToleranceModifier.GEOGRAPHIC
zTolerance = Formulas.LINEAR_TOLERANCE * 2;
- toleranceModifier = ToleranceModifiers.concatenate(ToleranceModifier.GEOGRAPHIC, toleranceModifier);
+// toleranceModifier = ToleranceModifiers.concatenate(ToleranceModifier.GEOGRAPHIC, toleranceModifier);
verifyInDomain(new double[] {-179, -85, -500},
new double[] {+179, +85, +500},
new int[] { 8, 8, 8},
@@ -346,7 +235,7 @@
@Test
public void testProvider() throws FactoryException, TransformException {
final MathTransformFactory factory = new MathTransformFactoryMock(new Molodensky());
- final var builder = factory.builder("Molodenski");
+ final var builder = builder(factory, "Molodenski");
final ParameterValueGroup parameters = builder.parameters();
parameters.parameter("dim").setValue(3);
parameters.parameter("dx").setValue(-3.0);
@@ -365,17 +254,6 @@
}
/**
- * Runs the test defined in the GeoAPI-conformance module.
- *
- * @throws FactoryException if an error occurred while creating a transform step.
- * @throws TransformException if a transformation failed.
- */
- @Test
- public void runGeoapiTest() throws FactoryException, TransformException {
- new ParameterizedTransformTest(new MathTransformFactoryMock(new AbridgedMolodensky())).testAbridgedMolodensky();
- }
-
- /**
* Verifies that creating a Molodensky operation with same source and target ellipsoid and zero translation
* results in an identity affine transform.
*
@@ -399,7 +277,7 @@
*/
@Test
public void testRedimension3Dto2D() throws FactoryException, TransformException {
- final MathTransformFactory factory = DefaultMathTransformFactory.provider();
+ final DefaultMathTransformFactory factory = DefaultMathTransformFactory.provider();
transform = new MolodenskyTransform(
HardCodedDatum.WGS84.getEllipsoid(), true,
GeodeticDatumMock.ED50.getEllipsoid(), true,
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java
index 3764122..a5823eb 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java
@@ -34,8 +34,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.operation.PointMotionOperation;
+// Specific to the main branch:
+import org.opengis.referencing.operation.PassThroughOperation;
/**
@@ -152,9 +152,9 @@
assertEquals(Set.of(nad), shifts);
assertEquals(Set.of(nad), shifts);
/*
- * Test filtering: the test should not contain any point motion operation.
+ * Test filtering: the test should not contain any pass-through operation.
*/
- assertEmpty(create(PointMotionOperation.class, methods));
+ assertEmpty(create(PassThroughOperation.class, methods));
/*
* Opportunist tests.
*/
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java
index 132e1aa..be6207c 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java
@@ -36,9 +36,8 @@
import org.apache.sis.test.TestUtilities;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.CalculationType;
-import org.opengis.test.ToleranceModifier;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -216,21 +215,19 @@
* Now process to the transform and compares the results with the expected ones.
*/
tolerance = 0; // Results should be strictly identical because we used the same inputs.
- toleranceModifier = null;
final double[] transformedData = new double[StrictMath.max(sourceDim, targetDim) * numPts];
transform.transform(passthroughData, 0, transformedData, 0, numPts);
- assertCoordinatesEqual(targetDim, expectedData, 0, transformedData, 0, numPts, CalculationType.DIRECT_TRANSFORM,
- "PassThroughTransform results do not match the results computed by this test.");
+ assertCoordinatesEqual("PassThroughTransform results do not match the results computed by this test.",
+ targetDim, expectedData, 0, transformedData, 0, numPts, false);
/*
* Test inverse transform.
*/
if (isInverseTransformSupported) {
tolerance = 1E-8;
- toleranceModifier = ToleranceModifier.RELATIVE;
Arrays.fill(transformedData, Double.NaN);
transform.inverse().transform(expectedData, 0, transformedData, 0, numPts);
- assertCoordinatesEqual(sourceDim, passthroughData, 0, transformedData, 0, numPts, CalculationType.INVERSE_TRANSFORM,
- "Inverse of PassThroughTransform do not give back the original data.");
+ assertCoordinatesEqual("Inverse of PassThroughTransform do not give back the original data.",
+ sourceDim, passthroughData, 0, transformedData, 0, numPts, false);
}
/*
* Verify the consistency between different 'transform(…)' methods.
@@ -238,16 +235,6 @@
final float[] sourceAsFloat = ArraysExt.copyAsFloats(passthroughData);
final float[] targetAsFloat = verifyConsistency(sourceAsFloat);
assertEquals(expectedData.length, targetAsFloat.length, "Unexpected length of transformed array.");
- /*
- * We use a relatively high tolerance threshold because result are
- * computed using inputs stored as float values.
- */
- if (transform instanceof LinearTransform) {
- tolerance = 1E-4;
- toleranceModifier = ToleranceModifier.RELATIVE;
- assertCoordinatesEqual(sourceDim, expectedData, 0, targetAsFloat, 0, numPts, CalculationType.DIRECT_TRANSFORM,
- "PassThroughTransform.transform(…) variants produce inconsistent results.");
- }
}
/**
@@ -284,8 +271,8 @@
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1});
- assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(0)), null,
- "Expected removal of dimensions 0 and 4 before pass-through");
+ assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(0)), 0,
+ "Expected removal of dimensions 0 and 4 before pass-through");
/*
* The number of pass-through dimensions have decreased from 2 to 1 on both sides of the sub-transform.
*/
@@ -302,8 +289,8 @@
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1});
- assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(2)), null,
- "Expected removal of dimensions 1 and 2 after pass-through");
+ assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(2)), 0,
+ "Expected removal of dimensions 1 and 2 after pass-through");
}
/**
@@ -378,6 +365,6 @@
final Matrix m = MathTransforms.getMatrix(c.transform1);
assertNotNull(m);
assertSame(passThrough, c.transform2);
- assertMatrixEquals(expected, m, null, null);
+ assertMatrixEquals(expected, m, 0, null);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java
index f858d2b..d6b642b 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java
@@ -26,9 +26,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Tests {@link PolarToCartesian}.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
index 8f737b5..e315d47 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
@@ -41,9 +41,11 @@
import org.apache.sis.test.FailureDetailsReporter;
import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
-import org.opengis.test.referencing.AffineTransformTest;
+// Specific to the main branch:
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.junit.jupiter.api.Disabled;
+import org.opengis.test.referencing.TransformTestCase;
+import org.apache.sis.test.GeoapiAssert;
/**
@@ -54,8 +56,19 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("doclint:missing")
@ExtendWith(FailureDetailsReporter.class)
-public class ProjectiveTransformTest extends AffineTransformTest {
+public class ProjectiveTransformTest extends TransformTestCase {
+ /**
+ * The factory to use for creating linear transforms.
+ */
+ private final MathTransformFactory mtFactory;
+
+ /**
+ * The matrix for the tested transform.
+ */
+ private Matrix matrix;
+
/**
* A math transform factory which delegates instantiations to the enclosing test class.
* This is a workaround while waiting for JEP 447: Statements before super(…).
@@ -74,7 +87,7 @@
* Creates a new test suite.
*/
public ProjectiveTransformTest() {
- super(new Proxy());
+ mtFactory = new Proxy();
((Proxy) mtFactory).test = this;
}
@@ -116,7 +129,10 @@
}
/*
- * Inherit all the tests from GeoAPI:
+ * GeoAPI 3.1 defines the following tests. However since those tests are not available
+ * in GeoAPI 3.0, we put empty placeholder. For running the real test, see for example
+ * the JDK6 branch of Apache SIS.
+ *
* - testIdentity1D()
* - testIdentity2D()
* - testIdentity3D()
@@ -130,6 +146,64 @@
* - testDimensionReduction()
*/
+ static final String MESSAGE = "This test is not available in GeoAPI 3.0. "
+ + "See Apache SIS geoapi-4.0 branch for the actual tests.";
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testIdentity1D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testIdentity2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testIdentity3D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testAxisSwapping2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testSouthOrientated2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testTranslatation2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testUniformScale2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testGenericScale2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testRotation2D() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testGeneral() throws FactoryException, TransformException {
+ }
+
+ @Test
+ @Disabled(MESSAGE)
+ public void testDimensionReduction() throws FactoryException, TransformException {
+ }
+
/**
* Tests {@link ProjectiveTransform#optimize()}. In particular this method verifies that a non-square matrix
* that looks like diagonal is not confused with a real diagonal matrix.
@@ -148,14 +222,13 @@
});
transform = mtFactory.createAffineTransform(matrix);
assertInstanceOf(ProjectiveTransform.class, transform, "Non-diagonal matrix shall not be handled by ScaleTransform.");
- verifyConsistency(1, 2, 3, -3, -2, -1);
+ verifyConsistency(new float[] {1, 2, 3, -3, -2, -1});
/*
* Remove the "problematic" row. The new transform should now be optimizable.
*/
matrix = ((MatrixSIS) matrix).removeRows(3, 4);
transform = mtFactory.createAffineTransform(matrix);
assertInstanceOf(ScaleTransform.class, getOptimizedTransform(), "Diagonal matrix should be handled by a specialized class.");
- verifyConsistency(1, 2, 3, -3, -2, -1);
}
/**
@@ -169,9 +242,8 @@
public void testOptimizeConstant() throws FactoryException, TransformException {
matrix = new Matrix2(0, 10, 0, 1);
transform = mtFactory.createAffineTransform(matrix);
- Assertions.assertMatrixEquals(matrix, assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT,
+ GeoapiAssert.assertMatrixEquals(matrix, assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT,
"Transform shall use the given matrix unmodified.");
- verifyConsistency(1, 2, 3, -3, -2, -1);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java
index b3c21ad..a9f99aa 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java
@@ -27,8 +27,8 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
+// Specific to the main branch:
+import org.apache.sis.test.GeoapiAssert;
/**
@@ -55,7 +55,7 @@
final ScaleTransform tr = new ScaleTransform(matrix.getNumRow(), matrix.getNumCol(), elements);
assertEquals(sourceDimensions, tr.getSourceDimensions());
assertEquals(targetDimensions, tr.getTargetDimensions());
- Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
+ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
assertArrayEquals(elements, TranslationTransformTest.getElementAsNumbers(tr));
transform = tr;
validate();
@@ -135,7 +135,7 @@
final ScaleTransform tr = new ScaleTransform(4, 4, elements);
assertEquals(3, tr.getSourceDimensions());
assertEquals(3, tr.getTargetDimensions());
- Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
+ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
TranslationTransformTest.replaceZeroByNull(elements, O);
assertArrayEquals(elements, tr.getElementAsNumbers(false));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SpecializableTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SpecializableTransformTest.java
index 7ae496b..c972493 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SpecializableTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SpecializableTransformTest.java
@@ -135,7 +135,6 @@
public void testForwardConsistency() throws TransformException {
transform = create(false);
tolerance = 1E-14;
- isDerivativeSupported = false; // Actually supported, but our test transform has discontinuities.
verifyInDomain(CoordinateDomain.RANGE_10, -672445632505596619L);
}
@@ -152,7 +151,6 @@
public void testInverseConsistency() throws TransformException {
transform = create(false).inverse();
tolerance = 1E-12;
- isDerivativeSupported = false; // Actually supported, but our test transform has discontinuities.
verifyInDomain(CoordinateDomain.RANGE_100, 4308397764777385180L);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
index 3aef178..9b91460 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
@@ -30,9 +30,6 @@
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Tests {@link SphericalToCartesian}.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java
index d99bb74..bfd3256 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java
@@ -28,8 +28,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformResultComparator.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformResultComparator.java
index 57f9b54..77c6192 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformResultComparator.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformResultComparator.java
@@ -28,9 +28,9 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -113,9 +113,9 @@
*/
@Override
public DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws TransformException {
- final double[] expected = reference.transform(ptSrc, ptDst).getCoordinates();
+ final double[] expected = reference.transform(ptSrc, ptDst).getCoordinate();
final DirectPosition value = tested.transform(ptSrc, ptDst);
- assertArrayEquals(expected, value.getCoordinates(), tolerance);
+ assertArrayEquals(expected, value.getCoordinate(), tolerance);
return value;
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java
index 34bb46f..e52e750 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java
@@ -39,8 +39,8 @@
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.referencing.datum.HardCodedDatum;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
@@ -395,7 +395,7 @@
DirectPosition actual = null;
for (int t=0; t<50; t++) {
for (int i=source.getDimension(); --i>=0;) {
- source.setCoordinate(i, random.nextDouble());
+ source.setOrdinate(i, random.nextDouble());
}
step = tr1 .transform(source, step);
expected = tr2 .transform(step, expected);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformTestCase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformTestCase.java
new file mode 100644
index 0000000..b78d573
--- /dev/null
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * 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.referencing.operation.transform;
+
+import java.util.Random;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
+
+
+/**
+ * Placeholder for a GeoAPI 3.1 method which was not available in GeoAPI 3.0.
+ * This placeholder does nothing. See Apache SIS JDK6 branch for a real test.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+public class TransformTestCase extends org.opengis.test.referencing.TransformTestCase {
+ /**
+ * The deltas to use for approximating math transform derivatives by the finite differences method.
+ */
+ protected double[] derivativeDeltas;
+
+ /**
+ * Placeholder for a GeoAPI 3.1 method which was not available in GeoAPI 3.0.
+ * This placeholder does nothing. See Apache SIS JDK6 branch for a real test.
+ *
+ * @param coordinate Ignored.
+ */
+ protected final void verifyDerivative(final double... coordinate) {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+
+ /**
+ * Placeholder for a GeoAPI 3.1 method which was not available in GeoAPI 3.0.
+ * This placeholder does nothing. See Apache SIS JDK6 branch for a real test.
+ *
+ * @param minOrdinates Ignored.
+ * @param maxOrdinates Ignored.
+ * @param numOrdinates Ignored.
+ * @param randomGenerator Ignored.
+ */
+ protected final void verifyInDomain(final double[] minOrdinates, final double[] maxOrdinates,
+ final int[] numOrdinates, final Random randomGenerator)
+ {
+ // See GeoAPI 3.1 for the real test.
+ // The test is run on Apache SIS branches.
+ assumeTrue(PENDING_NEXT_GEOAPI_RELEASE); // For reporting the test as skippped.
+ }
+}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java
index 7dc07bb..176916a 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java
@@ -28,8 +28,8 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
+// Specific to the main branch:
+import org.apache.sis.test.GeoapiAssert;
/**
@@ -55,7 +55,7 @@
final TranslationTransform tr = new TranslationTransform(matrix.getNumRow(), elements);
assertEquals(dimensions, tr.getSourceDimensions());
assertEquals(dimensions, tr.getTargetDimensions());
- Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
+ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
assertArrayEquals(elements, getElementAsNumbers(tr));
transform = tr;
validate();
@@ -96,7 +96,7 @@
final TranslationTransform tr = new TranslationTransform(4, elements);
assertEquals(3, tr.getSourceDimensions());
assertEquals(3, tr.getTargetDimensions());
- Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
+ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix");
replaceZeroByNull(elements, O);
assertArrayEquals(elements, tr.getElementAsNumbers(false));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/WraparoundTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/WraparoundTransformTest.java
index 770cab8..13b8f32 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/WraparoundTransformTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/WraparoundTransformTest.java
@@ -32,8 +32,8 @@
import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
index 92f84c5..2967246 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
@@ -32,6 +32,13 @@
import org.apache.sis.referencing.cs.HardCodedCS;
import org.apache.sis.test.TestCase;
+// Specific to the main branch:
+import static org.apache.sis.referencing.privy.AxisDirections.TOWARDS;
+import static org.apache.sis.referencing.privy.AxisDirections.AWAY_FROM;
+import static org.apache.sis.referencing.privy.AxisDirections.CLOCKWISE;
+import static org.apache.sis.referencing.privy.AxisDirections.COUNTER_CLOCKWISE;
+import static org.apache.sis.referencing.privy.AxisDirections.UNSPECIFIED;
+
/**
* Tests the {@link AxisDirections} class.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/EllipsoidalHeightCombinerTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/EllipsoidalHeightCombinerTest.java
index 376493f..104eed6 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/EllipsoidalHeightCombinerTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/EllipsoidalHeightCombinerTest.java
@@ -40,8 +40,8 @@
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
import static org.apache.sis.test.Assertions.assertArrayEqualsIgnoreMetadata;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/GeodeticObjectBuilderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/GeodeticObjectBuilderTest.java
index 66fde6a..7c675be 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/GeodeticObjectBuilderTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/GeodeticObjectBuilderTest.java
@@ -28,8 +28,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ReferencingUtilitiesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ReferencingUtilitiesTest.java
index c6d794d..9fe54f8 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ReferencingUtilitiesTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ReferencingUtilitiesTest.java
@@ -119,10 +119,10 @@
assertEquals("cylindricalCS", toPropertyName(CoordinateSystem.class, CylindricalCS .class).toString());
assertEquals("ellipsoidalCS", toPropertyName(CoordinateSystem.class, EllipsoidalCS .class).toString());
assertEquals("linearCS", toPropertyName(CoordinateSystem.class, LinearCS .class).toString());
- assertEquals("parametricCS", toPropertyName(CoordinateSystem.class, ParametricCS .class).toString());
+// assertEquals("parametricCS", toPropertyName(CoordinateSystem.class, ParametricCS .class).toString());
assertEquals("polarCS", toPropertyName(CoordinateSystem.class, PolarCS .class).toString());
assertEquals("sphericalCS", toPropertyName(CoordinateSystem.class, SphericalCS .class).toString());
- assertEquals("temporalCS", toPropertyName(CoordinateSystem.class, TimeCS .class).toString());
+ assertEquals("timeCS", toPropertyName(CoordinateSystem.class, TimeCS .class).toString());
assertEquals("verticalCS", toPropertyName(CoordinateSystem.class, VerticalCS .class).toString());
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTUtilitiesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTUtilitiesTest.java
index 7779637..961b004 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTUtilitiesTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTUtilitiesTest.java
@@ -53,7 +53,7 @@
assertEquals(WKTKeywords.cylindrical, toType(CoordinateSystem.class, CylindricalCS .class));
assertEquals(WKTKeywords.ellipsoidal, toType(CoordinateSystem.class, EllipsoidalCS .class));
assertEquals(WKTKeywords.linear, toType(CoordinateSystem.class, LinearCS .class));
- assertEquals(WKTKeywords.parametric, toType(CoordinateSystem.class, ParametricCS .class));
+// assertEquals(WKTKeywords.parametric, toType(CoordinateSystem.class, ParametricCS .class));
assertEquals(WKTKeywords.polar, toType(CoordinateSystem.class, PolarCS .class));
assertEquals(WKTKeywords.spherical, toType(CoordinateSystem.class, SphericalCS .class));
assertEquals(WKTKeywords.temporal, toType(CoordinateSystem.class, TimeCS .class));
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateOperationMethods.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateOperationMethods.java
index 1327cf3..fbb5b1d 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateOperationMethods.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateOperationMethods.java
@@ -51,9 +51,9 @@
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.crs.DerivedCRS;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.crs.GeneralDerivedCRS;
/**
@@ -238,7 +238,7 @@
* ──────────────── EPSG IDENTIFIERS ────────────────────────────────────
*/
final StringBuilder buffer = new StringBuilder();
- for (final Identifier id : method.getIdentifiers()) {
+ for (final ReferenceIdentifier id : method.getIdentifiers()) {
if (Constants.EPSG.equalsIgnoreCase(id.getCodeSpace())) {
if (buffer.length() != 0) {
buffer.append(", ");
@@ -380,7 +380,7 @@
private void writeName(final ParameterDescriptor<?> param) throws IOException {
final int td = openTag("td class=\"sep\"");
openTag("details");
- final Identifier name = param.getName();
+ final ReferenceIdentifier name = param.getName();
final String codeSpace = name.getCodeSpace();
if (Constants.EPSG.equalsIgnoreCase(codeSpace)) {
println("summary", escape(name.getCode()));
@@ -414,14 +414,14 @@
final CRSAuthorityFactory factory) throws FactoryException
{
final Map<String, DefaultGeographicBoundingBox> domainOfValidity = new HashMap<>();
- for (final String code : factory.getAuthorityCodes(DerivedCRS.class)) {
+ for (final String code : factory.getAuthorityCodes(GeneralDerivedCRS.class)) {
final CoordinateReferenceSystem crs;
try {
crs = factory.createCoordinateReferenceSystem(code);
} catch (FactoryException e) {
continue; // Ignore and inspect the next element.
}
- if (crs instanceof DerivedCRS derived) {
+ if (crs instanceof GeneralDerivedCRS derived) {
final GeographicBoundingBox candidate = CRS.getGeographicBoundingBox(derived);
if (candidate != null) {
final String name = derived.getConversionFromBase().getMethod().getName().getCode();
@@ -529,8 +529,8 @@
/**
* Returns the first EPSG code found in the given collection, or {@code null} if none.
*/
- private static String getFirstEpsgCode(final Iterable<? extends Identifier> identifiers) {
- for (final Identifier id : identifiers) {
+ private static String getFirstEpsgCode(final Iterable<? extends ReferenceIdentifier> identifiers) {
+ for (final ReferenceIdentifier id : identifiers) {
if (Constants.EPSG.equalsIgnoreCase(id.getCodeSpace())) {
return id.getCode();
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
deleted file mode 100644
index feab090..0000000
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- * 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.referencing.report;
-
-import java.util.Locale;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.TreeMap;
-import java.util.NavigableMap;
-import java.util.Optional;
-import java.io.File;
-import java.io.IOException;
-import org.opengis.metadata.Identifier;
-import org.opengis.util.FactoryException;
-import org.opengis.util.InternationalString;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.cs.CartesianCS;
-import org.opengis.referencing.cs.SphericalCS;
-import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.crs.CompoundCRS;
-import org.opengis.referencing.crs.VerticalCRS;
-import org.opengis.referencing.crs.GeodeticCRS;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.crs.EngineeringCRS;
-import org.opengis.referencing.crs.DerivedCRS;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.CRSAuthorityFactory;
-import org.opengis.referencing.datum.Datum;
-import org.opengis.referencing.datum.RealizationMethod;
-import org.opengis.referencing.operation.OperationMethod;
-import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.internal.DeprecatedCode;
-import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.Deprecable;
-import org.apache.sis.util.Utilities;
-import org.apache.sis.util.Version;
-import org.apache.sis.util.privy.Constants;
-import org.apache.sis.referencing.crs.AbstractCRS;
-import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.util.iso.DefaultNameSpace;
-import org.apache.sis.util.logging.Logging;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.opengis.test.report.AuthorityCodesReport;
-
-
-/**
- * Generates a list of supported Coordinate Reference Systems in the current directory.
- * This class is for manual execution after the EPSG database has been updated,
- * or the projection implementations changed.
- *
- * <p><b>WARNING:</b>
- * this class implements heuristic rules for nicer sorting (e.g. of CRS having numbers as Roman letters).
- * Those heuristic rules were determined specifically for the EPSG dataset expanded with WMS codes.
- * This class is not likely to produce good results for any other authorities, and many need to be updated
- * after any upgrade of the EPSG dataset.</p>
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class CoordinateReferenceSystems extends AuthorityCodesReport {
- /**
- * The titles of some sections where to group CRS. By default CRS are grouped by datum names.
- * But if a name is listed in this map, then that alternative name will be used for grouping purpose.
- * Sometimes the change is only cosmetic (e.g. "Reseau Geodesique Francais" → "Réseau Géodésique Français").
- * But sometimes the changes have the effect of merging different datum under the same section.
- * For example, we merge the "Arc 1950" and "Arc 1960" sections into a single "Arc" section,
- * since those sections were small and we do not want to scatter the HTML page with too many sections.
- * However, we do not merge "NAD83" and "NAD83(HARN)" because those sections are already quite large,
- * and merging them will result in a too large section.
- *
- * <p>The decision to merge or not is arbitrary. Generally, we try to avoid small sections (less that 5 CRS)
- * but without merging together unrelated datum. Every CRS having a datum whose name <em>starts</em> with a
- * value in the left column will be reported in the section given in the right column.</p>
- */
- private static final NavigableMap<String,String> SECTION_TITLES = new TreeMap<>();
- static {
- rd("American Samoa", "American Samoa");
- rd("Arc", "Arc");
- rd("Ancienne Triangulation Francaise", "Ancienne Triangulation Française");
- rd("Australian Geodetic Datum", "Australian Geodetic Datum");
- rd("Australian Height Datum", "Australian Height Datum");
- rd("Azores Central Islands", "Azores Islands");
- rd("Azores Occidental Islands", "Azores Islands");
- rd("Azores Oriental Islands", "Azores Islands");
- rd("Baltic", "Baltic");
- rd("Batavia", "Batavia");
- rd("Bermuda", "Bermuda");
- rd("Bogota 1975", "Bogota 1975");
- rd("Carthage", "Carthage");
- rd("Bern 1938", "Bern / CH1903");
- rd("Cais", "Cais");
- rd("Cayman Brac", "Cayman Islands");
- rd("Cayman Islands", "Cayman Islands");
- rd("CH1903", "Bern / CH1903");
- rd("CH1903+", "Bern / CH1903");
- rd("Canadian Geodetic Vertical Datum", "Canadian Geodetic Vertical Datum");
- rd("Chatham Islands Datum", "Chatham Islands Datum");
- rd("Corrego Alegre", "Corrego Alegre");
- rd("Croatian Terrestrial Reference System", "Croatian Reference System");
- rd("Croatian Vertical Reference Datum", "Croatian Reference System");
- rd("Danger 1950", "Saint Pierre et Miquelon 1950");
- rd("Dansk", "Dansk");
- rd("Dealul Piscului", "Dealul Piscului");
- rd("Deutsches Haupthoehennetz", "Deutsches Haupthoehennetz");
- rd("Douala", "Douala");
- rd("Dunedin", "Dunedin");
- rd("Dunedin-Bluff", "Dunedin");
- rd("EGM2008 geoid", "EGM geoid");
- rd("EGM84 geoid", "EGM geoid");
- rd("EGM96 geoid", "EGM geoid");
- rd("Egypt", "Egypt");
- rd("EPSG example", "EPSG example");
- rd("Estonia", "Estonia");
- rd("European Datum", "European Datum");
- rd("European Terrestrial Reference Frame", "European Terrestrial Reference Frame");
- rd("European Vertical Reference Frame", "European Vertical Reference Frame");
- rd("Fahud", "Fahud");
- rd("Fao", "Fao");
- rd("Fehmarnbelt", "Fehmarnbelt");
- rd("Faroe Datum", "Faroe Islands");
- rd("Faroe Islands", "Faroe Islands");
- rd("fk89", "Faroe Islands");
- rd("Fiji", "Fiji");
- rd("Gan 1970", "Gandajika");
- rd("Grand Cayman", "Grand Cayman");
- rd("Greek", "Greek");
- rd("Greenland", "Greenland");
- rd("Guadeloupe", "Guadeloupe");
- rd("Guam", "Guam");
- rd("Gunung Segara", "Gunung Segara");
- rd("Helsinki", "Helsinki");
- rd("High Water", "High Water");
- rd("Higher High Water", "High Water");
- rd("Highest Astronomical Tide", "High Water");
- rd("Hong Kong", "Hong Kong");
- rd("Hungarian", "Hungarian Datum");
- rd("IG05", "Israeli Grid");
- rd("IGb", "IGb");
- rd("IGN", "IGN");
- rd("IGS", "IGS");
- rd("Indian", "Indian");
- rd("International Great Lakes Datum", "International Great Lakes Datum");
- rd("International Terrestrial Reference Frame", "International Terrestrial Reference Frame");
- rd("Islands Net", "Islands Net");
- rd("Israeli Geodetic Datum", "Israeli Geodetic Datum");
- rd("Jamaica", "Jamaica");
- rd("Japanese Geodetic Datum 2000", "Japanese Geodetic Datum 2000");
- rd("Japanese Geodetic Datum 2011", "Japanese Geodetic Datum 2011");
- rd("Japanese Standard Levelling Datum", "Japanese Standard Levelling Datum");
- rd("Kalianpur", "Kalianpur");
- rd("Kertau", "Kertau");
- rd("KOC Construction Datum", "KOC Construction Datum / Well Datum");
- rd("KOC Well Datum", "KOC Construction Datum / Well Datum");
- rd("Korean Datum", "Korean Datum");
- rd("Kuwait Oil Company", "Kuwait Oil Company / Kuwait Utility");
- rd("Kuwait PWD", "Kuwait Oil Company / Kuwait Utility");
- rd("Kuwait Utility", "Kuwait Oil Company / Kuwait Utility");
- rd("Lao", "Lao");
- rd("Latvia", "Latvia");
- rd("Lisbon", "Lisbon");
- rd("Lower Low Water Large Tide", "Low Water");
- rd("Lowest Astronomical Tide", "Low Water");
- rd("Macao", "Macao");
- rd("Makassar", "Makassar");
- rd("Manoca", "Manoca");
- rd("Martinique", "Martinique");
- rd("Maupiti", "Maupiti");
- rd("Mean High Water", "Mean Sea Level");
- rd("Mean Higher High Water", "Mean Sea Level");
- rd("Mean Low Water", "Mean Sea Level");
- rd("Mean Lower Low Water", "Mean Sea Level");
- rd("Missao Hidrografico Angola y Sao Tome 1951", "Missao Hidrografico Angola y Sao Tome");
- rd("Mhast (offshore)", "Missao Hidrografico Angola y Sao Tome");
- rd("Mhast (onshore)", "Missao Hidrografico Angola y Sao Tome");
- rd("Militar-Geographische Institut (Ferro)", "Militar-Geographische Institut");
- rd("MOMRA", "MOMRA");
- rd("Monte Mario (Rome)", "Monte Mario");
- rd("Moorea", "Moorea");
- rd("Nahrwan", "Nahrwan");
- rd("Naparima", "Naparima");
- rd("Nivellement General de la Corse", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("Nivellement General de la France", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("Nivellement General de Nouvelle Caledonie", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("Nivellement General de Polynesie Francaise", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("Nivellement General du Luxembourg", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("Nivellement General Guyanais", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
- rd("NGO 1948", "NGO 1948");
- rd("Nouvelle Triangulation Francaise", "Nouvelle Triangulation Française");
- rd("NAD83 Canadian Spatial Reference System", "North American Datum 1983 — Canadian Spatial Reference System");
- rd("NAD83 (Continuously Operating Reference Station 1996)", "North American Datum 1983 — Continuously Operating Reference Station 1996"); // For better sort order.
- rd("NAD83 (Federal Base Network)", "North American Datum 1983 — Federal Base Network");
- rd("NAD83 (High Accuracy Reference Network)", "North American Datum 1983 — High Accuracy Reference Network");
- rd("NAD83 (High Accuracy Reference Network - Corrected)", "North American Datum 1983 — High Accuracy Reference Network");
- rd("NAD83 (National Spatial Reference System 2007)", "North American Datum 1983 — National Spatial Reference System 2007");
- rd("NAD83 (National Spatial Reference System 2011)", "North American Datum 1983 — National Spatial Reference System 2011");
- rd("NAD83 (National Spatial Reference System MA11)", "North American Datum 1983 — National Spatial Reference System MA11 / PA11");
- rd("NAD83 (National Spatial Reference System PA11)", "North American Datum 1983 — National Spatial Reference System MA11 / PA11");
- rd("North American Datum of 1983 (CSRS)", "North American Datum 1983 — CSRS");
- rd("North American Datum of 1983 (CSRS96)", "North American Datum 1983 — CSRS");
- rd("New Zealand Vertical Datum", "New Zealand Vertical Datum");
- rd("Norway Normal Null", "Norway Normal Null");
- rd("Ordnance Datum Newlyn", "Ordnance Datum Newlyn");
- rd("OSGB", "OSGB");
- rd("Parametry Zemli 1990", "Parametry Zemli 1990");
- rd("PDO Height Datum 1993", "PDO Survey / Height Datum 1993");
- rd("PDO Survey Datum 1993", "PDO Survey / Height Datum 1993");
- rd("Pitcairn", "Pitcairn");
- rd("Port Moresby", "Port Moresby");
- rd("Porto Santo", "Porto Santo");
- rd("Posiciones Geodésicas Argentinas", "Posiciones Geodésicas Argentinas");
- rd("Puerto Rico", "Puerto Rico");
- rd("Qatar", "Qatar");
- rd("Qornoq", "Qornoq");
- rd("Reseau Geodesique de Nouvelle Caledonie", "Réseau Géodésique de Nouvelle-Calédonie");
- rd("Reseau National Belge", "Réseau National Belge");
- rd("Reunion", "Réunion");
- rd("Rikets hojdsystem", "Rikets hojdsystem");
- rd("Santa Cruz", "Santa Cruz");
- rd("Serbian", "Serbian Reference System / Network");
- rd("Sierra Leone", "Sierra Leone");
- rd("SIRGAS", "SIRGAS");
- rd("Slovenia", "Slovenia");
- rd("Slovenian", "Slovenia");
- rd("South American Datum", "South American Datum");
- rd("Sri Lanka", "Sri Lanka");
- rd("Stockholm 1938", "Stockholm 1938");
- rd("St. Helena", "St. Helena");
- rd("System of the Unified Trigonometrical Cadastral Network", "System of the Unified Trigonometrical Cadastral Network");
- rd("Tahaa", "Tahaa");
- rd("Tahiti", "Tahiti");
- rd("Taiwan", "Taiwan");
- rd("Tananarive 1925", "Tananarive 1925");
- rd("Tokyo", "Tokyo");
- rd("Viti Levu", "Viti Levu");
- rd("Voirol", "Voirol");
- rd("WGS 72 Transit Broadcast Ephemeris", "World Geodetic System 1972 — Transit Broadcast Ephemeris");
- rd("World Geodetic System 1984", "World Geodetic System 1984");
- rd("Yellow Sea", "Yellow Sea");
- }
-
- /**
- * The datums from the above list which are deprecated, but that we do not want to replace by the non-deprecated
- * datum. We disable some replacements when they allow better sorting of deprecated CRS.
- */
- private static final Set<String> KEEP_DEPRECATED_DATUM = Set.of(
- "Dealul Piscului 1970"); // Datum does not exist but is an alias for S-42 in Romania.
-
- /**
- * Shortcut for {@link #SECTION_TITLES} initialization.
- * {@code "rd"} stands for "rename datum".
- */
- private static void rd(final String datum, final String display) {
- assertNull(datum, SECTION_TITLES.put(datum, display));
- }
-
- /**
- * Words to ignore in a datum name in order to detect if a CRS name is the acronym of the datum name.
- */
- private static final Set<String> DATUM_WORDS_TO_IGNORE = Set.of(
- "of", // VIVD: Virgin Islands Vertical Datum of 2009
- "de", // RRAF: Reseau de Reference des Antilles Francaises
- "des", // RGAF: Reseau Geodesique des Antilles Francaises
- "la", // RGR: Reseau Geodesique de la Reunion
- "et", // RGSPM: Reseau Geodesique de Saint Pierre et Miquelon
- "para", // SIRGAS: Sistema de Referencia Geocentrico para America del Sur 1995
- "del", // SIRGAS: Sistema de Referencia Geocentrico para America del Sur 1995
- "las", // SIRGAS: Sistema de Referencia Geocentrico para las AmericaS 2000
- "Tides"); // MLWS: Mean Low Water Spring Tides
-
- /**
- * The keywords before which to cut the CRS names when sorting by alphabetical order.
- * The main intent here is to preserve the "far west", "west", "central west", "central",
- * "central east", "east", "far east" order.
- */
- private static final String[] CUT_BEFORE = {
- " far west", // "MAGNA-SIRGAS / Colombia Far West zone"
- " far east",
- " west", // "Bogota 1975 / Colombia West zone"
- " east", // "Bogota 1975 / Colombia East Central zone"
- " central", // "Korean 1985 / Central Belt" (between "East Belt" and "West Belt")
- " old central", // "NAD Michigan / Michigan Old Central"
- " bogota zone", // "Bogota 1975 / Colombia Bogota zone"
- // Do not declare "North" and "South" as it causes confusion with "WGS 84 / North Pole" and other cases.
- };
-
- /**
- * The keywords after which to cut the CRS names when sorting by alphabetical order.
- *
- * Note: alphabetical sorting of Roman numbers work for zones from I to VIII inclusive.
- * If there is more zones (for example with "JGD2000 / Japan Plane Rectangular"), then
- * we need to cut before those numbers in order to use sorting by EPSG codes instead.
- *
- * Note 2: if alphabetical sorting is okay for Roman numbers, it is actually preferable
- * because it give better position of names with height like "zone II + NGF IGN69 height".
- */
- private static final String[] CUT_AFTER = {
- " cs ", // "JGD2000 / Japan Plane Rectangular CS IX"
- " tm", // "ETRS89 / TM35FIN(E,N)" — we want to not interleave them between "TM35" and "TM36".
- " dktm", // "ETRS89 / DKTM1 + DVR90 height"
- "-gk", // "ETRS89 / ETRS-GK19FIN"
- " philippines zone ", // "Luzon 1911 / Philippines zone IV"
- " california zone ", // "NAD27 / California zone V"
- " ngo zone ", // "NGO 1948 (Oslo) / NGO zone I"
- " lambert zone ", // "NTF (Paris) / Lambert zone II + NGF IGN69 height"
- "fiji 1956 / utm zone " // Two zones: 60S and 1S with 60 before 1.
- };
-
- /**
- * The symbol to write in from of EPSG code of CRS having an axis order different
- * then the (longitude, latitude) one.
- */
- private static final char YX_ORDER = '\u21B7';
-
- /**
- * The factory which create CRS instances.
- */
- private final CRSAuthorityFactory factory;
-
- /**
- * The datum from the {@link #SECTION_TITLES} that we didn't found after we processed all codes.
- * Used for verification purpose only.
- */
- private final Set<String> unusedDatumMapping;
-
- /**
- * Creates a new instance.
- */
- private CoordinateReferenceSystems() throws FactoryException {
- super(null);
- unusedDatumMapping = new HashSet<>(SECTION_TITLES.keySet());
- properties.setProperty("TITLE", "Apache SIS™ Coordinate Reference System (CRS) codes");
- properties.setProperty("PRODUCT.NAME", "Apache SIS™");
- properties.setProperty("PRODUCT.VERSION", getVersion());
- properties.setProperty("PRODUCT.URL", "https://sis.apache.org");
- properties.setProperty("JAVADOC.GEOAPI", "https://www.geoapi.org/snapshot/javadoc");
- properties.setProperty("FACTORY.NAME", "EPSG");
- properties.setProperty("FACTORY.VERSION", "9.9.1");
- properties.setProperty("FACTORY.VERSION.SUFFIX", ", together with other sources");
- properties.setProperty("PRODUCT.VERSION.SUFFIX", " (provided that <a href=\"https://sis.apache.org/epsg.html\">a connection to an EPSG database exists</a>)");
- properties.setProperty("DESCRIPTION", "<p><b>Notation:</b></p>\n" +
- "<ul>\n" +
- " <li>The " + YX_ORDER + " symbol in front of authority codes (${PERCENT.ANNOTATED} of them) identifies" +
- " left-handed coordinate systems (for example with <var>latitude</var> axis before <var>longitude</var>).</li>\n" +
- " <li>The <del>codes with a strike</del> (${PERCENT.DEPRECATED} of them) identify deprecated CRS." +
- " In some cases, the remarks column indicates the replacement.</li>\n" +
- "</ul>");
- factory = CRS.getAuthorityFactory(null);
- add(factory);
- }
-
- /**
- * Generates the HTML report.
- *
- * @param args ignored.
- * @throws FactoryException if an error occurred while fetching the CRS.
- * @throws IOException if an error occurred while writing the HTML file.
- */
- @SuppressWarnings("UseOfSystemOutOrSystemErr")
- public static void main(final String[] args) throws FactoryException, IOException {
- Locale.setDefault(Locale.US); // We have to use this hack for now because exceptions are formatted in the current locale.
- final CoordinateReferenceSystems writer = new CoordinateReferenceSystems();
- final File file = writer.write(new File("CoordinateReferenceSystems.html"));
- System.out.println("Created " + file.getAbsolutePath());
- if (!writer.unusedDatumMapping.isEmpty()) {
- System.out.println();
- System.out.println("WARNING: the following datums were expected but not found. Maybe their spelling changed?");
- for (final String name : writer.unusedDatumMapping) {
- System.out.print(" - ");
- System.out.println(name);
- }
- }
- }
-
- /**
- * Returns the current Apache SIS version, with the {@code -SNAPSHOT} trailing part omitted.
- *
- * @return the current Apache SIS version.
- */
- private static String getVersion() {
- String version = Version.SIS.toString();
- final int snapshot = version.lastIndexOf('-');
- if (snapshot >= 2) {
- version = version.substring(0, snapshot);
- }
- return version;
- }
-
- /**
- * Creates the text to show in the "Remarks" column for the given CRS.
- */
- private String getRemark(final CoordinateReferenceSystem crs) {
- if (crs instanceof GeographicCRS) {
- return (crs.getCoordinateSystem().getDimension() == 3) ? "Geographic 3D" : "Geographic";
- }
- if (crs instanceof DerivedCRS derived) {
- final OperationMethod method = derived.getConversionFromBase().getMethod();
- final Identifier identifier = IdentifiedObjects.getIdentifier(method, Citations.EPSG);
- if (identifier != null) {
- return "<a href=\"CoordinateOperationMethods.html#" + identifier.getCode()
- + "\">" + method.getName().getCode().replace('_', ' ') + "</a>";
- }
- }
- if (crs instanceof GeodeticCRS) {
- final CoordinateSystem cs = crs.getCoordinateSystem();
- if (cs instanceof CartesianCS) {
- return "Geocentric (Cartesian coordinate system)";
- } else if (cs instanceof SphericalCS) {
- return "Geocentric (spherical coordinate system)";
- }
- return "Geodetic";
- }
- if (crs instanceof VerticalCRS vertical) {
- final Optional<RealizationMethod> method = vertical.getDatum().getRealizationMethod();
- if (method.isPresent()) {
- return CharSequences.camelCaseToSentence(method.get().name().toLowerCase(getLocale())) + " realization method";
- }
- }
- if (crs instanceof CompoundCRS compound) {
- final StringBuilder buffer = new StringBuilder();
- for (final CoordinateReferenceSystem component : compound.getComponents()) {
- if (buffer.length() != 0) {
- buffer.append(" + ");
- }
- buffer.append(getRemark(component));
- }
- return buffer.toString();
- }
- if (crs instanceof EngineeringCRS) {
- return "Engineering (" + crs.getCoordinateSystem().getName().getCode() + ')';
- }
- return "";
- }
-
- /**
- * Omits the trailing number, if any.
- * For example if the given name is "Abidjan 1987", then this method returns "Abidjan".
- */
- private static String omitTrailingNumber(String name) {
- int i = CharSequences.skipTrailingWhitespaces(name, 0, name.length());
- while (i != 0) {
- final char c = name.charAt(--i);
- if (c < '0' || c > '9') {
- name = name.substring(0, CharSequences.skipTrailingWhitespaces(name, 0, i+1));
- break;
- }
- }
- return name;
- }
-
- /**
- * If the first word of the CRS name seems to be an acronym of the datum name,
- * puts that acronym in a {@code <abbr title="datum name">...</abbr>} element.
- */
- static String insertAbbreviationTitle(final String crsName, final String datumName) {
- int s = crsName.indexOf(' ');
- if (s < 0) s = crsName.length();
- int p = crsName.indexOf('(');
- if (p >= 0 && p < s) s = p;
- p = datumName.indexOf('(');
- if (p < 0) p = datumName.length();
- final String acronym = crsName.substring(0, s);
- final String ar = omitTrailingNumber(acronym);
- final String dr = omitTrailingNumber(datumName.substring(0, p));
- if (dr.startsWith(ar)) {
- return crsName; // Avoid redudancy between CRS name and datum name.
- }
- /*
- * If the first CRS word does not seem to be an acronym of the datum name, verify
- * if there is some words that we should ignore in the datum name and try again.
- */
- if (!CharSequences.isAcronymForWords(ar, dr)) {
- final String[] words = (String[]) CharSequences.split(dr, ' ');
- int n = 0;
- for (final String word : words) {
- if (!DATUM_WORDS_TO_IGNORE.contains(word)) {
- words[n++] = word;
- }
- }
- if (n == words.length || n < 2) {
- return crsName;
- }
- final StringBuilder b = new StringBuilder();
- for (int i=0; i<n; i++) {
- if (i != 0) b.append(' ');
- b.append(words[i]);
- }
- if (!CharSequences.isAcronymForWords(ar, b)) {
- return crsName;
- }
- }
- return "<abbr title=\"" + datumName + "\">" + acronym + "</abbr>" + crsName.substring(s);
- }
-
- /**
- * Invoked when a CRS has been successfully created. This method modifies the default
- * {@link org.opengis.test.report.AuthorityCodesReport.Row} attribute values created
- * by GeoAPI.
- *
- * @param code the authority code of the created object.
- * @param object the object created from the given authority code.
- * @return the created row, or {@code null} if the row should be ignored.
- */
- @Override
- protected Row createRow(final String code, final IdentifiedObject object) {
- final Row row = super.createRow(code, object);
- final CoordinateReferenceSystem crs = (CoordinateReferenceSystem) object;
- final CoordinateReferenceSystem crsXY = AbstractCRS.castOrCopy(crs).forConvention(AxesConvention.RIGHT_HANDED);
- if (!Utilities.deepEquals(crs.getCoordinateSystem(), crsXY.getCoordinateSystem(), ComparisonMode.IGNORE_METADATA)) {
- row.annotation = YX_ORDER;
- }
- CoordinateReferenceSystem replacement = crs;
- row.remark = getRemark(crs);
- /*
- * If the object is deprecated, find the replacement.
- * We do not take the whole comment because it may be pretty long.
- */
- if (object instanceof Deprecable dep) {
- row.isDeprecated = dep.isDeprecated();
- if (row.isDeprecated) {
- String replacedBy = null;
- InternationalString i18n = object.getRemarks();
- for (final Identifier id : object.getIdentifiers()) {
- if (id instanceof Deprecable did && did.isDeprecated()) {
- i18n = did.getRemarks();
- if (id instanceof DeprecatedCode dc) {
- replacedBy = dc.replacedBy;
- }
- break;
- }
- }
- if (i18n != null) {
- row.remark = i18n.toString(getLocale());
- }
- /*
- * If a replacement exists for a deprecated CRS, use the datum of the replacement instead of
- * the datum of the deprecated CRS for determining in which section to put the CRS. The reason
- * is that some CRS are deprecated because they were associated to the wrong datum, in which
- * case the deprecated CRS would appear in the wrong section if we do not apply this correction.
- */
- if (!KEEP_DEPRECATED_DATUM.contains(CRS.getSingleComponents(crs).get(0).getDatum().getName().getCode())) {
- if (replacedBy != null) try {
- replacement = factory.createCoordinateReferenceSystem("EPSG:" + replacedBy);
- } catch (FactoryException e) {
- // Ignore - keep the datum of the deprecated object.
- }
- }
- }
- }
- ((ByName) row).setup(CRS.getSingleComponents(replacement).get(0).getDatum(), unusedDatumMapping);
- return row;
- }
-
- /**
- * Invoked when a CRS creation failed. This method modifies the default
- * {@link org.opengis.test.report.AuthorityCodesReport.Row} attribute values
- * created by GeoAPI.
- *
- * @param code the authority code of the object to create.
- * @param exception the exception that occurred while creating the identified object.
- * @return the created row, or {@code null} if the row should be ignored.
- */
- @Override
- protected Row createRow(final String code, final FactoryException exception) {
- if (code.startsWith(Constants.PROJ4 + DefaultNameSpace.DEFAULT_SEPARATOR)) {
- return null;
- }
- final Row row = super.createRow(code, exception);
- try {
- row.name = factory.getDescriptionText(CoordinateReferenceSystem.class, code).get().toString(getLocale());
- } catch (FactoryException e) {
- Logging.unexpectedException(null, CoordinateReferenceSystems.class, "createRow", e);
- }
- if (code.startsWith("AUTO2:")) {
- // It is normal to be unable to instantiate an "AUTO" CRS,
- // because those authority codes need parameters.
- row.hasError = false;
- row.remark = "Projected";
- ((ByName) row).setup(CommonCRS.WGS84.datum(), unusedDatumMapping);
- } else {
- row.remark = exception.getLocalizedMessage();
- ((ByName) row).setup(null, unusedDatumMapping);
- }
- return row;
- }
-
- /**
- * Invoked by {@link AuthorityCodesReport} for creating a new row instance.
- *
- * @return the new row instance.
- */
- @Override
- protected Row newRow() {
- return new ByName();
- }
-
-
-
-
- /**
- * A row with a natural ordering that use the first part of the name before to use the authority code.
- * We use only the part of the name prior some keywords (e.g. {@code "zone"}).
- * For example if the following codes:
- *
- * <pre class="text">
- * EPSG:32609 WGS 84 / UTM zone 9N
- * EPSG:32610 WGS 84 / UTM zone 10N</pre>
- *
- * We compare only the "WGS 84 / UTM" string, then the code. This is a reasonably easy way to keep a more
- * natural ordering ("9" sorted before "10", "UTM North" projections kept together and same for South).
- */
- private static final class ByName extends Row {
- /**
- * A string derived from the {@link #name} to use for sorting.
- */
- private String reducedName;
-
- /**
- * The datum name, or {@code null} if unknown.
- * If non-null, this is used for grouping CRS names by sections.
- */
- String section;
-
- /**
- * Creates a new row.
- */
- ByName() {
- }
-
- /**
- * Computes the {@link #reducedName} field value.
- */
- final void setup(final Datum datum, final Set<String> unusedDatumMapping) {
- final String datumName;
- if (datum != null) {
- datumName = datum.getName().getCode();
- } else {
- // Temporary patch (TODO: remove after we implemented the missing methods in SIS)
- if (name.startsWith("NSIDC EASE-Grid")) {
- datumName = "Unspecified datum";
- } else if (code.equals("EPSG:2163")) {
- datumName = "Unspecified datum";
- } else if (code.equals("EPSG:5818")) {
- datumName = "Seismic bin grid datum";
- } else {
- datumName = null; // Keep ordering based on the name.
- }
- }
- if (datumName != null) {
- final String prefix;
- final Map.Entry<String,String> group = SECTION_TITLES.floorEntry(datumName);
- if (group != null && datumName.startsWith(prefix = group.getKey())) {
- unusedDatumMapping.remove(prefix);
- section = group.getValue();
- } else {
- section = datumName;
- }
- }
- /*
- * Get a copy of the name in all lower case.
- */
- final StringBuilder b = new StringBuilder(name);
- for (int i=0; i<b.length(); i++) {
- b.setCharAt(i, Character.toLowerCase(b.charAt(i)));
- }
- /*
- * Cut the string to a shorter length if we find a keyword.
- * This will result in many string equals, which will then be sorted by EPSG codes.
- * This is useful when the EPSG codes give a better ordering than the alphabetic one
- * (for example with Roman numbers).
- */
- int s = 0;
- for (final String keyword : CUT_BEFORE) {
- int i = b.lastIndexOf(keyword);
- if (i > 0 && (s == 0 || i < s)) s = i;
- }
- for (final String keyword : CUT_AFTER) {
- int i = b.lastIndexOf(keyword);
- if (i >= 0) {
- i += keyword.length();
- if (i > s) s = i;
- }
- }
- if (s != 0) b.setLength(s);
- uniformizeZoneNumber(b);
- reducedName = b.toString();
- if (datumName != null) {
- name = insertAbbreviationTitle(name, datumName);
- }
- }
-
- /**
- * If the string ends with a number optionally followed by "N" or "S", replaces the hemisphere
- * symbol by a sign and makes sure that the number uses at least 3 digits (e.g. "2N" → "+002").
- * This string will be used for better sorting order.
- */
- private static void uniformizeZoneNumber(final StringBuilder b) {
- if (b.indexOf("/") < 0) {
- /*
- * Do not process names like "WGS 84". We want to process only names like "WGS 84 / UTM zone 2N",
- * otherwise the replacement of "WGS 84" by "WGS 084" causes unexpected sorting.
- */
- return;
- }
- int i = b.length();
- char c = b.charAt(i - 1);
- if (c == ')') {
- // Ignore suffix like " (ftUS)".
- i = b.lastIndexOf(" (");
- if (i < 0) return;
- c = b.charAt(i - 1);
- }
- char sign;
- switch (c) {
- default: sign = 0; break;
- case 'e': case 'n': sign = '+'; i--; break;
- case 'w': case 's': sign = '-'; i--; break;
- }
- int upper = i;
- do {
- if (i == 0) return;
- c = b.charAt(--i);
- } while (c >= '0' && c <= '9');
- switch (upper - ++i) {
- case 2: b.insert(i, '0'); upper++; break; // Found 2 digits.
- case 1: b.insert(i, "00"); upper+=2; break; // Only one digit found.
- case 0: return; // No digit.
- }
- if (sign != 0) {
- b.insert(i, sign);
- upper++;
- }
- b.setLength(upper);
- }
-
- /**
- * Compares this row with the given row for ordering by name.
- */
- @Override
- public int compareTo(final Row o) {
- int n = reducedName.compareTo(((ByName) o).reducedName);
- if (n == 0) {
- n = super.compareTo(o);
- }
- return n;
- }
- }
-
- /**
- * Sorts the rows, then inserts sections between CRS instances that use different datums.
- */
- @Override
- protected void sortRows() {
- super.sortRows();
- @SuppressWarnings("SuspiciousToArrayCall")
- final ByName[] data = rows.toArray(ByName[]::new);
- final Map<String,String> sections = new TreeMap<>();
- for (final ByName row : data) {
- final String section = row.section;
- if (section != null) {
- sections.put(CharSequences.toASCII(section).toString().toLowerCase(), section);
- }
- }
- rows.clear();
- /*
- * Recopy the rows, but section-by-section. We do this sorting here instead of in the Row.compareTo(Row)
- * method in order to preserve the alphabetical order of rows with unknown datum.
- * Algorithm below is inefficient, but this class should be rarely used anyway and only by site maintainer.
- */
- for (final String section : sections.values()) {
- final Row separator = new Row();
- separator.isSectionHeader = true;
- separator.name = section;
- rows.add(separator);
- boolean found = false;
- for (int i=0; i<data.length; i++) {
- final ByName row = data[i];
- if (row != null) {
- if (row.section != null) {
- found = section.equals(row.section);
- }
- if (found) {
- rows.add(row);
- data[i] = null;
- found = true;
- }
- }
- }
- }
- boolean found = false;
- for (final ByName row : data) {
- if (row != null) {
- if (!found) {
- final Row separator = new Row();
- separator.isSectionHeader = true;
- separator.name = "Unknown";
- rows.add(separator);
- }
- rows.add(row);
- found = true;
- }
- }
- }
-}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java
index 89a7682..1c01539 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java
@@ -222,7 +222,7 @@
*/
DirectPosition source = new DirectPosition2D(latitude, longitude);
DirectPosition target = completeTransform.transform(source, null);
- final double[] coordinate = target.getCoordinates();
+ final double[] coordinate = target.getCoordinate();
assertEquals(expectedX, coordinate[0], 0.01);
assertEquals(expectedY, coordinate[1], 0.01);
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateReferenceSystemTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateReferenceSystemTest.java
index 2d467cb..bd92e66 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateReferenceSystemTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateReferenceSystemTest.java
@@ -32,6 +32,9 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.referencing.crs.GeodeticCRS;
+// Specific to the main branch:
+import org.opengis.referencing.crs.GeneralDerivedCRS;
+
/**
* Advanced CRS constructions requiring the EPSG geodetic dataset.
@@ -70,7 +73,7 @@
assertInstanceOf(DerivedCRS .class, crs);
assertInstanceOf(GeodeticCRS.class, crs);
assertInstanceOf(CartesianCS.class, crs.getCoordinateSystem());
- assertInstanceOf(CartesianCS.class, ((DerivedCRS) crs).getBaseCRS().getCoordinateSystem());
+ assertInstanceOf(CartesianCS.class, ((GeneralDerivedCRS) crs).getBaseCRS().getCoordinateSystem());
/*
* Some tests are disabled because `EPSGDataAccess` confuses CRS type.
* We are waiting for upgrade to EPSG database 10+ before to re-evaluate
@@ -82,6 +85,6 @@
// assertInstanceOf(DerivedCRS .class, crs);
// assertInstanceOf(GeodeticCRS.class, crs);
assertInstanceOf(CartesianCS.class, crs.getCoordinateSystem());
- assertInstanceOf(EllipsoidalCS.class, ((DerivedCRS) crs).getBaseCRS().getCoordinateSystem());
+ assertInstanceOf(EllipsoidalCS.class, ((GeneralDerivedCRS) crs).getBaseCRS().getCoordinateSystem());
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java
index 36338f1..9986438 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java
@@ -70,9 +70,9 @@
import org.apache.sis.xml.test.DocumentComparator;
import org.apache.sis.xml.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.referencing.datum.RealizationMethod;
+// Specific to the main branch:
+import org.opengis.referencing.datum.VerticalDatumType;
+import org.apache.sis.pending.geoapi.evolution.UnsupportedCodeList;
/**
@@ -98,6 +98,18 @@
}
/**
+ * Creates a telephone number of the given type.
+ *
+ * @param type Either {@code "VOICE"}, {@code "FACSIMILE"} or {@code "SMS"}.
+ */
+ private static DefaultTelephone telephone(final String number, final String type) {
+ final DefaultTelephone tel = new DefaultTelephone();
+ tel.setNumber(number);
+ tel.setNumberType(UnsupportedCodeList.valueOf(type));
+ return tel;
+ }
+
+ /**
* Programmatically creates the metadata to marshal, or to compare against the unmarshalled metadata.
*
* @return the hard-coded representation of {@value #XML_FILE} content.
@@ -113,7 +125,6 @@
* with only the role changed. Note that we need to create an instance of the deprecated class,
* because this is what will be unmarshalled from the XML document.
*/
- @SuppressWarnings("deprecation")
final var author = new DefaultResponsibleParty(Role.AUTHOR);
final var country = new Anchor(URI.create("SDN:C320:2:FR"), "France"); // Non-public SIS class.
{
@@ -122,8 +133,8 @@
final var contact = new DefaultContact(online);
contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "IFREMER");
contact.setPhones(List.of(
- new DefaultTelephone("+33 (0)2 xx.xx.xx.x6", TelephoneType.VOICE),
- new DefaultTelephone("+33 (0)2 xx.xx.xx.x4", TelephoneType.FACSIMILE)
+ telephone("+33 (0)2 xx.xx.xx.x6", "VOICE"),
+ telephone("+33 (0)2 xx.xx.xx.x4", "FACSIMILE")
));
final var address = new DefaultAddress();
address.setDeliveryPoints(Set.of("Brest institute"));
@@ -145,14 +156,13 @@
new DefaultCitationDate(LocalDate.of(1990, 6, 5), DateType.REVISION),
new DefaultCitationDate(LocalDate.of(1979, 8, 3), DateType.CREATION)));
{
- @SuppressWarnings("deprecation")
final var originator = new DefaultResponsibleParty(Role.ORIGINATOR);
final var online = new DefaultOnlineResource(URI.create("http://www.com.univ-mrs.fr/LOB/"));
online.setProtocol(Constants.HTTP);
final var contact = new DefaultContact(online);
contact.setPhones(List.of(
- new DefaultTelephone("+33 (0)4 xx.xx.xx.x5", TelephoneType.VOICE),
- new DefaultTelephone("+33 (0)4 xx.xx.xx.x8", TelephoneType.FACSIMILE)
+ telephone("+33 (0)4 xx.xx.xx.x5", "VOICE"),
+ telephone("+33 (0)4 xx.xx.xx.x8", "FACSIMILE")
));
final var address = new DefaultAddress();
address.setDeliveryPoints(Set.of("Oceanology institute"));
@@ -169,7 +179,6 @@
Locale.ENGLISH, // Language,
TopicCategory.OCEANS); // Topic category
{
- @SuppressWarnings("deprecation")
final var custodian = new DefaultResponsibleParty((DefaultResponsibility) author);
custodian.setRole(Role.CUSTODIAN);
identification.setPointOfContacts(Set.of(custodian));
@@ -202,21 +211,20 @@
*/
{
final var constraint = new DefaultLegalConstraints();
- constraint.setAccessConstraints(Set.of(Restriction.LICENCE));
+ constraint.setAccessConstraints(Set.of(Restriction.LICENSE));
identification.setResourceConstraints(Set.of(constraint));
}
/*
* Data indentification / Aggregate information.
*/
{
- @SuppressWarnings("deprecation")
final var aggregateInfo = new DefaultAggregateInformation();
final var name = new DefaultCitation("Some oceanographic campaign");
name.setAlternateTitles(Set.of(new SimpleInternationalString("Pseudo group of data")));
name.setDates(Set.of(new DefaultCitationDate(LocalDate.of(1990, 6, 5), DateType.REVISION)));
aggregateInfo.setName(name);
aggregateInfo.setInitiativeType(InitiativeType.CAMPAIGN);
- aggregateInfo.setAssociationType(AssociationType.LARGER_WORK_CITATION);
+ aggregateInfo.setAssociationType(AssociationType.LARGER_WORD_CITATION); // There is a typo ("WORD" → "WORK"), but we have to use the wrong spelling for this branch.
identification.setAssociatedResources(Set.of(aggregateInfo));
}
/*
@@ -230,7 +238,7 @@
nameAndIdentifier("depth", "Depth", null), axis);
final var datum = new DefaultVerticalDatum(
- nameAndIdentifier("D28", "Depth below D28", "For testing purpose"), (RealizationMethod) null);
+ nameAndIdentifier("D28", "Depth below D28", "For testing purpose"), VerticalDatumType.OTHER_SURFACE);
final var vcrs = new DefaultVerticalCRS(
nameAndIdentifier("D28", "Depth below D28", "CRS for testing purpose"), datum, null, cs);
@@ -301,7 +309,6 @@
* Distribution information.
*/
{
- @SuppressWarnings("deprecation")
final var distributor = new DefaultResponsibleParty((DefaultResponsibility) author);
final var distributionInfo = new DefaultDistribution();
distributor.setRole(Role.DISTRIBUTOR);
@@ -335,7 +342,7 @@
properties.put(DefaultVerticalDatum.NAME_KEY, new NamedIdentifier(null, name));
properties.put(DefaultVerticalDatum.IDENTIFIERS_KEY, new NamedIdentifier(null, "test", identifier, null, null));
if (scope != null) {
- properties.put(ObjectDomain.SCOPE_KEY, scope);
+ properties.put(DefaultVerticalDatum.SCOPE_KEY, scope);
}
return properties;
}
@@ -373,6 +380,7 @@
"<gmx:Anchor xlink:href=\"SDN:L231:3:CDI\">Pseudo Common Data Index record</gmx:Anchor>");
replace(xml, "<gcol:CharacterString>4326</gcol:CharacterString>",
"<gmx:Anchor xlink:href=\"SDN:L101:2:4326\">4326</gmx:Anchor>");
+ replace(xml, "License", "Licence");
/*
* Ignore the "gml:id" attribute because SIS generates different values than the ones in our test XML file,
* and those values may change in future SIS version.
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java
index b933292..50fd253 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java
@@ -48,9 +48,10 @@
import static org.apache.sis.test.TestUtilities.getScope;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.nio.charset.StandardCharsets;
-import static org.opengis.test.Assertions.assertIdentifierEquals;
+// Specific to the main branch:
+import org.opengis.metadata.identification.CharacterSet;
+import org.opengis.referencing.datum.VerticalDatumType;
+import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals;
/**
@@ -88,10 +89,10 @@
@Test
public void testMetadataWithVerticalCRS() throws JAXBException {
final Metadata metadata = unmarshalFile(Metadata.class, openTestFile());
- assertEquals("20090901", metadata.getMetadataIdentifier().getCode());
- assertEquals(Locale.ENGLISH, getSingleton(metadata.getLocalesAndCharsets().keySet()));
- assertEquals(StandardCharsets.UTF_8, getSingleton(metadata.getLocalesAndCharsets().values()));
- assertEquals(LocalDate.of(2014, 1, 4), TemporalDate.toTemporal(getSingleton(metadata.getDateInfo()).getDate()));
+ assertEquals("20090901", metadata.getFileIdentifier());
+ assertEquals(Locale.ENGLISH, metadata.getLanguage());
+ assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet());
+ assertEquals(LocalDate.of(2014, 1, 4), TemporalDate.toTemporal(metadata.getDateStamp()));
/*
* <gmd:contact>
* <gmd:CI_ResponsibleParty>
@@ -99,13 +100,10 @@
* </gmd:CI_ResponsibleParty>
* </gmd:contact>
*/
- final Responsibility contact = getSingleton(metadata .getContacts());
- final Party party = getSingleton(contact .getParties());
- final Contact contactInfo = getSingleton(party .getContactInfo());
- final OnlineResource onlineResource = getSingleton(contactInfo.getOnlineResources());
- assertInstanceOf(Organisation.class, party);
+ final ResponsibleParty contact = getSingleton(metadata.getContacts());
+ final OnlineResource onlineResource = contact.getContactInfo().getOnlineResource();
assertNotNull(onlineResource);
- assertEquals("Apache SIS", party.getName().toString());
+ assertEquals("Apache SIS", contact.getOrganisationName().toString());
assertEquals(URI.create("http://sis.apache.org"), onlineResource.getLinkage());
assertEquals(OnLineFunction.INFORMATION, onlineResource.getFunction());
assertEquals(Role.PRINCIPAL_INVESTIGATOR, contact.getRole());
@@ -139,7 +137,7 @@
assertInstanceOf(NilObject.class, citation);
assertEquals(NilReason.MISSING, ((NilObject) citation).getNilReason());
assertEquals("SIS test", identification.getAbstract().toString());
- assertEquals(Locale.ENGLISH, getSingleton(identification.getLocalesAndCharsets().keySet()));
+ assertEquals(Locale.ENGLISH, getSingleton(identification.getLanguages()));
/*
* <gmd:geographicElement>
* <gmd:EX_GeographicBoundingBox>
@@ -170,6 +168,7 @@
final VerticalDatum datum = crs.getDatum();
verifyIdentifiers("test2", datum);
assertEquals("World", getScope(datum));
+ assertEquals(VerticalDatumType.DEPTH, datum.getVerticalDatumType()); // Inferred from the name.
final VerticalCS cs = crs.getCoordinateSystem();
verifyIdentifiers("test3", cs);
final CoordinateSystemAxis axis = cs.getAxis(0);
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CC_OperationParameterGroupTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CC_OperationParameterGroupTest.java
index 669a1cc..170b303 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CC_OperationParameterGroupTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CC_OperationParameterGroupTest.java
@@ -195,7 +195,7 @@
final ParameterDescriptor<?> actual)
{
assertEquals(expected.getName(), actual.getName());
- assertEquals(expected.getDescription(), actual.getDescription());
+// assertEquals(expected.getDescription(), actual.getDescription());
assertEquals(expected.getValueClass(), actual.getValueClass());
assertEquals(expected.getValidValues(), actual.getValidValues());
assertEquals(expected.getUnit(), actual.getUnit());
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CodeTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CodeTest.java
index 4013f29..21b7eab 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CodeTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/xml/bind/referencing/CodeTest.java
@@ -29,8 +29,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -46,10 +46,10 @@
}
/**
- * Tests the {@link Code#Code(Identifier)} constructor with {@code "EPSG:4326"} identifier.
+ * Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:4326"} identifier.
* This test intentionally uses an identifier with the {@code IOGP} authority instead of
* EPSG in order to make sure that the {@code codeSpace} attribute is set from
- * {@link Identifier#getCodeSpace()}, not from {@link Identifier#getAuthority()}.
+ * {@code Identifier.getCodeSpace()}, not from {@code Identifier.getAuthority()}.
*/
@Test
public void testSimple() {
@@ -70,7 +70,7 @@
}
/**
- * Tests the {@link Code#Code(Identifier)} constructor with {@code "EPSG:8.3:4326"} identifier.
+ * Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:8.3:4326"} identifier.
* This test intentionally uses an identifier with the {@code IOGP} authority instead of EPSG
* for the same reason as {@link #testSimple()}.
*/
diff --git a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/Band.java b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/Band.java
index c07058f..e0e17c9 100644
--- a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/Band.java
+++ b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/Band.java
@@ -94,11 +94,7 @@
sampleDimension = new DefaultSampleDimension();
}
sampleDimension.setDescription(band.title);
- if (band.group.reflectance) {
- sampleDimension.setUnits(Units.UNITY);
- } else {
- // W/(m² sr um)/DN
- }
+ // Can not set units in GeoAPI 3.0 because the API is restricted to units of length.
}
/**
diff --git a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
index 1108302..85e1982 100644
--- a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
+++ b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
@@ -66,8 +66,9 @@
import org.apache.sis.util.privy.Strings;
import static org.apache.sis.util.privy.CollectionsExt.singletonOrNull;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.operation.MathTransform;
+// Specific to the main branch:
+import org.apache.sis.referencing.privy.CoordinateOperations;
+import org.apache.sis.referencing.operation.transform.MathTransformBuilder;
/**
@@ -225,7 +226,7 @@
/**
* The map projection parameters. This is used only for the polar stereographic case.
*/
- private MathTransform.Builder projection;
+ private MathTransformBuilder projection;
/**
* The referencing objects factories.
@@ -671,8 +672,8 @@
if ("UTM".equalsIgnoreCase(value)) {
projection = null;
} else if ("PS".equalsIgnoreCase(value)) try {
- projection = factories.getMathTransformFactory()
- .builder(Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER);
+ projection = CoordinateOperations.builder(factories.getMathTransformFactory(),
+ Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER);
utmZone = -1;
} catch (NoSuchIdentifierException e) {
// Should never happen with Apache SIS implementation of MathTransformFactory.
@@ -849,7 +850,7 @@
*/
final Metadata getMetadata() throws FactoryException {
addLanguage(Locale.ENGLISH, StandardCharsets.US_ASCII, MetadataBuilder.Scope.METADATA);
- addResourceScope(ScopeCode.COVERAGE, null);
+ addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
addTopicCategory(TopicCategory.GEOSCIENTIFIC_INFORMATION);
try {
flushSceneTime();
diff --git a/endorsed/src/org.apache.sis.storage.earthobservation/test/org/apache/sis/storage/landsat/MetadataReaderTest.java b/endorsed/src/org.apache.sis.storage.earthobservation/test/org/apache/sis/storage/landsat/MetadataReaderTest.java
index 31099f6..d51b8ad 100644
--- a/endorsed/src/org.apache.sis.storage.earthobservation/test/org/apache/sis/storage/landsat/MetadataReaderTest.java
+++ b/endorsed/src/org.apache.sis.storage.earthobservation/test/org/apache/sis/storage/landsat/MetadataReaderTest.java
@@ -23,31 +23,6 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static java.util.Map.entry;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.time.OffsetDateTime;
-import java.time.ZoneOffset;
-import org.opengis.metadata.Metadata;
-import org.opengis.metadata.acquisition.Context;
-import org.opengis.metadata.acquisition.OperationType;
-import org.opengis.metadata.citation.Role;
-import org.opengis.metadata.citation.DateType;
-import org.opengis.metadata.content.CoverageContentType;
-import org.opengis.metadata.content.TransferFunctionType;
-import org.opengis.metadata.identification.Progress;
-import org.opengis.metadata.identification.TopicCategory;
-import org.opengis.metadata.extent.TemporalExtent;
-import org.opengis.metadata.maintenance.ScopeCode;
-import org.opengis.metadata.spatial.DimensionNameType;
-import org.opengis.util.FactoryException;
-import org.apache.sis.storage.AbstractResource;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.event.StoreListeners;
-import org.opengis.test.dataset.ContentVerifier;
-
/**
* Tests {@link MetadataReader}.
@@ -57,16 +32,6 @@
*/
public final class MetadataReaderTest extends TestCase {
/**
- * Helper class for verifying metadata content.
- */
- private ContentVerifier verifier;
-
- /**
- * A buffer for building paths to expected properties.
- */
- private StringBuilder buffer;
-
- /**
* Creates a new test case.
*/
public MetadataReaderTest() {
@@ -82,178 +47,4 @@
assertTrue(m.find());
assertEquals(22, m.end());
}
-
- /**
- * Tests {@link MetadataReader#read(BufferedReader)}.
- *
- * <p><b>Note for maintainer:</b> if the result of this test changes, consider updating
- * <a href="./doc-files/MetadataMapping.html">./doc-files/MetadataMapping.html</a> accordingly.</p>
- *
- * @throws IOException if an error occurred while reading the test file.
- * @throws DataStoreException if a property value cannot be parsed as a number or a date.
- * @throws FactoryException if an error occurred while creating the Coordinate Reference System.
- */
- @Test
- public void testRead() throws IOException, DataStoreException, FactoryException {
- final Metadata actual;
- try (BufferedReader in = new BufferedReader(new InputStreamReader(
- MetadataReaderTest.class.getResourceAsStream("LandsatTest.txt"), "UTF-8")))
- {
- final MetadataReader reader = new MetadataReader(null, "LandsatTest.txt", createListeners());
- reader.read(in);
- actual = reader.getMetadata();
- }
- verifier = new ContentVerifier();
- verifier.addPropertyToIgnore(Metadata.class, "metadataStandard"); // Because hard-coded in SIS.
- verifier.addPropertyToIgnore(Metadata.class, "referenceSystemInfo"); // Very verbose and depends on EPSG connection.
- verifier.addPropertyToIgnore(TemporalExtent.class, "extent"); // Because currently time-zone sensitive.
- verifier.addMetadataToVerify(actual);
- verifier.addExpectedValues(
- entry("defaultLocale+otherLocale[0]", "en"),
- entry("metadataIdentifier.code", "LandsatTest"),
- entry("metadataScope[0].resourceScope", ScopeCode.COVERAGE),
- entry("dateInfo[0].date", OffsetDateTime.of(2016, 6, 27, 16, 48, 12, 0, ZoneOffset.UTC)),
- entry("dateInfo[0].dateType", DateType.CREATION),
-
- entry("identificationInfo[0].topicCategory[0]", TopicCategory.GEOSCIENTIFIC_INFORMATION),
- entry("identificationInfo[0].citation.date[0].date", OffsetDateTime.of(2016, 6, 27, 16, 48, 12, 0, ZoneOffset.UTC)),
- entry("identificationInfo[0].citation.date[0].dateType", DateType.CREATION),
- entry("identificationInfo[0].citation.title", "LandsatTest"),
- entry("identificationInfo[0].credit[0]", "Derived from U.S. Geological Survey data"),
-
- entry("identificationInfo[0].resourceFormat[0].formatSpecificationCitation.title", "GeoTIFF Coverage Encoding Profile"),
- entry("identificationInfo[0].resourceFormat[0].formatSpecificationCitation.alternateTitle[0]", "GeoTIFF"),
- entry("identificationInfo[0].resourceFormat[0].formatSpecificationCitation.citedResponsibleParty[0].party[0].name", "Open Geospatial Consortium"),
- entry("identificationInfo[0].resourceFormat[0].formatSpecificationCitation.citedResponsibleParty[0].role", Role.PRINCIPAL_INVESTIGATOR),
-
- entry("identificationInfo[0].extent[0].geographicElement[0].extentTypeCode", true),
- entry("identificationInfo[0].extent[0].geographicElement[0].westBoundLongitude", 108.34),
- entry("identificationInfo[0].extent[0].geographicElement[0].eastBoundLongitude", 110.44),
- entry("identificationInfo[0].extent[0].geographicElement[0].southBoundLatitude", 10.50),
- entry("identificationInfo[0].extent[0].geographicElement[0].northBoundLatitude", 12.62),
- entry("identificationInfo[0].spatialResolution[0].distance", 15.0),
- entry("identificationInfo[0].spatialResolution[1].distance", 30.0),
-
- entry("acquisitionInformation[0].platform[0].identifier.code", "Pseudo LANDSAT"),
- entry("acquisitionInformation[0].platform[0].instrument[0].identifier.code", "Pseudo TIRS"),
- entry("acquisitionInformation[0].acquisitionRequirement[0].identifier.code", "Software unit tests"),
- entry("acquisitionInformation[0].operation[0].significantEvent[0].context", Context.ACQUISITION),
- entry("acquisitionInformation[0].operation[0].significantEvent[0].time", OffsetDateTime.of(2016, 6, 26, 3, 2, 1, 90_000_000, ZoneOffset.UTC)),
- entry("acquisitionInformation[0].operation[0].status", Progress.COMPLETED),
- entry("acquisitionInformation[0].operation[0].type", OperationType.REAL),
-
- entry("contentInfo[0].processingLevelCode.authority.title", "Landsat"),
- entry("contentInfo[0].processingLevelCode.codeSpace", "Landsat"),
- entry("contentInfo[0].processingLevelCode.code", "Pseudo LT1"),
-
- entry("contentInfo[0].cloudCoverPercentage", 8.3),
- entry("contentInfo[0].illuminationAzimuthAngle", 116.9),
- entry("contentInfo[0].illuminationElevationAngle", 58.8),
-
- entry("spatialRepresentationInfo[0].numberOfDimensions", 2),
- entry("spatialRepresentationInfo[1].numberOfDimensions", 2),
- entry("spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionName", DimensionNameType.SAMPLE),
- entry("spatialRepresentationInfo[1].axisDimensionProperties[0].dimensionName", DimensionNameType.SAMPLE),
- entry("spatialRepresentationInfo[0].axisDimensionProperties[1].dimensionName", DimensionNameType.LINE),
- entry("spatialRepresentationInfo[1].axisDimensionProperties[1].dimensionName", DimensionNameType.LINE),
- entry("spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionSize", 7600),
- entry("spatialRepresentationInfo[0].axisDimensionProperties[1].dimensionSize", 7800),
- entry("spatialRepresentationInfo[1].axisDimensionProperties[0].dimensionSize", 15000),
- entry("spatialRepresentationInfo[1].axisDimensionProperties[1].dimensionSize", 15500),
- entry("spatialRepresentationInfo[0].transformationParameterAvailability", false),
- entry("spatialRepresentationInfo[1].transformationParameterAvailability", false),
- entry("spatialRepresentationInfo[0].checkPointAvailability", false),
- entry("spatialRepresentationInfo[1].checkPointAvailability", false),
-
- entry("resourceLineage[0].source[0].description", "Pseudo GLS"));
-
- /*
- * The expected values in "contentInfo[0].attributeGroup[…].attribute[…].*" have a lot of redundancy.
- * Therefore, we set those expected values by loop instead of repeating tens of long property paths.
- */
- final String[] descriptions = {
- "Coastal Aerosol",
- "Blue",
- "Green",
- "Red",
- "Near-Infrared",
- "Short Wavelength Infrared (SWIR) 1",
- "Short Wavelength Infrared (SWIR) 2",
- "Cirrus",
- "Panchromatic",
- "Thermal Infrared Sensor (TIRS) 1",
- "Thermal Infrared Sensor (TIRS) 2"
- };
- final short[] peakResponses = {433, 482, 562, 655, 865, 1610, 2200, 1375, 590, 10800, 12000};
- int band = 0;
-
- buffer = new StringBuilder(80).append("contentInfo[0].attributeGroup[");
- final int groupBase = buffer.length();
- final int[] numAttributes = {8, 1, 2};
- for (int group = 0; group < numAttributes.length; group++) {
- final boolean mainGroups = (group != 2);
- /*
- * contentInfo[0].attributeGroup[0…2].contentType[0]
- */
- buffer.setLength(groupBase);
- buffer.append(group).append("].");
- addExpectedValue("contentType[0]", CoverageContentType.PHYSICAL_MEASUREMENT);
- /*
- * contentInfo[0].attributeGroup[0…2].attribute[…].minValue
- * contentInfo[0].attributeGroup[0…2].attribute[…].maxValue
- * ... etc ...
- */
- final int attributeBase = buffer.append("attribute[").length();
- for (int attribute = 0; attribute < numAttributes[group]; attribute++) {
- buffer.setLength(attributeBase);
- buffer.append(attribute).append("].");
- addExpectedValue("minValue", 1.0);
- addExpectedValue("maxValue", 65535.0);
- addExpectedValue("description", descriptions[band]);
- addExpectedValue("peakResponse", (double) peakResponses[band++]);
- addExpectedValue("boundUnits", "nm");
- addExpectedValue("transferFunctionType", TransferFunctionType.LINEAR);
- addExpectedValue("scaleFactor", mainGroups ? 2.0E-5 : 0.000334);
- addExpectedValue("offset", mainGroups ? -0.1 : 0.1);
- if (mainGroups) {
- addExpectedValue("units", "");
- }
- }
- }
- assertEquals(descriptions.length, band);
- assertEquals(peakResponses.length, band);
- verifier.assertMetadataEquals();
- }
-
- /**
- * Adds an expected value for the given property. The path to that property is the
- * current content of {@link #buffer}, including a trailing {@code '.'} separator.
- * The buffer is reset to its original length after this method call.
- */
- private void addExpectedValue(final String tip, Object value) {
- final int length = buffer.length();
- verifier.addExpectedValue(buffer.append(tip).toString(), value);
- buffer.setLength(length);
- }
-
- /**
- * Creates a dummy set of store listeners.
- * Used only for constructors that require a non-null {@link StoreListeners} instance.
- *
- * @return a dummy set of listeners.
- */
- private static StoreListeners createListeners() {
- final class DummyResource extends AbstractResource {
- /** Creates a dummy resource without parent. */
- DummyResource() {
- super(null, false);
- }
-
- /** Makes listeners accessible to this package. */
- StoreListeners listeners() {
- return listeners;
- }
- }
- return new DummyResource().listeners();
- }
}
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
index 7871b0c..bd1a6b2 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
@@ -404,7 +404,7 @@
builder.setPredefinedFormat(Constants.GEOTIFF, listeners, true);
builder.addFormatReaderSIS(Constants.GEOTIFF);
builder.addLanguage(Locale.ENGLISH, encoding, MetadataBuilder.Scope.METADATA);
- builder.addResourceScope(ScopeCode.COVERAGE, null);
+ builder.addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
}
/**
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
index c1e2415..650b229 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
@@ -61,8 +61,8 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.math.Fraction;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
index c24d460..62ccac3 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
@@ -1152,7 +1152,7 @@
cs = replaceLinearUnit(cs, linearUnit);
}
// TODO: datum should be DatumEnsemble for some case such as EPSG:4326.
- final GeodeticCRS crs = getCRSFactory().createGeodeticCRS(properties(getOrDefault(names, GCRS)), datum, null, cs);
+ final GeodeticCRS crs = getCRSFactory().createGeocentricCRS(properties(getOrDefault(names, GCRS)), datum, cs);
lastName = crs.getName();
return crs;
}
@@ -1162,7 +1162,7 @@
* But if the file also defines the components, verify that those components are consistent
* with what we would expect for a CRS of the given EPSG code.
*/
- final GeodeticCRS crs = getCRSAuthorityFactory().createGeodeticCRS(String.valueOf(epsg));
+ final GeodeticCRS crs = getCRSAuthorityFactory().createGeocentricCRS(String.valueOf(epsg));
verify(crs);
return crs;
}
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/GeoTiffStoreTest.java b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/GeoTiffStoreTest.java
index 7c0f6b7..6f66a3d 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/GeoTiffStoreTest.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/GeoTiffStoreTest.java
@@ -41,9 +41,9 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertMatrixEquals;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/AttributeNames.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/AttributeNames.java
index c8289cd..ada1343 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/AttributeNames.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/AttributeNames.java
@@ -350,7 +350,7 @@
* This is a character array with a line for each invocation of a program that has modified the dataset.
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getResourceLineages() resourceLineage} /
+ * {@link org.apache.sis.metadata.iso.DefaultMetadata#getResourceLineages() resourceLineage} /
* {@link Lineage#getStatement() statement}</li></ul>
*
* <h4>Departure from convention</h4>
@@ -367,7 +367,7 @@
* The {@value} attribute name for the method of production of the original data (<em>Recommended</em>).
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getResourceLineages() resourceLineage} /
+ * {@link org.apache.sis.metadata.iso.DefaultMetadata#getResourceLineages() resourceLineage} /
* {@link Lineage#getSources() source} /
* {@link Source#getDescription() description}</li></ul>
*
@@ -401,7 +401,7 @@
* subgroup.
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getDateInfo() dateInfo}
+ * {@code dateInfo}
* {@link CitationDate#getDate() date} with {@link DateType#CREATION}</li></ul>
*/
public static final String METADATA_CREATION = "metadata_creation";
@@ -411,7 +411,7 @@
* (<em>Suggested</em>).
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getDateInfo() dateInfo}
+ * {@code dateInfo}
* {@link CitationDate#getDate() date} with {@link DateType#REVISION}</li></ul>
*
* @since 0.8
@@ -1188,7 +1188,7 @@
* For example, it may be the URL to an ISO 19115 metadata in XML format.
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getMetadataLinkages() metadataLinkage} /
+ * {@code metadataLinkage} /
* {@link OnlineResource#getLinkage() linkage}</li></ul>
*
* @see <a href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#metadata_link">ESIP reference</a>
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java
index c720d6e..3df0857 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java
@@ -75,8 +75,8 @@
import org.apache.sis.math.Vector;
import static org.apache.sis.storage.netcdf.AttributeNames.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.NameFactory;
+// Specific to the main branch:
+import org.apache.sis.util.iso.DefaultNameFactory;
/**
@@ -463,16 +463,15 @@
* If we cannot share the whole existing instance, we usually can share parts of it like the address.
*/
ResponsibleParty responsibility = pointOfContact;
- Contact contact = null;
- Address address = null;
- OnlineResource resource = null;
+ Contact contact = null;
+ Address address = null;
+ OnlineResource resource = null;
if (responsibility != null) {
- final Party party = CollectionsExt.first(responsibility.getParties());
- if (party != null) {
- contact = CollectionsExt.first(party.getContactInfo());
+ { // Additional indentation for having the same level than SIS branches for GeoAPI snapshots (makes merges easier).
+ contact = responsibility.getContactInfo();
if (contact != null) {
- address = CollectionsExt.first(contact.getAddresses());
- resource = CollectionsExt.first(contact.getOnlineResources());
+ address = contact.getAddress();
+ resource = contact.getOnlineResource();
}
if (!canShare(resource, url)) {
resource = null;
@@ -485,14 +484,9 @@
responsibility = null;
}
if (responsibility != null) {
- if (party instanceof Organisation) {
- // Individual (if any) is considered an organisation member. See comment in next block.
- if (!canShare(party.getName(), organisationName) ||
- !canShare(CollectionsExt.first(((Organisation) party).getIndividual()).getName(), individualName))
- {
- responsibility = null;
- }
- } else if (!canShare(party.getName(), individualName)) {
+ if (!canShare(responsibility.getOrganisationName(), organisationName) ||
+ !canShare(responsibility.getIndividualName(), individualName))
+ {
responsibility = null;
}
}
@@ -512,7 +506,7 @@
if (individualName != null || organisationName != null || contact != null) { // Do not test role.
AbstractParty party = null;
if (individualName != null) party = new DefaultIndividual(individualName, null, null);
- if (organisationName != null) party = new DefaultOrganisation(organisationName, null, (Individual) party, null);
+ if (organisationName != null) party = new DefaultOrganisation(organisationName, null, (DefaultIndividual) party, null);
if (party == null) party = isOrganisation(keys) ? new DefaultOrganisation() : new DefaultIndividual();
if (contact != null) party.setContactInfo(Set.of(contact));
responsibility = new DefaultResponsibleParty(role);
@@ -595,9 +589,9 @@
addCitedResponsibleParty(contributor, null);
}
final ResponsibleParty r = createResponsibleParty(PUBLISHER, false);
- if (r != null) {
+ if (r instanceof DefaultResponsibility) {
addDistributor(r);
- for (final Party party : r.getParties()) {
+ for (final AbstractParty party : ((DefaultResponsibility) r).getParties()) {
publisher = addIfNonNull(publisher, party.getName());
}
}
@@ -647,8 +641,8 @@
addUseLimitation (stringValue(LICENSE));
addKeywords(standard, KeywordType.THEME, stringValue(STANDARD_NAME.VOCABULARY));
addKeywords(keywords, KeywordType.THEME, stringValue(KEYWORDS.VOCABULARY));
- addKeywords(project, KeywordType.PROJECT, null);
- addKeywords(publisher, KeywordType.DATA_CENTRE, null);
+ addKeywords(project, KeywordType.valueOf("PROJECT"), null);
+ addKeywords(publisher, KeywordType.valueOf("DATA_CENTRE"), null);
/*
* Add geospatial bounds as a geometric object. This optional operation requires
* an external library (ESRI or JTS) to be present on the module path.
@@ -979,7 +973,7 @@
newSampleDimension();
final String name = Strings.trimOrNull(variable.getName());
if (name != null) {
- final NameFactory f = decoder.nameFactory;
+ final DefaultNameFactory f = decoder.nameFactory;
final StringBuilder buffer = new StringBuilder(20);
variable.writeDataTypeName(buffer);
setBandIdentifier(f.createMemberName(null, name, f.createTypeName(null, buffer.toString())));
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
index 5057c53..cea5b8f 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
@@ -583,7 +583,7 @@
*/
final String alt = coordinates.getAttributeAsString(CDM.LONG_NAME);
if (alt != null && !similar(alt, name)) {
- properties.put(org.opengis.metadata.Identifier.DESCRIPTION_KEY, alt); // Description associated to primary name.
+ properties.put(org.apache.sis.referencing.ImmutableIdentifier.DESCRIPTION_KEY, alt); // Description associated to primary name.
if (!similar(alt, standardName)) {
aliases.add(new NamedIdentifier(null, alt)); // Additional alias.
}
@@ -633,7 +633,7 @@
} else switch (order) {
case 0: dir = AxisDirection.COLUMN_POSITIVE; break;
case 1: dir = AxisDirection.ROW_POSITIVE; break;
- default: dir = AxisDirection.UNSPECIFIED; break;
+ default: dir = AxisDirections.UNSPECIFIED; break;
}
}
final String abbr;
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
index 5f1ce20..bfcaeb9 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
@@ -61,6 +61,11 @@
import org.apache.sis.measure.NumberRange;
import org.apache.sis.measure.Units;
+// Specific to the main branch:
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.referencing.datum.DatumOrEnsemble;
+import org.apache.sis.temporal.TemporalDate;
+
/**
* Temporary object for building a coordinate reference system from the variables in a netCDF file.
@@ -134,17 +139,10 @@
/**
* The datum created by {@link #createDatum(DatumFactory, Map)}.
- * At least one of {@code datum} and {@link #datumEnsemble} shall be initialized.
*/
protected D datum;
/**
- * The datum ensemble created by {@link #createDatum(DatumFactory, Map)}.
- * At least one of {@link #datum} and {@code datumEnsemble} shall be initialized.
- */
- protected DatumEnsemble<D> datumEnsemble;
-
- /**
* The coordinate system created by {@link #createCS(CSFactory, Map, CoordinateSystemAxis[])}.
*/
protected CS coordinateSystem;
@@ -630,10 +628,7 @@
* The predefined CRS is {@link #defaultCRS} or a spherical CRS.
*/
protected final void setDatum(final CommonCRS crs) {
- datum = crs.datum();
- if (datum == null) {
- datumEnsemble = crs.datumEnsemble();
- }
+ datum = DatumOrEnsemble.asDatum(crs.geographic());
}
/**
@@ -686,8 +681,7 @@
}
referenceSystem = crs;
coordinateSystem = (SphericalCS) crs.getCoordinateSystem();
- datum = crs.getDatum();
- datumEnsemble = crs.getDatumEnsemble();
+ datum = DatumOrEnsemble.asDatum(crs);
} else {
setDatum(defaultCRS);
}
@@ -701,8 +695,10 @@
@Override void createCS(CSFactory factory, Map<String,?> properties, CoordinateSystemAxis[] axes) throws FactoryException {
if (axes.length > 2) {
coordinateSystem = factory.createSphericalCS(properties, axes[0], axes[1], axes[2]);
+ } else if (factory instanceof GeodeticObjectFactory) {
+ coordinateSystem = ((GeodeticObjectFactory) factory).createSphericalCS(properties, axes[0], axes[1]);
} else {
- coordinateSystem = factory.createSphericalCS(properties, axes[0], axes[1]);
+ throw new FactoryException("Unsupported factory implementation.");
}
}
@@ -711,7 +707,7 @@
* This method is invoked under conditions similar to the ones of above {@code createCS(…)} method.
*/
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
- referenceSystem = factory.createGeodeticCRS(properties, datum, datumEnsemble, coordinateSystem);
+ referenceSystem = factory.createGeocentricCRS(properties, datum, coordinateSystem);
}
}
@@ -750,8 +746,7 @@
}
referenceSystem = crs;
coordinateSystem = crs.getCoordinateSystem();
- datum = crs.getDatum();
- datumEnsemble = crs.getDatumEnsemble();
+ datum = DatumOrEnsemble.asDatum(crs);
} else {
setDatum(defaultCRS);
final Integer epsg = epsgCandidateCS(Units.DEGREE);
@@ -781,7 +776,7 @@
* This method is invoked under conditions similar to the ones of above {@code createCS(…)} method.
*/
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
- referenceSystem = factory.createGeographicCRS(properties, datum, datumEnsemble, coordinateSystem);
+ referenceSystem = factory.createGeographicCRS(properties, datum, coordinateSystem);
}
}
@@ -856,10 +851,9 @@
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
final boolean is3D = (coordinateSystem.getDimension() >= 3);
GeographicCRS baseCRS = is3D ? sphericalDatum.geographic3D() : sphericalDatum.geographic();
- if (!Utilities.equalsIgnoreMetadata(baseCRS.getDatum(), datum) &&
- !Utilities.equalsIgnoreMetadata(baseCRS.getDatumEnsemble(), datumEnsemble))
+ if (!Utilities.equalsIgnoreMetadata(baseCRS.getDatum(), datum))
{
- baseCRS = factory.createGeographicCRS(properties, datum, datumEnsemble, baseCRS.getCoordinateSystem());
+ baseCRS = factory.createGeographicCRS(properties, datum, baseCRS.getCoordinateSystem());
}
referenceSystem = factory.createProjectedCRS(properties, baseCRS, UNKNOWN_PROJECTION, coordinateSystem);
}
@@ -909,9 +903,8 @@
/**
* Creates a {@link VerticalDatum} for <q>Unknown datum based on Mean Sea Level</q>.
*/
- @SuppressWarnings("deprecation")
@Override void createDatum(DatumFactory factory, Map<String,?> properties) throws FactoryException {
- datum = factory.createVerticalDatum(properties, RealizationMethod.GEOID);
+ datum = factory.createVerticalDatum(properties, VerticalDatumType.GEOIDAL);
}
/**
@@ -927,7 +920,7 @@
* Creates the coordinate reference system from datum and coordinate system computed in previous steps.
*/
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
- referenceSystem = factory.createVerticalCRS(properties, datum, datumEnsemble, coordinateSystem);
+ referenceSystem = factory.createVerticalCRS(properties, datum, coordinateSystem);
}
}
@@ -985,7 +978,7 @@
datum = c.datum();
} else {
properties = properties("Time since " + epoch);
- datum = factory.createTemporalDatum(properties, epoch);
+ datum = factory.createTemporalDatum(properties, TemporalDate.toDate(epoch));
}
}
}
@@ -1007,7 +1000,7 @@
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
properties = properties(getFirstAxis().coordinates.getUnitsString());
if (datum != null) {
- referenceSystem = factory.createTemporalCRS(properties, datum, datumEnsemble, coordinateSystem);
+ referenceSystem = factory.createTemporalCRS(properties, datum, coordinateSystem);
} else {
referenceSystem = factory.createEngineeringCRS(properties,
CommonCRS.Engineering.TIME.datum(), coordinateSystem);
@@ -1054,7 +1047,7 @@
try {
switch (axes.length) {
case 0: break; // Should never happen but we are paranoiac.
- case 1: coordinateSystem = factory.createParametricCS(properties, axes[0]); return;
+ case 1: coordinateSystem = new org.apache.sis.referencing.cs.DefaultParametricCS(properties, axes[0]); return;
case 2: coordinateSystem = factory.createAffineCS(properties, axes[0], axes[1]); return;
default: coordinateSystem = factory.createAffineCS(properties, axes[0], axes[1], axes[2]); return;
}
@@ -1073,7 +1066,7 @@
* Creates the coordinate reference system from datum and coordinate system computed in previous steps.
*/
@Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException {
- referenceSystem = factory.createEngineeringCRS(properties, datum, datumEnsemble, coordinateSystem);
+ referenceSystem = factory.createEngineeringCRS(properties, datum, coordinateSystem);
}
}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Decoder.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Decoder.java
index 0c9a86c..8d44ab3 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Decoder.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Decoder.java
@@ -51,9 +51,6 @@
import org.apache.sis.util.iso.DefaultNameFactory;
import org.apache.sis.referencing.privy.ReferencingFactoryContainer;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.NameFactory;
-
/**
* The API used internally by Apache SIS for fetching variables and attribute values from a netCDF file.
@@ -110,7 +107,7 @@
/**
* The factory to use for creating variable identifiers.
*/
- public final NameFactory nameFactory;
+ public final DefaultNameFactory nameFactory;
/**
* The library for geometric objects, or {@code null} for the default.
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
index dd5789e..4ec3418 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
@@ -54,10 +54,10 @@
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.math.Vector;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Attribute;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.AbstractAttribute;
/**
@@ -90,7 +90,7 @@
/**
* The number of instances for each feature, or {@code null} if none. If non-null, then the number of features
- * is the length of this vector and each {@link Feature} instance has multi-valued properties with a number of
+ * is the length of this vector and each {@code Feature} instance has multi-valued properties with a number of
* elements given by this count. If null, the number of features is determined by the length of other variables.
*
* @see #getFeatureCount()
@@ -171,7 +171,7 @@
/**
* The type of all features to be read by this {@code FeatureSet}.
*/
- private final FeatureType type;
+ private final DefaultFeatureType type;
/**
* Creates a new discrete sampling parser for features identified by the given variable.
@@ -581,7 +581,7 @@
* Returns the type of all features to be read by this {@code FeatureSet}.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return type;
}
@@ -640,7 +640,7 @@
* @param parallel ignored, since current version does not support parallelism.
*/
@Override
- public Stream<Feature> features(boolean parallel) throws DataStoreException {
+ public Stream<AbstractFeature> features(boolean parallel) throws DataStoreException {
try {
return StreamSupport.stream(new Iter(), false);
} catch (IOException e) {
@@ -651,7 +651,7 @@
/**
* Implementation of the iterator returned by {@link #features(boolean)}.
*/
- private final class Iter implements Spliterator<Feature> {
+ private final class Iter implements Spliterator<AbstractFeature> {
/**
* Expected number of feature instances.
*/
@@ -744,8 +744,8 @@
* @throws BackingStoreException if an {@link IOException} or {@link DataStoreException} occurred.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) {
- final Feature feature = type.newInstance();
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) {
+ final AbstractFeature feature = type.newInstance();
final Vector[] coordinateValues;
int offset, length;
try {
@@ -860,7 +860,7 @@
* The time vector is the first vector after the geometry dimensions.
*/
if (hasTime) {
- MovingFeatures.setTimes((Attribute<?>) feature.getProperty(TRAJECTORY),
+ MovingFeatures.setTimes((AbstractAttribute<?>) feature.getProperty(TRAJECTORY),
coordinateValues[geometryDimension], timeCRS);
}
action.accept(feature);
@@ -919,7 +919,7 @@
* Current implementation cannot split this iterator.
*/
@Override
- public Spliterator<Feature> trySplit() {
+ public Spliterator<AbstractFeature> trySplit() {
return null;
}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
index 9c8bc92..c6c62b4 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
@@ -42,11 +42,11 @@
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.Conversion;
-import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.datum.DatumFactory;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.datum.PrimeMeridian;
@@ -86,8 +86,8 @@
import org.apache.sis.io.wkt.Warnings;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.datum.DatumEnsemble;
+// Specific to the main branch:
+import org.apache.sis.referencing.datum.DatumOrEnsemble;
/**
@@ -416,7 +416,6 @@
*/
final Object bursaWolf = definition.remove(Convention.TOWGS84);
final GeodeticDatum datum;
- DatumEnsemble<GeodeticDatum> ensemble = null;
if (isSpecified | bursaWolf != null) {
Map<String,Object> properties = properties(definition, Convention.GEODETIC_DATUM_NAME, false, ellipsoid);
if (bursaWolf instanceof BursaWolfParameters) {
@@ -426,10 +425,7 @@
}
datum = datumFactory.createGeodeticDatum(properties, ellipsoid, meridian);
} else {
- datum = defaultDefinitions.datum();
- if (datum == null) {
- ensemble = defaultDefinitions.datumEnsemble();
- }
+ datum = DatumOrEnsemble.asDatum(defaultDefinitions.geographic());
}
/*
* Geographic CRS from all above properties.
@@ -439,7 +435,6 @@
return decoder.getCRSFactory().createGeographicCRS(
properties,
datum,
- ensemble,
defaultDefinitions.geographic().getCoordinateSystem());
} else {
return defaultDefinitions.geographic();
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/ucar/FeaturesWrapper.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/ucar/FeaturesWrapper.java
index dddf78a..091843b 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/ucar/FeaturesWrapper.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/ucar/FeaturesWrapper.java
@@ -23,9 +23,9 @@
import org.apache.sis.storage.netcdf.base.DiscreteSampling;
import org.apache.sis.storage.event.StoreListeners;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -59,7 +59,7 @@
}
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
throw new UnsupportedOperationException(); // TODO
}
@@ -67,7 +67,7 @@
* Returns the stream of features.
*/
@Override
- public Stream<Feature> features(boolean parallel) {
+ public Stream<AbstractFeature> features(boolean parallel) {
throw new UnsupportedOperationException(); // TODO
}
}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/MetadataReaderTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/MetadataReaderTest.java
index 689854a..25f3fba 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/MetadataReaderTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/MetadataReaderTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.sis.storage.netcdf;
+import static java.util.Map.entry;
import java.io.IOException;
import java.time.ZoneOffset;
import java.time.LocalDateTime;
import java.time.temporal.Temporal;
-import static java.util.Map.entry;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.Role;
import org.opengis.metadata.citation.Citation;
@@ -42,9 +42,9 @@
import org.apache.sis.storage.netcdf.base.TestCase;
import org.apache.sis.storage.netcdf.classic.ChannelDecoderTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.ContentVerifier;
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
+import org.apache.sis.test.ContentVerifier;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
index c9856d4..d8eabed 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
@@ -32,8 +32,8 @@
import org.apache.sis.storage.DataStoreMock;
import org.apache.sis.storage.netcdf.base.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
index a2ea937..b1d35ca 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
@@ -27,8 +27,8 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCaseWithLogs;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/DecoderTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/DecoderTest.java
index 607ef17..cc73129 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/DecoderTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/DecoderTest.java
@@ -25,9 +25,6 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
-
/**
* Tests the {@link Decoder} implementation. The default implementation tests
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/FeatureSetTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/FeatureSetTest.java
deleted file mode 100644
index c90680b..0000000
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/FeatureSetTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.storage.netcdf.base;
-
-import java.awt.Shape;
-import java.awt.geom.PathIterator;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.Optional;
-import java.io.IOException;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.metadata.Metadata;
-import org.opengis.parameter.ParameterValueGroup;
-import org.apache.sis.feature.privy.AttributeConvention;
-import org.apache.sis.storage.DataStore;
-import org.apache.sis.storage.DataStoreException;
-
-// Test dependencies
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import org.opengis.test.dataset.TestData;
-
-
-/**
- * Tests the {@link FeatureSet} implementation. The default implementation uses the UCAR library,
- * which is is our reference implementation. Subclass overrides {@link #createDecoder(TestData)}
- * method in order to test a different implementation.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public class FeatureSetTest extends TestCase {
- /**
- * Type of the features read from the netCDF file.
- */
- private FeatureType type;
-
- /**
- * Index of the feature to verify.
- */
- private int featureIndex;
-
- /**
- * Instant from which time are measured.
- */
- private final Instant timeOrigin;
-
- /**
- * Creates a new test case.
- */
- public FeatureSetTest() {
- timeOrigin = Instant.parse("2014-11-29T00:00:00Z");
- }
-
- /**
- * Forgets the data used by the current test. This method makes {@code this} instance
- * ready for another test method reusing the decoders that are already opened.
- */
- @Override
- @AfterEach
- public void reset() {
- super.reset();
- type = null;
- featureIndex = 0;
- }
-
- /**
- * Returns a dummy data store implementation for the sole purpose of providing a non-null lock.
- */
- private static DataStore lock() {
- return new DataStore() {
- @Override public Optional<ParameterValueGroup> getOpenParameters() {return Optional.empty();}
- @Override public Metadata getMetadata() {return null;}
- @Override public void close() {}
- };
- }
-
- /**
- * Tests {@link FeatureSet} with a moving features file.
- *
- * @throws IOException if an I/O error occurred while opening the file.
- * @throws DataStoreException if a logical error occurred.
- */
- @Test
- public void testMovingFeatures() throws IOException, DataStoreException {
- final DataStore lock = lock();
- final FeatureSet[] features;
- synchronized (lock) {
- features = FeatureSet.create(selectDataset(TestData.MOVING_FEATURES), lock);
- }
- assertEquals(1, features.length);
- type = features[0].getType();
- verifyType(type.getProperties(false).iterator());
- features[0].features(false).forEach(this::verifyInstance);
- }
-
- /**
- * Verifies that given properties are the expected ones
- * for {@link TestData#MOVING_FEATURES} feature type.
- */
- private static void verifyType(final Iterator<? extends PropertyType> it) {
- assertEquals("sis:identifier", it.next().getName().toString());
- assertEquals("sis:envelope", it.next().getName().toString());
- assertEquals("sis:geometry", it.next().getName().toString());
-
- AttributeType<?> at = (AttributeType<?>) it.next();
- assertEquals("features", at.getName().toString());
-
- at = (AttributeType<?>) it.next();
- assertEquals("trajectory", at.getName().toString());
- assertEquals(Shape.class, at.getValueClass());
-
- at = (AttributeType<?>) it.next();
- assertEquals("stations", at.getName().toString());
- assertEquals(String.class, at.getValueClass());
-
- assertFalse(it.hasNext());
- }
-
- /**
- * Verifies the given feature instance.
- */
- private void verifyInstance(final Feature instance) {
- assertSame(type, instance.getType());
- final float[] longitudes, latitudes;
- final short[] times; // In minutes since 2014-11-29 00:00:00.
- final String[] stations;
- final String identifier;
- switch (featureIndex++) {
- case 0: {
- identifier = "a4078a16";
- longitudes = new float[] {139.622715f, 139.696899f, 139.740440f, 139.759640f, 139.763328f, 139.766084f};
- latitudes = new float[] { 35.466188f, 35.531328f, 35.630152f, 35.665498f, 35.675069f, 35.681382f};
- times = new short[] { 1068, 1077, 1087, 1094, 1096, 1098};
- stations = new String[] {
- "Yokohama", "Kawasaki", "Shinagawa", "Shinbashi", "Yurakucho", "Tokyo"
- };
- break;
- }
- case 1: {
- identifier = "1e146c16";
- longitudes = new float[] {139.700258f, 139.730667f, 139.763786f, 139.774219f};
- latitudes = new float[] { 35.690921f, 35.686014f, 35.699855f, 35.698683f};
- times = new short[] { 1075, 1079, 1087, 1090};
- stations = new String[] {
- "Shinjuku", "Yotsuya", "Ochanomizu", "Akihabara"
- };
- break;
- }
- case 2: {
- identifier = "f50ff004";
- longitudes = new float[] {139.649867f, 139.665652f, 139.700258f};
- latitudes = new float[] { 35.705385f, 35.706032f, 35.690921f};
- times = new short[] { 3480, 3482, 3486};
- stations = new String[] {
- "Koenji", "Nakano", "Shinjuku"
- };
- break;
- }
- default: {
- fail("Unexpected feature instance.");
- return;
- }
- }
- // Convert the time vector to an array of instants.
- final var instants = new Instant[times.length];
- for (int i=0; i<times.length; i++) {
- instants[i] = timeOrigin.plus(times[i], ChronoUnit.MINUTES);
- }
- /*
- * Verify property values and characteristics.
- */
- assertEquals(identifier, instance.getPropertyValue("features"));
- final var trajectory = (Attribute<?>) instance.getProperty("trajectory");
- asserLineStringEquals((Shape) trajectory.getValue(), longitudes, latitudes);
- assertArrayEquals(stations, ((Collection<?>) instance.getPropertyValue("stations")).toArray());
- assertArrayEquals(instants, trajectory.characteristics().get("datetimes").getValues().toArray());
- assertInstanceOf(GeographicCRS.class, AttributeConvention.getCRSCharacteristic(instance, "trajectory"));
- }
-
- /**
- * Asserts the given shape is a line string with the following coordinates.
- *
- * @param trajectory the shape to verify.
- * @param x expected X coordinates.
- * @param y expected Y coordinates.
- */
- private static void asserLineStringEquals(final Shape trajectory, final float[] x, final float[] y) {
- assertEquals(x.length, y.length);
- final PathIterator it = trajectory.getPathIterator(null);
- final float[] point = new float[2];
- for (int i=0; i < x.length; i++) {
- assertFalse(it.isDone());
- assertEquals(i == 0 ? PathIterator.SEG_MOVETO : PathIterator.SEG_LINETO, it.currentSegment(point));
- assertEquals(x[i], point[0], "x");
- assertEquals(y[i], point[1], "y");
- it.next();
- }
- assertTrue(it.isDone());
- }
-}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/GridTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/GridTest.java
index 7a1cdb4..8d3fc7e 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/GridTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/GridTest.java
@@ -26,9 +26,6 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
-
/**
* Tests the {@link Grid} implementation. The default implementation tests
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestCase.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestCase.java
index c34b3ef..662b4fa 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestCase.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestCase.java
@@ -42,9 +42,6 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.apache.sis.storage.DataStoreMock;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
-
/**
* Base class of netCDF tests. The base class uses the UCAR decoder, which is taken as a reference implementation.
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestData.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestData.java
new file mode 100644
index 0000000..f2cabd7
--- /dev/null
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/TestData.java
@@ -0,0 +1,50 @@
+/*
+ * 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.storage.netcdf.base;
+
+import java.net.URL;
+import java.io.InputStream;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assumptions.abort;
+
+
+/**
+ * Place-holder for a GeoAPI 3.1 class. Used only for allowing the code to compile.
+ * For real test execution, see the development branches on GeoAPI 4.0-SNAPSHOT.
+ */
+@SuppressWarnings("doclint:missing")
+public enum TestData {
+ NETCDF_2D_GEOGRAPHIC,
+
+ NETCDF_4D_PROJECTED;
+
+ public URL location() {
+ abort("This test requires GeoAPI 3.1.");
+ return null;
+ }
+
+ public InputStream open() {
+ abort("This test requires GeoAPI 3.1.");
+ return null;
+ }
+
+ public byte[] content() {
+ abort("This test requires GeoAPI 3.1.");
+ return null;
+ }
+}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/VariableTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/VariableTest.java
index f7250df..aedc9a8 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/VariableTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/base/VariableTest.java
@@ -30,9 +30,6 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
-
/**
* Tests the {@link Variable} implementation. The default implementation tests
@@ -296,18 +293,4 @@
assertEquals(-180 + 5*i, data.floatValue(i), "Longitude value");
}
}
-
- /**
- * Tests {@link Variable#readAnyType()} on strings.
- *
- * @throws IOException if an error occurred while reading the netCDF file.
- * @throws DataStoreException if a logical error occurred.
- */
- @Test
- public void testReadStrings() throws IOException, DataStoreException {
- final Variable variable = selectDataset(TestData.MOVING_FEATURES).findVariable("features");
- assertEquals("features", variable.getName());
- final List<?> identifiers = variable.readAnyType();
- assertArrayEquals(new String[] {"a4078a16", "1e146c16", "f50ff004", "", ""}, identifiers.toArray());
- }
}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/ChannelDecoderTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/ChannelDecoderTest.java
index 0dca724..779cd13 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/ChannelDecoderTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/ChannelDecoderTest.java
@@ -28,8 +28,8 @@
// Test dependencies
import org.apache.sis.storage.netcdf.base.DecoderTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/FeatureSetTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/FeatureSetTest.java
deleted file mode 100644
index 19e5e16..0000000
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/FeatureSetTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.storage.netcdf.classic;
-
-import java.io.IOException;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.netcdf.base.Decoder;
-
-// Test dependencies
-import org.opengis.test.dataset.TestData;
-
-
-/**
- * Tests the {@link org.apache.sis.storage.netcdf.base.FeatureSet} implementation
- * using the Apache SIS implementation of netCDF reader.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class FeatureSetTest extends org.apache.sis.storage.netcdf.base.FeatureSetTest {
- /**
- * Creates a new test case.
- */
- public FeatureSetTest() {
- }
-
- /**
- * Creates a new decoder for the specified dataset.
- *
- * @param file the dataset as one of the above-cited constants.
- * @return the decoder for the specified dataset.
- * @throws IOException if an I/O error occurred while opening the file.
- * @throws DataStoreException if a logical error occurred.
- */
- @Override
- protected Decoder createDecoder(final TestData file) throws IOException, DataStoreException {
- return ChannelDecoderTest.createChannelDecoder(file);
- }
-}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/GridInfoTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/GridInfoTest.java
index 2878392..2ca041d 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/GridInfoTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/GridInfoTest.java
@@ -25,8 +25,8 @@
// Test dependencies
import org.apache.sis.storage.netcdf.base.GridTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/VariableInfoTest.java b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/VariableInfoTest.java
index bed3b34..7f11bc0 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/VariableInfoTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/classic/VariableInfoTest.java
@@ -23,8 +23,8 @@
// Test dependencies
import org.apache.sis.storage.netcdf.base.VariableTest;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
index 7b997b6..c0c1276 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
@@ -135,7 +135,7 @@
private final GeometryLibrary geomLibrary;
/**
- * The result of inspecting database schema for deriving {@link org.opengis.feature.FeatureType}s.
+ * The result of inspecting database schema for deriving {@code FeatureType}s.
* Created when first needed. May be discarded and recreated if the store needs a refresh.
*
* @see #model()
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/ExtendedClauseWriter.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/ExtendedClauseWriter.java
index e19880f..41956ae 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/ExtendedClauseWriter.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/ExtendedClauseWriter.java
@@ -18,8 +18,8 @@
import org.apache.sis.storage.sql.feature.SelectionClauseWriter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAdapter.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAdapter.java
index de957bb..457d601 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAdapter.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAdapter.java
@@ -31,13 +31,13 @@
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.collection.WeakValueHashMap;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
- * Converter of {@link ResultSet} rows to {@link Feature} instances.
+ * Converter of {@link ResultSet} rows to {@code Feature} instances.
* Each {@code FeatureAdapter} instance is specific to the set of rows given by a SQL query,
* ignoring {@code DISTINCT}, {@code ORDER BY} and filter conditions in the {@code WHERE} clause.
* This class does not hold JDBC resources; {@link ResultSet} must be provided by the caller.
@@ -61,7 +61,7 @@
*
* @see Table#featureType
*/
- private final FeatureType featureType;
+ private final DefaultFeatureType featureType;
/**
* Attributes in feature instances, excluding operations and associations to other tables.
@@ -335,8 +335,8 @@
* @return the feature with attribute values initialized.
* @throws Exception if an error occurred while reading the database or converting values.
*/
- final Feature createFeature(final InfoStatements stmts, final ResultSet result) throws Exception {
- final Feature feature = featureType.newInstance();
+ final AbstractFeature createFeature(final InfoStatements stmts, final ResultSet result) throws Exception {
+ final AbstractFeature feature = featureType.newInstance();
for (int i=0; i<attributes.length; i++) {
final Column column = attributes[i];
final Object value = column.valueGetter.getValue(stmts, result, i+1);
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAnalyzer.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAnalyzer.java
index 7918ac1..2f61ea2 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAnalyzer.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureAnalyzer.java
@@ -36,8 +36,8 @@
import org.apache.sis.util.Classes;
import org.apache.sis.util.Numbers;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -402,7 +402,7 @@
*
* @return the feature type.
*/
- final FeatureType buildFeatureType() throws DataStoreException, SQLException {
+ final DefaultFeatureType buildFeatureType() throws DataStoreException, SQLException {
String remarks = id.freeText;
if (remarks != null) {
feature.setDefinition(remarks);
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureIterator.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureIterator.java
index 12904c2..40adc12 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureIterator.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureIterator.java
@@ -28,16 +28,16 @@
import org.apache.sis.feature.privy.FeatureProjection;
import org.apache.sis.util.collection.WeakValueHashMap;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.SortOrder;
-import org.opengis.filter.SortProperty;
-import org.opengis.filter.SortBy;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.SortOrder;
+import org.apache.sis.pending.geoapi.filter.SortProperty;
+import org.apache.sis.pending.geoapi.filter.SortBy;
/**
* Iterator over feature instances.
- * This iterator converters {@link ResultSet} rows to {@link Feature} instances.
+ * This iterator converters {@link ResultSet} rows to {@code Feature} instances.
* Each {@code FeatureIterator} iterator is created for one specific SQL query
* and can be used for only one iteration.
*
@@ -48,7 +48,7 @@
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*/
-final class FeatureIterator implements Spliterator<Feature>, AutoCloseable {
+final class FeatureIterator implements Spliterator<AbstractFeature>, AutoCloseable {
/**
* Characteristics of the iterator. The value returned by {@link #characteristics()}
* must be consistent with the value given to {@code DeferredStream} constructor.
@@ -58,7 +58,7 @@
static final int CHARACTERISTICS = NONNULL;
/**
- * The converter from a {@link ResultSet} row to a {@link Feature} instance.
+ * The converter from a {@link ResultSet} row to a {@code Feature} instance.
*/
private final FeatureAdapter adapter;
@@ -126,7 +126,7 @@
final Connection connection,
final boolean distinct,
final SelectionClause selection,
- final SortBy<? super Feature> sort,
+ final SortBy<? super AbstractFeature> sort,
final long offset,
final long count,
final FeatureProjection projection)
@@ -153,7 +153,7 @@
}
if (sort != null) {
String separator = " ORDER BY ";
- for (final SortProperty<? super Feature> s : sort.getSortProperties()) {
+ for (final SortProperty<? super AbstractFeature> s : sort.getSortProperties()) {
builder.append(separator).appendIdentifier(s.getValueReference().getXPath());
final SortOrder order = s.getSortOrder();
if (order != null) {
@@ -185,7 +185,7 @@
* Creates a new iterator over the dependencies of a feature.
*
* @param table the source table, or {@code null} if we are creating an iterator for a dependency.
- * @param adapter converter from a {@link ResultSet} row to a {@link Feature} instance.
+ * @param adapter converter from a {@link ResultSet} row to a {@code Feature} instance.
* @param connection connection to the database, used for creating statement.
* @param filter condition to append, not including the {@code WHERE} keyword.
* @param distinct whether the set should contain distinct feature instances.
@@ -237,7 +237,7 @@
* @return always {@code null}.
*/
@Override
- public Spliterator<Feature> trySplit() {
+ public Spliterator<AbstractFeature> trySplit() {
return null;
}
@@ -245,7 +245,7 @@
* Gives the next feature to the given consumer.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) {
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) {
try {
return fetch(action, false);
} catch (Exception e) {
@@ -257,7 +257,7 @@
* Gives all remaining features to the given consumer.
*/
@Override
- public void forEachRemaining(final Consumer<? super Feature> action) {
+ public void forEachRemaining(final Consumer<? super AbstractFeature> action) {
try {
fetch(action, true);
} catch (Exception e) {
@@ -269,13 +269,13 @@
* Gives at least the next feature to the given consumer.
* Gives all remaining features if {@code all} is {@code true}.
*
- * @param action the action to execute for each {@link Feature} instances fetched by this method.
+ * @param action the action to execute for each {@code Feature} instances fetched by this method.
* @param all {@code true} for reading all remaining feature instances, or {@code false} for only the next one.
* @return {@code true} if we have read an instance and {@code all} is {@code false} (so there is maybe other instances).
*/
- private boolean fetch(final Consumer<? super Feature> action, final boolean all) throws Exception {
+ private boolean fetch(final Consumer<? super AbstractFeature> action, final boolean all) throws Exception {
while (result.next()) {
- Feature feature = adapter.createFeature(spatialInformation, result);
+ AbstractFeature feature = adapter.createFeature(spatialInformation, result);
for (int i=0; i < dependencies.length; i++) {
WeakValueHashMap<?,Object> instances = null;
Object key = null, value = null;
@@ -332,8 +332,8 @@
* @param owner if the features to fetch are components of another feature, that container feature instance.
* @return the feature as a singleton {@code Feature} or as a {@code Collection<Feature>}.
*/
- private Object fetchReferenced(final Feature owner) throws Exception {
- final var features = new ArrayList<Feature>();
+ private Object fetchReferenced(final AbstractFeature owner) throws Exception {
+ final var features = new ArrayList<AbstractFeature>();
try (ResultSet r = statement.executeQuery()) {
result = r;
fetch(features::add, true);
@@ -341,7 +341,7 @@
result = null;
}
if (owner != null && adapter.deferredAssociation != null) {
- for (final Feature feature : features) {
+ for (final AbstractFeature feature : features) {
feature.setPropertyValue(adapter.deferredAssociation, owner);
}
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java
index 6d7f3aa..8db3036 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java
@@ -41,10 +41,10 @@
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.feature.privy.FeatureProjection;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.filter.Filter;
-import org.opengis.filter.SortBy;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.SortBy;
/**
@@ -60,7 +60,7 @@
* @author Alexis Manin (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-final class FeatureStream extends DeferredStream<Feature> {
+final class FeatureStream extends DeferredStream<AbstractFeature> {
/**
* The table which is the source of features.
*/
@@ -109,7 +109,7 @@
/**
* The {@code ORDER BY} clauses, or {@code null} if none.
*/
- private SortBy<? super Feature> sort;
+ private SortBy<? super AbstractFeature> sort;
/**
* Number of rows to skip in underlying SQL query, or 0 for none.
@@ -143,7 +143,7 @@
* Marks this stream as inactive and returns an empty stream.
* This method is invoked when an operation resulted in an empty stream.
*/
- private Stream<Feature> empty() {
+ private Stream<AbstractFeature> empty() {
count = 0;
delegate(); // Mark this stream as inactive.
return Stream.empty();
@@ -166,7 +166,7 @@
* to express the filter using SQL statements.
*/
@Override
- public Stream<Feature> filter(final Predicate<? super Feature> predicate) {
+ public Stream<AbstractFeature> filter(final Predicate<? super AbstractFeature> predicate) {
Objects.requireNonNull(predicate);
if (predicate == Filter.include()) return this;
if (predicate == Filter.exclude()) return empty();
@@ -191,12 +191,12 @@
* if we have a "F₀ AND F₁ AND F₂" chain, it is possible to have some Fₙ as SQL statements and
* other Fₙ executed in Java code.
*/
- Stream<Feature> stream = this;
+ Stream<AbstractFeature> stream = this;
try {
WarningEvent.LISTENER.set(selection);
final var optimization = new Optimization();
optimization.setFeatureType(table.featureType);
- for (final var filter : optimization.applyAndDecompose((Filter<? super Feature>) predicate)) {
+ for (final var filter : optimization.applyAndDecompose((Filter<? super AbstractFeature>) predicate)) {
if (filter == Filter.include()) continue;
if (filter == Filter.exclude()) return empty();
if (!selection.tryAppend(filterToSQL, filter)) {
@@ -216,7 +216,7 @@
* This operation will be done with a SQL {@code DISTINCT} clause if possible.
*/
@Override
- public Stream<Feature> distinct() {
+ public Stream<AbstractFeature> distinct() {
if (isPagined()) {
return delegate().distinct();
} else {
@@ -229,7 +229,7 @@
* Returns an equivalent stream that is unordered.
*/
@Override
- public Stream<Feature> unordered() {
+ public Stream<AbstractFeature> unordered() {
if (isPagined()) {
return delegate().unordered();
} else {
@@ -241,10 +241,10 @@
/**
* Returns an equivalent stream that is sorted by feature natural order.
* This is defined as a matter of principle, but will cause a {@link ClassCastException} to be thrown
- * when a terminal operation will be executed because {@link Feature} instances are not comparable.
+ * when a terminal operation will be executed because {@code Feature} instances are not comparable.
*/
@Override
- public Stream<Feature> sorted() {
+ public Stream<AbstractFeature> sorted() {
if (isPagined()) {
return delegate().sorted();
} else {
@@ -256,11 +256,11 @@
* Returns a stream with features of this stream sorted using the given comparator.
*/
@Override
- public Stream<Feature> sorted(final Comparator<? super Feature> comparator) {
+ public Stream<AbstractFeature> sorted(final Comparator<? super AbstractFeature> comparator) {
if (isPagined() || hasComparator) {
return delegate().sorted(comparator);
}
- final SortBy<? super Feature> c = SortByComparator.concatenate(sort, comparator);
+ final SortBy<? super AbstractFeature> c = SortByComparator.concatenate(sort, comparator);
if (c != null) {
sort = c;
return this;
@@ -274,7 +274,7 @@
* This operation will be done with a SQL {@code OFFSET} clause.
*/
@Override
- public Stream<Feature> skip(final long n) {
+ public Stream<AbstractFeature> skip(final long n) {
// Do not require this stream to be active because this method may be invoked by `PaginedStream`.
ArgumentChecks.ensurePositive("n", n);
offset = Math.addExact(offset, n);
@@ -292,7 +292,7 @@
* This operation will be done with a SQL {@code FETCH NEXT} clause.
*/
@Override
- public Stream<Feature> limit(final long maxSize) {
+ public Stream<AbstractFeature> limit(final long maxSize) {
// Do not require this stream to be active because this method may be invoked by `PaginedStream`.
ArgumentChecks.ensurePositive("maxSize", maxSize);
if (maxSize == 0) {
@@ -309,7 +309,7 @@
*/
@Override
@SuppressWarnings("unchecked")
- public <R> Stream<R> map(final Function<? super Feature, ? extends R> mapper) {
+ public <R> Stream<R> map(final Function<? super AbstractFeature, ? extends R> mapper) {
if (projection == null && mapper instanceof FeatureProjection) {
projection = (FeatureProjection) mapper;
return (Stream) this;
@@ -422,7 +422,7 @@
* @throws SQLException if an error occurs while executing the SQL statement.
*/
@Override
- protected Spliterator<Feature> createSourceIterator() throws Exception {
+ protected Spliterator<AbstractFeature> createSourceIterator() throws Exception {
Table projected = table;
FeatureProjection completion = null;
if (projection != null) {
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
index 1bf546c..e498a8a 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
@@ -59,8 +59,8 @@
import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Warnings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -791,7 +791,7 @@
* If we cannot find an identifier that we can map to a SRID, then this loop may be
* executed more times with CRS from EPSG database that are equal, ignoring axis order.
*/
- for (final Identifier id : candidate.getIdentifiers()) {
+ for (final ReferenceIdentifier id : candidate.getIdentifiers()) {
final String authority = id.getCodeSpace();
if (authority == null) continue;
final int code;
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SchemaModifier.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SchemaModifier.java
index 49b1c82..a001099 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SchemaModifier.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SchemaModifier.java
@@ -21,8 +21,8 @@
import org.apache.sis.io.stream.InternalOptionKey;
import org.apache.sis.setup.OptionKey;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -49,7 +49,7 @@
* @throws DataStoreException if an error occurred while modifying the feature type.
* @return the feature type to use for the specified table.
*/
- default FeatureType editFeatureType(TableReference table, FeatureTypeBuilder feature) throws DataStoreException {
+ default DefaultFeatureType editFeatureType(TableReference table, FeatureTypeBuilder feature) throws DataStoreException {
return feature.build();
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
index c456c25..ff31e23 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
@@ -39,11 +39,10 @@
import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Filter;
-import org.opengis.filter.ValueReference;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -144,7 +143,7 @@
*
* @see #REPLACE_UNSPECIFIED_CRS
*/
- final boolean acceptColumnCRS(final ValueReference<Feature,?> ref) {
+ final boolean acceptColumnCRS(final ValueReference<AbstractFeature,?> ref) {
final Column c = table.getColumn(ref.getXPath());
if (c != null && c.getGeometryType().isPresent()) {
final Optional<CoordinateReferenceSystem> crs = c.getDefaultCRS();
@@ -163,7 +162,7 @@
*
* @param ref reference to a property to insert in SQL statement.
*/
- final void appendColumnName(final ValueReference<Feature,?> ref) {
+ final void appendColumnName(final ValueReference<AbstractFeature,?> ref) {
final Column c = table.getColumn(ref.getXPath());
if (c != null) {
appendIdentifier(c.name);
@@ -298,7 +297,7 @@
* @param filter the filter to try to convert to SQL statements.
* @return {@code true} on success, or {@code false} in this {@code SelectionClause} is unchanged.
*/
- final boolean tryAppend(final SelectionClauseWriter writer, final Filter<? super Feature> filter) {
+ final boolean tryAppend(final SelectionClauseWriter writer, final Filter<? super AbstractFeature> filter) {
final int pos = buffer.length();
if (pos != 0) {
buffer.append(" AND ");
@@ -358,7 +357,7 @@
final LogRecord record = resources().createLogRecord(
Level.WARNING,
Resources.Keys.IncompatibleLiteralCRS_2,
- event.getOperatorType().map(CodeList::identifier).orElse("?"),
+ event.getOperatorType().map(Enum::name).orElse("?"),
event.getParameter(ValueReference.class).map(ValueReference<?,?>::getXPath).orElse("?"));
record.setThrown(event.exception);
log(record);
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java
index 2f4cb10..ebf56d5 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java
@@ -27,19 +27,18 @@
import org.apache.sis.filter.privy.FunctionNames;
import org.apache.sis.filter.privy.Visitor;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Literal;
-import org.opengis.filter.Expression;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.BetweenComparisonOperator;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
+import org.apache.sis.pending.geoapi.filter.LogicalOperatorName;
+import org.apache.sis.pending.geoapi.filter.ComparisonOperatorName;
+import org.apache.sis.pending.geoapi.filter.BinaryComparisonOperator;
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.BetweenComparisonOperator;
/**
@@ -60,7 +59,7 @@
* @author Alexis Manin (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public class SelectionClauseWriter extends Visitor<Feature, SelectionClause> {
+public class SelectionClauseWriter extends Visitor<AbstractFeature, SelectionClause> {
/**
* The default instance.
*/
@@ -79,14 +78,14 @@
setFilterHandler(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO, new Comparison(" >= "));
setFilterHandler(ComparisonOperatorName.PROPERTY_IS_LESS_THAN, new Comparison(" < "));
setFilterHandler(ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO, new Comparison(" <= "));
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_BETWEEN), (f,sql) -> {
- final BetweenComparisonOperator<Feature> filter = (BetweenComparisonOperator<Feature>) f;
+ setFilterHandler(ComparisonOperatorName.PROPERTY_IS_BETWEEN, (f,sql) -> {
+ final BetweenComparisonOperator<AbstractFeature> filter = (BetweenComparisonOperator<AbstractFeature>) f;
/* Nothing to append */ if (write(sql, filter.getExpression())) return;
sql.append(" BETWEEN "); if (write(sql, filter.getLowerBoundary())) return;
sql.append(" AND "); write(sql, filter.getUpperBoundary());
});
setNullAndNilHandlers((filter, sql) -> {
- final List<Expression<Feature, ?>> expressions = filter.getExpressions();
+ final List<Expression<AbstractFeature, ?>> expressions = filter.getExpressions();
if (expressions.size() == 1) {
write(sql, expressions.get(0));
sql.append(" IS NULL");
@@ -112,8 +111,8 @@
setExpressionHandler(FunctionNames.Subtract, new Arithmetic(" - "));
setExpressionHandler(FunctionNames.Divide, new Arithmetic(" / "));
setExpressionHandler(FunctionNames.Multiply, new Arithmetic(" * "));
- setExpressionHandler(FunctionNames.Literal, (e,sql) -> sql.appendLiteral(((Literal<Feature,?>) e).getValue()));
- setExpressionHandler(FunctionNames.ValueReference, (e,sql) -> sql.appendColumnName((ValueReference<Feature,?>) e));
+ setExpressionHandler(FunctionNames.Literal, (e,sql) -> sql.appendLiteral(((Literal<AbstractFeature,?>) e).getValue()));
+ setExpressionHandler(FunctionNames.ValueReference, (e,sql) -> sql.appendColumnName((ValueReference<AbstractFeature,?>) e));
// Filters created from Filter Encoding XML can specify "PropertyName" instead of "Value reference".
setExpressionHandler("PropertyName", getExpressionHandler(FunctionNames.ValueReference));
}
@@ -161,7 +160,7 @@
final boolean lowerCase = metadata.storesLowerCaseIdentifiers();
final boolean upperCase = metadata.storesUpperCaseIdentifiers();
for (final SpatialOperatorName type : SpatialOperatorName.values()) {
- final BiConsumer<Filter<Feature>, SelectionClause> function = getFilterHandler(type);
+ final BiConsumer<Filter<AbstractFeature>, SelectionClause> function = getFilterHandler(type);
if (function instanceof Function) {
String name = ((Function) function).name;
if (lowerCase) name = name.toLowerCase(Locale.US);
@@ -208,7 +207,7 @@
* may be truncated (later) to the length that it has the last time that it was valid.
*/
@Override
- protected final void typeNotFound(CodeList<?> type, Filter<Feature> filter, SelectionClause sql) {
+ protected final void typeNotFound(Enum<?> type, Filter<AbstractFeature> filter, SelectionClause sql) {
sql.invalidate();
}
@@ -217,7 +216,7 @@
* and may be truncated (later) to the length that it has the last time that it was valid.
*/
@Override
- protected final void typeNotFound(String type, Expression<Feature,?> expression, SelectionClause sql) {
+ protected final void typeNotFound(String type, Expression<AbstractFeature,?> expression, SelectionClause sql) {
sql.invalidate();
}
@@ -233,8 +232,8 @@
* @return value of {@link SelectionClause#isInvalid} flag, for allowing caller to short-circuit.
*/
@SuppressWarnings("unchecked")
- final boolean write(final SelectionClause sql, final Filter<? super Feature> filter) {
- visit((Filter<Feature>) filter, sql);
+ final boolean write(final SelectionClause sql, final Filter<? super AbstractFeature> filter) {
+ visit((Filter<AbstractFeature>) filter, sql);
return sql.isInvalid();
}
@@ -245,7 +244,7 @@
* @param expression the expression for which to execute an action based on its type.
* @return value of {@link SelectionClause#isInvalid} flag, for allowing caller to short-circuit.
*/
- private boolean write(final SelectionClause sql, final Expression<Feature, ?> expression) {
+ private boolean write(final SelectionClause sql, final Expression<AbstractFeature, ?> expression) {
visit(expression, sql);
return sql.isInvalid();
}
@@ -258,7 +257,7 @@
* @param filter the filter for which to append the expressions.
* @param operator the operator to write between the expressions.
*/
- protected final void writeBinaryOperator(final SelectionClause sql, final Filter<Feature> filter, final String operator) {
+ protected final void writeBinaryOperator(final SelectionClause sql, final Filter<AbstractFeature> filter, final String operator) {
writeParameters(sql, filter.getExpressions(), operator, true);
}
@@ -270,7 +269,7 @@
* @param separator the separator to insert between expression.
* @param binary whether the list of expressions shall contain exactly 2 elements.
*/
- private void writeParameters(final SelectionClause sql, final List<Expression<Feature,?>> expressions,
+ private void writeParameters(final SelectionClause sql, final List<Expression<AbstractFeature,?>> expressions,
final String separator, final boolean binary)
{
final int n = expressions.size();
@@ -295,7 +294,7 @@
* The filter can contain an arbitrary number of operands, all separated by the same keyword.
* All operands are grouped between parenthesis.
*/
- private final class Logic implements BiConsumer<Filter<Feature>, SelectionClause> {
+ private final class Logic implements BiConsumer<Filter<AbstractFeature>, SelectionClause> {
/**
* The {@code AND}, {@code OR} or {@code NOT} keyword.
* Shall contain a trailing space and eventually a leading space.
@@ -315,9 +314,9 @@
}
/** Invoked when a logical filter needs to be converted to SQL clause. */
- @Override public void accept(final Filter<Feature> f, final SelectionClause sql) {
- final LogicalOperator<Feature> filter = (LogicalOperator<Feature>) f;
- final List<Filter<Feature>> operands = filter.getOperands();
+ @Override public void accept(final Filter<AbstractFeature> f, final SelectionClause sql) {
+ final var filter = (LogicalOperator<AbstractFeature>) f;
+ final List<Filter<AbstractFeature>> operands = filter.getOperands();
final int n = operands.size();
if (unary ? (n != 1) : (n == 0)) {
sql.invalidate();
@@ -343,7 +342,7 @@
* into SQL clauses. The filter is expected to contain exactly two operands, otherwise the
* SQL is declared invalid.
*/
- private final class Comparison implements BiConsumer<Filter<Feature>, SelectionClause> {
+ private final class Comparison implements BiConsumer<Filter<AbstractFeature>, SelectionClause> {
/** The comparison operator symbol. */
private final String operator;
@@ -353,8 +352,8 @@
}
/** Invoked when a comparison needs to be converted to SQL clause. */
- @Override public void accept(final Filter<Feature> f, final SelectionClause sql) {
- final BinaryComparisonOperator<Feature> filter = (BinaryComparisonOperator<Feature>) f;
+ @Override public void accept(final Filter<AbstractFeature> f, final SelectionClause sql) {
+ final BinaryComparisonOperator<AbstractFeature> filter = (BinaryComparisonOperator<AbstractFeature>) f;
if (filter.isMatchingCase()) {
writeBinaryOperator(sql, filter, operator);
} else {
@@ -370,7 +369,7 @@
* Handler for converting {@code +}, {@code -}, {@code *} or {@code /} filter into SQL clauses.
* The filter is expected to contain exactly two operands, otherwise the SQL is declared invalid.
*/
- private final class Arithmetic implements BiConsumer<Expression<Feature,?>, SelectionClause> {
+ private final class Arithmetic implements BiConsumer<Expression<AbstractFeature,?>, SelectionClause> {
/** The arithmetic operator symbol. */
private final String operator;
@@ -380,7 +379,7 @@
}
/** Invoked when an arithmetic expression needs to be converted to SQL clause. */
- @Override public void accept(final Expression<Feature,?> expression, final SelectionClause sql) {
+ @Override public void accept(final Expression<AbstractFeature,?> expression, final SelectionClause sql) {
writeParameters(sql, expression.getParameters(), operator, true);
}
}
@@ -394,7 +393,7 @@
* the trailing part of the SQL in an invalid state. Callers should check if this is
* the case by invoking {@link SelectionClause#isInvalid()} after this method call.
*/
- private final class Function implements BiConsumer<Filter<Feature>, SelectionClause> {
+ private final class Function implements BiConsumer<Filter<AbstractFeature>, SelectionClause> {
/** Name the function. */
final String name;
@@ -410,13 +409,13 @@
* of the geometry column when those CRS are known. Therefore, it should not be needed to perform any
* geometry transformation in this method.
*/
- @Override public void accept(final Filter<Feature> filter, final SelectionClause sql) {
+ @Override public void accept(final Filter<AbstractFeature> filter, final SelectionClause sql) {
sql.appendSpatialFunction(name);
- final List<Expression<Feature, ?>> expressions = filter.getExpressions();
+ final List<Expression<AbstractFeature, ?>> expressions = filter.getExpressions();
if (SelectionClause.REPLACE_UNSPECIFIED_CRS) {
- for (Expression<Feature,?> exp : expressions) {
+ for (Expression<AbstractFeature,?> exp : expressions) {
if (exp instanceof ValueReference<?,?>) {
- if (sql.acceptColumnCRS((ValueReference<Feature,?>) exp)) {
+ if (sql.acceptColumnCRS((ValueReference<AbstractFeature,?>) exp)) {
break;
}
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Table.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Table.java
index c5711cc..3dcc702 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Table.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Table.java
@@ -46,19 +46,17 @@
import org.apache.sis.util.iso.DefaultNameSpace;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.filter.InvalidFilterValueException;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.DefaultAssociationRole;
/**
* Description of a table in the database, including columns, primary keys and foreigner keys.
- * This class contains a {@link FeatureType} inferred from the table structure.
- * The {@link FeatureType} contains an {@link AttributeType} for each table column,
- * except foreigner keys which are represented by {@link FeatureAssociationRole}s.
+ * This class contains a {@code FeatureType} inferred from the table structure.
+ * The {@code FeatureType} contains an {@code AttributeType} for each table column,
+ * except foreigner keys which are represented by {@code FeatureAssociationRole}s.
*
* <h2>Multi-threading</h2>
* This class is immutable (except for the cache) and safe for concurrent use by many threads.
@@ -89,7 +87,7 @@
*
* @see #getType()
*/
- final FeatureType featureType;
+ final DefaultFeatureType featureType;
/**
* The SQL query to execute for fetching data, or {@code null} for querying the table identified by {@link #name}.
@@ -113,7 +111,7 @@
* This array shall not be modified after construction.
*
* <p>Columns may have alias if it was necessary to avoid name collisions.
- * The alias is given by {@link Column#propertyName} and will be the name used in {@link FeatureType}.</p>
+ * The alias is given by {@link Column#propertyName} and will be the name used in {@code FeatureType}.</p>
*/
final Column[] attributes;
@@ -152,7 +150,7 @@
private Map<String,Column> attributeToColumns;
/**
- * The converter of {@link ResultSet} rows to {@link Feature} instances.
+ * The converter of {@link ResultSet} rows to {@code Feature} instances.
* Created when first needed.
*
* @see #adapter(Connection)
@@ -210,7 +208,7 @@
* @param projection description of the columns to keep.
* @param reusedNames an initially empty set where to store the names of attributes that are not renamed.
* @param unhandled where to set the bits for indexes of expressions that are not handled by the new table.
- * @throws InvalidFilterValueException if there is an error in the declaration of property values.
+ * @throws IllegalArgumentException if there is an error in the declaration of property values.
*/
@SuppressWarnings("LocalVariableHidesMemberVariable")
Table(final Table source,
@@ -267,7 +265,7 @@
exportedKeys[exportedKeysCount++] = relation;
continue;
}
- throw new InvalidFilterValueException(Errors.forLocale(listeners.getLocale())
+ throw new IllegalArgumentException(Errors.forLocale(listeners.getLocale())
.getString(Errors.Keys.PropertyNotFound_2, source.featureType.getName(), xpath));
}
/*
@@ -314,7 +312,7 @@
* have been set to association names. If `ClassCastException` occurs here, it is a bug
* in our object constructions.
*/
- final var association = (FeatureAssociationRole) featureType.getProperty(relation.getPropertyName());
+ final var association = (DefaultAssociationRole) featureType.getProperty(relation.getPropertyName());
final Table table = tables.get(association.getValueType().getName());
if (table == null) {
throw new InternalDataStoreException(association.toString());
@@ -399,7 +397,7 @@
* created behind a {@link org.apache.sis.storage.FeatureSubset}.
*/
@Override
- public final FeatureType getType() {
+ public final DefaultFeatureType getType() {
return featureType;
}
@@ -574,7 +572,7 @@
}
/**
- * Returns the converter of {@link ResultSet} rows to {@link Feature} instances.
+ * Returns the converter of {@link ResultSet} rows to {@code Feature} instances.
* The converter is created the first time that this method is invoked, then cached.
*
* @param connection source of database metadata to use if the adapter needs to be created.
@@ -594,7 +592,7 @@
* @throws DataStoreException if an error occurred while creating the stream.
*/
@Override
- public Stream<Feature> features(final boolean parallel) throws DataStoreException {
+ public Stream<AbstractFeature> features(final boolean parallel) throws DataStoreException {
return new FeatureStream(this, parallel);
}
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/package-info.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/package-info.java
index d4b582c..edfce4d 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/package-info.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/package-info.java
@@ -17,7 +17,7 @@
/**
- * Build {@link org.opengis.feature.FeatureType}s by inspection of database schemas.
+ * Build {@link org.apache.sis.feature.DefaultFeatureType}s by inspection of database schemas.
* The work done here is similar to reverse engineering.
*
* <STRONG>Do not use!</STRONG>
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/package-info.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/package-info.java
index ec2b149..f650b19 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/package-info.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/package-info.java
@@ -19,11 +19,11 @@
/**
* Data store capable to read and write features using a JDBC connection to a database.
* {@link org.apache.sis.storage.sql.SimpleFeatureStore} takes one or more tables at construction time.
- * Each enumerated table is represented by a {@link org.opengis.feature.FeatureType}.
- * Each row in those table represents a {@link org.opengis.feature.Feature} instance.
- * Each relation defined by a foreigner key is represented by an {@link org.opengis.feature.FeatureAssociationRole}
+ * Each enumerated table is represented by a {@code FeatureType}.
+ * Each row in those table represents a {@code Feature} instance.
+ * Each relation defined by a foreigner key is represented by an {@code FeatureAssociationRole}
* to another feature (with transitive dependencies automatically resolved), and the other columns are represented
- * by {@link org.opengis.feature.AttributeType}.
+ * by {@code AttributeType}.
*
* <p>The storage of spatial features in <abbr>SQL</abbr> databases is described by the
* <a href="https://www.ogc.org/standards/sfs">OGC Simple feature access - Part 2: SQL option</a>
@@ -40,7 +40,7 @@
* <p>A subset of features can be obtained by applying filters on the stream returned by
* {@link org.apache.sis.storage.FeatureSet#features(boolean)}.
* While the filter can be any {@link java.util.function.Predicate},
- * performances will be much better if they are instances of {@link org.opengis.filter.Filter}
+ * performances will be much better if they are instances of {@link org.apache.sis.filter.Filter}
* because Apache SIS will know how to translate some of them to <abbr>SQL</abbr> statements.</p>
*
* <p>In filter expressions like {@code ST_Intersects(A,B)} where the <var>A</var> and <var>B</var> parameters are
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/ExtendedClauseWriter.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/ExtendedClauseWriter.java
index 0e0ee05..2a284d5 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/ExtendedClauseWriter.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/ExtendedClauseWriter.java
@@ -18,8 +18,8 @@
import org.apache.sis.storage.sql.feature.SelectionClauseWriter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
+// Specific to the main branch:
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
/**
diff --git a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/SQLStoreTest.java b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/SQLStoreTest.java
index 62b2593..6b88e59 100644
--- a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/SQLStoreTest.java
+++ b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/SQLStoreTest.java
@@ -42,14 +42,12 @@
import org.apache.sis.metadata.sql.TestDatabase;
import static org.apache.sis.test.Assertions.assertSetEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.SortOrder;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.DefaultAssociationRole;
/**
@@ -96,12 +94,12 @@
* This feature should appear twice, and all those occurrences should use the exact same instance.
* We use that for verifying the {@code Table.instanceForPrimaryKeys} caching.
*/
- private Feature canada;
+ private AbstractFeature canada;
/**
* Factory to use for creating filter objects.
*/
- private final FilterFactory<Feature,Object,Object> FF;
+ private final DefaultFilterFactory<AbstractFeature,Object,Object> FF;
/**
* Creates a new test.
@@ -178,7 +176,7 @@
try (var store = new SimpleFeatureStore(new SQLStoreProvider(), connector, table)) {
verifyFeatureTypes(store);
final var countryCount = new HashMap<String,Integer>();
- try (Stream<Feature> features = store.findResource("Cities").features(false)) {
+ try (Stream<AbstractFeature> features = store.findResource("Cities").features(false)) {
features.forEach((f) -> verifyContent(f, countryCount));
}
assertEquals(Integer.valueOf(2), countryCount.remove("CAN"));
@@ -233,9 +231,9 @@
/**
* Verifies the result of analyzing the structure of the {@code "Cities"} table.
*/
- private static void verifyFeatureType(final FeatureType type, final String[] expectedNames, final Object[] expectedTypes) {
+ private static void verifyFeatureType(final DefaultFeatureType type, final String[] expectedNames, final Object[] expectedTypes) {
int i = 0;
- for (PropertyType pt : type.getProperties(false)) {
+ for (AbstractIdentifiedType pt : type.getProperties(false)) {
if (i >= expectedNames.length) {
fail("Returned feature-type contains more properties than expected. Example: " + pt.getName());
}
@@ -246,10 +244,10 @@
final Object value;
if (expectedType instanceof Class<?>) {
label = "attribute type";
- value = ((AttributeType<?>) pt).getValueClass();
+ value = ((DefaultAttributeType<?>) pt).getValueClass();
} else {
label = "association type";
- value = ((FeatureAssociationRole) pt).getValueType().getName().toString();
+ value = ((DefaultAssociationRole) pt).getValueType().getName().toString();
}
assertEquals(expectedType, value, label);
}
@@ -265,7 +263,7 @@
* @param feature a feature returned by the stream.
* @param countryCount number of time that the each country has been seen while iterating over the cities.
*/
- private void verifyContent(final Feature feature, final Map<String,Integer> countryCount) {
+ private void verifyContent(final AbstractFeature feature, final Map<String,Integer> countryCount) {
final String city = feature.getPropertyValue("native_name").toString();
final City c;
boolean isCanada = false;
@@ -289,7 +287,7 @@
*/
assertEquals(c.countryName, getIndirectPropertyValue(feature, "country", "native_name"));
if (isCanada) {
- final var f = (Feature) feature.getPropertyValue("country");
+ final var f = (AbstractFeature) feature.getPropertyValue("country");
if (canada == null) {
canada = f;
} else {
@@ -306,7 +304,7 @@
assertEquals(c.parks.length, actualParks.size());
final Collection<String> expectedParks = new HashSet<>(Arrays.asList(c.parks));
for (final Object park : actualParks) {
- final Feature pf = (Feature) park;
+ final AbstractFeature pf = (AbstractFeature) park;
final String npn = (String) pf.getPropertyValue("native_name");
final String epn = (String) pf.getPropertyValue("english_name");
assertNotNull(npn, "park.native_name");
@@ -326,10 +324,10 @@
/**
* Follows an association in the given feature.
*/
- private static Object getIndirectPropertyValue(final Feature feature, final String p1, final String p2) {
+ private static Object getIndirectPropertyValue(final AbstractFeature feature, final String p1, final String p2) {
final Object dependency = feature.getPropertyValue(p1);
assertNotNull(dependency, p1);
- return assertInstanceOf(Feature.class, dependency, p1).getPropertyValue(p2);
+ return assertInstanceOf(AbstractFeature.class, dependency, p1).getPropertyValue(p2);
}
/**
@@ -355,21 +353,19 @@
final FeatureSet parks = dataset.findResource("Parks");
final FeatureQuery query = new FeatureQuery();
query.setProjection(FF.property(desiredProperty));
- query.setSortBy(FF.sort(FF.property("country"), SortOrder.DESCENDING),
- FF.sort(FF.property(desiredProperty), SortOrder.ASCENDING));
final FeatureSet subset = parks.subset(query);
/*
- * Verify that all features have the expected property, then verify the sorted values.
+ * Verify that all features have the expected property.
*/
final Object[] values;
- try (Stream<Feature> features = subset.features(false)) {
+ try (Stream<AbstractFeature> features = subset.features(false)) {
values = features.map(f -> {
- final PropertyType p = TestUtilities.getSingleton(f.getType().getProperties(true));
+ final AbstractIdentifiedType p = TestUtilities.getSingleton(f.getType().getProperties(true));
assertEquals(desiredProperty, p.getName().toString(), "Feature has wrong property.");
return f.getPropertyValue(desiredProperty);
}).toArray();
}
- assertArrayEquals(expectedValues, values, "Values are not sorted as expected.");
+ assertEquals(new HashSet<>(Arrays.asList(expectedValues)), new HashSet<>(Arrays.asList(values)));
}
/**
@@ -410,7 +406,7 @@
final FeatureQuery query = new FeatureQuery();
query.setSelection(FF.equal(FF.property("country"), FF.literal("CAN")));
final Object[] names;
- try (Stream<Feature> features = cities.subset(query).features(false)) {
+ try (Stream<AbstractFeature> features = cities.subset(query).features(false)) {
names = features.map(f -> f.getPropertyValue(desiredProperty)).toArray();
}
assertSetEquals(Arrays.asList(expectedValues), Arrays.asList(names));
@@ -431,7 +427,7 @@
query.setSelection(FF.equal(FF.property("sis:identifier"), FF.literal("CAN")));
final String executionMode;
final Object[] names;
- try (Stream<Feature> features = countries.subset(query).features(false)) {
+ try (Stream<AbstractFeature> features = countries.subset(query).features(false)) {
executionMode = features.toString();
names = features.map(f -> f.getPropertyValue(desiredProperty)).toArray();
}
@@ -459,11 +455,11 @@
query.setProjection("sis:identifier", "native_name");
final FeatureSet countries = dataset.findResource("Countries").subset(query);
List<Object> names;
- try (Stream<Feature> features = countries.features(false)) {
+ try (Stream<AbstractFeature> features = countries.features(false)) {
names = features.map(f -> f.getPropertyValue("sis:identifier")).toList();
}
assertSetEquals(List.of("CAN", "FRA", "JPN"), names);
- try (Stream<Feature> features = countries.features(false)) {
+ try (Stream<AbstractFeature> features = countries.features(false)) {
names = features.map(f -> f.getPropertyValue("native_name")).toList();
}
assertSetEquals(List.of("Canada", "France", "日本"), names);
@@ -477,7 +473,7 @@
* @param cities a feature set containing all cities defined for the test class.
*/
private void verifyStreamOperations(final FeatureSet cities) throws DataStoreException {
- try (Stream<Feature> features = cities.features(false)) {
+ try (Stream<AbstractFeature> features = cities.features(false)) {
final var peekCount = new AtomicInteger();
final var mapCount = new AtomicInteger();
final long actualPopulations = features.peek(f -> peekCount.incrementAndGet())
@@ -514,7 +510,7 @@
{
final FeatureSet cities = store.findResource("LargeCities");
final var countryCount = new HashMap<String,Integer>();
- try (Stream<Feature> features = cities.features(false)) {
+ try (Stream<AbstractFeature> features = cities.features(false)) {
features.forEach((f) -> verifyContent(f, countryCount));
}
assertEquals(Integer.valueOf(1), countryCount.remove("CAN"));
@@ -530,28 +526,27 @@
*/
private void verifyNestedSQLQuery(final StorageConnector connector) throws Exception {
try (SimpleFeatureStore store = new SimpleFeatureStore(null, connector, ResourceDefinition.query("MyParks",
- "SELECT * FROM " + SCHEMA + ".\"Parks\"")))
+ "SELECT * FROM " + SCHEMA + ".\"Parks\" ORDER BY \"native_name\" DESC")))
{
final FeatureSet parks = store.findResource("MyParks");
/*
* Add a filter for parks in France.
*/
final var query = new FeatureQuery();
- query.setSortBy(FF.sort(FF.property("native_name"), SortOrder.DESCENDING));
query.setSelection(FF.equal(FF.property("country"), FF.literal("FRA")));
query.setProjection(FF.property("native_name"));
final FeatureSet frenchParks = parks.subset(query);
/*
* Verify the feature type.
*/
- final PropertyType property = TestUtilities.getSingleton(frenchParks.getType().getProperties(true));
+ final AbstractIdentifiedType property = TestUtilities.getSingleton(frenchParks.getType().getProperties(true));
assertEquals("native_name", property.getName().toString());
- assertEquals(String.class, ((AttributeType<?>) property).getValueClass());
+ assertEquals(String.class, ((DefaultAttributeType<?>) property).getValueClass());
/*
* Verify the values.
*/
final Object[] result;
- try (Stream<Feature> fs = frenchParks.features(false)) {
+ try (Stream<AbstractFeature> fs = frenchParks.features(false)) {
result = fs.map(f -> f.getPropertyValue("native_name")).toArray();
}
assertArrayEquals(new String[] {"Jardin du Luxembourg", "Jardin des Tuileries"}, result);
@@ -571,8 +566,8 @@
"OFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY")))
{
final FeatureSet parks = store.findResource("MyQuery");
- final FeatureType type = parks.getType();
- final var property = (AttributeType<?>) TestUtilities.getSingleton(type.getProperties(true));
+ final DefaultFeatureType type = parks.getType();
+ final var property = (DefaultAttributeType<?>) TestUtilities.getSingleton(type.getProperties(true));
assertEquals("title", property.getName().toString(), "Property name should be label defined in query");
assertEquals(String.class, property.getValueClass(), "Attribute should be a string");
assertEquals(0, property.getMinimumOccurs(), "Column should be nullable.");
@@ -597,7 +592,7 @@
* then returns the values of the "title" property of all features.
*/
private static String[] getTitles(final FeatureSet parks, final long skip, final long limit) throws DataStoreException {
- try (Stream<Feature> in = parks.features(false).skip(skip).limit(limit)) {
+ try (Stream<AbstractFeature> in = parks.features(false).skip(skip).limit(limit)) {
return in.map(f -> f.getPropertyValue("title").toString()).toArray(String[]::new);
}
}
@@ -611,7 +606,7 @@
"SELECT \"country\" FROM " + SCHEMA + ".\"Parks\" ORDER BY \"country\"")))
{
final FeatureSet countries = store.findResource("Countries");
- try (Stream<Feature> features = countries.features(false).distinct()) {
+ try (Stream<AbstractFeature> features = countries.features(false).distinct()) {
expected = features.map(f -> f.getPropertyValue("country")).toArray();
}
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
index d4e304c..8ad4ea6 100644
--- a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
+++ b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
@@ -33,12 +33,10 @@
import org.apache.sis.metadata.sql.TestDatabase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.SpatialOperator;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.filter.Filter;
/**
@@ -51,7 +49,7 @@
/**
* The factory to use for creating the filter objects.
*/
- private final FilterFactory<Feature,Object,Object> FF;
+ private final DefaultFilterFactory<AbstractFeature,Object,Object> FF;
/**
* A dummy table for testing purpose.
@@ -89,7 +87,7 @@
* Creates a filter without geometry and verifies that it is translated to the expected SQL fragment.
*/
private void testSimpleFilter() {
- final Filter<Feature> filter = FF.and(
+ final Filter<AbstractFeature> filter = FF.and(
FF.greater(FF.property("ALPHA"), FF.property("BETA")),
FF.or(FF.isNull(FF.property("GAMMA")),
FF.equal(FF.literal(3.14), FF.property("PI"))));
@@ -101,7 +99,7 @@
* Creates a filter with a geometric objects and verifies that it is translated to the expected SQL fragment.
*/
private void testGeometricFilter() {
- final SpatialOperator<Feature> filter = FF.intersects(
+ final Filter<AbstractFeature> filter = FF.intersects(
FF.property("ALPHA"),
FF.literal(new GeneralEnvelope(new double[] {-12.3, 43.3}, new double[] {2.1, 51.7})));
@@ -114,7 +112,7 @@
* This method add a CRS on a property for testing purpose.
*/
@Override
- public FeatureType editFeatureType(final TableReference table, final FeatureTypeBuilder feature) {
+ public DefaultFeatureType editFeatureType(final TableReference table, final FeatureTypeBuilder feature) {
assertEquals("", table.catalog);
assertEquals("APP", table.schema);
assertEquals("TEST", table.table);
@@ -129,7 +127,7 @@
final GeneralEnvelope bbox = new GeneralEnvelope(HardCodedCRS.WGS84_LATITUDE_FIRST);
bbox.setEnvelope(-10, 20, -5, 25);
- Filter<Feature> filter = FF.intersects(FF.property("BETA"), FF.literal(bbox));
+ Filter<AbstractFeature> filter = FF.intersects(FF.property("BETA"), FF.literal(bbox));
final Optimization optimization = new Optimization();
optimization.setFeatureType(table.featureType);
verifySQL(optimization.apply(filter), "ST_Intersects(\"BETA\", " +
@@ -140,7 +138,7 @@
* Formats the given filter as a SQL {@code WHERE} statement body
* and verifies that the result is equal to the expected string.
*/
- private void verifySQL(final Filter<Feature> filter, final String expected) {
+ private void verifySQL(final Filter<AbstractFeature> filter, final String expected) {
final SelectionClause sql = new SelectionClause(table);
assertTrue(sql.tryAppend(SelectionClauseWriter.DEFAULT, filter));
assertEquals(expected, sql.toString());
diff --git a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/postgis/PostgresTest.java b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/postgis/PostgresTest.java
index 0ee3a90..29d3150 100644
--- a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/postgis/PostgresTest.java
+++ b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/postgis/PostgresTest.java
@@ -67,8 +67,9 @@
import org.apache.sis.metadata.sql.TestDatabase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.metadata.iso.identification.AbstractIdentification;
/**
@@ -115,7 +116,8 @@
*/
private static void validate(final Metadata metadata) {
final Identification identification = TestUtilities.getSingleton(metadata.getIdentificationInfo());
- assertTrue(identification.getSpatialRepresentationTypes().containsAll(
+ var defId = assertInstanceOf(AbstractIdentification.class, identification);
+ assertTrue(defId.getSpatialRepresentationTypes().containsAll(
Arrays.asList(SpatialRepresentationType.TEXT_TABLE,
SpatialRepresentationType.VECTOR,
SpatialRepresentationType.GRID)));
@@ -218,10 +220,10 @@
final Envelope envelope = resource.getEnvelope().get();
assertEquals(-72, envelope.getMinimum(0), 1);
assertEquals( 43, envelope.getMaximum(1), 1);
- try (Stream<Feature> features = resource.features(false)) {
+ try (Stream<AbstractFeature> features = resource.features(false)) {
features.forEach(PostgresTest::validate);
}
- try (Stream<Feature> features = resource.features(false)) {
+ try (Stream<AbstractFeature> features = resource.features(false)) {
assertEquals(8, features.count());
}
}
@@ -258,7 +260,7 @@
}
final var factory = DefaultFilterFactory.forFeatures();
final var filter = factory.intersects(factory.property("geom4326"), factory.literal(geom));
- try (Stream<Feature> features = resource.features(false).filter(filter)) {
+ try (Stream<AbstractFeature> features = resource.features(false).filter(filter)) {
assertEquals(4, features.count());
}
}
@@ -267,7 +269,7 @@
* Invoked for each feature instances for performing some checks on the feature.
* This method performs only a superficial verification of geometries.
*/
- private static void validate(final Feature feature) {
+ private static void validate(final AbstractFeature feature) {
final String filename = feature.getPropertyValue("filename").toString();
final Geometry geometry = (Geometry) feature.getPropertyValue("geometry");
final GridCoverage raster = (GridCoverage) feature.getPropertyValue("image");
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Copyright.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Copyright.java
index 88bc82c..0697471 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Copyright.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Copyright.java
@@ -39,11 +39,16 @@
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
-import org.opengis.metadata.identification.BrowseGraphic;
-import org.apache.sis.util.SimpleInternationalString;
+// Specific to the main branch:
+import java.util.Date;
+import org.opengis.metadata.citation.Contact;
+import org.opengis.metadata.citation.Series;
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.apache.sis.metadata.iso.citation.AbstractParty;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
+import org.apache.sis.metadata.iso.constraint.DefaultConstraints;
+import org.apache.sis.temporal.TemporalDate;
/**
@@ -63,15 +68,11 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class Copyright implements LegalConstraints, Responsibility, Party, Citation, CitationDate {
+public final class Copyright implements LegalConstraints, ResponsibleParty, Citation, CitationDate {
/**
* The copyright holder.
* This field is mandatory in principle, but {@code Copyright} implementation is robust to null value.
- * This field is mapped to the {@linkplain #getName() responsible party name} in ISO 19115 metadata.
- *
- * @see #getResponsibleParties()
- * @see #getParties()
- * @see #getName()
+ * This field is mapped to the {@code getName() responsible party name} in ISO 19115 metadata.
*/
@XmlAttribute(name = Attributes.AUTHOR, required = true)
public String author;
@@ -87,9 +88,7 @@
/**
* Link to an external file containing the license text, or {@code null} if none.
- * This field is mapped to the {@linkplain #getOnlineResources() online resources} in ISO 19115 metadata.
- *
- * @see #getOnlineResources()
+ * This field is mapped to the online resources in ISO 19115 metadata.
*/
@XmlElement(name = Tags.LICENSE)
public URI license;
@@ -105,21 +104,25 @@
* Copies properties from the given ISO 19115 metadata.
*/
private Copyright(final LegalConstraints c, final Locale locale) {
-resp: for (final Responsibility r : c.getResponsibleParties()) {
- for (final Party p : r.getParties()) {
+ if (!(c instanceof DefaultConstraints)) {
+ return;
+ }
+resp: for (final DefaultResponsibility r : ((DefaultConstraints) c).getResponsibleParties()) {
+ for (final AbstractParty p : r.getParties()) {
author = Types.toString(p.getName(), locale);
if (author != null) break resp;
}
}
- for (final Citation ci : c.getReferences()) {
+ for (final Citation ci : ((DefaultConstraints) c).getReferences()) {
for (final CitationDate d : ci.getDates()) {
- final Temporal date = d.getReferenceDate();
+ final Temporal date = TemporalDate.toTemporal(d.getDate());
if (date != null) {
year = date.get(ChronoField.YEAR);
break;
}
}
- for (final OnlineResource r : ci.getOnlineResources()) {
+ if (!(ci instanceof DefaultCitation)) continue;
+ for (final OnlineResource r : ((DefaultCitation) ci).getOnlineResources()) {
license = r.getLinkage();
if (license != null) break;
}
@@ -152,13 +155,11 @@
* ISO 19115 metadata property determined by the {@link #license} field.
*
* @return restrictions or limitations or warnings on using the data.
- *
- * @see #getReferences()
*/
@Override
public Collection<Restriction> getUseConstraints() {
if (license != null) {
- return List.of(Restriction.COPYRIGHT, Restriction.LICENCE);
+ return List.of(Restriction.COPYRIGHT, Restriction.valueOf("LICENCE"));
} else {
return Collections.singleton(Restriction.COPYRIGHT);
}
@@ -167,44 +168,21 @@
/**
* ISO 19115 metadata property not specified by GPX.
*
- * @return graphics or symbols indicating the constraint.
+ * @return other restrictions and legal prerequisites for accessing and using the resource.
*/
@Override
- public Collection<BrowseGraphic> getGraphics() {
+ public Collection<InternationalString> getOtherConstraints() {
return Collections.emptySet();
}
/**
- * ISO 19115 metadata property determined by the {@link #year} and {@link #license} fields.
- * Invoking this method is one of the steps in the path from the {@code LegalConstraints} root
- * to the {@link #getDate()} and {@link #getOnlineResources()} methods.
+ * ISO 19115 metadata property not specified by GPX.
*
- * @return citations for the limitation of constraint.
- *
- * @see #getTitle()
- * @see #getDates()
- * @see #getPresentationForms()
- * @see #getOnlineResources()
+ * @return limitation affecting the fitness for use of the resource.
*/
@Override
- public Collection<? extends Citation> getReferences() {
- return thisOrEmpty(year != null || license != null);
- }
-
- /**
- * ISO 19115 metadata property determined by the {@link #author} field.
- * Invoking this method is one of the steps in the path from the {@code LegalConstraints} root
- * to the {@link #getName()} method.
- *
- * @return parties responsible for the resource constraints.
- *
- * @see #getRole()
- * @see #getParties()
- * @see #getCitedResponsibleParties()
- */
- @Override
- public Collection<? extends Responsibility> getResponsibleParties() {
- return thisOrEmpty(author != null);
+ public Collection<InternationalString> getUseLimitations() {
+ return Collections.emptySet();
}
@@ -215,7 +193,7 @@
/**
* ISO 19115 metadata property fixed to {@link Role#OWNER}.
- * This is part of the properties returned by {@link #getResponsibleParties()}.
+ * This is part of the properties returned by {@code getResponsibleParties()}.
*
* @return function performed by the responsible party.
*/
@@ -225,29 +203,46 @@
}
/**
- * ISO 19115 metadata property determined by the {@link #author} field.
- * This is part of the properties returned by {@link #getResponsibleParties()}.
- * Invoking this method is one of the steps in the path from the {@code LegalConstraints} root
- * to the {@link #getName()} method.
+ * ISO 19115 metadata property not specified by GPX. Actually could be the {@link #author},
+ * but we have no way to know if the author is an individual or an organization.
*
- * @return information about the parties.
- *
- * @see #getName()
+ * @return name of the organization, or {@code null} if none.
*/
@Override
- public Collection<? extends Party> getParties() {
- return thisOrEmpty(author != null);
+ public InternationalString getOrganisationName() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return position of the individual in the organization, or {@code null} if none.
+ */
+ @Override
+ public InternationalString getPositionName() {
+ return null;
}
/**
* ISO 19115 metadata property determined by the {@link #author} field.
- * This is part of the properties returned by {@link #getParties()}.
+ * This is part of the properties returned by {@code getParties()}.
*
* @return name of the party, or {@code null} if none.
*/
@Override
- public InternationalString getName() {
- return (author != null) ? new SimpleInternationalString(author) : null;
+ public String getIndividualName() {
+ return author;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getParties()}.
+ *
+ * @return contact information for the party.
+ */
+ @Override
+ public Contact getContactInfo() {
+ return null;
}
/**
@@ -268,7 +263,7 @@
/**
* ISO 19115 metadata property not specified by GPX.
- * This is part of the properties returned by {@link #getReferences()}.
+ * This is part of the properties returned by {@code getReferences()}.
* It would be the license title if that information was provided.
*
* @return the license name.
@@ -279,8 +274,19 @@
}
/**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return other names for the resource.
+ */
+ @Override
+ public Collection<InternationalString> getAlternateTitles() {
+ return Collections.emptySet();
+ }
+
+ /**
* ISO 19115 metadata property determined by the {@link #year} field.
- * This is part of the properties returned by {@link #getReferences()}.
+ * This is part of the properties returned by {@code getReferences()}.
* Invoking this method is one of the steps in the path from the {@code LegalConstraints} root
* to the {@link #getDate()} method.
*
@@ -301,27 +307,61 @@
* @return reference date for the cited resource.
*/
@Override
- public Temporal getReferenceDate() {
+ public Date getDate() {
if (year != null) {
- return Year.of(year);
+ return TemporalDate.toDate(Year.of(year));
}
return null;
}
/**
- * ISO 19115 metadata property fixed to {@link DateType#IN_FORCE}.
+ * ISO 19115 metadata property fixed to {@code DateType.IN_FORCE}.
* This is part of the properties returned by {@link #getDates()}.
*
* @return event used for reference date.
*/
@Override
public DateType getDateType() {
- return DateType.IN_FORCE;
+ return DateType.valueOf("IN_FORCE");
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return the license version, or {@code null} if none.
+ */
+ @Override
+ public InternationalString getEdition() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return the license edition date, or {@code null} if none.
+ */
+ @Override
+ public Date getEditionDate() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ * It would be the license author if that information was provided.
+ *
+ * @return the information for individuals or organisations that are responsible for the license.
+ */
+ @Override
+ public Collection<ResponsibleParty> getCitedResponsibleParties() {
+ return Collections.emptySet();
}
/**
* ISO 19115 metadata property fixed to {@link PresentationForm#DOCUMENT_DIGITAL}.
- * This is part of the properties returned by {@link #getReferences()}.
+ * This is part of the properties returned by {@code getReferences()}.
*
* @return the presentation mode of the license.
*/
@@ -331,14 +371,59 @@
}
/**
- * ISO 19115 metadata property determined by the {@link #license} field.
- * This is part of the properties returned by {@link #getReferences()}.
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
*
- * @return online references to the cited resource.
+ * @return the series or aggregate dataset of which the dataset is a part.
*/
@Override
- public Collection<OnlineResource> getOnlineResources() {
- return (license != null) ? Collections.singleton(new Link(license)) : Collections.emptySet();
+ public Series getSeries() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return other details.
+ */
+ @Override
+ public InternationalString getOtherCitationDetails() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return the common title.
+ */
+ @Override
+ @Deprecated
+ public InternationalString getCollectiveTitle() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return the International Standard Book Number.
+ */
+ @Override
+ public String getISBN() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ * This is part of the properties returned by {@code getReferences()}.
+ *
+ * @return the International Standard Serial Number.
+ */
+ @Override
+ public String getISSN() {
+ return null;
}
/**
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Link.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Link.java
index 0593a47..575b32b 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Link.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Link.java
@@ -155,6 +155,26 @@
}
/**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return connection protocol to be used.
+ */
+ @Override
+ public String getProtocol() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return application profile that can be used with the online resource.
+ */
+ @Override
+ public String getApplicationProfile() {
+ return null;
+ }
+
+ /**
* ISO 19115 metadata property determined by the {@link #text} field.
*
* @return name of the online resource.
@@ -185,16 +205,6 @@
}
/**
- * ISO 19115 metadata property not specified by GPX.
- *
- * @return request used to access the resource, or {@code null}.
- */
- @Override
- public String getProtocolRequest() {
- return null;
- }
-
- /**
* Compares this {@code Link} with the given object for equality.
*
* @param obj the object to compare with this {@code Link}.
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Metadata.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Metadata.java
index f49e0e1..0322d8c 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Metadata.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Metadata.java
@@ -53,9 +53,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Responsibility;
-import org.apache.sis.metadata.iso.citation.Citations;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
/**
@@ -134,8 +133,6 @@
/**
* URLs associated with the location described in the file, or {@code null} if none.
- *
- * @see #getOnlineResources()
*/
@XmlElement(name = Tags.LINK)
public List<Link> links;
@@ -208,8 +205,10 @@
if (time != null) break;
}
}
- for (final OnlineResource r : ci.getOnlineResources()) {
- links = addIfNonNull(links, Link.castOrCopy(r, locale));
+ if (ci instanceof DefaultCitation) {
+ for (final OnlineResource r : ((DefaultCitation) ci).getOnlineResources()) {
+ links = addIfNonNull(links, Link.castOrCopy(r, locale));
+ }
}
}
if (description == null) {
@@ -219,7 +218,7 @@
* identificationInfo.pointOfContact.party.name → creator if role is ORIGINATOR
* identificationInfo.pointOfContact.party.name → author.name if role is AUTHOR
*/
- for (final Responsibility r : id.getPointOfContacts()) {
+ for (final ResponsibleParty r : id.getPointOfContacts()) {
final Person p = Person.castOrCopy(r, locale);
if (p != null) {
if (p.isCreator) {
@@ -373,17 +372,6 @@
}
/**
- * ISO 19115 metadata property determined by the {@link #links} field.
- * This is part of the information returned by {@link #getCitation()}.
- *
- * @return online references to the cited resource.
- */
- @Override
- public Collection<OnlineResource> getOnlineResources() {
- return (links != null) ? Collections.unmodifiableList(links) : Collections.emptyList();
- }
-
- /**
* Names of features types available for the GPX format, or an empty list if none.
* This property is not part of metadata described in GPX file; it is rather a hard-coded value shared by all
* GPX files. Users could however filter the list of features, for example with only routes and no tracks.
@@ -420,16 +408,6 @@
}
/**
- * Citation(s) for the standard(s) to which the metadata conform.
- *
- * @return ISO 19115-1 citation.
- */
- @Override
- public Collection<Citation> getMetadataStandards() {
- return Collections.singleton(Citations.ISO_19115.get(0));
- }
-
- /**
* Compares this {@code Metadata} with the given object for equality.
*
* @param obj the object to compare with this {@code Metadata}.
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Person.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Person.java
index e194656..24272c7 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Person.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Person.java
@@ -32,16 +32,6 @@
import org.opengis.metadata.citation.Telephone;
import org.opengis.metadata.citation.ResponsibleParty;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
-import org.apache.sis.util.SimpleInternationalString;
-import org.apache.sis.util.iso.Types;
-
-// Specific to the geoapi-3.1 branch:
-import java.util.AbstractSet;
-import java.util.Iterator;
-
/**
* Information about a person or organization.
@@ -56,19 +46,17 @@
* Those properties can be read or modified directly. All methods defined in this class are bridges to
* the ISO 19115 metadata model and can be ignored if the user only wants to manipulate the GPX model.
*
- * <p>Note that {@link Party} is an abstract type in ISO 19115 model. We are supposed to implement a subtype
- * ({@link org.opengis.metadata.citation.Individual} or {@link org.opengis.metadata.citation.Organisation}).
+ * <p>Note that {@code Party} is an abstract type in ISO 19115 model. We are supposed to implement a subtype
+ * ({@code Individual} or {@code Organisation}).
* However, the GPX metadata does not specifies whether the "person" is actually an individual or an organization.
* In this situation of doubt, we do not select a subtype for avoiding to provide a wrong information.</p>
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class Person implements ResponsibleParty, Party, Contact, Address {
+public final class Person implements ResponsibleParty, Contact, Address {
/**
* Name of person or organization.
- *
- * @see #getName()
*/
@XmlElement(name = Tags.NAME)
public String name;
@@ -89,8 +77,6 @@
/**
* Link to Web site or other external information about person.
- *
- * @see #getOnlineResources()
*/
@XmlElement(name = Tags.LINK)
public Link link;
@@ -117,21 +103,19 @@
* @param locale the locale to use for localized strings.
* @return the GPX metadata, or {@code null}.
*/
- public static Person castOrCopy(final Responsibility r, final Locale locale) {
+ public static Person castOrCopy(final ResponsibleParty r, final Locale locale) {
if (r == null || r instanceof Person) {
return (Person) r;
}
final Role role = r.getRole();
final boolean isCreator = (role == Role.ORIGINATOR);
- if (isCreator || role == Role.AUTHOR) {
- for (final Party p : r.getParties()) {
- final String name = Types.toString(p.getName(), locale);
- if (name != null) {
- final Person pr = new Person();
- pr.name = name;
- pr.isCreator = isCreator;
- return pr;
- }
+ if (isCreator || Role.AUTHOR.equals(role)) {
+ final String name = r.getIndividualName();
+ if (name != null) {
+ final Person pr = new Person();
+ pr.name = name;
+ pr.isCreator = isCreator;
+ return pr;
}
}
return null;
@@ -147,21 +131,6 @@
return isCreator ? Role.ORIGINATOR : Role.AUTHOR;
}
- /**
- * ISO 19115 metadata property determined by the {@link #name}, {@link #email} and {@link #link} fields.
- * Invoking this method is one of the steps in the path from the {@code Responsibility} root to the
- * {@link #getName()}, {@link #getElectronicMailAddresses()} and {@link #getOnlineResources()} methods.
- *
- * @return information about the parties.
- *
- * @see #getName()
- * @see #getContactInfo()
- */
- @Override
- public Collection<? extends Party> getParties() {
- return thisOrEmpty(name != null || email != null || link != null);
- }
-
/* ---------------------------------------------------------------------------------
* Implementation of the Party object returned by Responsibility.getParties().
@@ -169,16 +138,6 @@
* --------------------------------------------------------------------------------- */
/**
- * ISO 19115 metadata property determined by the {@link #name} field.
- *
- * @return name of the party, or {@code null} if none.
- */
- @Override
- public InternationalString getName() {
- return (name != null) ? new SimpleInternationalString(name) : null;
- }
-
- /**
* ISO 19115 metadata property not specified by GPX. Actually could be the {@link #name},
* but we have no way to know if the author is an individual or an organization.
*
@@ -212,36 +171,13 @@
/**
* ISO 19115 metadata property determined by the {@link #email} and {@link #link} fields.
* Invoking this method is one of the steps in the path from the {@code Responsibility} root
- * to the {@link #getElectronicMailAddresses()} and {@link #getOnlineResources()} methods.
+ * to the {@link #getElectronicMailAddresses()} and {@link #getOnlineResource()} methods.
*
* @return contact information for the party.
- *
- * @see #getAddresses()
- * @see #getOnlineResources()
*/
@Override
- public Proxy getContactInfo() { // Both Contact singleton and Collection<Contact>.
- return new Proxy();
- }
-
- private final class Proxy extends AbstractSet<Contact> implements Contact {
- @Override public int size() {
- return (email != null || link != null) ? 1 : 0;
- }
-
- @Override public Iterator<Contact> iterator() {
- return Collections.<Contact>singleton(Person.this).iterator();
- }
-
- @Override public Collection<? extends Telephone> getPhones() {return Person.this.getPhones();}
- @Override public Telephone getPhone() {return Person.this.getPhone();}
- @Override public Collection<? extends Address> getAddresses() {return Person.this.getAddresses();}
- @Override public Address getAddress() {return Person.this.getAddress();}
- @Override public Collection<OnlineResource> getOnlineResources() {return Person.this.getOnlineResources();}
- @Override public OnlineResource getOnlineResource() {return Person.this.getOnlineResource();}
- @Override public InternationalString getHoursOfService() {return Person.this.getHoursOfService();}
- @Override public InternationalString getContactInstructions() {return Person.this.getContactInstructions();}
- @Override public InternationalString getContactType() {return Person.this.getContactType();}
+ public Contact getContactInfo() {
+ return (email != null || link != null) ? this : null;
}
@@ -251,6 +187,16 @@
* --------------------------------------------------------------------------------- */
/**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return telephone numbers at which the organization or individual may be contacted.
+ */
+ @Override
+ public Telephone getPhone() {
+ return null;
+ }
+
+ /**
* ISO 19115 metadata property determined by the {@link #email} field.
* Invoking this method is one of the steps in the path from the {@code Responsibility} root
* to the {@link #getElectronicMailAddresses()} method.
@@ -260,8 +206,8 @@
* @see #getElectronicMailAddresses()
*/
@Override
- public Collection<? extends Address> getAddresses() {
- return thisOrEmpty(email != null);
+ public Address getAddress() {
+ return (email != null) ? this : null;
}
/**
@@ -270,8 +216,28 @@
* @return on-line information that can be used to contact the individual or organization.
*/
@Override
- public Collection<OnlineResource> getOnlineResources() {
- return (link != null) ? Collections.singleton(link) : Collections.emptySet();
+ public OnlineResource getOnlineResource() {
+ return link;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return time period when individuals can contact the organization or individual.
+ */
+ @Override
+ public InternationalString getHoursOfService() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return supplemental instructions on how or when to contact the individual or organization.
+ */
+ @Override
+ public InternationalString getContactInstructions() {
+ return null;
}
@@ -281,6 +247,56 @@
* --------------------------------------------------------------------------------- */
/**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return address line for the location.
+ */
+ @Override
+ public Collection<String> getDeliveryPoints() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return the city of the location.
+ */
+ @Override
+ public InternationalString getCity() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return state, province of the location.
+ */
+ @Override
+ public InternationalString getAdministrativeArea() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return ZIP or other postal code, or {@code null}.
+ */
+ @Override
+ public String getPostalCode() {
+ return null;
+ }
+
+ /**
+ * ISO 19115 metadata property not specified by GPX.
+ *
+ * @return country of the physical address, or {@code null}.
+ */
+ @Override
+ public InternationalString getCountry() {
+ return null;
+ }
+
+ /**
* ISO 19115 metadata property determined by the {@link #email} field.
*
* @return address of the electronic mailbox of the responsible organization or individual.
@@ -291,14 +307,6 @@
}
/**
- * Returns this object as a singleton if the given condition is {@code true},
- * or an empty set if the given condition is {@code false}.
- */
- private Collection<Person> thisOrEmpty(final boolean condition) {
- return condition ? Collections.singleton(this) : Collections.emptySet();
- }
-
- /**
* Compares this {@code Person} with the given object for equality.
*
* @param obj the object to compare with this {@code Person}.
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Reader.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Reader.java
index 324d4f7..1809717 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Reader.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Reader.java
@@ -36,8 +36,8 @@
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -318,7 +318,7 @@
* or various {@link RuntimeException}.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) throws BackingStoreException {
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) throws BackingStoreException {
try {
return parse(action, false);
} catch (Exception e) { // Many possible exceptions including unchecked ones.
@@ -335,7 +335,7 @@
* or various {@link RuntimeException}.
*/
@Override
- public void forEachRemaining(final Consumer<? super Feature> action) throws BackingStoreException {
+ public void forEachRemaining(final Consumer<? super AbstractFeature> action) throws BackingStoreException {
try {
parse(action, true);
} catch (Exception e) { // Many possible exceptions including unchecked ones.
@@ -359,7 +359,7 @@
* @throws EOFException if the file seems to be truncated.
*/
@SuppressWarnings("fallthrough")
- private boolean parse(final Consumer<? super Feature> action, final boolean all) throws Exception {
+ private boolean parse(final Consumer<? super AbstractFeature> action, final boolean all) throws Exception {
for (int type = reader.getEventType(); ; type = reader.next()) {
/*
* We do not need to check 'reader.hasNext()' in above loop
@@ -367,7 +367,7 @@
*/
switch (type) {
case START_ELEMENT: {
- final Feature f;
+ final AbstractFeature f;
switch (isGPX() ? reader.getLocalName() : "") {
case Tags.WAY_POINT: f = parseWayPoint(++wayPointId); break;
case Tags.ROUTES: f = parseRoute (++routeId); break;
@@ -393,7 +393,7 @@
*
* @throws Exception see the list of exceptions documented in {@link #parse(Consumer, boolean)}.
*/
- private Feature parseWayPoint(final int index) throws Exception {
+ private AbstractFeature parseWayPoint(final int index) throws Exception {
assert reader.isStartElement();
/*
* Way points might be located in different elements: <wpt>, <rtept> and <trkpt>.
@@ -408,7 +408,7 @@
(lat == null) ? Attributes.LATITUDE : Attributes.LONGITUDE, tagName));
}
final Types types = ((Store) owner).types;
- final Feature feature = types.wayPoint.newInstance();
+ final AbstractFeature feature = types.wayPoint.newInstance();
feature.setPropertyValue(AttributeConvention.IDENTIFIER, index);
feature.setPropertyValue(AttributeConvention.GEOMETRY, types.geometries.createPoint(parseDouble(lon), parseDouble(lat)));
List<Link> links = null;
@@ -471,11 +471,11 @@
*
* @throws Exception see the list of exceptions documented in {@link #parse(Consumer, boolean)}.
*/
- private Feature parseRoute(final int index) throws Exception {
+ private AbstractFeature parseRoute(final int index) throws Exception {
assert reader.isStartElement() && Tags.ROUTES.equals(reader.getLocalName());
- final Feature feature = ((Store) owner).types.route.newInstance();
+ final AbstractFeature feature = ((Store) owner).types.route.newInstance();
feature.setPropertyValue(AttributeConvention.IDENTIFIER, index);
- List<Feature> wayPoints = null;
+ List<AbstractFeature> wayPoints = null;
List<Link> links = null;
while (true) {
/*
@@ -527,11 +527,11 @@
*
* @throws Exception see the list of exceptions documented in {@link #parse(Consumer, boolean)}.
*/
- private Feature parseTrackSegment(final int index) throws Exception {
+ private AbstractFeature parseTrackSegment(final int index) throws Exception {
assert reader.isStartElement() && Tags.TRACK_SEGMENTS.equals(reader.getLocalName());
- final Feature feature = ((Store) owner).types.trackSegment.newInstance();
+ final AbstractFeature feature = ((Store) owner).types.trackSegment.newInstance();
feature.setPropertyValue(AttributeConvention.IDENTIFIER, index);
- List<Feature> wayPoints = null;
+ List<AbstractFeature> wayPoints = null;
while (true) {
/*
* We do not need to check 'reader.hasNext()' in above loop
@@ -570,11 +570,11 @@
*
* @throws Exception see the list of exceptions documented in {@link #parse(Consumer, boolean)}.
*/
- private Feature parseTrack(final int index) throws Exception {
+ private AbstractFeature parseTrack(final int index) throws Exception {
assert reader.isStartElement() && Tags.TRACKS.equals(reader.getLocalName());
- final Feature feature = ((Store) owner).types.track.newInstance();
+ final AbstractFeature feature = ((Store) owner).types.track.newInstance();
feature.setPropertyValue(AttributeConvention.IDENTIFIER, index);
- List<Feature> segments = null;
+ List<AbstractFeature> segments = null;
List<Link> links = null;
while (true) {
/*
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java
index ebe8c6d..2664f1a 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java
@@ -39,9 +39,9 @@
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.metadata.iso.distribution.DefaultFormat;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -71,7 +71,7 @@
private Reader reader;
/**
- * The {@link org.opengis.feature.FeatureType} for routes, tracks, way points, <i>etc</i>.
+ * The {@code FeatureType} for routes, tracks, way points, <i>etc</i>.
* Currently always {@link Types#DEFAULT}, but we use a field for keeping {@code Reader}
* and {@code Writer} ready to handle profiles or extensions.
*/
@@ -181,7 +181,7 @@
* @return base type of all GPX types.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return types.parent;
}
@@ -196,7 +196,7 @@
* @throws DataStoreException if an error occurred while creating the feature stream.
*/
@Override
- public final synchronized Stream<Feature> features(boolean parallel) throws DataStoreException {
+ public final synchronized Stream<AbstractFeature> features(boolean parallel) throws DataStoreException {
Reader r = reader;
reader = null;
if (r == null) try {
@@ -209,7 +209,7 @@
} catch (Exception e) {
throw new DataStoreException(e);
}
- final Stream<Feature> features = StreamSupport.stream(r, false);
+ final Stream<AbstractFeature> features = StreamSupport.stream(r, false);
return features.onClose(r);
}
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java
index 99cfd33..6c279b1 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java
@@ -43,9 +43,9 @@
import org.apache.sis.storage.base.MetadataBuilder;
import org.apache.sis.util.iso.DefaultNameFactory;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Operation;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractOperation;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -60,27 +60,27 @@
/**
* The parent of all other feature types.
*/
- final FeatureType parent;
+ final DefaultFeatureType parent;
/**
* Way point GPX feature type.
*/
- final FeatureType wayPoint;
+ final DefaultFeatureType wayPoint;
/**
* Route GPX feature type.
*/
- final FeatureType route;
+ final DefaultFeatureType route;
/**
* Track GPX feature type.
*/
- final FeatureType track;
+ final DefaultFeatureType track;
/**
* Track segment GPX feature type.
*/
- final FeatureType trackSegment;
+ final DefaultFeatureType trackSegment;
/**
* The list of feature types to be given to GPC metadata objects.
@@ -206,7 +206,7 @@
* │ rtept │ WayPoint │ gpx:wptType │ [0 … ∞] │
* └────────────────┴────────────────┴───────────────────────┴──────────────┘
*/
- Operation groupOp = groupAsPolyline(geomInfo, Tags.ROUTE_POINTS, wayPoint);
+ AbstractOperation groupOp = groupAsPolyline(geomInfo, Tags.ROUTE_POINTS, wayPoint);
builder.clear().setSuperTypes(parent).setNameSpace(Tags.PREFIX).setName("Route");
builder.addProperty(groupOp);
builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
@@ -286,7 +286,7 @@
* @param previous previously created international strings as array of length 2.
* The first element is the designation and the second element is the definition.
*/
- private static FeatureType create(final FeatureTypeBuilder builder, final Map<String,InternationalString[]> previous) {
+ private static DefaultFeatureType create(final FeatureTypeBuilder builder, final Map<String,InternationalString[]> previous) {
for (final PropertyTypeBuilder p : builder.properties()) {
final GenericName name = p.getName();
if (!AttributeConvention.contains(name)) {
@@ -308,7 +308,7 @@
* @param components name of the property providing the geometries to group as a polyline.
* @param type type of the property identified by {@code components}.
*/
- private Operation groupAsPolyline(final Map<String,?> geomInfo, final String components, final FeatureType type) {
+ private AbstractOperation groupAsPolyline(final Map<String,?> geomInfo, final String components, final DefaultFeatureType type) {
var c = new DefaultAssociationRole(Map.of(DefaultAssociationRole.NAME_KEY, components), type, 1, 1);
return FeatureOperations.groupAsPolyline(geomInfo, geometries.library, c);
}
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Updater.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Updater.java
index e96c028..2815fc8 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Updater.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Updater.java
@@ -25,8 +25,8 @@
import org.apache.sis.storage.xml.stream.RewriteOnUpdate;
import org.apache.sis.storage.xml.stream.StaxStreamWriter;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -58,7 +58,7 @@
* @throws DataStoreException if an error occurred while fetching the features.
*/
@Override
- protected Stream<? extends Feature> features() throws DataStoreException {
+ protected Stream<? extends AbstractFeature> features() throws DataStoreException {
metadata = Metadata.castOrCopy(source.getMetadata(), getLocale());
return super.features();
}
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/WritableStore.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/WritableStore.java
index 71a4317..22a96c1 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/WritableStore.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/WritableStore.java
@@ -30,9 +30,9 @@
import org.apache.sis.storage.IllegalFeatureTypeException;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -64,7 +64,7 @@
* @throws DataStoreException if the given type is not compatible with the types supported by the store.
*/
@Override
- public void updateType(final FeatureType newType) throws DataStoreException {
+ public void updateType(final DefaultFeatureType newType) throws DataStoreException {
if (!newType.equals(getType())) {
throw new IllegalFeatureTypeException(getLocale(), StoreProvider.NAME, newType.getName());
}
@@ -78,7 +78,7 @@
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
@Override
- public synchronized void add(final Iterator<? extends Feature> features) throws DataStoreException {
+ public synchronized void add(final Iterator<? extends AbstractFeature> features) throws DataStoreException {
try (Updater updater = updater()) {
updater.add(features);
updater.flush();
@@ -92,7 +92,7 @@
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
@Override
- public synchronized void removeIf(final Predicate<? super Feature> filter) throws DataStoreException {
+ public synchronized void removeIf(final Predicate<? super AbstractFeature> filter) throws DataStoreException {
try (Updater updater = updater()) {
updater.removeIf(filter);
updater.flush();
@@ -104,11 +104,11 @@
* If the given operator returns {@code null}, then the filtered feature is removed.
*
* @param filter a predicate which returns {@code true} for feature instances to be updated.
- * @param replacement operation called for each matching {@link Feature} instance. May return {@code null}.
+ * @param replacement operation called for each matching {@code Feature} instance. May return {@code null}.
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
@Override
- public synchronized void replaceIf(final Predicate<? super Feature> filter, final UnaryOperator<Feature> replacement)
+ public synchronized void replaceIf(final Predicate<? super AbstractFeature> filter, final UnaryOperator<AbstractFeature> replacement)
throws DataStoreException
{
try (Updater updater = updater()) {
@@ -145,7 +145,7 @@
* @see <a href="https://issues.apache.org/jira/browse/SIS-411">SIS-411</a>
*/
@Deprecated(since="1.3")
- public synchronized void write(final Metadata metadata, final Stream<? extends Feature> features) throws DataStoreException {
+ public synchronized void write(final Metadata metadata, final Stream<? extends AbstractFeature> features) throws DataStoreException {
try {
/*
* If we created a reader for reading metadata, we need to close that reader now otherwise the call
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Writer.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Writer.java
index 5eed73d..e8b5770 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Writer.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Writer.java
@@ -30,9 +30,9 @@
import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.util.Version;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -77,7 +77,7 @@
/**
* Writes the XML declaration followed by GPX metadata.
- * This method shall be invoked exactly once before {@link #write(Feature)}.
+ * This method shall be invoked exactly once before {@code write(Feature)}.
*
* @throws Exception if an error occurred while writing to the XML file.
*/
@@ -141,10 +141,10 @@
* @throws JAXBException if underlying JAXB marshaller encounter an error.
*/
@Override
- public void write(final Feature feature) throws DataStoreException, XMLStreamException, JAXBException {
+ public void write(final AbstractFeature feature) throws DataStoreException, XMLStreamException, JAXBException {
if (feature != null) {
final Types types = ((WritableStore) owner).types;
- final FeatureType type = feature.getType();
+ final DefaultFeatureType type = feature.getType();
if (types.wayPoint.isAssignableFrom(type)) {
writeWayPoint(feature, Tags.WAY_POINT);
} else {
@@ -164,14 +164,14 @@
}
if (isRoute) {
for (Object prop : (Collection<?>) feature.getPropertyValue(Tags.ROUTE_POINTS)) {
- writeWayPoint((Feature) prop, Tags.ROUTE_POINTS);
+ writeWayPoint((AbstractFeature) prop, Tags.ROUTE_POINTS);
}
} else {
for (Object segment : (Collection<?>) feature.getPropertyValue(Tags.TRACK_SEGMENTS)) {
if (segment != null) {
writer.writeStartElement(Tags.TRACK_SEGMENTS);
- for (Object prop : (Collection<?>) ((Feature) segment).getPropertyValue(Tags.TRACK_POINTS)) {
- writeWayPoint((Feature) prop, Tags.TRACK_POINTS);
+ for (Object prop : (Collection<?>) ((AbstractFeature) segment).getPropertyValue(Tags.TRACK_POINTS)) {
+ writeWayPoint((AbstractFeature) prop, Tags.TRACK_POINTS);
}
writer.writeEndElement();
}
@@ -190,7 +190,7 @@
* @throws XMLStreamException if underlying STAX writer encounter an error.
* @throws JAXBException if underlying JAXB marshaller encounter an error.
*/
- private void writeWayPoint(final Feature feature, final String tagName) throws XMLStreamException, JAXBException {
+ private void writeWayPoint(final AbstractFeature feature, final String tagName) throws XMLStreamException, JAXBException {
if (feature != null) {
final double[] pt = Geometries.wrap(feature.getPropertyValue(AttributeConvention.GEOMETRY))
.map(GeometryWrapper::getPointCoordinates).orElse(null);
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/RewriteOnUpdate.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/RewriteOnUpdate.java
index 1a1839b..2841975 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/RewriteOnUpdate.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/RewriteOnUpdate.java
@@ -36,8 +36,8 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -76,7 +76,7 @@
*
* @see #filtered()
*/
- private Stream<? extends Feature> filtered;
+ private Stream<? extends AbstractFeature> filtered;
/**
* Creates an updater for the given source of features.
@@ -119,7 +119,7 @@
*
* @throws DataStoreException if the feature stream cannot be obtained.
*/
- private Stream<? extends Feature> filtered() throws DataStoreException {
+ private Stream<? extends AbstractFeature> filtered() throws DataStoreException {
if (filtered == null) {
filtered = features();
}
@@ -133,7 +133,7 @@
* @return all features contained in the dataset.
* @throws DataStoreException if an error occurred while fetching the features.
*/
- protected Stream<? extends Feature> features() throws DataStoreException {
+ protected Stream<? extends AbstractFeature> features() throws DataStoreException {
return source.features(false);
}
@@ -144,9 +144,9 @@
* @param features feature instances to append in the {@code FeatureSet}.
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
- public void add(final Iterator<? extends Feature> features) throws DataStoreException {
+ public void add(final Iterator<? extends AbstractFeature> features) throws DataStoreException {
ArgumentChecks.ensureNonNull("features", features);
- final Stream<? extends Feature> toAdd = StreamSupport.stream(
+ final Stream<? extends AbstractFeature> toAdd = StreamSupport.stream(
Spliterators.spliteratorUnknownSize(features, Spliterator.ORDERED), false);
if (isEmpty()) {
filtered = toAdd;
@@ -161,7 +161,7 @@
* @param filter a predicate which returns {@code true} for feature instances to be removed.
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
- public void removeIf(final Predicate<? super Feature> filter) throws DataStoreException {
+ public void removeIf(final Predicate<? super AbstractFeature> filter) throws DataStoreException {
ArgumentChecks.ensureNonNull("filter", filter);
if (!isEmpty()) {
filtered = filtered().filter((feature) -> {
@@ -175,10 +175,10 @@
* If the given operator returns {@code null}, then the filtered feature is removed.
*
* @param filter a predicate which returns {@code true} for feature instances to be updated.
- * @param updater operation called for each matching {@link Feature} instance. May return {@code null}.
+ * @param updater operation called for each matching {@code Feature} instance. May return {@code null}.
* @throws DataStoreException if the feature stream cannot be obtained or updated.
*/
- public void replaceIf(final Predicate<? super Feature> filter, final UnaryOperator<Feature> updater) throws DataStoreException {
+ public void replaceIf(final Predicate<? super AbstractFeature> filter, final UnaryOperator<AbstractFeature> updater) throws DataStoreException {
ArgumentChecks.ensureNonNull("filter", filter);
ArgumentChecks.ensureNonNull("updater", updater);
if (!isEmpty()) {
@@ -212,7 +212,7 @@
* @throws DataStoreException if an error occurred.
*/
public void flush() throws DataStoreException {
- try (Stream<? extends Feature> content = filtered) {
+ try (Stream<? extends AbstractFeature> content = filtered) {
if (content != null) {
filtered = null;
OutputStream temporary = null;
@@ -259,7 +259,7 @@
*/
@Override
public void close() {
- final Stream<? extends Feature> content = filtered;
+ final Stream<? extends AbstractFeature> content = filtered;
if (content != null) {
filtered = null;
content.close();
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamReader.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamReader.java
index 7d0d73a..e2b7071 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamReader.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamReader.java
@@ -47,8 +47,8 @@
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -103,7 +103,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public abstract class StaxStreamReader extends StaxStreamIO implements XMLStreamConstants, Spliterator<Feature>, Runnable {
+public abstract class StaxStreamReader extends StaxStreamIO implements XMLStreamConstants, Spliterator<AbstractFeature>, Runnable {
/**
* The XML stream reader.
*/
@@ -163,7 +163,7 @@
* or various {@link RuntimeException} among others.
*/
@Override
- public abstract boolean tryAdvance(Consumer<? super Feature> action) throws BackingStoreException;
+ public abstract boolean tryAdvance(Consumer<? super AbstractFeature> action) throws BackingStoreException;
/**
* Returns {@code null} by default since non-binary XML files are hard to split.
@@ -171,7 +171,7 @@
* @return {@code null}.
*/
@Override
- public Spliterator<Feature> trySplit() {
+ public Spliterator<AbstractFeature> trySplit() {
return null;
}
diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamWriter.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamWriter.java
index b83bac8..1af3a5d 100644
--- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamWriter.java
+++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/xml/stream/StaxStreamWriter.java
@@ -34,8 +34,8 @@
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -87,7 +87,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public abstract class StaxStreamWriter extends StaxStreamIO implements Consumer<Feature> {
+public abstract class StaxStreamWriter extends StaxStreamIO implements Consumer<AbstractFeature> {
/**
* The XML stream writer.
*/
@@ -169,16 +169,16 @@
* but also {@link JAXBException} if JAXB is used for marshalling metadata objects,
* {@link DataStoreException}, {@link ClassCastException}, <i>etc.</i>
*/
- public abstract void write(Feature feature) throws Exception;
+ public abstract void write(AbstractFeature feature) throws Exception;
/**
- * Delegates to {@link #write(Feature)}, wrapping {@code Exception} into unchecked {@code BackingStoreException}.
+ * Delegates to {@code write(Feature)}, wrapping {@code Exception} into unchecked {@code BackingStoreException}.
*
* @param feature the feature to write.
* @throws BackingStoreException if an error occurred while writing to the XML file.
*/
@Override
- public void accept(final Feature feature) throws BackingStoreException {
+ public void accept(final AbstractFeature feature) throws BackingStoreException {
try {
write(feature);
} catch (BackingStoreException e) {
diff --git a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/MetadataTest.java b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/MetadataTest.java
index 6ea920a..217f8c4 100644
--- a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/MetadataTest.java
+++ b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/MetadataTest.java
@@ -26,6 +26,9 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.TestUtilities.date;
+// Specific to the main branch:
+import org.junit.jupiter.api.Disabled;
+
/**
* Tests the {@link Metadata} class.
@@ -62,6 +65,11 @@
* @throws URISyntaxException if a {@link Link} element is constructed with an invalid URI.
*/
@Test
+ @Disabled("Can not execute this test on this branch because it depends on Citation.getOnlineResources() "
+ + "and Identification.getExtents() methods, which are not present in GeoAPI 3.0 interfaces. "
+ + "Despite this test failure, the copy constructor should nevertheless works in practice "
+ + "if the Citation and Identification objects are instances of DefaultCitation or AbstractExtent "
+ + "(the SIS implementations of GeoAPI interfaces).")
public void testCopyConstructor() throws URISyntaxException {
final Metadata md1 = create();
final Metadata md2 = new Metadata(md1, null);
diff --git a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/ReaderTest.java b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/ReaderTest.java
index 79c3efa..5e668db 100644
--- a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/ReaderTest.java
+++ b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/ReaderTest.java
@@ -38,9 +38,9 @@
import static org.apache.sis.test.TestUtilities.date;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.FeatureTypeInfo;
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.opengis.util.GenericName;
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -194,10 +194,10 @@
*/
final var content = assertInstanceOf(FeatureCatalogueDescription.class, getSingleton(md.getContentInfo()));
assertTrue(content.isIncludedWithDataset());
- final Iterator<? extends FeatureTypeInfo> it = content.getFeatureTypeInfo().iterator();
- assertStringEquals("Route", it.next().getFeatureTypeName().tip());
- assertStringEquals("Track", it.next().getFeatureTypeName().tip());
- assertStringEquals("WayPoint", it.next().getFeatureTypeName().tip());
+ final Iterator<? extends GenericName> it = content.getFeatureTypes().iterator();
+ assertStringEquals("Route", it.next().tip());
+ assertStringEquals("Track", it.next().tip());
+ assertStringEquals("WayPoint", it.next().tip());
assertFalse(it.hasNext());
}
@@ -211,8 +211,8 @@
try (Store reader = create(TestData.V1_0, TestData.WAYPOINT)) {
verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
assertEquals(StoreProvider.V1_0, reader.getVersion());
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyPoint(it.next(), 0, false);
verifyPoint(it.next(), 1, false);
verifyPoint(it.next(), 2, false);
@@ -231,8 +231,8 @@
try (Store reader = create(TestData.V1_1, TestData.WAYPOINT)) {
verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
assertEquals(StoreProvider.V1_1, reader.getVersion());
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyPoint(it.next(), 0, true);
verifyPoint(it.next(), 1, true);
verifyPoint(it.next(), 2, true);
@@ -251,8 +251,8 @@
try (Store reader = create(TestData.V1_0, TestData.ROUTE)) {
verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
assertEquals(StoreProvider.V1_0, reader.getVersion());
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyRoute(it.next(), false, 1);
verifyEmpty(it.next(), "rtept");
assertFalse(it.hasNext());
@@ -279,8 +279,8 @@
* This verification is shared by {@link #testRoute110()} and {@link #testSequentialReads()}.
*/
static void verifyRoute110(final Store reader) throws DataStoreException {
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyRoute(it.next(), true, 3);
verifyEmpty(it.next(), "rtept");
assertFalse(it.hasNext());
@@ -295,7 +295,7 @@
* @param numLinks expected number of links.
*/
@SuppressWarnings("fallthrough")
- private static void verifyRoute(final Feature f, final boolean v11, final int numLinks) {
+ private static void verifyRoute(final AbstractFeature f, final boolean v11, final int numLinks) {
assertEquals("Route name", f.getPropertyValue("name"));
assertEquals("Route comment", f.getPropertyValue("cmt"));
assertEquals("Route description", f.getPropertyValue("desc"));
@@ -315,9 +315,9 @@
final List<?> points = assertInstanceOf(List.class, f.getPropertyValue("rtept"));
assertEquals(3, points.size());
- verifyPoint((Feature) points.get(0), 0, v11);
- verifyPoint((Feature) points.get(1), 1, v11);
- verifyPoint((Feature) points.get(2), 2, v11);
+ verifyPoint((AbstractFeature) points.get(0), 0, v11);
+ verifyPoint((AbstractFeature) points.get(1), 1, v11);
+ verifyPoint((AbstractFeature) points.get(2), 2, v11);
final Polyline p = assertInstanceOf(Polyline.class, f.getPropertyValue("sis:geometry"));
assertEquals(3, p.getPointCount());
@@ -333,7 +333,7 @@
* @param f the route or track to verify.
* @param dep {@code "rtept"} if verifying a route, or {@code "trkseg"} if verifying a track.
*/
- private static void verifyEmpty(final Feature f, final String dep) {
+ private static void verifyEmpty(final AbstractFeature f, final String dep) {
assertNull(f.getPropertyValue("name"));
assertNull(f.getPropertyValue("cmt"));
assertNull(f.getPropertyValue("desc"));
@@ -356,8 +356,8 @@
try (Store reader = create(TestData.V1_0, TestData.TRACK)) {
verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
assertEquals(StoreProvider.V1_0, reader.getVersion());
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyTrack(it.next(), false, 1);
verifyEmpty(it.next(), "trkseg");
assertFalse(it.hasNext());
@@ -375,8 +375,8 @@
try (Store reader = create(TestData.V1_1, TestData.TRACK)) {
verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
assertEquals(StoreProvider.V1_1, reader.getVersion());
- try (Stream<Feature> features = reader.features(false)) {
- final Iterator<Feature> it = features.iterator();
+ try (Stream<AbstractFeature> features = reader.features(false)) {
+ final Iterator<AbstractFeature> it = features.iterator();
verifyTrack(it.next(), true, 3);
verifyEmpty(it.next(), "trkseg");
assertFalse(it.hasNext());
@@ -392,7 +392,7 @@
* @param numLinks expected number of links.
*/
@SuppressWarnings("fallthrough")
- private static void verifyTrack(final Feature f, final boolean v11, final int numLinks) {
+ private static void verifyTrack(final AbstractFeature f, final boolean v11, final int numLinks) {
assertEquals("Track name", f.getPropertyValue("name"));
assertEquals("Track comment", f.getPropertyValue("cmt"));
assertEquals("Track description", f.getPropertyValue("desc"));
@@ -412,13 +412,13 @@
final List<?> segments = assertInstanceOf(List.class, f.getPropertyValue("trkseg"));
assertEquals(2, segments.size());
- final Feature seg1 = (Feature) segments.get(0);
- final Feature seg2 = (Feature) segments.get(1);
+ final AbstractFeature seg1 = (AbstractFeature) segments.get(0);
+ final AbstractFeature seg2 = (AbstractFeature) segments.get(1);
final List<?> points = assertInstanceOf(List.class, seg1.getPropertyValue("trkpt"));
assertEquals(3, points.size());
- verifyPoint((Feature) points.get(0), 0, v11);
- verifyPoint((Feature) points.get(1), 1, v11);
- verifyPoint((Feature) points.get(2), 2, v11);
+ verifyPoint((AbstractFeature) points.get(0), 0, v11);
+ verifyPoint((AbstractFeature) points.get(1), 1, v11);
+ verifyPoint((AbstractFeature) points.get(2), 2, v11);
assertTrue(assertInstanceOf(Collection.class, seg2.getPropertyValue("trkpt")).isEmpty());
final Polyline p = assertInstanceOf(Polyline.class, f.getPropertyValue("sis:geometry"));
@@ -436,7 +436,7 @@
* @param index index of the point being verified: 0, 1 or 2.
* @param v11 {@code true} for GPX 1.1, or {@code false} for GPX 1.0.
*/
- private static void verifyPoint(final Feature f, final int index, final boolean v11) {
+ private static void verifyPoint(final AbstractFeature f, final int index, final boolean v11) {
assertEquals(index + 1, f.getPropertyValue("sis:identifier"));
switch (index) {
case 0: {
@@ -590,14 +590,14 @@
@Test
public void testConcurrentReads() throws DataStoreException {
try (Store reader = createFromURL()) {
- final Stream<Feature> f1 = reader.features(false);
- final Iterator<Feature> i1 = f1.iterator();
+ final Stream<AbstractFeature> f1 = reader.features(false);
+ final Iterator<AbstractFeature> i1 = f1.iterator();
verifyRoute(i1.next(), true, 3);
- final Stream<Feature> f2 = reader.features(false);
- final Iterator<Feature> i2 = f2.iterator();
+ final Stream<AbstractFeature> f2 = reader.features(false);
+ final Iterator<AbstractFeature> i2 = f2.iterator();
verifyEmpty(i1.next(), "rtept");
- final Stream<Feature> f3 = reader.features(false);
- final Iterator<Feature> i3 = f3.iterator();
+ final Stream<AbstractFeature> f3 = reader.features(false);
+ final Iterator<AbstractFeature> i3 = f3.iterator();
verifyRoute(i2.next(), true, 3);
verifyRoute(i3.next(), true, 3);
verifyEmpty(i3.next(), "rtept");
diff --git a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/TypesTest.java b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/TypesTest.java
index 589e94d..24db12e 100644
--- a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/TypesTest.java
+++ b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/TypesTest.java
@@ -27,9 +27,9 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.AbstractIdentifiedType;
/**
@@ -62,8 +62,8 @@
/**
* Verifies that all designations and definitions can be read from the resources.
*/
- private static void testResources(final FeatureType type) {
- for (final PropertyType p : type.getProperties(false)) {
+ private static void testResources(final DefaultFeatureType type) {
+ for (final AbstractIdentifiedType p : type.getProperties(false)) {
final GenericName name = p.getName();
if (!AttributeConvention.contains(name)) {
final String label = name.toString();
diff --git a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/UpdaterTest.java b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/UpdaterTest.java
index 02ee8f6..4d4a02a 100644
--- a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/UpdaterTest.java
+++ b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/UpdaterTest.java
@@ -38,8 +38,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -110,9 +110,9 @@
public void testWriteEmpty() throws DataStoreException, IOException {
try (final WritableStore store = create()) {
final Types types = store.types;
- final Feature point1 = types.wayPoint.newInstance();
- final Feature point2 = types.wayPoint.newInstance();
- final Feature point3 = types.wayPoint.newInstance();
+ final AbstractFeature point1 = types.wayPoint.newInstance();
+ final AbstractFeature point2 = types.wayPoint.newInstance();
+ final AbstractFeature point3 = types.wayPoint.newInstance();
point1.setPropertyValue("sis:geometry", new Point(15, 10));
point2.setPropertyValue("sis:geometry", new Point(25, 20));
point3.setPropertyValue("sis:geometry", new Point(35, 30));
diff --git a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/WriterTest.java b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/WriterTest.java
index 0f3c9ac..4e1e104 100644
--- a/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/WriterTest.java
+++ b/endorsed/src/org.apache.sis.storage.xml/test/org/apache/sis/storage/gpx/WriterTest.java
@@ -36,8 +36,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -233,7 +233,7 @@
* Way Points as defined in "waypoint.xml" test file.
* Appear also in "route.xml" and "track.xml" files.
*/
- final Feature point1 = types.wayPoint.newInstance();
+ final AbstractFeature point1 = types.wayPoint.newInstance();
point1.setPropertyValue("sis:geometry", new Point(15, 10));
point1.setPropertyValue("time", Instant.parse("2010-01-10T00:00:00Z"));
point1.setPropertyValue("name", "first point");
@@ -255,7 +255,7 @@
point1.setPropertyValue("link", List.of(new Link(new URI("http://first-address1.org")),
new Link(new URI("http://first-address2.org")),
new Link(new URI("http://first-address3.org"))));
- final Feature point3 = types.wayPoint.newInstance();
+ final AbstractFeature point3 = types.wayPoint.newInstance();
point3.setPropertyValue("sis:geometry", new Point(35, 30));
point3.setPropertyValue("time", Instant.parse("2010-01-30T00:00:00Z"));
point3.setPropertyValue("name", "third point");
@@ -276,17 +276,17 @@
point3.setPropertyValue("fix", Fix.THREE_DIMENSIONAL);
point3.setPropertyValue("link", List.of(new Link(new URI("http://third-address1.org")),
new Link(new URI("http://third-address2.org"))));
- final Feature point2 = types.wayPoint.newInstance();
+ final AbstractFeature point2 = types.wayPoint.newInstance();
point2.setPropertyValue("sis:geometry", new Point(25, 20));
- final List<Feature> wayPoints = List.of(point1, point2, point3);
- final List<Feature> features;
+ final List<AbstractFeature> wayPoints = List.of(point1, point2, point3);
+ final List<AbstractFeature> features;
switch (type) {
case WAY_POINT: {
features = wayPoints;
break;
}
case ROUTE: {
- final Feature route1 = types.route.newInstance();
+ final AbstractFeature route1 = types.route.newInstance();
route1.setPropertyValue("name", "Route name");
route1.setPropertyValue("cmt", "Route comment");
route1.setPropertyValue("desc", "Route description");
@@ -297,16 +297,16 @@
route1.setPropertyValue("link", List.of(new Link(new URI("http://route-address1.org")),
new Link(new URI("http://route-address2.org")),
new Link(new URI("http://route-address3.org"))));
- final Feature route2 = types.route.newInstance();
+ final AbstractFeature route2 = types.route.newInstance();
features = List.of(route1, route2);
break;
}
case TRACK: {
- final Feature seg1 = types.trackSegment.newInstance();
- final Feature seg2 = types.trackSegment.newInstance();
+ final AbstractFeature seg1 = types.trackSegment.newInstance();
+ final AbstractFeature seg2 = types.trackSegment.newInstance();
seg1.setPropertyValue("trkpt", wayPoints);
- final Feature track1 = types.track.newInstance();
+ final AbstractFeature track1 = types.track.newInstance();
track1.setPropertyValue("name", "Track name");
track1.setPropertyValue("cmt", "Track comment");
track1.setPropertyValue("desc", "Track description");
@@ -317,7 +317,7 @@
track1.setPropertyValue("link", List.of(new Link(new URI("http://track-address1.org")),
new Link(new URI("http://track-address2.org")),
new Link(new URI("http://track-address3.org"))));
- final Feature track2 = types.track.newInstance();
+ final AbstractFeature track2 = types.track.newInstance();
features = List.of(track1, track2);
break;
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractFeatureSet.java
index 56ca921..d80d8d7 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractFeatureSet.java
@@ -23,8 +23,8 @@
import org.apache.sis.storage.event.StoreListeners;
import org.apache.sis.storage.base.MetadataBuilder;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -93,7 +93,7 @@
*/
@Override
public Optional<GenericName> getIdentifier() throws DataStoreException {
- final FeatureType type = getType();
+ final DefaultFeatureType type = getType();
return (type != null) ? Optional.of(type.getName()) : Optional.empty();
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Aggregate.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Aggregate.java
index d864d97..5890799 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Aggregate.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Aggregate.java
@@ -49,10 +49,10 @@
* {@link org.apache.sis.metadata.iso.DefaultMetadata#getMetadataScopes() metadataScope} /
* {@link org.apache.sis.metadata.iso.DefaultMetadataScope#getResourceScope() resourceScope} sets to
* {@link org.opengis.metadata.maintenance.ScopeCode#SERIES} or
- * {@link org.opengis.metadata.maintenance.ScopeCode#INITIATIVE} if applicable.
+ * {@code ScopeCode.INITIATIVE} if applicable.
* If not too expensive to compute, the names of all components should be listed as
* {@linkplain org.apache.sis.metadata.iso.identification.AbstractIdentification#getAssociatedResources()
- * associated resources} with an {@link org.opengis.metadata.identification.AssociationType#IS_COMPOSED_OF} relation.
+ * associated resources} with an {@code AssociationType.IS_COMPOSED_OF} relation.
*
* @author Johann Sorel (Geomatys)
* @version 1.0
@@ -68,7 +68,7 @@
* <blockquote><code><b>this</b>.metadata</code> /
* {@link org.apache.sis.metadata.iso.DefaultMetadata#getIdentificationInfo() identificationInfo} /
* {@link org.apache.sis.metadata.iso.identification.AbstractIdentification#getAssociatedResources() associatedResource}
- * with {@link org.opengis.metadata.identification.AssociationType#IS_COMPOSED_OF}</blockquote>
+ * with {@code AssociationType.IS_COMPOSED_OF}</blockquote>
*
* The name of each child resource in the returned collection is given by the following metadata element:
*
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/CoverageSubset.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/CoverageSubset.java
index e6aa5a8..c6bc6ce 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/CoverageSubset.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/CoverageSubset.java
@@ -145,7 +145,7 @@
List<double[]> resolutions = source.getResolutions();
if (reduction != null) {
JDK16.toList(resolutions.stream()
- .map((resolution) -> reduction.apply(new DirectPositionView.Double(resolution)).getCoordinates()));
+ .map((resolution) -> reduction.apply(new DirectPositionView.Double(resolution)).getCoordinate()));
}
return resolutions;
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataStore.java
index 3a4abcd..fddb5fd 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataStore.java
@@ -41,6 +41,9 @@
import org.apache.sis.storage.event.StoreListener;
import org.apache.sis.storage.event.StoreListeners;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
+
/**
* Manages a series of features, coverages or sensor data.
@@ -340,12 +343,12 @@
}
}
if (citation != null) {
- Identifier first = null;
+ ReferenceIdentifier first = null;
for (final Identifier c : citation.getIdentifiers()) {
if (c instanceof GenericName) {
return Optional.of((GenericName) c);
- } else if (first == null) {
- first = c;
+ } else if (first == null && c instanceof ReferenceIdentifier) {
+ first = (ReferenceIdentifier) c;
}
}
if (first != null) {
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureNaming.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureNaming.java
index 466257c..3db2e93 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureNaming.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureNaming.java
@@ -32,8 +32,8 @@
/**
* Helper class for mapping {@link GenericName} instances and their shortened names to features.
- * The features are typically represented by instances of {@link org.opengis.feature.FeatureType}
- * or {@link org.opengis.coverage.Coverage} (sometimes seen as a kind of features), but this class
+ * The features are typically represented by instances of {@code FeatureType}
+ * or {@code Coverage} (sometimes seen as a kind of features), but this class
* actually puts no restriction on the kind of object associated to {@code GenericName}s;
* {@link DataStore} implementations are free to choose their internal object.
* Those objects can be stored and fetched using the {@code String} representation of their name
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureQuery.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureQuery.java
index 4412e94..a0a15a2 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureQuery.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureQuery.java
@@ -46,21 +46,16 @@
import org.apache.sis.util.UnconvertibleObjectException;
import org.apache.sis.util.iso.Names;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.InvalidFilterValueException;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.SortBy;
-import org.opengis.filter.SortProperty;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractAttribute;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
+import org.apache.sis.pending.geoapi.filter.SortBy;
+import org.apache.sis.pending.geoapi.filter.SortProperty;
/**
@@ -117,7 +112,7 @@
* @see #setSelection(Filter)
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
- private Filter<? super Feature> selection;
+ private Filter<? super AbstractFeature> selection;
/**
* The number of feature instances to skip from the beginning.
@@ -146,7 +141,7 @@
* @see #setSortBy(SortBy)
*/
@SuppressWarnings("serial") // Most SIS implementations are serializable.
- private SortBy<Feature> sortBy;
+ private SortBy<AbstractFeature> sortBy;
/**
* Hint used by resources to optimize returned features, or {@code null} for full resolution.
@@ -233,13 +228,13 @@
*/
@SafeVarargs
@SuppressWarnings("varargs")
- public final void setProjection(final Expression<? super Feature, ?>... properties) {
+ public final void setProjection(final Expression<? super AbstractFeature, ?>... properties) {
NamedExpression[] wrappers = null;
if (properties != null) {
ArgumentChecks.ensureNonEmpty("properties", properties);
wrappers = new NamedExpression[properties.length];
for (int i=0; i<wrappers.length; i++) {
- final Expression<? super Feature, ?> e = properties[i];
+ final Expression<? super AbstractFeature, ?> e = properties[i];
ArgumentChecks.ensureNonNullElement("properties", i, e);
wrappers[i] = new NamedExpression(e);
}
@@ -300,9 +295,9 @@
*/
@Override
public void setSelection(final Envelope domain) {
- Filter<Feature> filter = null;
+ Filter<AbstractFeature> filter = null;
if (domain != null) {
- final FilterFactory<Feature,Object,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,Object,?> ff = DefaultFilterFactory.forFeatures();
filter = ff.bbox(ff.property(AttributeConvention.GEOMETRY), domain);
}
setSelection(filter);
@@ -315,7 +310,7 @@
*
* @param selection the filter, or {@code null} if none.
*/
- public void setSelection(final Filter<? super Feature> selection) {
+ public void setSelection(final Filter<? super AbstractFeature> selection) {
this.selection = selection;
}
@@ -326,7 +321,7 @@
*
* @return the filter, or {@code null} if none.
*/
- public Filter<? super Feature> getSelection() {
+ public Filter<? super AbstractFeature> getSelection() {
return selection;
}
@@ -389,17 +384,19 @@
/**
* Sets the expressions to use for sorting the feature instances.
- * {@code SortBy} objects are used to order the {@link Feature} instances returned by the {@link FeatureSet}.
+ * {@code SortBy} objects are used to order the {@code Feature} instances returned by the {@link FeatureSet}.
* {@code SortBy} clauses are applied in declaration order, like SQL.
*
* @param properties expressions to use for sorting the feature instances,
* or {@code null} or an empty array if none.
+ *
+ * @todo Not yet in public API. Pending publication of {@link SortProperty} interface.
*/
@SafeVarargs
@SuppressWarnings("varargs")
- public final void setSortBy(final SortProperty<Feature>... properties) {
+ final void setSortBy(final SortProperty<AbstractFeature>... properties) {
@SuppressWarnings("LocalVariableHidesMemberVariable")
- SortBy<Feature> sortBy = null;
+ SortBy<AbstractFeature> sortBy = null;
if (properties != null) {
sortBy = SortByComparator.create(properties);
}
@@ -408,11 +405,13 @@
/**
* Sets the expressions to use for sorting the feature instances.
- * {@code SortBy} objects are used to order the {@link Feature} instances returned by the {@link FeatureSet}.
+ * {@code SortBy} objects are used to order the {@code Feature} instances returned by the {@link FeatureSet}.
*
* @param sortBy expressions to use for sorting the feature instances, or {@code null} if none.
+ *
+ * @todo Not yet in public API. Pending publication of {@link SortProperty} interface.
*/
- public void setSortBy(final SortBy<Feature> sortBy) {
+ final void setSortBy(final SortBy<AbstractFeature> sortBy) {
this.sortBy = sortBy;
}
@@ -421,8 +420,10 @@
* This is the value specified in the last call to {@link #setSortBy(SortBy)}.
*
* @return expressions to use for sorting the feature instances, or {@code null} if none.
+ *
+ * @todo Not yet in public API. Pending publication of {@link SortProperty} interface.
*/
- public SortBy<Feature> getSortBy() {
+ final SortBy<AbstractFeature> getSortBy() {
return sortBy;
}
@@ -449,8 +450,8 @@
/**
* Whether a property evaluated by a query is computed on the fly or stored.
* By default, an expression is evaluated only once for each feature instance,
- * then the result is stored as a feature {@link Attribute} value.
- * But the same expression can also be wrapped in a feature {@link Operation}
+ * then the result is stored as a feature {@link AbstractAttribute} value.
+ * But the same expression can also be wrapped in a feature {@link AbstractOperation}
* and evaluated every times that the value is requested.
*
* <h2>Analogy with relational databases</h2>
@@ -467,7 +468,7 @@
/**
* The expression is evaluated exactly once when a feature instance is created,
* and the result is stored as a feature attribute.
- * The feature property type will be {@link Attribute} and its value will be modifiable.
+ * The feature property type will be {@link AbstractAttribute} and its value will be modifiable.
* This is the default projection type.
*
* <h4>Feature instances in expression evaluation</h4>
@@ -498,7 +499,7 @@
/**
* The expression is evaluated every times that the property value is requested.
- * The feature property type will be {@link Operation}.
+ * The feature property type will be {@link AbstractOperation}.
* This projection type may be preferable to {@link #STORED} in the following circumstances:
*
* <ul>
@@ -551,7 +552,7 @@
* Never {@code null}.
*/
@SuppressWarnings("serial")
- public final Expression<? super Feature, ?> expression;
+ public final Expression<? super AbstractFeature, ?> expression;
/**
* The name to assign to the expression result, or {@code null} if unspecified.
@@ -561,8 +562,8 @@
/**
* Whether the expression result should be stored or evaluated every times that it is requested.
- * A stored value will exist as a feature {@link Attribute}, while a virtual value will exist as
- * a feature {@link Operation}. The latter are commonly called "computed fields" and are equivalent
+ * A stored value will exist as a feature {@link AbstractAttribute}, while a virtual value will exist as
+ * a feature {@link AbstractOperation}. The latter are commonly called "computed fields" and are equivalent
* to SQL {@code GENERATED ALWAYS} keyword for columns.
*
* @since 1.4
@@ -574,7 +575,7 @@
*
* @param expression the literal, value reference or expression to be retrieved by a {@code Query}.
*/
- public NamedExpression(final Expression<? super Feature, ?> expression) {
+ public NamedExpression(final Expression<? super AbstractFeature, ?> expression) {
this(expression, (GenericName) null);
}
@@ -584,7 +585,7 @@
* @param expression the literal, value reference or expression to be retrieved by a {@code Query}.
* @param alias the name to assign to the expression result, or {@code null} if unspecified.
*/
- public NamedExpression(final Expression<? super Feature,?> expression, final GenericName alias) {
+ public NamedExpression(final Expression<? super AbstractFeature,?> expression, final GenericName alias) {
this(expression, alias, ProjectionType.STORED);
}
@@ -595,7 +596,7 @@
* @param expression the literal, value reference or expression to be retrieved by a {@code Query}.
* @param alias the name to assign to the expression result, or {@code null} if unspecified.
*/
- public NamedExpression(final Expression<? super Feature,?> expression, final String alias) {
+ public NamedExpression(final Expression<? super AbstractFeature,?> expression, final String alias) {
this.expression = Objects.requireNonNull(expression);
this.alias = (alias != null) ? Names.createLocalName(null, null, alias) : null;
this.type = ProjectionType.STORED;
@@ -606,11 +607,11 @@
*
* @param expression the literal, value reference or expression to be retrieved by a {@code Query}.
* @param alias the name to assign to the expression result, or {@code null} if unspecified.
- * @param type whether to create a feature {@link Attribute} or a feature {@link Operation}.
+ * @param type whether to create a feature {@link AbstractAttribute} or a feature {@link AbstractOperation}.
*
* @since 1.4
*/
- public NamedExpression(final Expression<? super Feature,?> expression, final GenericName alias, ProjectionType type) {
+ public NamedExpression(final Expression<? super AbstractFeature,?> expression, final GenericName alias, ProjectionType type) {
this.expression = Objects.requireNonNull(expression);
this.type = Objects.requireNonNull(type);
this.alias = alias;
@@ -626,7 +627,7 @@
* @throws UnconvertibleObjectException if the property default value cannot be converted to the expected type.
*/
final boolean addTo(final FeatureProjectionBuilder builder) {
- final FeatureExpression<? super Feature, ?> fex = FeatureExpression.castOrCopy(expression);
+ final FeatureExpression<? super AbstractFeature, ?> fex = FeatureExpression.castOrCopy(expression);
if (fex != null) {
final FeatureProjectionBuilder.Item item = fex.expectedType(builder);
if (item != null) {
@@ -755,7 +756,7 @@
* @throws UnconvertibleObjectException if a property default value cannot be converted to the expected type.
* @throws UnsupportedOperationException if there is an attempt to rename a property which is used by an operation.
*/
- final Optional<FeatureProjection> project(final FeatureType sourceType, final Locale locale) {
+ final Optional<FeatureProjection> project(final DefaultFeatureType sourceType, final Locale locale) {
if (projection == null) {
return Optional.empty();
}
@@ -764,7 +765,7 @@
final NamedExpression item = projection[column];
if (!item.addTo(builder)) {
final var name = item.expression.getFunctionName().toInternationalString();
- throw new InvalidFilterValueException(Resources.forLocale(locale)
+ throw new IllegalArgumentException(Resources.forLocale(locale)
.getString(Resources.Keys.InvalidExpression_2, column, name));
}
}
@@ -899,7 +900,7 @@
}
if (sortBy != null) {
String separator = " ORDER BY ";
- for (final SortProperty<Feature> p : sortBy.getSortProperties()) {
+ for (final SortProperty<AbstractFeature> p : sortBy.getSortProperties()) {
sb.append(separator);
separator = ", ";
sb.append(p.getValueReference().getXPath()).append(' ').append(p.getSortOrder());
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSet.java
index 29b6fad..81724f2 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSet.java
@@ -19,9 +19,9 @@
import java.util.Objects;
import java.util.stream.Stream;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -67,14 +67,14 @@
* @return description of common properties (never {@code null}).
* @throws DataStoreException if an error occurred while reading definitions from the underlying data store.
*/
- FeatureType getType() throws DataStoreException;
+ DefaultFeatureType getType() throws DataStoreException;
/**
* Requests a subset of features and/or feature properties from this resource.
* The filtering can be applied in two domains:
*
* <ul>
- * <li>The returned {@code FeatureSet} may contain a smaller number of {@link Feature} instances.</li>
+ * <li>The returned {@code FeatureSet} may contain a smaller number of {@code Feature} instances.</li>
* <li>In each {@code Feature} instance of the returned set, the number of
* {@linkplain org.apache.sis.feature.DefaultFeatureType#getProperty properties} may be smaller.</li>
* </ul>
@@ -145,5 +145,5 @@
* @return all features contained in this dataset.
* @throws DataStoreException if an error occurred while creating the stream.
*/
- Stream<Feature> features(boolean parallel) throws DataStoreException;
+ Stream<AbstractFeature> features(boolean parallel) throws DataStoreException;
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSubset.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSubset.java
index 3838769..bddd605 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSubset.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/FeatureSubset.java
@@ -24,11 +24,11 @@
import org.apache.sis.storage.base.StoreUtilities;
import org.apache.sis.storage.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.SortBy;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.pending.geoapi.filter.SortBy;
/**
@@ -61,7 +61,7 @@
* The type of features in this set. May or may not be the same as {@link #source}.
* This is computed when first needed.
*/
- private FeatureType resultType;
+ private DefaultFeatureType resultType;
/**
* Creates a new set of features by filtering the given set using the given query.
@@ -91,9 +91,9 @@
* Returns a description of properties that are common to all features in this dataset.
*/
@Override
- public synchronized FeatureType getType() throws DataStoreException {
+ public synchronized DefaultFeatureType getType() throws DataStoreException {
if (resultType == null) {
- final FeatureType type = source.getType();
+ final DefaultFeatureType type = source.getType();
try {
projection = query.project(type, listeners.getLocale()).orElse(null);
resultType = (projection != null) ? projection.typeRequested : type;
@@ -109,19 +109,19 @@
* Returns a stream of all features contained in this dataset.
*/
@Override
- public Stream<Feature> features(final boolean parallel) throws DataStoreException {
- Stream<Feature> stream = source.features(parallel);
+ public Stream<AbstractFeature> features(final boolean parallel) throws DataStoreException {
+ Stream<AbstractFeature> stream = source.features(parallel);
/*
* Apply filter.
*/
- final Filter<? super Feature> selection = query.getSelection();
+ final Filter<? super AbstractFeature> selection = query.getSelection();
if (selection != null && !selection.equals(Filter.include())) {
stream = stream.filter(selection);
}
/*
* Apply sorting.
*/
- final SortBy<Feature> sortBy = query.getSortBy();
+ final SortBy<AbstractFeature> sortBy = query.getSortBy();
if (sortBy != null) {
stream = stream.sorted(sortBy);
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/IllegalFeatureTypeException.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/IllegalFeatureTypeException.java
index e477d4d..9cebd43 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/IllegalFeatureTypeException.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/IllegalFeatureTypeException.java
@@ -23,7 +23,7 @@
/**
* Thrown when a store cannot write the given feature because its type is not one of the supported types.
- * The {@link org.opengis.feature.FeatureType} is given by {@link org.opengis.feature.Feature#getType()},
+ * The {@code FeatureType} is given by {@code Feature.getType()},
* and the type expected by the data store is given by {@link FeatureSet#getType()}. Those two values must
* match, except when the type of the feature set is {@linkplain WritableFeatureSet#updateType updated}.
*
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Query.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Query.java
index 05b3936..1b16f94 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Query.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Query.java
@@ -18,9 +18,6 @@
import org.opengis.geometry.Envelope;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.QueryExpression;
-
/**
* Definition of filtering to apply for fetching a resource subset.
@@ -52,7 +49,7 @@
*
* @since 0.8
*/
-public abstract class Query implements QueryExpression {
+public abstract class Query {
/**
* Creates a new, initially empty, query.
*/
@@ -61,7 +58,7 @@
/**
* Sets the approximate area of feature instances or pixels to include in the subset.
- * For feature set, the domain is materialized by a {@link org.opengis.filter.Filter}.
+ * For feature set, the domain is materialized by a {@link org.apache.sis.filter.Filter}.
* For grid coverage resource, the given envelope specifies the coverage domain.
*
* <p>The given envelope is approximate.
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/RasterLoadingStrategy.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/RasterLoadingStrategy.java
index 7fc0019..37ad65b 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/RasterLoadingStrategy.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/RasterLoadingStrategy.java
@@ -23,8 +23,8 @@
import org.apache.sis.coverage.grid.GridGeometry;
import org.apache.sis.coverage.grid.GridCoverage;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Resource.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Resource.java
index 6102271..0b04f65 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Resource.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/Resource.java
@@ -119,7 +119,7 @@
* {@link org.opengis.metadata.maintenance.ScopeCode#DATASET} if the resource is a {@link DataSet}, or
* {@link org.opengis.metadata.maintenance.ScopeCode#SERVICE} if the resource is a web service, or
* {@link org.opengis.metadata.maintenance.ScopeCode#SERIES} or
- * {@link org.opengis.metadata.maintenance.ScopeCode#INITIATIVE}
+ * {@code ScopeCode.INITIATIVE}
* if the resource is an {@link Aggregate} other than a transfer aggregate.</li>
* <li>{@code metadata} /
* {@link org.apache.sis.metadata.iso.DefaultMetadata#getContentInfo() contentInfo} /
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/WritableFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/WritableFeatureSet.java
index 06ce25d..ee46e96 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/WritableFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/WritableFeatureSet.java
@@ -21,9 +21,9 @@
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -50,12 +50,12 @@
* @throws IllegalFeatureTypeException if the given type is not compatible with the types supported by the store.
* @throws DataStoreException if another error occurred while changing the feature type.
*/
- void updateType(FeatureType newType) throws DataStoreException;
+ void updateType(DefaultFeatureType newType) throws DataStoreException;
/**
* Inserts new feature instances in this {@code FeatureSet}.
* Any feature already present in this {@link FeatureSet} will remain unmodified.
- * If a {@linkplain Feature#getProperty feature property} is used as unique identifier, then:
+ * If a {@linkplain AbstractFeature#getProperty feature property} is used as unique identifier, then:
*
* <ul>
* <li>If a given feature assigns to that property a value already in use, an exception will be thrown.</li>
@@ -75,7 +75,7 @@
* @throws IllegalFeatureTypeException if a feature given by the iterator is not of the type expected by this {@code FeatureSet}.
* @throws DataStoreException if another error occurred while storing new features.
*/
- void add(Iterator<? extends Feature> features) throws DataStoreException;
+ void add(Iterator<? extends AbstractFeature> features) throws DataStoreException;
/**
* Removes all feature instances from this {@code FeatureSet} which matches the given predicate.
@@ -83,25 +83,25 @@
* @param filter a predicate which returns {@code true} for feature instances to be removed.
* @throws DataStoreException if an error occurred while removing features.
*/
- void removeIf(Predicate<? super Feature> filter) throws DataStoreException;
+ void removeIf(Predicate<? super AbstractFeature> filter) throws DataStoreException;
/**
* Updates all feature instances from this {@code FeatureSet} which match the given predicate.
- * For each {@link Feature} instance matching the given {@link Predicate},
+ * For each {@code Feature} instance matching the given {@link Predicate},
* the <code>{@linkplain UnaryOperator#apply UnaryOperator.apply(Feature)}</code> method will be invoked.
* {@code UnaryOperator}s are free to modify the given {@code Feature} <i>in-place</i>
* or to return a different feature instance. Two behaviors are possible:
*
* <ul>
- * <li>If the operator returns a non-null {@link Feature}, then the modified feature is stored
+ * <li>If the operator returns a non-null {@code Feature}, then the modified feature is stored
* in replacement of the previous feature (not necessarily at the same location).</li>
* <li>If the operator returns {@code null}, then the feature will be removed from the {@code FeatureSet}.</li>
* </ul>
*
* @param filter a predicate which returns {@code true} for feature instances to be updated.
- * @param updater operation called for each matching {@link Feature} instance.
+ * @param updater operation called for each matching {@code Feature} instance.
* @throws IllegalFeatureTypeException if a feature given by the operator is not of the type expected by this {@code FeatureSet}.
* @throws DataStoreException if another error occurred while replacing features.
*/
- void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature> updater) throws DataStoreException;
+ void replaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) throws DataStoreException;
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java
index 63b180e..b2e4e99 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java
@@ -33,8 +33,8 @@
import org.apache.sis.storage.event.StoreListeners;
import org.apache.sis.storage.base.MetadataBuilder;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -158,7 +158,7 @@
final MetadataBuilder metadata = new MetadataBuilder();
metadata.addDefaultMetadata(this, listeners);
for (final FeatureSet fs : dependencies()) {
- final FeatureType type = fs.getType();
+ final DefaultFeatureType type = fs.getType();
metadata.addSource(fs.getMetadata(), ScopeCode.FEATURE_TYPE,
(type == null) ? null : new CharSequence[] {type.getName().toInternationalString()});
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java
index f7a5d84..e2adb3b 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java
@@ -35,9 +35,9 @@
import org.apache.sis.util.privy.UnmodifiableArrayList;
import org.apache.sis.storage.internal.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -69,7 +69,7 @@
/**
* The most specific feature type common to all feature sets in the {@linkplain #sources} list.
*/
- private final FeatureType commonType;
+ private final DefaultFeatureType commonType;
/**
* Creates a new concatenated feature set with the same types as the given feature set,
@@ -98,7 +98,7 @@
ArgumentChecks.ensureNonNullElement("sources", i, sources[i]);
}
this.sources = UnmodifiableArrayList.wrap(sources);
- final FeatureType[] types = new FeatureType[sources.length];
+ final DefaultFeatureType[] types = new DefaultFeatureType[sources.length];
for (int i=0; i<types.length; i++) {
types[i] = sources[i].getType();
}
@@ -169,7 +169,7 @@
* @return the common type of all features returned by this set.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return commonType;
}
@@ -213,7 +213,7 @@
* @return all features contained in this dataset.
*/
@Override
- public Stream<Feature> features(final boolean parallel) {
+ public Stream<AbstractFeature> features(final boolean parallel) {
final Stream<FeatureSet> sets = parallel ? sources.parallelStream() : sources.stream();
return sets.flatMap(set -> {
try {
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedGridCoverage.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedGridCoverage.java
index cb55747..bab29f5 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedGridCoverage.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/ConcatenatedGridCoverage.java
@@ -36,8 +36,8 @@
import org.apache.sis.util.privy.Numerics;
import static org.apache.sis.image.privy.ImageUtilities.LOGGER;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/DimensionAppender.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/DimensionAppender.java
index 4dd5e24..7c7f242 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/DimensionAppender.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/DimensionAppender.java
@@ -42,9 +42,6 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.logging.Logging;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.apache.sis.util.ArraysExt;
-
/**
* A wrapper over an existing grid coverage resource with dimensions appended.
@@ -228,7 +225,10 @@
final var sb = new StringBuilder(40);
sb.append(source).append(" + dimensions[");
final GridExtent extent = dimToAdd.getExtent();
- final double[] coordinates = ArraysExt.copyAsDoubles(extent.getLow().getCoordinateValues());
+ final double[] coordinates = new double[extent.getDimension()];
+ for (int i=0; i<coordinates.length; i++) {
+ coordinates[i] = extent.getLow(i);
+ }
try {
dimToAdd.getGridToCRS(PixelInCell.CELL_CORNER).transform(coordinates, 0, coordinates, 0, 1);
} catch (RuntimeException | TransformException e) {
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/JoinFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/JoinFeatureSet.java
index 4c53391..93c94f9 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/JoinFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/JoinFeatureSet.java
@@ -37,15 +37,13 @@
import org.apache.sis.util.collection.Containers;
import org.apache.sis.filter.DefaultFilterFactory;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.Expression;
-import org.opengis.filter.BinaryComparisonOperator;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.AbstractOperation;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.pending.geoapi.filter.BinaryComparisonOperator;
/**
@@ -135,7 +133,7 @@
/**
* The type of features included in this set. Contains two associations as described in class javadoc.
*/
- private final FeatureType type;
+ private final DefaultFeatureType type;
/**
* The first source of features.
@@ -176,12 +174,12 @@
* This condition specifies also if the comparison is {@linkplain BinaryComparisonOperator#isMatchingCase() case
* sensitive} and {@linkplain BinaryComparisonOperator#getMatchAction() how to compare multi-values}.
*/
- public final BinaryComparisonOperator<Feature> condition;
+ public final BinaryComparisonOperator<AbstractFeature> condition;
/**
* The factory to use for creating {@code Query} expressions for retrieving subsets of feature sets.
*/
- private final FilterFactory<Feature,?,?> factory;
+ private final DefaultFilterFactory<AbstractFeature,?,?> factory;
/**
* Creates a new feature set joining the two given sets. The {@code featureInfo} map defines the name,
@@ -202,19 +200,19 @@
* @param rightAlias name of the associations to the {@code right} features, or {@code null} for a default name.
* @param joinType whether values on both sides are required (inner join), or only one side (outer join).
* @param condition join condition as <var>property from left feature</var> = <var>property from right feature</var>.
- * @param featureInfo information about the {@link FeatureType} of this feature set.
+ * @param featureInfo information about the {@code FeatureType} of this feature set.
* @throws DataStoreException if an error occurred while creating the feature set.
*/
public JoinFeatureSet(final Resource parent,
final FeatureSet left, String leftAlias,
final FeatureSet right, String rightAlias,
- final Type joinType, final BinaryComparisonOperator<Feature> condition,
+ final Type joinType, final BinaryComparisonOperator<AbstractFeature> condition,
Map<String,?> featureInfo)
throws DataStoreException
{
super(parent);
- final FeatureType leftType = left.getType();
- final FeatureType rightType = right.getType();
+ final DefaultFeatureType leftType = left.getType();
+ final DefaultFeatureType rightType = right.getType();
final GenericName leftName = leftType.getName();
final GenericName rightName = rightType.getName();
if (leftAlias == null) leftAlias = leftName.toString();
@@ -231,7 +229,7 @@
* We could build the FeatureType only when first needed, but the type is required by the iterators.
* Since we are going to need the type for any use of this JoinFeatureSet, better to create it now.
*/
- PropertyType[] properties = new PropertyType[] {
+ AbstractIdentifiedType[] properties = new AbstractIdentifiedType[] {
new DefaultAssociationRole(properties(leftAlias), leftType, joinType.minimumOccurs(false), 1),
new DefaultAssociationRole(properties(rightAlias), rightType, joinType.minimumOccurs(true), 1)
};
@@ -239,7 +237,7 @@
if (identifierDelimiter != null && AttributeConvention.hasIdentifier(leftType)
&& AttributeConvention.hasIdentifier(rightType))
{
- final Operation identifier = FeatureOperations.compound(
+ final AbstractOperation identifier = FeatureOperations.compound(
properties(AttributeConvention.IDENTIFIER_PROPERTY), identifierDelimiter,
Containers.property(featureInfo, "identifierPrefix", String.class),
Containers.property(featureInfo, "identifierSuffix", String.class), properties);
@@ -290,7 +288,7 @@
* @return a description of properties that are common to all features in this dataset.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return type;
}
@@ -302,7 +300,7 @@
* @throws DataStoreException if an error occurred while creating the stream.
*/
@Override
- public Stream<Feature> features(final boolean parallel) throws DataStoreException {
+ public Stream<AbstractFeature> features(final boolean parallel) throws DataStoreException {
final Iterator it = new Iterator();
return StreamSupport.stream(it, parallel).onClose(it);
}
@@ -311,13 +309,13 @@
* Creates a new features containing an association to the two given features.
* The {@code main} feature cannot be null (this is not verified).
*/
- private Feature join(Feature main, Feature filtered) {
+ private AbstractFeature join(AbstractFeature main, AbstractFeature filtered) {
if (swapSides) {
- final Feature t = main;
+ final AbstractFeature t = main;
main = filtered;
filtered = t;
}
- final Feature f = type.newInstance();
+ final AbstractFeature f = type.newInstance();
f.setPropertyValue(leftName, main);
f.setPropertyValue(rightName, filtered);
return f;
@@ -327,7 +325,7 @@
* Iterator over the features resulting from the inner or outer join operation.
* The {@link #run()} method disposes the resources.
*/
- private final class Iterator implements Spliterator<Feature>, Consumer<Feature>, Runnable {
+ private final class Iterator implements Spliterator<AbstractFeature>, Consumer<AbstractFeature>, Runnable {
/**
* The main stream or a split iterator to close when the {@link #run()} method will be invoked.
* This is initially the stream from which {@link #mainIterator} has been created. However, if
@@ -345,31 +343,31 @@
* <p>Only one iteration will be performed on those features, contrarily to the other side where we may
* iterate over the same elements many times.</p>
*/
- private final Spliterator<Feature> mainIterator;
+ private final Spliterator<AbstractFeature> mainIterator;
/**
* A feature fetched from the {@link #mainIterator}. The join operation will match this feature with
* zero, one or more features from the other side. A {@code null} value means that this feature needs
* to be retrieved with {@code mainIterator.tryAdvance(…)}.
*/
- private Feature mainFeature;
+ private AbstractFeature mainFeature;
/**
* The stream over features in the other (usually right) side. A new stream will be created every time a new
* feature from the main side is processed. For this reason, it should be the cheapest stream if possible.
*/
- private Stream<Feature> filteredStream;
+ private Stream<AbstractFeature> filteredStream;
/**
* Iterator for the {@link #filteredStream}. A new iterator will be recreated every time a new feature
* from the main side is processed.
*/
- private Spliterator<Feature> filteredIterator;
+ private Spliterator<AbstractFeature> filteredIterator;
/**
* A feature fetched from the {@link #filteredIterator}, or {@code null} if none.
*/
- private Feature filteredFeature;
+ private AbstractFeature filteredFeature;
/**
* Creates a new iterator. We do not use parallelized {@code mainStream} here because the {@code accept(…)}
@@ -378,7 +376,7 @@
* so the {@link Stream} wrapping it can use parallelization.
*/
Iterator() throws DataStoreException {
- final Stream<Feature> mainStream = (swapSides ? right : left).features(false);
+ final Stream<AbstractFeature> mainStream = (swapSides ? right : left).features(false);
mainCloseHandler = mainStream::close;
mainIterator = mainStream.spliterator();
}
@@ -386,7 +384,7 @@
/**
* Creates an iterator resulting from the call to {@link #trySplit()}.
*/
- private Iterator(final Spliterator<Feature> it) {
+ private Iterator(final Spliterator<AbstractFeature> it) {
mainIterator = it;
}
@@ -396,8 +394,8 @@
* Returns {@code null} if this iterator cannot be partitioned.
*/
@Override
- public Spliterator<Feature> trySplit() {
- final Spliterator<Feature> s = mainIterator.trySplit();
+ public Spliterator<AbstractFeature> trySplit() {
+ final Spliterator<AbstractFeature> s = mainIterator.trySplit();
if (s == null) {
return null;
}
@@ -449,7 +447,7 @@
* This method is idempotent: it has no effect if the stream is already closed.
*/
private void closeFilteredIterator() {
- final Stream<Feature> stream = filteredStream;
+ final Stream<AbstractFeature> stream = filteredStream;
filteredStream = null; // Cleared before call to close() in case of error.
filteredIterator = null;
filteredFeature = null; // Used as a sentinel value by this.forEachRemaining(…).
@@ -464,7 +462,7 @@
* The filtering condition is determined by the current {@link #mainFeature}.
*/
private void createFilteredIterator() {
- final Expression<Feature,?> expression1, expression2;
+ final Expression<AbstractFeature,?> expression1, expression2;
final FeatureSet filteredSet;
if (swapSides) {
expression1 = condition.getOperand2();
@@ -476,10 +474,9 @@
filteredSet = right;
}
final Object mainValue = expression1.apply(mainFeature);
- final Filter<Feature> filter;
+ final Filter<AbstractFeature> filter;
if (mainValue != null) {
- filter = factory.equal(expression2, factory.literal(mainValue),
- condition.isMatchingCase(), condition.getMatchAction());
+ filter = factory.equal(expression2, factory.literal(mainValue));
} else {
filter = factory.isNull(expression2);
}
@@ -497,13 +494,13 @@
* Executes the given action on all remaining features in the {@code JoinFeatureSet}.
*/
@Override
- public void forEachRemaining(final Consumer<? super Feature> action) {
- final Consumer<Feature> forFiltered = (final Feature feature) -> {
+ public void forEachRemaining(final Consumer<? super AbstractFeature> action) {
+ final Consumer<AbstractFeature> forFiltered = (final AbstractFeature feature) -> {
if (feature != null) {
action.accept(join(mainFeature, filteredFeature = feature));
}
};
- final Consumer<Feature> forMain = (final Feature feature) -> {
+ final Consumer<AbstractFeature> forMain = (final AbstractFeature feature) -> {
if (feature != null) {
mainFeature = feature;
createFilteredIterator();
@@ -525,7 +522,7 @@
* Used by {@link #tryAdvance(Consumer)} implementation only.
*/
@Override
- public void accept(final Feature feature) {
+ public void accept(final AbstractFeature feature) {
filteredFeature = feature;
}
@@ -533,7 +530,7 @@
* Executes the given action on the next feature in the {@code JoinFeatureSet}.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) {
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) {
for (;;) {
if (mainFeature == null) {
do if (!mainIterator.tryAdvance(this)) {
@@ -552,7 +549,7 @@
return true;
}
}
- final Feature feature = mainFeature;
+ final AbstractFeature feature = mainFeature;
closeFilteredIterator();
if (none && isOuterJoin) {
action.accept(join(feature, null));
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/Capability.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/Capability.java
index 36f7cc4..7a067c4 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/Capability.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/Capability.java
@@ -24,9 +24,9 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.InternationalString;
-import org.opengis.metadata.citation.Citation;
+// Specific to the main branch:
+import org.opengis.metadata.distribution.Format;
+import org.apache.sis.util.iso.Types;
/**
@@ -102,9 +102,13 @@
* Get a title for the format, followed by the short name between parenthesis
* if it does not repeat the main title.
*/
+ final Format format = provider.getFormat();
String title, complement;
try {
- title = title(provider.getFormat().getFormatSpecificationCitation()).toString(locale);
+ title = Types.toString(format.getSpecification(), locale);
+ if (title == null) {
+ title = Types.toString(format.getName(), locale);
+ }
complement = provider.getShortName();
} catch (BackingStoreException e) {
title = provider.getShortName();
@@ -118,16 +122,4 @@
}
return list;
}
-
- /**
- * Returns the title or alternate title of the given citation, or "untitled" if none.
- */
- private static InternationalString title(final Citation specification) {
- final InternationalString title = specification.getTitle();
- if (title != null) return title;
- for (final InternationalString t : specification.getAlternateTitles()) {
- if (t != null) return t;
- }
- return Vocabulary.formatInternational(Vocabulary.Keys.Untitled);
- }
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/LegalSymbols.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/LegalSymbols.java
index 4399710..ccc5360 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/LegalSymbols.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/LegalSymbols.java
@@ -229,7 +229,7 @@
constraints.getReferences().add(citation);
}
if (year != 0) {
- final var date = new DefaultCitationDate(Year.of(year), DateType.IN_FORCE);
+ final var date = new DefaultCitationDate(Year.of(year), DateType.valueOf("IN_FORCE"));
final var dates = citation.getDates();
if (!dates.contains(date)) {
dates.add(date);
@@ -246,8 +246,8 @@
final String owner = buffer.toString();
if (locale != null) {
for (final var cited : citation.getCitedResponsibleParties()) {
- if (cited.getRole() == Role.OWNER) {
- for (final var party : cited.getParties()) {
+ if (cited.getRole() == Role.OWNER && cited instanceof DefaultResponsibleParty) {
+ for (final var party : ((DefaultResponsibleParty) cited).getParties()) {
final var i18n = party.getName();
if (CharSequences.startsWith(owner, i18n.toString(Locale.ENGLISH), true)) {
/*
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MemoryFeatureSet.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MemoryFeatureSet.java
index 8b25894..c2b08a2 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MemoryFeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MemoryFeatureSet.java
@@ -23,9 +23,9 @@
import org.apache.sis.storage.Resource;
import org.apache.sis.storage.AbstractFeatureSet;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -39,24 +39,24 @@
/**
* The type specified at construction time and returned by {@link #getType()}.
*/
- private final FeatureType type;
+ private final DefaultFeatureType type;
/**
* The features specified at construction time, potentially as a modifiable collection.
- * For all features in this collection, {@link Feature#getType()} shall be {@link #type}.
+ * For all features in this collection, {@link AbstractFeature#getType()} shall be {@link #type}.
*/
- private final Collection<Feature> features;
+ private final Collection<AbstractFeature> features;
/**
* Creates a new set of features stored in memory. It is caller responsibility to ensure that
- * <code>{@linkplain Feature#getType()} == type</code> for all elements in the given collection
+ * <code>{@linkplain AbstractFeature#getType()} == type</code> for all elements in the given collection
* (this is not verified).
*
* @param parent the parent resource, or {@code null} if none.
* @param type the type of all features in the given collection.
* @param features collection of stored features. This collection will not be copied.
*/
- public MemoryFeatureSet(final Resource parent, final FeatureType type, final Collection<Feature> features) {
+ public MemoryFeatureSet(final Resource parent, final DefaultFeatureType type, final Collection<AbstractFeature> features) {
super(parent);
this.type = Objects.requireNonNull(type);
this.features = Objects.requireNonNull(features);
@@ -68,7 +68,7 @@
* @return a description of properties that are common to all features in this dataset.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return type;
}
@@ -89,7 +89,7 @@
* @return all features contained in this dataset.
*/
@Override
- public Stream<Feature> features(final boolean parallel) {
+ public Stream<AbstractFeature> features(final boolean parallel) {
return parallel ? features.parallelStream() : features.stream();
}
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
index 476d084..a307bc7 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
@@ -105,8 +105,8 @@
import org.apache.sis.pending.jdk.JDK21;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -1049,6 +1049,11 @@
if (abbreviation != null && abbreviation.length() != 0) {
if (format == null) try {
format = MetadataSource.getProvided().lookup(Format.class, abbreviation);
+ /*
+ * Additional step for converting deprecated "name" and "specification" into non-deprecated properties.
+ * This step is not required on SIS branches that depend on development branches of GeoAPI 3.1 or 4.0.
+ */
+ format = DefaultFormat.castOrCopy(format);
return true;
} catch (MetadataStoreException e) {
if (listeners != null) {
@@ -1088,7 +1093,7 @@
/**
* Adds information about the scope of the resource.
- * The scope is typically (but not restricted to) {@link ScopeCode#COVERAGE},
+ * The scope is typically (but not restricted to) {@code ScopeCode.COVERAGE},
* {@link ScopeCode#FEATURE} or the more generic {@link ScopeCode#DATASET}.
* Storage locations are:
*
@@ -1119,7 +1124,7 @@
* </ul>
*
* If a date already exists for the given type, then the earliest date is retained (oldest date are discarded)
- * except for {@link DateType#LAST_REVISION}, {@link DateType#LAST_UPDATE LAST_UPDATE} or any other date type
+ * except for {@code DateType.LAST_REVISION}, {@code DateType.LAST_UPDATE LAST_UPDATE} or any other date type
* prefixed by {@code "LATE_"}, where only the latest date is kept.
*
* @param date the date to add, or {@code null} for no-operation..
@@ -1141,12 +1146,12 @@
* If two dates are of the same type, retains the latest one if the type name starts with {@code "LATE_"}
* or retains the earliest date otherwise.
*/
- private static void addEarliest(final Collection<CitationDate> dates, final CitationDate date, final DateType type) {
+ private static void addEarliest(final Collection<CitationDate> dates, final DefaultCitationDate date, final DateType type) {
for (final Iterator<CitationDate> it = dates.iterator(); it.hasNext();) {
final CitationDate existing = it.next();
- if (type.equals(existing.getDateType())) {
+ if (type.equals(existing.getDateType()) && existing instanceof DefaultCitationDate) {
final int method = type.name().startsWith("LATE_") ? TimeMethods.BEFORE : TimeMethods.AFTER;
- if (TimeMethods.compareAny(method, existing.getReferenceDate(), date.getReferenceDate())) {
+ if (TimeMethods.compareAny(method, ((DefaultCitationDate) existing).getReferenceDate(), date.getReferenceDate())) {
it.remove();
break;
}
@@ -1876,7 +1881,7 @@
* Note that ISO-19115 considers 0 as an invalid value. Consequently, if 0, the feature is not added.
* @return the name of the added feature (even if not added to the metadata), or {@code null} if none.
*/
- public final GenericName addFeatureType(final FeatureType type, final long occurrences) {
+ public final GenericName addFeatureType(final DefaultFeatureType type, final long occurrences) {
if (type == null) {
return null;
}
@@ -2886,6 +2891,7 @@
* @see #addProcessing(CharSequence, String)
* @see #addProcessDescription(CharSequence)
*/
+ @SuppressWarnings("deprecation")
public final void addSource(final CharSequence description, final ScopeCode level, final CharSequence feature) {
final InternationalString i18n = trim(description);
if (i18n != null) {
@@ -2933,8 +2939,11 @@
source.setSourceReferenceSystem(CollectionsExt.first(metadata.getReferenceSystemInfo()));
for (final Identification id : metadata.getIdentificationInfo()) {
source.setSourceCitation(id.getCitation());
- source.setSourceSpatialResolution(CollectionsExt.first(id.getSpatialResolutions()));
- scope.setExtents(id.getExtents());
+ if (id instanceof AbstractIdentification) {
+ final AbstractIdentification aid = (AbstractIdentification) id;
+ source.setSourceSpatialResolution(CollectionsExt.first(aid.getSpatialResolutions()));
+ scope.setExtents(aid.getExtents());
+ }
if (features != null && features.length != 0) {
/*
* Note: the same ScopeDescription may be shared by many Source instances
@@ -3224,7 +3233,7 @@
*
* <ul>
* <li>{@code metadata/metadataLinkage/linkage}
- * with {@code function} set to {@link OnLineFunction#COMPLETE_METADATA}</li>
+ * with {@code function} set to {@code OnLineFunction.COMPLETE_METADATA}</li>
* </ul>
*
* @param link URL to a more complete description of the metadata, or {@code null}.
@@ -3232,7 +3241,7 @@
public final void addCompleteMetadata(final URI link) {
if (link != null) {
final var ln = new DefaultOnlineResource(link);
- ln.setFunction(OnLineFunction.COMPLETE_METADATA);
+ ln.setFunction(OnLineFunction.valueOf("COMPLETE_METADATA"));
ln.setProtocol(link.getScheme());
addIfNotPresent(metadata().getMetadataLinkages(), ln);
}
@@ -3309,22 +3318,10 @@
for (ResponsibleParty r : c.getCitedResponsibleParties()) {
addIfNotPresent(citation.getCitedResponsibleParties(), r);
}
- for (OnlineResource r : c.getOnlineResources()) {
- addIfNotPresent(citation.getOnlineResources(), r);
- }
citation.getPresentationForms().addAll(c.getPresentationForms());
}
@SuppressWarnings("LocalVariableHidesMemberVariable")
final DefaultDataIdentification identification = identification();
- for (Extent e : info.getExtents()) {
- addIfNotPresent(identification.getExtents(), e);
- }
- for (Resolution r : info.getSpatialResolutions()) {
- addIfNotPresent(identification.getSpatialResolutions(), r);
- }
- for (TemporalAmount r : info.getTemporalResolutions()) {
- addIfNotPresent(identification.getTemporalResolutions(), r);
- }
for (Format r : info.getResourceFormats()) {
addCompression(r.getFileDecompressionTechnique());
// Ignore format name (see Javadoc).
@@ -3332,8 +3329,23 @@
for (Constraints r : info.getResourceConstraints()) {
addIfNotPresent(identification.getResourceConstraints(), r);
}
- identification.getTopicCategories().addAll(info.getTopicCategories());
- identification.getSpatialRepresentationTypes().addAll(info.getSpatialRepresentationTypes());
+ if (info instanceof DataIdentification) {
+ final var di = (DataIdentification) info;
+ for (Extent e : di.getExtents()) {
+ addIfNotPresent(identification.getExtents(), e);
+ }
+ for (Resolution r : di.getSpatialResolutions()) {
+ addIfNotPresent(identification.getSpatialResolutions(), r);
+ }
+ identification.getTopicCategories().addAll(di.getTopicCategories());
+ identification.getSpatialRepresentationTypes().addAll(di.getSpatialRepresentationTypes());
+ }
+ if (info instanceof AbstractIdentification) {
+ final var di = (AbstractIdentification) info;
+ for (TemporalAmount r : di.getTemporalResolutions()) {
+ addIfNotPresent(identification.getTemporalResolutions(), r);
+ }
+ }
}
@SuppressWarnings("LocalVariableHidesMemberVariable")
final DefaultMetadata metadata = metadata();
@@ -3356,9 +3368,6 @@
addIfNotPresent(distribution().getDistributors(), r);
}
}
- for (Lineage info : component.getResourceLineages()) {
- addIfNotPresent(metadata.getResourceLineages(), info);
- }
}
/**
@@ -3403,9 +3412,9 @@
else if (source instanceof Extent) target = extent();
else if (source instanceof LegalConstraints) target = constraints();
else if (source instanceof Series) target = series();
- else if (source instanceof Responsibility) target = responsibility();
- else if (source instanceof Party) target = party();
- else if (source instanceof AttributeGroup) target = attributeGroup();
+ else if (source instanceof DefaultResponsibleParty) target = responsibility();
+ else if (source instanceof AbstractParty) target = party();
+ else if (source instanceof DefaultAttributeGroup) target = attributeGroup();
else if (source instanceof SampleDimension) target = sampleDimension();
else if (source instanceof GCPCollection) target = groundControlPoints();
else if (source instanceof Format) target = format();
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataFetcher.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataFetcher.java
index b9d249c..9cd1626 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataFetcher.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataFetcher.java
@@ -48,9 +48,9 @@
import org.apache.sis.util.collection.CodeListSet;
import org.apache.sis.temporal.TemporalDate;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
+// Specific to the main branch:
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.apache.sis.metadata.iso.DefaultMetadata;
/**
@@ -68,14 +68,14 @@
* Types of date to accept as a date of last update, in preference order.
*/
private static final DateType[] LAST_UPDATE_TYPES = {
- DateType.LAST_UPDATE,
- DateType.LAST_REVISION,
+ DateType.valueOf("LAST_UPDATE"),
+ DateType.valueOf("LAST_REVISION"),
DateType.REVISION,
- DateType.IN_FORCE,
- DateType.RELEASED,
- DateType.DISTRIBUTION,
+ DateType.valueOf("IN_FORCE"),
+ DateType.valueOf("RELEASED"),
+ DateType.valueOf("DISTRIBUTION"),
DateType.PUBLICATION,
- DateType.ADOPTED,
+ DateType.valueOf("ADOPTED"),
DateType.CREATION
};
@@ -205,9 +205,11 @@
public void accept(final Metadata info) {
if (info != null) {
forEach(MetadataFetcher::accept, info.getIdentificationInfo());
- forEach(MetadataFetcher::accept, info.getResourceLineages());
forEach(MetadataFetcher::accept, info.getAcquisitionInformation());
forEach(MetadataFetcher::accept, info.getSpatialRepresentationInfo());
+ if (info instanceof DefaultMetadata) {
+ forEach(MetadataFetcher::accept, ((DefaultMetadata) info).getResourceLineages());
+ }
}
}
@@ -241,8 +243,9 @@
* @param info the responsible party (not null).
* @return whether to stop iteration after the given object.
*/
- protected boolean accept(final Responsibility info) {
- party = addStrings(party, info.getParties(), Party::getName);
+ protected boolean accept(final ResponsibleParty info) {
+ party = addString(party, info.getIndividualName());
+ party = addString(party, info.getOrganisationName());
return false;
}
@@ -482,7 +485,7 @@
for (int i = lastUpdateType; --i >= 0;) {
if (LAST_UPDATE_TYPES[i].equals(type)) {
lastUpdateType = i;
- lastUpdate = date.getReferenceDate();
+ lastUpdate = TemporalDate.toTemporal(date.getDate());
if (i == 0) break search;
}
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/ResourceLineage.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/ResourceLineage.java
index 9abc7f6..709decc 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/ResourceLineage.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/ResourceLineage.java
@@ -31,8 +31,8 @@
import org.apache.sis.metadata.iso.maintenance.DefaultScope;
import static org.apache.sis.util.privy.CollectionsExt.nonNull;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.MetadataScope;
+// Specific to the main branch:
+import org.opengis.metadata.identification.DataIdentification;
/**
@@ -98,8 +98,8 @@
description = citation.getTitle();
}
}
- if (resolution == null) {
- for (final Resolution candidate : nonNull(info.getSpatialResolutions())) {
+ if (resolution == null && info instanceof DataIdentification) {
+ for (final Resolution candidate : nonNull(((DataIdentification) info).getSpatialResolutions())) {
if (candidate != null) {
resolution = candidate;
}
@@ -121,8 +121,7 @@
*/
private static ScopeCode getScopeLevel(final Metadata source) {
ScopeCode level = null;
- for (final MetadataScope ms : nonNull(source.getMetadataScopes())) {
- final ScopeCode c = ms.getResourceScope();
+ for (final ScopeCode c : nonNull(source.getHierarchyLevels())) {
if (c != null) {
if (level == null) {
level = c;
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/StoreUtilities.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/StoreUtilities.java
index 3b3a539..42e9aa2 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/StoreUtilities.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/StoreUtilities.java
@@ -54,8 +54,9 @@
import org.apache.sis.system.Modules;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.metadata.iso.identification.AbstractIdentification;
/**
@@ -197,7 +198,10 @@
GeneralEnvelope bounds = null;
if (metadata != null) {
for (final Identification identification : metadata.getIdentificationInfo()) {
- for (final Extent extent : identification.getExtents()) {
+ if (!(identification instanceof AbstractIdentification)) {
+ continue; // Following cast is specific to GeoAPI 3.0 branch.
+ }
+ for (final Extent extent : ((AbstractIdentification) identification).getExtents()) {
for (final GeographicExtent ge : extent.getGeographicElements()) {
if (ge instanceof GeographicBoundingBox) {
final GeneralEnvelope env = new GeneralEnvelope((GeographicBoundingBox) ge);
@@ -372,7 +376,7 @@
*/
public static void copy(final FeatureSet source, final WritableFeatureSet target) throws DataStoreException {
target.updateType(source.getType());
- try (Stream<Feature> stream = source.features(false)) {
+ try (Stream<AbstractFeature> stream = source.features(false)) {
target.add(stream.iterator());
}
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
index 425ea42..8d305cf 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
@@ -52,8 +52,8 @@
// Specific to the main and geoapi-3.1 branches:
import org.opengis.geometry.MismatchedDimensionException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridResource.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridResource.java
index 0b5c4e4..26edb6e 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridResource.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridResource.java
@@ -53,8 +53,8 @@
import static org.apache.sis.storage.base.TiledGridCoverage.X_DIMENSION;
import static org.apache.sis.storage.base.TiledGridCoverage.Y_DIMENSION;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/WritableGridCoverageSupport.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/WritableGridCoverageSupport.java
index c9d2790..5767d90 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/WritableGridCoverageSupport.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/WritableGridCoverageSupport.java
@@ -43,8 +43,8 @@
import org.apache.sis.util.Localized;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/FeatureIterator.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/FeatureIterator.java
index b3044e7..3a7a1e7 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/FeatureIterator.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/FeatureIterator.java
@@ -26,10 +26,10 @@
import org.apache.sis.util.ObjectConverters;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -50,7 +50,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-class FeatureIterator implements Spliterator<Feature> {
+class FeatureIterator implements Spliterator<AbstractFeature> {
/**
* Index of the column containing trajectory coordinates.
* Columns before the trajectory are Moving Feature identifier {@code mfIdRef}, start time and end time.
@@ -92,12 +92,12 @@
@SuppressWarnings({"unchecked", "rawtypes", "fallthrough"})
FeatureIterator(final Store store) {
this.store = store;
- final Collection<? extends PropertyType> properties = store.featureType.getProperties(true);
+ final Collection<? extends AbstractIdentifiedType> properties = store.featureType.getProperties(true);
converters = new ObjectConverter[properties.size()];
values = new Object[converters.length];
propertyNames = new String[converters.length];
int i = -1;
- for (final PropertyType p : properties) {
+ for (final AbstractIdentifiedType p : properties) {
propertyNames[++i] = p.getName().tip().toString();
/*
* According Moving Features specification:
@@ -135,7 +135,7 @@
*/
}
default: {
- c = ObjectConverters.find(String.class, ((AttributeType) p).getValueClass());
+ c = ObjectConverters.find(String.class, ((DefaultAttributeType) p).getValueClass());
break;
}
}
@@ -161,7 +161,7 @@
* is not guaranteed to cover a strict prefix of the elements.
*/
@Override
- public Spliterator<Feature> trySplit() {
+ public Spliterator<AbstractFeature> trySplit() {
if (splitCount == null) {
splitCount = new AtomicInteger();
}
@@ -175,7 +175,7 @@
* Executes the given action only on the next feature, if any.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) {
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) {
try {
return read(action, false);
} catch (IOException | IllegalArgumentException | DateTimeException e) {
@@ -187,7 +187,7 @@
* Executes the given action on all remaining features.
*/
@Override
- public void forEachRemaining(final Consumer<? super Feature> action) {
+ public void forEachRemaining(final Consumer<? super AbstractFeature> action) {
try {
read(action, true);
} catch (IOException | IllegalArgumentException | DateTimeException e) {
@@ -213,12 +213,12 @@
* @throws IllegalArgumentException if parsing of a number failed, or other error.
* @throws DateTimeException if parsing of a date failed.
*/
- private boolean read(final Consumer<? super Feature> action, final boolean all) throws IOException {
+ private boolean read(final Consumer<? super AbstractFeature> action, final boolean all) throws IOException {
final FixedSizeList elements = new FixedSizeList(values);
String line;
while ((line = store.readLine()) != null) {
Store.split(line, elements);
- final Feature feature = store.featureType.newInstance();
+ final AbstractFeature feature = store.featureType.newInstance();
int i, n = elements.size();
for (i=0; i<n; i++) {
values[i] = converters[i].apply((String) values[i]);
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureBuilder.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureBuilder.java
index e8d7999..070d408 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureBuilder.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureBuilder.java
@@ -31,9 +31,9 @@
import org.apache.sis.util.CorruptedObjectException;
import org.apache.sis.util.privy.UnmodifiableArrayList;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractAttribute;
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -112,7 +112,7 @@
/**
* Adds a time range.
- * The minimal and maximal values will be used by {@link #storeTimeRange(String, String, Feature)}.
+ * The minimal and maximal values will be used by {@link #storeTimeRange(String, String, AbstractFeature)}.
*
* @param startTime beginning in milliseconds since Java epoch of the period when the property value is valid.
* @param endTime end in milliseconds since Java epoch of the period when the property value is valid.
@@ -147,7 +147,7 @@
* @param endTime name of the property where to store the end time.
* @param dest feature where to store the start time and end time.
*/
- public final void storeTimeRange(final String startTime, final String endTime, final Feature dest) {
+ public final void storeTimeRange(final String startTime, final String endTime, final AbstractFeature dest) {
if (tmin < tmax) {
final Instant t = Instant.ofEpochMilli(tmin);
dest.setPropertyValue(startTime, t);
@@ -164,7 +164,7 @@
* @param dest attribute where to store the value.
*/
@SuppressWarnings("unchecked")
- public final <V> void storeAttribute(final int index, final Attribute<V> dest) {
+ public final <V> void storeAttribute(final int index, final AbstractAttribute<V> dest) {
int n = count[index];
final long[] times = new long[n];
final V[] values = (V[]) Array.newInstance(dest.getType().getValueClass(), n);
@@ -194,7 +194,7 @@
* source method name and logger name, then forward to a {@code WarningListener}.
*/
public final <G> void storeGeometry(final String featureName, final int index, final int dimension,
- final Geometries<G> factory, final Attribute<G> dest, final Consumer<LogRecord> warningListener)
+ final Geometries<G> factory, final AbstractAttribute<G> dest, final Consumer<LogRecord> warningListener)
{
int n = count[index];
final var vectors = new Vector[n];
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureIterator.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureIterator.java
index aa6ff8e..03efe5c 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureIterator.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/MovingFeatureIterator.java
@@ -24,9 +24,9 @@
import java.time.DateTimeException;
import java.io.IOException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractAttribute;
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -74,10 +74,10 @@
* This method can only be invoked after {@link #readMoving(Consumer, boolean)} completion.
* This method is ignored if the CSV file contains only static features.
*/
- Feature[] createMovingFeatures() {
+ AbstractFeature[] createMovingFeatures() {
int n = 0;
final int np = values.length - TRAJECTORY_COLUMN;
- final Feature[] features = new Feature[builders.size()];
+ final AbstractFeature[] features = new AbstractFeature[builders.size()];
for (final Map.Entry<String,MovingFeatureBuilder> entry : builders.entrySet()) {
features[n++] = createMovingFeature(entry.getKey(), entry.getValue(), np);
}
@@ -92,18 +92,18 @@
* @param np number of properties, ignoring the ones before the trajectory column.
*/
@SuppressWarnings("unchecked")
- private Feature createMovingFeature(final String featureName, final MovingFeatureBuilder mf, final int np) {
- final Feature feature = store.featureType.newInstance();
+ private AbstractFeature createMovingFeature(final String featureName, final MovingFeatureBuilder mf, final int np) {
+ final AbstractFeature feature = store.featureType.newInstance();
feature.setPropertyValue(propertyNames[0], featureName);
mf.storeTimeRange(propertyNames[1], propertyNames[2], feature);
int column = 0;
if (store.hasTrajectories()) {
mf.storeGeometry(featureName, column, store.spatialDimensionCount(), store.geometries,
- (Attribute) feature.getProperty(propertyNames[TRAJECTORY_COLUMN]), this);
+ (AbstractAttribute) feature.getProperty(propertyNames[TRAJECTORY_COLUMN]), this);
column++;
}
while (column < np) {
- mf.storeAttribute(column, (Attribute<?>) feature.getProperty(propertyNames[TRAJECTORY_COLUMN + column]));
+ mf.storeAttribute(column, (AbstractAttribute<?>) feature.getProperty(propertyNames[TRAJECTORY_COLUMN + column]));
column++;
}
return feature;
@@ -121,7 +121,7 @@
* @throws IllegalArgumentException if parsing of a number failed, or other error.
* @throws DateTimeException if parsing of a date failed.
*/
- boolean readMoving(final Consumer<? super Feature> action, final boolean all) throws IOException {
+ boolean readMoving(final Consumer<? super AbstractFeature> action, final boolean all) throws IOException {
final FixedSizeList elements = new FixedSizeList(values);
final int np = values.length - TRAJECTORY_COLUMN;
String line;
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/Store.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/Store.java
index b0d43af..75900f3 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/Store.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/csv/Store.java
@@ -74,11 +74,9 @@
import org.apache.sis.setup.OptionKey;
import org.apache.sis.measure.Units;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
/**
@@ -159,7 +157,7 @@
*
* @see #parseFeatureType(List)
*/
- final FeatureType featureType;
+ final DefaultFeatureType featureType;
/**
* {@code true} if {@link #featureType} contains a trajectory column.
@@ -209,7 +207,7 @@
* All parsed moving features, or {@code null} if none or if not yet parsed. If {@link #dissociate}
* is {@code false}, then this list will be created by {@link #features(boolean)} when first needed.
*/
- private transient List<Feature> movingFeatures;
+ private transient List<AbstractFeature> movingFeatures;
/**
* Creates a new CSV store from the given file, URL or stream.
@@ -228,7 +226,7 @@
geometries = Geometries.factory(connector.getOption(OptionKey.GEOMETRY_LIBRARY));
dissociate = connector.getOption(DataOptionKey.FOLIATION_REPRESENTATION) == FoliationRepresentation.FRAGMENTED;
@SuppressWarnings("LocalVariableHidesMemberVariable") GeneralEnvelope envelope = null;
- @SuppressWarnings("LocalVariableHidesMemberVariable") FeatureType featureType = null;
+ @SuppressWarnings("LocalVariableHidesMemberVariable") DefaultFeatureType featureType = null;
@SuppressWarnings("LocalVariableHidesMemberVariable") Foliation foliation = null;
try {
final List<String> elements = new ArrayList<>();
@@ -499,10 +497,10 @@
* @return the column metadata, or {@code null} if the given list does not contain enough elements.
*/
@SuppressWarnings("rawtypes") // "rawtypes" because of generic array creation.
- private FeatureType parseFeatureType(final List<String> elements) throws DataStoreException {
- AttributeType[] characteristics = null;
+ private DefaultFeatureType parseFeatureType(final List<String> elements) throws DataStoreException {
+ DefaultAttributeType[] characteristics = null;
final int size = elements.size();
- final List<PropertyType> properties = new ArrayList<>();
+ final List<AbstractIdentifiedType> properties = new ArrayList<>();
for (int i=1; i<size; i++) {
final String name = elements.get(i);
Class<?> type = null;
@@ -557,7 +555,7 @@
type = double[].class;
} else {
type = geometries.getGeometryClass(GeometryType.LINESTRING);
- characteristics = new AttributeType[] {MovingFeatureBuilder.TIME_AS_INSTANTS};
+ characteristics = new DefaultAttributeType[] {MovingFeatureBuilder.TIME_AS_INSTANTS};
}
minOccurrence = 1;
maxOccurrence = 1;
@@ -571,15 +569,15 @@
// Do not use Map.of(…) because `name` may be null. Let constructor throw the exception.
final String name = IOUtilities.filenameWithoutExtension(super.getDisplayName());
return new DefaultFeatureType(Collections.singletonMap(DefaultFeatureType.NAME_KEY, name),
- false, null, properties.toArray(PropertyType[]::new));
+ false, null, properties.toArray(AbstractIdentifiedType[]::new));
}
/**
* Creates a property type for the given name and type.
* This is a helper method for {@link #parseFeatureType(List)}.
*/
- private static PropertyType createProperty(final String name, final Class<?> type,
- final int minOccurrence, final int maxOccurrence, final AttributeType<?>[] characteristics)
+ private static AbstractIdentifiedType createProperty(final String name, final Class<?> type,
+ final int minOccurrence, final int maxOccurrence, final DefaultAttributeType<?>[] characteristics)
{
return new DefaultAttributeType<>(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name),
type, minOccurrence, maxOccurrence, null, characteristics);
@@ -662,7 +660,7 @@
* @return type of features in the CSV file.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return featureType;
}
@@ -677,7 +675,7 @@
* @todo If sequential order, publish Feature as soon as identifier changed.
*/
@Override
- public final synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException {
+ public final synchronized Stream<AbstractFeature> features(final boolean parallel) throws DataStoreException {
/*
* If the user asks for one feature instance per line, then we can return a FeatureIter instance directly.
* Since each feature is fully constructed from a single line and each line are read atomically, we can
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
index 55e7202..89f3c30 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
@@ -153,7 +153,7 @@
final MetadataBuilder builder = new MetadataBuilder();
builder.setPredefinedFormat(formatKey, listeners, true);
builder.addFormatReaderSIS(provider != null ? provider.getShortName() : null);
- builder.addResourceScope(ScopeCode.COVERAGE, null);
+ builder.addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
builder.addLanguage(Locale.ENGLISH, encoding, MetadataBuilder.Scope.METADATA);
builder.addSpatialRepresentation(null, gridGeometry, true);
builder.addExtent(gridGeometry.getEnvelope(), listeners);
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/WritableStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/WritableStore.java
index 66ca682..f47e705 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/WritableStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/WritableStore.java
@@ -41,8 +41,8 @@
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.StringBuilders;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
+// Specific to the main branch:
+import org.apache.sis.image.SequenceType;
/**
@@ -211,6 +211,7 @@
* "NaN" because the default is -9999, and we need to overwrite that default if it cannot be used.
*/
final ChannelDataOutput out = (output != null) ? output : h.channel(input().input);
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
final Number nodataValue = setCoverage(coverage, data, band);
header.put(NODATA_VALUE, nodataValue);
writeHeader(header, out);
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/Store.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/Store.java
index c172a02..11c61fc 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/Store.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/Store.java
@@ -259,7 +259,7 @@
public synchronized Metadata getMetadata() {
if (metadata == null) {
final var mb = new MetadataBuilder();
- mb.addResourceScope(ScopeCode.COLLECTION, Resources.formatInternational(Resources.Keys.DirectoryContent_1, getDisplayName()));
+ mb.addResourceScope(ScopeCode.valueOf("COLLECTION"), Resources.formatInternational(Resources.Keys.DirectoryContent_1, getDisplayName()));
mb.addLanguage(configuration.getOption(OptionKey.LOCALE),
configuration.getOption(OptionKey.ENCODING),
MetadataBuilder.Scope.RESOURCE);
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/StoreProvider.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/StoreProvider.java
index d653455..f036fc5 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/StoreProvider.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/folder/StoreProvider.java
@@ -50,6 +50,9 @@
import org.apache.sis.storage.base.StoreUtilities;
import org.apache.sis.setup.OptionKey;
+// Specific to the main branch:
+import org.apache.sis.parameter.DefaultParameterDescriptor;
+
/**
* The provider of {@link Store} instances. This provider is intentionally registered with lowest priority
@@ -117,7 +120,7 @@
* Creates a parameter descriptor equals to the given one except for the remarks which are set to the given value.
*/
private static <T> ParameterDescriptor<T> annotate(ParameterBuilder builder, ParameterDescriptor<T> e, InternationalString remark) {
- return builder.addName(e.getName()).setDescription(e.getDescription().orElse(null)).setRemarks(remark).create(e.getValueClass(), null);
+ return builder.addName(e.getName()).setDescription(((DefaultParameterDescriptor) e).getDescription().orElse(null)).setRemarks(remark).create(e.getValueClass(), null);
}
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WorldFileStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WorldFileStore.java
index b483426..6512182 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WorldFileStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WorldFileStore.java
@@ -533,7 +533,7 @@
}
builder.addFormatName(format); // Does nothing if `format` is null.
builder.addFormatReaderSIS(WorldFileStoreProvider.NAME);
- builder.addResourceScope(ScopeCode.COVERAGE, null);
+ builder.addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
builder.addSpatialRepresentation(null, getGridGeometry(MAIN_IMAGE), true);
if (gridGeometry.isDefined(GridGeometry.ENVELOPE)) {
builder.addExtent(gridGeometry.getEnvelope(), listeners);
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/xml/GeographicEnvelope.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/xml/GeographicEnvelope.java
index 1b21789..ba43baa 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/xml/GeographicEnvelope.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/xml/GeographicEnvelope.java
@@ -26,6 +26,11 @@
import org.apache.sis.geometry.AbstractEnvelope;
import org.apache.sis.referencing.CommonCRS;
+// Specific to the main branch:
+import org.opengis.metadata.extent.TemporalExtent;
+import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.util.InternationalString;
+
/**
* Base class of geographic bounding boxes to expose also as an envelope and an ISO 19115 extent.
@@ -109,6 +114,17 @@
}
/**
+ * Returns the spatial and temporal extent for the referring object.
+ * The default implementation unconditionally returns {@code null}.
+ *
+ * @return the spatial and temporal extent, or {@code null} in none.
+ */
+ @Override
+ public InternationalString getDescription() {
+ return null;
+ }
+
+ /**
* Provides geographic component of the extent of the referring object.
* The default implementation returns a singleton containing only this
* geographic bounding box.
@@ -121,6 +137,28 @@
}
/**
+ * Provides temporal component of the extent of the referring object.
+ * The default implementation unconditionally returns an empty set.
+ *
+ * @return the temporal extent, or an empty set if none.
+ */
+ @Override
+ public Collection<? extends TemporalExtent> getTemporalElements() {
+ return Collections.emptySet();
+ }
+
+ /**
+ * Provides vertical component of the extent of the referring object.
+ * The default implementation unconditionally returns an empty set.
+ *
+ * @return the vertical extent, or an empty set if none.
+ */
+ @Override
+ public Collection<? extends VerticalExtent> getVerticalElements() {
+ return Collections.emptySet();
+ }
+
+ /**
* Indication of whether the bounding box encompasses an area covered by the data
* (<dfn>inclusion</dfn>) or an area where data is not present (<dfn>exclusion</dfn>).
* The default implementation unconditionally returns {@link Boolean#TRUE}.
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/FeatureQueryTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/FeatureQueryTest.java
index 80ea1a7..bebf13e 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/FeatureQueryTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/FeatureQueryTest.java
@@ -36,19 +36,13 @@
import static org.apache.sis.test.Assertions.assertSetEquals;
import static org.apache.sis.test.Assertions.assertMessageContains;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.Operation;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.MatchAction;
-import org.opengis.filter.SortOrder;
-import org.opengis.filter.SortProperty;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.AbstractOperation;
+import org.apache.sis.filter.Expression;
/**
@@ -63,7 +57,7 @@
/**
* An arbitrary number of features, all of the same type.
*/
- private Feature[] features;
+ private AbstractFeature[] features;
/**
* The {@link #features} array wrapped in a in-memory feature set.
@@ -88,8 +82,8 @@
private void createFeatureWithIdentifier() {
final FeatureTypeBuilder ftb = new FeatureTypeBuilder().setName("Test");
ftb.addAttribute(String.class).setName("id").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- final FeatureType type = ftb.build();
- features = new Feature[] {
+ final DefaultFeatureType type = ftb.build();
+ features = new AbstractFeature[] {
type.newInstance()
};
features[0].setPropertyValue("id", "id-0");
@@ -106,15 +100,15 @@
// A dependency of the test feature type.
ftb = new FeatureTypeBuilder().setName("Dependency");
ftb.addAttribute(Integer.class).setName("value3");
- final FeatureType dependency = ftb.build();
+ final DefaultFeatureType dependency = ftb.build();
// Test feature type with attributes and association.
ftb = new FeatureTypeBuilder().setName("Test");
ftb.addAttribute(Integer.class).setName("value1");
ftb.addAttribute(Integer.class).setName("value2");
ftb.addAssociation(dependency).setName("dependency");
- final FeatureType type = ftb.build();
- features = new Feature[] {
+ final DefaultFeatureType type = ftb.build();
+ features = new AbstractFeature[] {
feature(type, null, 3, 1, 0),
feature(type, null, 2, 2, 0),
feature(type, dependency, 2, 1, 25),
@@ -128,14 +122,14 @@
* Creates an instance of the test feature type with the given values.
* The {@code value3} is stored only if {@code dependency} is non-null.
*/
- private static Feature feature(final FeatureType type, final FeatureType dependency,
+ private static AbstractFeature feature(final DefaultFeatureType type, final DefaultFeatureType dependency,
final int value1, final int value2, final int value3)
{
- final Feature f = type.newInstance();
+ final AbstractFeature f = type.newInstance();
f.setPropertyValue("value1", value1);
f.setPropertyValue("value2", value2);
if (dependency != null) {
- final Feature d = dependency.newInstance();
+ final AbstractFeature d = dependency.newInstance();
d.setPropertyValue("value3", value3);
f.setPropertyValue("dependency", d);
}
@@ -145,7 +139,7 @@
/**
* Configures the query for returning a single instance and returns that instance.
*/
- private Feature executeAndGetFirst() throws DataStoreException {
+ private AbstractFeature executeAndGetFirst() throws DataStoreException {
query.setLimit(1);
final FeatureSet subset = query.execute(featureSet);
return TestUtilities.getSingleton(subset.features(false).collect(Collectors.toList()));
@@ -159,11 +153,11 @@
*/
private void verifyQueryResult(final int... indices) throws DataStoreException {
final FeatureSet fs = query.execute(featureSet);
- final List<Feature> result = fs.features(false).collect(Collectors.toList());
+ final List<AbstractFeature> result = fs.features(false).collect(Collectors.toList());
assertEquals(indices.length, result.size());
for (int i=0; i<indices.length; i++) {
- final Feature expected = features[indices[i]];
- final Feature actual = result.get(i);
+ final AbstractFeature expected = features[indices[i]];
+ final AbstractFeature actual = result.get(i);
if (!expected.equals(actual)) {
fail(String.format("Unexpected feature at index %d%n"
+ "Expected:%n%s%n"
@@ -208,21 +202,6 @@
}
/**
- * Verifies the effect of {@link FeatureQuery#setSortBy(SortProperty[])}.
- *
- * @throws DataStoreException if an error occurred while executing the query.
- */
- @Test
- public void testSortBy() throws DataStoreException {
- createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
- query.setSortBy(ff.sort(ff.property("value1", Integer.class), SortOrder.ASCENDING),
- ff.sort(ff.property("value2", Integer.class), SortOrder.DESCENDING));
- assertXPathsEqual();
- verifyQueryResult(3, 1, 2, 0, 4);
- }
-
- /**
* Verifies the effect of {@link FeatureQuery#setSelection(Filter)}.
*
* @throws DataStoreException if an error occurred while executing the query.
@@ -230,9 +209,9 @@
@Test
public void testSelection() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setSelection(ff.equal(ff.property("value1", Integer.class),
- ff.literal(2), true, MatchAction.ALL));
+ ff.literal(2)));
assertXPathsEqual("value1");
verifyQueryResult(1, 2);
}
@@ -246,7 +225,7 @@
@Test
public void testSelectionThroughAssociation() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setSelection(ff.equal(ff.property("dependency/value3"), ff.literal(18)));
assertXPathsEqual("dependency/value3");
verifyQueryResult(3);
@@ -260,26 +239,26 @@
@Test
public void testProjection() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setProjection(new FeatureQuery.NamedExpression(ff.property("value1", Integer.class), (String) null),
new FeatureQuery.NamedExpression(ff.property("value1", Integer.class), "renamed1"),
new FeatureQuery.NamedExpression(ff.literal("a literal"), "computed"));
assertXPathsEqual("value1");
// Check result type.
- final Feature instance = executeAndGetFirst();
- final FeatureType resultType = instance.getType();
+ final AbstractFeature instance = executeAndGetFirst();
+ final DefaultFeatureType resultType = instance.getType();
assertEquals("Test", resultType.getName().toString());
assertEquals(3, resultType.getProperties(true).size());
- final PropertyType pt1 = resultType.getProperty("value1");
- final PropertyType pt2 = resultType.getProperty("renamed1");
- final PropertyType pt3 = resultType.getProperty("computed");
- assertTrue(pt1 instanceof AttributeType);
- assertTrue(pt2 instanceof AttributeType);
- assertTrue(pt3 instanceof AttributeType);
- assertEquals(Integer.class, ((AttributeType) pt1).getValueClass());
- assertEquals(Integer.class, ((AttributeType) pt2).getValueClass());
- assertEquals(String.class, ((AttributeType) pt3).getValueClass());
+ final AbstractIdentifiedType pt1 = resultType.getProperty("value1");
+ final AbstractIdentifiedType pt2 = resultType.getProperty("renamed1");
+ final AbstractIdentifiedType pt3 = resultType.getProperty("computed");
+ assertTrue(pt1 instanceof DefaultAttributeType);
+ assertTrue(pt2 instanceof DefaultAttributeType);
+ assertTrue(pt3 instanceof DefaultAttributeType);
+ assertEquals(Integer.class, ((DefaultAttributeType) pt1).getValueClass());
+ assertEquals(Integer.class, ((DefaultAttributeType) pt2).getValueClass());
+ assertEquals(String.class, ((DefaultAttributeType) pt3).getValueClass());
// Check feature instance.
assertEquals(3, instance.getPropertyValue("value1"));
@@ -297,8 +276,8 @@
createFeaturesWithAssociation();
query.setProjection("value2");
assertXPathsEqual("value2");
- final Feature instance = executeAndGetFirst();
- final PropertyType p = TestUtilities.getSingleton(instance.getType().getProperties(true));
+ final AbstractFeature instance = executeAndGetFirst();
+ final AbstractIdentifiedType p = TestUtilities.getSingleton(instance.getType().getProperties(true));
assertEquals("value2", p.getName().toString());
}
@@ -311,20 +290,20 @@
@Test
public void testDefaultColumnName() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setLimit(1);
query.setProjection(
ff.add(ff.property("value1", Number.class), ff.literal(1)),
ff.add(ff.property("value2", Number.class), ff.literal(1)));
assertXPathsEqual("value1", "value2");
final FeatureSet subset = featureSet.subset(query);
- final FeatureType type = subset.getType();
- final Iterator<? extends PropertyType> properties = type.getProperties(true).iterator();
+ final DefaultFeatureType type = subset.getType();
+ final Iterator<? extends AbstractIdentifiedType> properties = type.getProperties(true).iterator();
assertEquals("Unnamed #1", properties.next().getName().toString());
assertEquals("Unnamed #2", properties.next().getName().toString());
assertFalse(properties.hasNext());
- final Feature instance = TestUtilities.getSingleton(subset.features(false).collect(Collectors.toList()));
+ final AbstractFeature instance = TestUtilities.getSingleton(subset.features(false).collect(Collectors.toList()));
assertSame(type, instance.getType());
}
@@ -338,22 +317,22 @@
@Test
public void testProjectionOfAbstractType() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setProjection(new FeatureQuery.NamedExpression(ff.property("value1"), (String) null),
new FeatureQuery.NamedExpression(ff.property("/*/unknown"), "unexpected"));
assertXPathsEqual("value1", "/*/unknown");
// Check result type.
- final Feature instance = executeAndGetFirst();
- final FeatureType resultType = instance.getType();
+ final AbstractFeature instance = executeAndGetFirst();
+ final DefaultFeatureType resultType = instance.getType();
assertEquals("Test", resultType.getName().toString());
assertEquals(2, resultType.getProperties(true).size());
- final PropertyType pt1 = resultType.getProperty("value1");
- final PropertyType pt2 = resultType.getProperty("unexpected");
- assertTrue(pt1 instanceof AttributeType<?>);
- assertTrue(pt2 instanceof AttributeType<?>);
- assertEquals(Integer.class, ((AttributeType<?>) pt1).getValueClass());
- assertEquals(Object.class, ((AttributeType<?>) pt2).getValueClass());
+ final AbstractIdentifiedType pt1 = resultType.getProperty("value1");
+ final AbstractIdentifiedType pt2 = resultType.getProperty("unexpected");
+ assertTrue(pt1 instanceof DefaultAttributeType<?>);
+ assertTrue(pt2 instanceof DefaultAttributeType<?>);
+ assertEquals(Integer.class, ((DefaultAttributeType<?>) pt1).getValueClass());
+ assertEquals(Object.class, ((DefaultAttributeType<?>) pt2).getValueClass());
// Check feature property values.
assertEquals(3, instance.getPropertyValue("value1"));
@@ -369,12 +348,12 @@
@Test
public void testProjectionThroughAssociation() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setProjection(new FeatureQuery.NamedExpression(ff.property("value1"), (String) null),
new FeatureQuery.NamedExpression(ff.property("dependency/value3"), "value3"));
assertXPathsEqual("value1", "dependency/value3");
query.setOffset(2);
- final Feature instance = executeAndGetFirst();
+ final AbstractFeature instance = executeAndGetFirst();
assertEquals( 2, instance.getPropertyValue("value1"));
assertEquals(25, instance.getPropertyValue("value3"));
}
@@ -390,14 +369,14 @@
createFeatureWithIdentifier();
query.setProjection(AttributeConvention.IDENTIFIER);
assertXPathsEqual(AttributeConvention.IDENTIFIER);
- final Feature instance = executeAndGetFirst();
+ final AbstractFeature instance = executeAndGetFirst();
assertEquals("id-0", instance.getPropertyValue(AttributeConvention.IDENTIFIER));
}
/**
* Shortcut for creating expression for a projection computed on-the-fly.
*/
- private static FeatureQuery.NamedExpression virtualProjection(final Expression<Feature, ?> expression, final String alias) {
+ private static FeatureQuery.NamedExpression virtualProjection(final Expression<AbstractFeature, ?> expression, final String alias) {
return new FeatureQuery.NamedExpression(expression, Names.createLocalName(null, null, alias), FeatureQuery.ProjectionType.COMPUTING);
}
@@ -409,7 +388,7 @@
@Test
public void testVirtualProjection() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setProjection(
new FeatureQuery.NamedExpression(ff.property("value1", Integer.class), (String) null),
virtualProjection(ff.property("value1", Integer.class), "renamed1"),
@@ -417,23 +396,23 @@
assertXPathsEqual("value1");
// Check result type.
- final Feature instance = executeAndGetFirst();
- final FeatureType resultType = instance.getType();
+ final AbstractFeature instance = executeAndGetFirst();
+ final DefaultFeatureType resultType = instance.getType();
assertEquals("Test", resultType.getName().toString());
assertEquals(3, resultType.getProperties(true).size());
- final PropertyType pt1 = resultType.getProperty("value1");
- final PropertyType pt2 = resultType.getProperty("renamed1");
- final PropertyType pt3 = resultType.getProperty("computed");
- assertTrue(pt1 instanceof AttributeType<?>);
- assertTrue(pt2 instanceof Operation);
- assertTrue(pt3 instanceof Operation);
- final IdentifiedType result2 = ((Operation) pt2).getResult();
- final IdentifiedType result3 = ((Operation) pt3).getResult();
- assertEquals(Integer.class, ((AttributeType<?>) pt1).getValueClass());
- assertTrue(result2 instanceof AttributeType<?>);
- assertTrue(result3 instanceof AttributeType<?>);
- assertEquals(Integer.class, ((AttributeType<?>) result2).getValueClass());
- assertEquals(String.class, ((AttributeType<?>) result3).getValueClass());
+ final AbstractIdentifiedType pt1 = resultType.getProperty("value1");
+ final AbstractIdentifiedType pt2 = resultType.getProperty("renamed1");
+ final AbstractIdentifiedType pt3 = resultType.getProperty("computed");
+ assertTrue(pt1 instanceof DefaultAttributeType<?>);
+ assertTrue(pt2 instanceof AbstractOperation);
+ assertTrue(pt3 instanceof AbstractOperation);
+ final AbstractIdentifiedType result2 = ((AbstractOperation) pt2).getResult();
+ final AbstractIdentifiedType result3 = ((AbstractOperation) pt3).getResult();
+ assertEquals(Integer.class, ((DefaultAttributeType<?>) pt1).getValueClass());
+ assertTrue(result2 instanceof DefaultAttributeType<?>);
+ assertTrue(result3 instanceof DefaultAttributeType<?>);
+ assertEquals(Integer.class, ((DefaultAttributeType<?>) result2).getValueClass());
+ assertEquals(String.class, ((DefaultAttributeType<?>) result3).getValueClass());
// Check feature instance.
assertEquals(3, instance.getPropertyValue("value1"));
@@ -454,7 +433,7 @@
@Test
public void testIncorrectVirtualProjection() throws DataStoreException {
createFeaturesWithAssociation();
- final FilterFactory<Feature,?,?> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature,?,?> ff = DefaultFilterFactory.forFeatures();
query.setProjection(new FeatureQuery.NamedExpression(ff.property("value1", Integer.class), (String) null),
virtualProjection(ff.property("valueMissing", Integer.class), "renamed1"));
assertXPathsEqual("value1", "valueMissing");
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/ConcatenatedFeatureSetTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/ConcatenatedFeatureSetTest.java
index d3ef537..b0961db 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/ConcatenatedFeatureSetTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/ConcatenatedFeatureSetTest.java
@@ -34,9 +34,10 @@
import static org.apache.sis.metadata.Assertions.assertFeatureSourceEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.metadata.iso.DefaultMetadata;
/**
@@ -63,7 +64,7 @@
builder.addAttribute(String.class).setName("name");
builder.addAttribute(Integer.class).setName("population");
- final FeatureType ft = builder.build();
+ final DefaultFeatureType ft = builder.build();
final FeatureSet cfs = ConcatenatedFeatureSet.create(
new MemoryFeatureSet(null, ft, List.of(ft.newInstance(), ft.newInstance())),
new MemoryFeatureSet(null, ft, List.of(ft.newInstance())));
@@ -74,7 +75,7 @@
final Metadata md = cfs.getMetadata();
assertNotNull(md);
assertContentInfoEquals("City", 3, (FeatureCatalogueDescription) getSingleton(md.getContentInfo()));
- final Lineage lineage = getSingleton(md.getResourceLineages());
+ final Lineage lineage = getSingleton(((DefaultMetadata) md).getResourceLineages());
assertFeatureSourceEquals("City", new String[] {"City"}, getSingleton(lineage.getSources()));
}
@@ -93,32 +94,32 @@
builder.addAttribute(Integer.class).setName("value");
builder.setName("parent");
- final FeatureType superType = builder.build();
+ final DefaultFeatureType superType = builder.build();
builder.clear();
builder.setSuperTypes(superType);
builder.addAttribute(String.class).setName("label");
- final FeatureType t1 = builder.setName("t1").build();
- final FeatureType t2 = builder.setName("t2").build();
+ final DefaultFeatureType t1 = builder.setName("t1").build();
+ final DefaultFeatureType t2 = builder.setName("t2").build();
// Populate a feature set for first type.
- final Feature t1f1 = t1.newInstance();
+ final AbstractFeature t1f1 = t1.newInstance();
t1f1.setPropertyValue("value", 2);
t1f1.setPropertyValue("label", "first-first");
- final Feature t1f2 = t1.newInstance();
+ final AbstractFeature t1f2 = t1.newInstance();
t1f2.setPropertyValue("value", 3);
t1f2.setPropertyValue("label", "first-second");
final FeatureSet t1fs = new MemoryFeatureSet(null, t1, List.of(t1f1, t1f2));
// Populate a feature set for second type.
- final Feature t2f1 = t2.newInstance();
+ final AbstractFeature t2f1 = t2.newInstance();
t2f1.setPropertyValue("value", 3);
t2f1.setPropertyValue("label", "second-first");
- final Feature t2f2 = t2.newInstance();
+ final AbstractFeature t2f2 = t2.newInstance();
t2f2.setPropertyValue("value", 4);
t2f2.setPropertyValue("label", "second-second");
@@ -154,9 +155,9 @@
public void noCommonType() {
final FeatureTypeBuilder builder = new FeatureTypeBuilder();
builder.setName("super");
- final FeatureType mockSuperType = builder.build();
- final FeatureType firstType = builder.setSuperTypes(mockSuperType).setName("first").build();
- final FeatureType secondType = builder.clear().setName("second").build();
+ final DefaultFeatureType mockSuperType = builder.build();
+ final DefaultFeatureType firstType = builder.setSuperTypes(mockSuperType).setName("first").build();
+ final DefaultFeatureType secondType = builder.clear().setName("second").build();
final FeatureSet fs1 = new MemoryFeatureSet(null, firstType, List.of());
final FeatureSet fs2 = new MemoryFeatureSet(null, secondType, List.of());
var e = assertThrows(DataStoreContentException.class, () -> ConcatenatedFeatureSet.create(fs1, fs2),
@@ -175,7 +176,7 @@
"An empty concatenation has been created.");
assertNotNull(e);
final FeatureTypeBuilder builder = new FeatureTypeBuilder().setName("mock");
- final FeatureType mockType = builder.build();
+ final DefaultFeatureType mockType = builder.build();
final FeatureSet fs1 = new MemoryFeatureSet(null, mockType, List.of());
final FeatureSet set = ConcatenatedFeatureSet.create(fs1);
assertSame(fs1, set, "A concatenation has been created from a single type.");
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/JoinFeatureSetTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/JoinFeatureSetTest.java
index 29151b1..2fabfc1 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/JoinFeatureSetTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/aggregate/JoinFeatureSetTest.java
@@ -34,12 +34,12 @@
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.MatchAction;
+// Specific to the main branch:
+import org.apache.sis.filter.Filter;
+import org.apache.sis.feature.AbstractAttribute;
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.pending.geoapi.filter.BinaryComparisonOperator;
/**
@@ -68,7 +68,7 @@
builder.addAttribute( String.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
builder.addAttribute( String.class).setName("myNameSpace", "att1");
builder.addAttribute(Integer.class).setName("myNameSpace", "att2");
- final FeatureType type1 = builder.build();
+ final DefaultFeatureType type1 = builder.build();
featureSet1 = new MemoryFeatureSet(null, type1, List.of(
newFeature1(type1, "fid_1_0", "str1", 1),
newFeature1(type1, "fid_1_1", "str2", 2),
@@ -80,7 +80,7 @@
builder.addAttribute( String.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
builder.addAttribute(Integer.class).setName("otherNameSpace", "att3");
builder.addAttribute( Double.class).setName("otherNameSpace", "att4");
- final FeatureType type2 = builder.build();
+ final DefaultFeatureType type2 = builder.build();
featureSet2 = new MemoryFeatureSet(null, type2, List.of(
newFeature2(type2, "fid_2_0", 1, 10),
newFeature2(type2, "fid_2_1", 2, 20),
@@ -94,8 +94,8 @@
* Creates a new feature of type 1 with the given identifier and attribute values.
* This is a helper method for the constructor only.
*/
- private static Feature newFeature1(final FeatureType type, final String id, final String att1, final int att2) {
- final Feature f = type.newInstance();
+ private static AbstractFeature newFeature1(final DefaultFeatureType type, final String id, final String att1, final int att2) {
+ final AbstractFeature f = type.newInstance();
f.setPropertyValue(AttributeConvention.IDENTIFIER, id);
f.setPropertyValue("att1", att1);
f.setPropertyValue("att2", att2);
@@ -106,8 +106,8 @@
* Creates a new feature of type 2 with the given identifier and attribute values.
* This is a helper method for the constructor only.
*/
- private static Feature newFeature2(final FeatureType type, final String id, final int att3, final double att4) {
- final Feature f = type.newInstance();
+ private static AbstractFeature newFeature2(final DefaultFeatureType type, final String id, final int att3, final double att4) {
+ final AbstractFeature f = type.newInstance();
f.setPropertyValue(AttributeConvention.IDENTIFIER, id);
f.setPropertyValue("att3", att3);
f.setPropertyValue("att4", att4);
@@ -118,15 +118,15 @@
* Creates a new join feature set of the given type using the {@link #featureSet1} and {@link #featureSet2}.
*/
private FeatureSet create(final JoinFeatureSet.Type type) throws DataStoreException {
- final FilterFactory<Feature, Object, ?> factory = DefaultFilterFactory.forFeatures();
- final BinaryComparisonOperator<Feature> condition = factory.equal(
+ final DefaultFilterFactory<AbstractFeature, Object, ?> factory = DefaultFilterFactory.forFeatures();
+ final Filter<AbstractFeature> condition = factory.equal(
factory.property("att2", String.class),
- factory.property("att3", String.class),
- true, MatchAction.ANY);
+ factory.property("att3", String.class));
final Map<String,Object> properties = new HashMap<>(4);
assertNull(properties.put("name", "JoinSet"));
assertNull(properties.put("identifierDelimiter", " "));
- return new JoinFeatureSet(null, featureSet1, "s1", featureSet2, "s2", type, condition, properties);
+ return new JoinFeatureSet(null, featureSet1, "s1", featureSet2, "s2", type,
+ (BinaryComparisonOperator<AbstractFeature>) condition, properties);
}
/**
@@ -134,7 +134,7 @@
* then this method copies the features in a temporary list using parallelized paths
* before to return the stream of that list.
*/
- private Stream<Feature> stream(final FeatureSet col) throws DataStoreException {
+ private Stream<AbstractFeature> stream(final FeatureSet col) throws DataStoreException {
if (parallel) {
return col.features(true).collect(Collectors.toList()).stream();
} else {
@@ -145,7 +145,7 @@
/**
* Returns the identifier of the given feature.
*/
- private static String getId(final Feature feature) {
+ private static String getId(final AbstractFeature feature) {
return String.valueOf(feature.getPropertyValue(AttributeConvention.IDENTIFIER));
}
@@ -157,12 +157,12 @@
@Test
public void testInnerJoin() throws DataStoreException {
final FeatureSet col = create(JoinFeatureSet.Type.INNER);
- try (Stream<Feature> stream = stream(col)) {
- final Iterator<Feature> ite = stream.iterator();
+ try (Stream<AbstractFeature> stream = stream(col)) {
+ final Iterator<AbstractFeature> ite = stream.iterator();
int count = 0;
while (ite.hasNext()) {
count++;
- final Feature f = ite.next();
+ final AbstractFeature f = ite.next();
final String att1; // Expected value of "att1".
final int join; // Expected value of "att2" and "att3", on which the join operation is done.
final double att4; // Expected value of "att4".
@@ -173,12 +173,12 @@
case "fid_1_2 fid_2_3": att1 = "str3"; join = 3; att4 = 40; break;
default: fail("unexpected feature"); continue;
}
- final Feature c1 = (Feature) f.getPropertyValue("s1");
- final Feature c2 = (Feature) f.getPropertyValue("s2");
- assertEquals(att1, c1.getProperty("att1").getValue());
- assertEquals(join, c1.getProperty("att2").getValue());
- assertEquals(join, c2.getProperty("att3").getValue());
- assertEquals(att4, c2.getProperty("att4").getValue());
+ final AbstractFeature c1 = (AbstractFeature) f.getPropertyValue("s1");
+ final AbstractFeature c2 = (AbstractFeature) f.getPropertyValue("s2");
+ assertEquals(att1, ((AbstractAttribute) c1.getProperty("att1")).getValue());
+ assertEquals(join, ((AbstractAttribute) c1.getProperty("att2")).getValue());
+ assertEquals(join, ((AbstractAttribute) c2.getProperty("att3")).getValue());
+ assertEquals(att4, ((AbstractAttribute) c2.getProperty("att4")).getValue());
}
assertEquals(4, count, "Unexpected number of features.");
}
@@ -213,46 +213,46 @@
* @param nr 1 if testing outer right, 0 otherwise.
*/
private void testOuter(final FeatureSet col, final int nl, final int nr) throws DataStoreException {
- try (Stream<Feature> stream = stream(col)) {
- final Iterator<Feature> ite = stream.iterator();
+ try (Stream<AbstractFeature> stream = stream(col)) {
+ final Iterator<AbstractFeature> ite = stream.iterator();
int foundStr1 = 0, foundStr20 = 0, foundStr50 = 0, foundStr60 = 0,
foundStr3 = 0, foundStr21 = 0, foundStr51 = 0, foundStr61 = 0, count = 0;
while (ite.hasNext()) {
- final Feature f = ite.next();
- final Feature c1 = (Feature) f.getPropertyValue("s1");
- final Feature c2 = (Feature) f.getPropertyValue("s2");
+ final AbstractFeature f = ite.next();
+ final AbstractFeature c1 = (AbstractFeature) f.getPropertyValue("s1");
+ final AbstractFeature c2 = (AbstractFeature) f.getPropertyValue("s2");
if (c1 != null) {
- switch ((String) c1.getProperty("att1").getValue()) {
+ switch ((String) ((AbstractAttribute) c1.getProperty("att1")).getValue()) {
case "str1": {
- assertEquals( 1, c1.getProperty("att2").getValue());
- assertEquals( 1, c2.getProperty("att3").getValue());
- assertEquals(10d, c2.getProperty("att4").getValue());
+ assertEquals( 1, ((AbstractAttribute) c1.getProperty("att2")).getValue());
+ assertEquals( 1, ((AbstractAttribute) c2.getProperty("att3")).getValue());
+ assertEquals(10d, ((AbstractAttribute) c2.getProperty("att4")).getValue());
foundStr1++;
break;
}
case "str2": {
- assertEquals(2, c1.getProperty("att2").getValue());
- assertEquals(2, c2.getProperty("att3").getValue());
- double att4 = (Double) c2.getProperty("att4").getValue();
+ assertEquals(2, ((AbstractAttribute) c1.getProperty("att2")).getValue());
+ assertEquals(2, ((AbstractAttribute) c2.getProperty("att3")).getValue());
+ double att4 = (Double) ((AbstractAttribute) c2.getProperty("att4")).getValue();
if (att4 == 20) foundStr20++;
if (att4 == 30) foundStr21++;
break;
}
case "str3": {
- assertEquals( 3, c1.getProperty("att2").getValue());
- assertEquals( 3, c2.getProperty("att3").getValue());
- assertEquals(40d, c2.getProperty("att4").getValue());
+ assertEquals( 3, ((AbstractAttribute) c1.getProperty("att2")).getValue());
+ assertEquals( 3, ((AbstractAttribute) c2.getProperty("att3")).getValue());
+ assertEquals(40d, ((AbstractAttribute) c2.getProperty("att4")).getValue());
foundStr3++;
break;
}
case "str50": {
- assertEquals(50, c1.getProperty("att2").getValue());
+ assertEquals(50, ((AbstractAttribute) c1.getProperty("att2")).getValue());
assertNull(c2);
foundStr50++;
break;
}
case "str51": {
- assertEquals(51, c1.getProperty("att2").getValue());
+ assertEquals(51, ((AbstractAttribute) c1.getProperty("att2")).getValue());
assertNull(c2);
foundStr51++;
break;
@@ -263,14 +263,14 @@
}
}
} else {
- switch ((Integer) c2.getProperty("att3").getValue()) {
+ switch ((Integer) ((AbstractAttribute) c2.getProperty("att3")).getValue()) {
case 60: {
- assertEquals(c2.getProperty("att4").getValue(), 60d);
+ assertEquals(((AbstractAttribute) c2.getProperty("att4")).getValue(), 60d);
foundStr60++;
break;
}
case 61: {
- assertEquals(c2.getProperty("att4").getValue(), 61d);
+ assertEquals(((AbstractAttribute) c2.getProperty("att4")).getValue(), 61d);
foundStr61++;
break;
}
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java
index 9ef0405..dbbd619 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java
@@ -34,11 +34,11 @@
import static org.apache.sis.metadata.Assertions.assertPartyNameEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.content.FeatureCatalogueDescription;
-import org.opengis.metadata.content.FeatureTypeInfo;
-import org.opengis.metadata.constraint.LegalConstraints;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.metadata.iso.citation.DefaultCitationDate;
+import org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints;
+import org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription;
+import org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo;
/**
@@ -89,10 +89,14 @@
private static void verifyCopyrightParsing(final String notice) {
final var builder = new MetadataBuilder();
builder.parseLegalNotice(null, notice);
- final Citation ref = copyright(builder);
+ final var constraints = assertInstanceOf(DefaultLegalConstraints.class, getSingleton(getSingleton(
+ builder.build().getIdentificationInfo()).getResourceConstraints()));
+
+ assertEquals(Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints()));
+ final Citation ref = getSingleton(constraints.getReferences());
assertTitleEquals(notice, ref, "reference.title");
assertPartyNameEquals("John Smith", ref, "reference.citedResponsibleParty");
- assertEquals(Year.of(1992), getSingleton(ref.getDates()).getReferenceDate());
+ assertEquals(Year.of(1992), ((DefaultCitationDate) getSingleton(ref.getDates())).getReferenceDate());
}
/**
@@ -101,7 +105,7 @@
*/
private static Citation copyright(final MetadataBuilder builder) {
final var id = getSingleton(builder.build().getIdentificationInfo());
- final var constraints = assertInstanceOf(LegalConstraints.class, getSingleton(id.getResourceConstraints()));
+ final var constraints = assertInstanceOf(DefaultLegalConstraints.class, getSingleton(id.getResourceConstraints()));
assertEquals(Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints()));
return getSingleton(constraints.getReferences());
}
@@ -115,7 +119,7 @@
builder.parseLegalNotice(Locale.ENGLISH, "Copyright (C), John Smith, 1997. All rights reserved.");
builder.parseLegalNotice(Locale.FRENCH, "Copyright (C), John Smith, 1997. Tous droits réservés.");
final Citation ref = copyright(builder);
- assertEquals(Year.of(1997), getSingleton(ref.getDates()).getReferenceDate());
+ assertEquals(Year.of(1997), ((DefaultCitationDate) getSingleton(ref.getDates())).getReferenceDate());
assertPartyNameEquals("John Smith", ref, "reference.citedResponsibleParty");
final var title = ref.getTitle();
assertEquals("Copyright (C), John Smith, 1997. All rights reserved.", title.toString(Locale.ENGLISH));
@@ -123,7 +127,7 @@
}
/**
- * Tests {@link MetadataBuilder#addFeatureType(FeatureType, long)}.
+ * Tests {@link MetadataBuilder#addFeatureType(DefaultFeatureType, long)}.
*/
@Test
public void testAddFeatureType() {
@@ -136,7 +140,7 @@
/**
* Creates a new simple metadata with a single simple feature type and the given
- * {@linkplain FeatureTypeInfo#getFeatureInstanceCount() feature instance count}.
+ * {@linkplain DefaultFeatureTypeInfo#getFeatureInstanceCount() feature instance count}.
* Then, asserts that the value in the built metadata is compliant with a given control value.
*
* @param expected the feature instance count value we want to see in the metadata (control value).
@@ -154,8 +158,8 @@
assertTrue(metadata.getContentInfo().isEmpty());
} else {
final ContentInformation content = getSingleton(metadata.getContentInfo());
- final var catalog = assertInstanceOf(FeatureCatalogueDescription.class, content);
- final FeatureTypeInfo info = getSingleton(catalog.getFeatureTypeInfo());
+ final var catalog = assertInstanceOf(DefaultFeatureCatalogueDescription.class, content);
+ final DefaultFeatureTypeInfo info = getSingleton(catalog.getFeatureTypeInfo());
assertEquals(expected, info.getFeatureInstanceCount(), errorMessage);
}
}
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/csv/StoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/csv/StoreTest.java
index de9ed14..b4f73f8 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/csv/StoreTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/csv/StoreTest.java
@@ -39,11 +39,12 @@
import static org.apache.sis.test.TestUtilities.date;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.metadata.iso.identification.AbstractIdentification;
/**
@@ -108,7 +109,7 @@
try (Store store = open(true)) {
metadata = store.getMetadata();
}
- final Extent extent = getSingleton(getSingleton(metadata.getIdentificationInfo()).getExtents());
+ final Extent extent = getSingleton(((AbstractIdentification) getSingleton(metadata.getIdentificationInfo())).getExtents());
final GeographicBoundingBox bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements());
assertEquals(50.23, bbox.getWestBoundLongitude());
assertEquals(50.31, bbox.getEastBoundLongitude());
@@ -127,7 +128,7 @@
try (Store store = open(true)) {
verifyFeatureType(store.featureType, double[].class, 1);
assertEquals(Foliation.TIME, store.foliation);
- final Iterator<Feature> it = store.features(false).iterator();
+ final Iterator<AbstractFeature> it = store.features(false).iterator();
assertPropertyEquals(it.next(), "a", "12:33:51", "12:36:11", new double[] {11, 2, 12, 3}, "walking", 1);
assertPropertyEquals(it.next(), "b", "12:33:51", "12:36:51", new double[] {10, 2, 11, 3}, "walking", 2);
assertPropertyEquals(it.next(), "a", "12:36:11", "12:36:51", new double[] {12, 3, 10, 3}, "walking", 2);
@@ -156,7 +157,7 @@
try (Store store = open(false)) {
verifyFeatureType(store.featureType, Polyline.class, Integer.MAX_VALUE);
assertEquals(Foliation.TIME, store.foliation);
- final Iterator<Feature> it = store.features(false).iterator();
+ final Iterator<AbstractFeature> it = store.features(false).iterator();
assertPropertyEquals(it.next(), "a", "12:33:51", "12:36:51", new double[] {11, 2, 12, 3, 10, 3}, List.of("walking"), List.of(1, 2));
assertPropertyEquals(it.next(), "b", "12:33:51", "12:36:51", new double[] {10, 2, 11, 3}, List.of("walking"), List.of(2));
assertPropertyEquals(it.next(), "c", "12:33:51", "12:36:51", new double[] {12, 1, 10, 2, 11, 3}, List.of("vehicle"), List.of(1));
@@ -167,21 +168,21 @@
/**
* Verifies that the feature type is equal to the expected one.
*/
- private static void verifyFeatureType(final FeatureType type, final Class<?> geometryType, final int maxOccurs) {
- final Iterator<? extends PropertyType> it = type.getProperties(true).iterator();
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "mfidref", String.class, 1, 1);
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "startTime", Instant.class, 1, 1);
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "endTime", Instant.class, 1, 1);
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "trajectory", geometryType, 1, 1);
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "state", String.class, 0, maxOccurs);
- assertPropertyTypeEquals((AttributeType<?>) it.next(), "\"type\" code", Integer.class, 0, maxOccurs);
+ private static void verifyFeatureType(final DefaultFeatureType type, final Class<?> geometryType, final int maxOccurs) {
+ final Iterator<? extends AbstractIdentifiedType> it = type.getProperties(true).iterator();
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "mfidref", String.class, 1, 1);
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "startTime", Instant.class, 1, 1);
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "endTime", Instant.class, 1, 1);
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "trajectory", geometryType, 1, 1);
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "state", String.class, 0, maxOccurs);
+ assertPropertyTypeEquals((DefaultAttributeType<?>) it.next(), "\"type\" code", Integer.class, 0, maxOccurs);
assertFalse(it.hasNext());
}
/**
* Asserts that the given property type has the given information.
*/
- private static void assertPropertyTypeEquals(final AttributeType<?> p,
+ private static void assertPropertyTypeEquals(final DefaultAttributeType<?> p,
final String name, final Class<?> valueClass, final int minOccurs, final int maxOccurs)
{
assertEquals(name, p.getName().toString());
@@ -193,7 +194,7 @@
/**
* Asserts that the property of the given name in the given feature has expected information.
*/
- private void assertPropertyEquals(final Feature f, final String mfidref,
+ private void assertPropertyEquals(final AbstractFeature f, final String mfidref,
final String startTime, final String endTime, final double[] trajectory,
final Object state, final Object typeCode)
{
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/AsciiGridStoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/AsciiGridStoreTest.java
index 237d5a0..77eab42 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/AsciiGridStoreTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/AsciiGridStoreTest.java
@@ -37,8 +37,8 @@
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.Identification;
+// Specific to the main branch:
+import org.opengis.metadata.identification.DataIdentification;
/**
@@ -94,9 +94,7 @@
* Format information is hard-coded in "SpatialMetadata" database. Complete string should
* be "ESRI ArcInfo ASCII Grid format" but it depends on the presence of Derby dependency.
*/
- final Identification id = getSingleton(metadata.getIdentificationInfo());
- final String format = getSingleton(id.getResourceFormats()).getFormatSpecificationCitation().getTitle().toString();
- assertTrue(format.contains("ASCII Grid"), format);
+ final DataIdentification id = (DataIdentification) getSingleton(metadata.getIdentificationInfo());
/*
* This information should have been read from the PRJ file.
*/
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/image/WorldFileStoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/image/WorldFileStoreTest.java
index 8c5af76..eaf19f5 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/image/WorldFileStoreTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/image/WorldFileStoreTest.java
@@ -39,8 +39,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.identification.Identification;
+// Specific to the main branch:
+import org.opengis.metadata.identification.DataIdentification;
/**
@@ -100,9 +100,7 @@
*/
assertEquals("gradient", store.getIdentifier().get().toString());
final Metadata metadata = store.getMetadata();
- final Identification id = getSingleton(metadata.getIdentificationInfo());
- final String format = getSingleton(id.getResourceFormats()).getFormatSpecificationCitation().getTitle().toString();
- assertTrue(format.contains("PNG"), format);
+ final DataIdentification id = (DataIdentification) getSingleton(metadata.getIdentificationInfo());
assertEquals("WGS 84", getSingleton(metadata.getReferenceSystemInfo()).getName().getCode());
final var bbox = (GeographicBoundingBox) getSingleton(getSingleton(id.getExtents()).getGeographicElements());
assertEquals( -90, bbox.getSouthBoundLatitude());
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/CoverageReadConsistency.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/CoverageReadConsistency.java
index d461510..4f25fb3 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/CoverageReadConsistency.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/CoverageReadConsistency.java
@@ -401,8 +401,13 @@
* two-dimensional image, the following loop will be executed only once. If reading a 3D
* or 4D image, the loop is executed for all possible two-dimensional slices in the cube.
*/
- final long[] sliceMin = actualReadExtent.getLow() .getCoordinateValues();
- final long[] sliceMax = actualReadExtent.getHigh().getCoordinateValues();
+ final int sd = actualReadExtent.getDimension();
+ final long[] sliceMin = new long[sd];
+ final long[] sliceMax = new long[sd];
+ for (int i=0; i<sd; i++) {
+ sliceMin[i] = actualReadExtent.getLow(i);
+ sliceMax[i] = actualReadExtent.getHigh(i);
+ }
nextSlice: for (;;) {
System.arraycopy(sliceMin, BIDIMENSIONAL, sliceMax, BIDIMENSIONAL, dimension - BIDIMENSIONAL);
final PixelIterator itr = iterator(full, sliceMin, sliceMax, subsampling, subOffsets, allowSubsampling);
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/wkt/StoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/wkt/StoreTest.java
index d156296..a8d5b14 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/wkt/StoreTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/wkt/StoreTest.java
@@ -31,8 +31,8 @@
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/xml/StoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/xml/StoreTest.java
index 4420c2d..f5fd2a2 100644
--- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/xml/StoreTest.java
+++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/xml/StoreTest.java
@@ -32,8 +32,8 @@
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.TestUtilities.getSingleton;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.nio.charset.StandardCharsets;
+// Specific to the main branch:
+import org.opengis.metadata.identification.CharacterSet;
/**
@@ -73,7 +73,7 @@
" <gmd:onlineResource>\n" +
" <gmd:CI_OnlineResource>\n" +
" <gmd:linkage>\n" +
- " <gmd:URL>https://sis.apache.org</gmd:URL>\n" +
+ " <gmd:URL>http://sis.apache.org</gmd:URL>\n" +
" </gmd:linkage>\n" +
" <gmd:function>\n" +
" <gmd:CI_OnLineFunctionCode codeListValue=\"information\" codeSpace=\"fra\">Information</gmd:CI_OnLineFunctionCode>\n" +
@@ -102,17 +102,15 @@
metadata = store.getMetadata();
assertSame(metadata, store.getMetadata(), "Expected cached value.");
}
- final Responsibility resp = getSingleton(metadata.getContacts());
- final Party party = getSingleton(resp.getParties());
- final Contact contact = getSingleton(party.getContactInfo());
- final OnlineResource resource = getSingleton(contact.getOnlineResources());
+ final ResponsibleParty resp = getSingleton(metadata.getContacts());
+ final Contact contact = resp.getContactInfo();
+ final OnlineResource resource = contact.getOnlineResource();
- assertInstanceOf(Organisation.class, party, "party");
- assertEquals(Locale.ENGLISH, getSingleton(metadata.getLocalesAndCharsets().keySet()));
- assertEquals(StandardCharsets.UTF_8, getSingleton(metadata.getLocalesAndCharsets().values()));
+ assertEquals(Locale.ENGLISH, metadata.getLanguage());
+ assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet());
assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole());
- assertEquals("Apache SIS", String.valueOf(party.getName()));
- assertEquals("https://sis.apache.org", String.valueOf(resource.getLinkage()));
+ assertEquals("Apache SIS", String.valueOf(resp.getOrganisationName()));
+ assertEquals("http://sis.apache.org", String.valueOf(resource.getLinkage()));
assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
}
}
diff --git a/endorsed/src/org.apache.sis.util/main/module-info.java b/endorsed/src/org.apache.sis.util/main/module-info.java
index 3b01093..ddc371d 100644
--- a/endorsed/src/org.apache.sis.util/main/module-info.java
+++ b/endorsed/src/org.apache.sis.util/main/module-info.java
@@ -30,7 +30,7 @@
requires transitive java.sql;
requires transitive java.logging;
requires transitive java.measure;
- requires transitive org.opengis.geoapi.pending;
+ requires transitive org.opengis.geoapi;
provides javax.measure.spi.ServiceProvider
with org.apache.sis.measure.UnitServices;
@@ -126,7 +126,6 @@
org.apache.sis.referencing,
org.apache.sis.referencing.gazetteer,
org.apache.sis.feature,
- org.apache.sis.geometry, // In the "incubator" sub-project.
org.apache.sis.storage,
org.apache.sis.storage.xml,
org.apache.sis.storage.sql,
@@ -134,8 +133,6 @@
org.apache.sis.storage.geoheif, // In the "incubator" sub-project.
org.apache.sis.storage.geotiff,
org.apache.sis.storage.earthobservation,
- org.apache.sis.cql, // In the "incubator" sub-project.
- org.apache.sis.portrayal.map, // In the "incubator" sub-project.
org.apache.sis.portrayal,
org.apache.sis.storage.gdal, // In the "optional" sub-project.
org.apache.sis.storage.gsf, // In the "incubator" sub-project.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/IdentifiedObjectFormat.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/IdentifiedObjectFormat.java
index 66f04ba..6f7b5f8 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/IdentifiedObjectFormat.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/IdentifiedObjectFormat.java
@@ -27,8 +27,8 @@
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.privy.MetadataServices;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
@@ -60,7 +60,7 @@
*/
@Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
- final Identifier identifier = ((IdentifiedObject) obj).getName();
+ final ReferenceIdentifier identifier = ((IdentifiedObject) obj).getName();
if (identifier == null) {
return toAppendTo.append(Vocabulary.forLocale(locale).getString(Vocabulary.Keys.Unnamed));
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/LineAppender.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/LineAppender.java
index e59669e..77705e2 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/LineAppender.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/LineAppender.java
@@ -306,7 +306,6 @@
*
* @param lineSeparator the new line separator, or {@code null} for forwarding EOL <i>as-is</i>.
*
- * @see System#lineSeparator()
* @see Characters#isLineOrParagraphSeparator(int)
*/
public void setLineSeparator(final String lineSeparator) {
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/TabularFormat.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/TabularFormat.java
index fa2cdc2..14f980c 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/TabularFormat.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/io/TabularFormat.java
@@ -213,7 +213,7 @@
* <li>If present, {@code '?'} shall be the first character in the pattern.</li>
* <li>The repeated character (specified inside the pair of brackets) is mandatory.</li>
* <li>In the current implementation, the repeated character must be in the
- * {@linkplain Character#isBmpCodePoint(int) Basic Multilanguage Plane}.</li>
+ * Basic Multilanguage Plane.</li>
* <li>If {@code '/'} is present, anything on its right side shall be compliant
* with the {@link Pattern} syntax.</li>
* </ul>
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/CompoundDirectPositions.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/CompoundDirectPositions.java
index 02a0cab..d20a906 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/CompoundDirectPositions.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/CompoundDirectPositions.java
@@ -20,6 +20,9 @@
import org.opengis.geometry.DirectPosition;
import org.apache.sis.util.resources.Errors;
+// Specific to the main branch:
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
/**
* A sequence of {@code DirectPosition}s which is a view over arrays of coordinate values.
@@ -99,6 +102,26 @@
}
/**
+ * Returns {@code this} since this object is already a direct position.
+ *
+ * @return always {@code this}.
+ */
+ @Override
+ public DirectPosition getDirectPosition() {
+ return this;
+ }
+
+ /**
+ * Returns {@code null} since there is no CRS associated to this object.
+ *
+ * @return always {@code null}.
+ */
+ @Override
+ public CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return null;
+ }
+
+ /**
* Returns the number of dimensions.
*/
@Override
@@ -110,7 +133,23 @@
* Return the coordinate value at the given dimension.
*/
@Override
- public double getCoordinate(final int dimension) {
+ public double getOrdinate(final int dimension) {
return coordinates[dimension].doubleValue(index);
}
+
+ /**
+ * Not needed.
+ */
+ @Override
+ public double[] getCoordinate() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not needed.
+ */
+ @Override
+ public void setOrdinate(int dimension, double value) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Line.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Line.java
index 0b1c196..51246ba 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Line.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Line.java
@@ -26,8 +26,8 @@
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -310,14 +310,13 @@
for (final DirectPosition p : points) {
final int dimension = p.getDimension();
if (dimension != DIMENSION) {
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3,
- Strings.toIndexed("points", i), DIMENSION, dimension));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3,
+ Strings.toIndexed("points", i), DIMENSION, dimension));
}
i++;
final double x,y;
- if (!isNaN(y = p.getCoordinate(1)) && // Test first the dimension which is most likely to contain NaN.
- !isNaN(x = p.getCoordinate(0)))
+ if (!isNaN(y = p.getOrdinate(1)) && // Test first the dimension which is most likely to contain NaN.
+ !isNaN(x = p.getOrdinate(0)))
{
mean_x = mean_x.add(x, false);
mean_y = mean_y.add(y, false);
@@ -344,8 +343,8 @@
DoubleDouble mean_xy = DoubleDouble.ZERO;
for (final DirectPosition p : points) {
final double y, x;
- if (!isNaN(y = p.getCoordinate(1)) && // Test first the dimension which is most likely to contain NaN.
- !isNaN(x = p.getCoordinate(0)))
+ if (!isNaN(y = p.getOrdinate(1)) && // Test first the dimension which is most likely to contain NaN.
+ !isNaN(x = p.getOrdinate(0)))
{
var dx = DoubleDouble.of(x, true).subtract(mean_x); // Δx = x - mean_x
mean_x2 = mean_x2.add(dx.square()); // mean_x² += (Δx)²
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/MathFunctions.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/MathFunctions.java
index 0cefe14..6c61102 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/MathFunctions.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/MathFunctions.java
@@ -240,7 +240,7 @@
* returns directly the {@linkplain Math#abs(double) absolute value} of that element
* without computing {@code sqrt(v²)}, in order to avoid rounding error. This special case
* has been implemented because this method is often invoked for computing the length of
- * {@linkplain org.opengis.coverage.grid.RectifiedGrid#getOffsetVectors() offset vectors},
+ * offset vectors,
* typically aligned with the axes of a {@linkplain org.opengis.referencing.cs.CartesianCS
* Cartesian coordinate system}.
*
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Plane.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Plane.java
index dedfb85..aa1ee48 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Plane.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Plane.java
@@ -30,8 +30,8 @@
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -403,14 +403,13 @@
for (final DirectPosition p : points) {
final int dimension = p.getDimension();
if (dimension != DIMENSION) {
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedDimension_3,
- Strings.toIndexed("points", i), DIMENSION, dimension));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3,
+ Strings.toIndexed("points", i), DIMENSION, dimension));
}
i++;
- final double x = p.getCoordinate(0); if (Double.isNaN(x)) continue;
- final double y = p.getCoordinate(1); if (Double.isNaN(y)) continue;
- final double z = p.getCoordinate(2); if (Double.isNaN(z)) continue;
+ final double x = p.getOrdinate(0); if (Double.isNaN(x)) continue;
+ final double y = p.getOrdinate(1); if (Double.isNaN(y)) continue;
+ final double z = p.getOrdinate(2); if (Double.isNaN(z)) continue;
sum_x = sum_x .add(x, false);
sum_y = sum_y .add(y, false);
sum_z = sum_z .add(z, false);
@@ -518,9 +517,9 @@
} else {
if (!points.hasNext()) break;
final DirectPosition p = points.next();
- x = p.getCoordinate(0);
- y = p.getCoordinate(1);
- z = p.getCoordinate(2);
+ x = p.getOrdinate(0);
+ y = p.getOrdinate(1);
+ z = p.getOrdinate(2);
}
x = (x - mean_x) * sx;
y = (y - mean_y) * sy;
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Angle.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Angle.java
index bb3bc61..a53bc95 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Angle.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Angle.java
@@ -164,7 +164,7 @@
final AxisDirection dir = axis.getDirection();
final boolean isPositive = dir.equals(positive);
if (isPositive || dir.equals(negative)) {
- double value = position.getCoordinate(i);
+ double value = position.getOrdinate(i);
if (!isPositive) value = -value;
final Unit<?> unit = axis.getUnit();
if (unit != Units.DEGREE) try {
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/MeasurementRange.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/MeasurementRange.java
index 00b4bd8..054f752 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/MeasurementRange.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/MeasurementRange.java
@@ -258,13 +258,6 @@
* instead of {@code MeasurementRange}. Nevertheless this method may return {@code null} if a unit
* <em>should</em> exist but for some reason is unavailable.
*
- * <h4>Example</h4>
- * ISO 19115-1 {@code SampleDimension} specifies that its
- * {@linkplain org.opengis.metadata.content.SampleDimension#getUnits() unit} property is mandatory if the
- * {@linkplain org.opengis.metadata.content.SampleDimension#getMinValue() minimum value} or
- * {@linkplain org.opengis.metadata.content.SampleDimension#getMaxValue() maximum value} are provided.
- * Nevertheless it happens sometimes that this information is missing in metadata.
- *
* @return the unit of measurement, or {@code null}.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/NumberRange.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/NumberRange.java
index 2bfd8d3..f2a0d62 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/NumberRange.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/NumberRange.java
@@ -64,8 +64,8 @@
* <a href="https://en.wikipedia.org/wiki/Interval_%28mathematics%29">mathematical definition of interval</a>.
* It is closely related, while not identical, to the ISO 19123 (<cite>Coverage geometry and functions</cite>)
* definition of "ranges". At the difference of the parent {@link Range} class, which can be used only with
- * {@linkplain org.opengis.coverage.DiscreteCoverage discrete coverages}, the {@code NumberRange} class can
- * also be used with {@linkplain org.opengis.coverage.ContinuousCoverage continuous coverages}.
+ * discrete coverages, the {@code NumberRange} class can
+ * also be used with continuous coverages.
*
* <h2>Immutability and thread safety</h2>
* This class and the {@link MeasurementRange} subclasses are immutable, and thus inherently thread-safe.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
index 0ee5fbb..d6ae2f8 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
@@ -57,8 +57,8 @@
*
* <h2>Relationship with ISO 19123 definition of range</h2>
* The ISO 19123 standard (<cite>Coverage geometry and functions</cite>) defines the range as the set
- * (either finite or {@linkplain org.opengis.geometry.TransfiniteSet transfinite}) of feature attribute
- * values associated by a function (the {@linkplain org.opengis.coverage.Coverage coverage}) with the
+ * (either finite or transfinite) of feature attribute
+ * values associated by a function (the coverage) with the
* elements of the coverage domain. In other words, if we see a coverage as a function, then a range
* is the set of possible return values.
*
@@ -69,9 +69,8 @@
* is closely related, but not identical, to the ISO 19123 definition or range.</p>
*
* <p>Ranges are not necessarily numeric. Numeric and non-numeric ranges can be associated to
- * {@linkplain org.opengis.coverage.DiscreteCoverage discrete coverages}, while typically only
- * numeric ranges can be associated to {@linkplain org.opengis.coverage.ContinuousCoverage
- * continuous coverages}.</p>
+ * discrete coverages, while typically only
+ * numeric ranges can be associated to continuous coverages.</p>
*
* <h2>Immutability and thread safety</h2>
* This class and the {@link NumberRange} / {@link MeasurementRange} subclasses are immutable,
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/setup/GeometryLibrary.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/setup/GeometryLibrary.java
index 2af321a..acc07cb 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/setup/GeometryLibrary.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/setup/GeometryLibrary.java
@@ -93,24 +93,6 @@
JTS("JTS"),
/**
- * The SIS library. This open source library provides an object model
- * for a large set of geometry types but has limited geometric functions.
- * The library is available under Apache 2 license.
- *
- * <table class="sis">
- * <caption>Implementation classes</caption>
- * <tr><th>Geometry type</th> <th>Class name</th></tr>
- * <tr><td>Root geometry class</td> <td>{@code org.apache.sis.geometries.Geometry}</td></tr>
- * <tr><td>{@link GeometryType#POINT}</td> <td>{@code org.apache.sis.geometries.Point}</td></tr>
- * <tr><td>{@link GeometryType#LINEAR}</td> <td>{@code org.apache.sis.geometries.LineString}</td></tr>
- * <tr><td>{@link GeometryType#AREAL}</td> <td>{@code org.apache.sis.geometries.Polygon}</td></tr>
- * </table>
- *
- * @since 2.0 (temporary version number until this branch is released)
- */
- SIS("SIS"),
-
- /**
* The GeoAPI geometry interfaces.
* Since GeoAPI interfaces are implementation neutral, the actual implementation is currently unspecified
* (a future Apache SIS version may provide some control on that).
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
index 4c9a7d9..f4c1c8c 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
@@ -116,7 +116,7 @@
*
* @see org.apache.sis.util.Version
*/
- public static final int MINOR_VERSION = 9;
+ public static final int MINOR_VERSION = 5;
/**
* The prefix of all classnames in Apache SIS, including a trailing dot.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Supervisor.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Supervisor.java
index 648b2f3..3c29a48 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Supervisor.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Supervisor.java
@@ -56,7 +56,7 @@
* Java compiler to omit any dependency to this {@code Supervisor} class.
*/
@Configuration
- static final boolean ENABLED = true;
+ static final boolean ENABLED = false;
/**
* The JMX object name for the {@code Supervisor} service.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/AbstractInternationalString.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/AbstractInternationalString.java
index 72d0bff..a546c1c 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/AbstractInternationalString.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/AbstractInternationalString.java
@@ -38,7 +38,7 @@
* by a {@link org.opengis.util.CodeList} value. This can be done with:
*
* <ul>
- * <li>{@link org.apache.sis.util.iso.Types#getCodeTitle(ControlledVocabulary)} for getting
+ * <li>{@link org.apache.sis.util.iso.Types#getCodeTitle(CodeList)} for getting
* the {@link InternationalString} instance to store in a metadata property.</li>
* <li>{@link org.apache.sis.util.iso.Types#forCodeTitle(CharSequence)} for retrieving the
* {@link org.opengis.util.CodeList} previously stored as an {@code InternationalString}.</li>
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ArgumentChecks.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ArgumentChecks.java
index 8031a19..2d413d4 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ArgumentChecks.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ArgumentChecks.java
@@ -27,9 +27,8 @@
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.coverage.grid.GridEnvelope;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -771,7 +770,7 @@
if (cs != null) { // Should never be null, but let be safe.
final int dimension = cs.getDimension();
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -796,7 +795,7 @@
if (cs != null) {
final int dimension = cs.getDimension();
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -820,7 +819,7 @@
if (indices != null) {
final int dimension = indices.length;
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -842,7 +841,7 @@
if (vector != null) {
final int dimension = vector.length;
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -864,7 +863,7 @@
if (position != null) {
final int dimension = position.getDimension();
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -886,31 +885,7 @@
if (envelope != null) {
final int dimension = envelope.getDimension();
if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
- Errors.Keys.MismatchedDimension_3, name, expected, dimension));
- }
- }
- }
-
- /**
- * Ensures that the given grid envelope, if non-null, has the expected number of dimensions.
- * This method does nothing if the given grid envelope is null.
- *
- * @param name the name of the argument to be checked. Used only if an exception is thrown.
- * @param expected the expected number of dimensions.
- * @param envelope the grid envelope to check for its dimension, or {@code null}.
- * @throws MismatchedDimensionException if the given envelope is non-null and does
- * not have the expected number of dimensions.
- *
- * @since 1.3
- */
- public static void ensureDimensionMatches(final String name, final int expected, final GridEnvelope envelope)
- throws MismatchedDimensionException
- {
- if (envelope != null) {
- final int dimension = envelope.getDimension();
- if (dimension != expected) {
- throw new org.opengis.geometry.MismatchedDimensionException(Errors.format(
+ throw new MismatchedDimensionException(Errors.format(
Errors.Keys.MismatchedDimension_3, name, expected, dimension));
}
}
@@ -943,9 +918,8 @@
expectedSource = expectedTarget;
side = 1;
}
- throw new org.opengis.geometry.MismatchedDimensionException(
- Errors.format(Errors.Keys.MismatchedTransformDimension_4,
- name, side, expectedSource, dimension));
+ throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedTransformDimension_4,
+ name, side, expectedSource, dimension));
}
}
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
index 92e0be6..432b03b 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
@@ -27,6 +27,9 @@
import org.apache.sis.util.privy.CheckedArrayList;
import org.apache.sis.util.resources.Errors;
+// Specific to the main branch:
+import org.apache.sis.util.privy.CodeLists;
+
/**
* A specialized {@code Set} implementation for use with {@link CodeList} values.
@@ -135,7 +138,7 @@
public CodeListSet(final Class<E> elementType, final boolean fill) throws IllegalArgumentException {
this(elementType);
if (fill) {
- codes = POOL.unique(CodeList.values(elementType));
+ codes = POOL.unique(CodeLists.values(elementType));
int n = codes.length;
if (n < Long.SIZE) {
values = (1L << n) - 1;
@@ -166,7 +169,7 @@
final E valueOf(final int ordinal) {
E[] array = codes;
if (array == null || ordinal >= array.length) {
- codes = array = POOL.unique(CodeList.values(elementType));
+ codes = array = POOL.unique(CodeLists.values(elementType));
}
return array[ordinal];
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/CodeLists.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/CodeLists.java
index 323e2cb..271f6bd 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/CodeLists.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/CodeLists.java
@@ -25,29 +25,51 @@
import org.apache.sis.util.Characters.Filter;
import org.apache.sis.util.resources.Errors;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import java.lang.reflect.Array;
/**
* Implementation of some {@link org.apache.sis.util.iso.Types} methods needed by {@code org.apache.sis.util} module.
- * This class opportunistically implements {@link Predicate} interface, but this is an implementation details.
+ * This class opportunistically implements {@code CodeList.Filter} interface, but this is an implementation details.
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class CodeLists implements Predicate<CodeList<?>> {
+public final class CodeLists implements CodeList.Filter {
+ /**
+ * The name of bundle resources for code list titles.
+ * Keys are {@link CodeList#identifier()}.
+ */
+ public static final String RESOURCES = "org.apache.sis.metadata.iso.CodeLists";
+
/**
* The name to compare during filtering operation.
*/
private final String codename;
/**
+ * {@code true} if {@link CodeList#valueOf} is allowed to create new code lists.
+ */
+ private final boolean canCreate;
+
+ /**
* Creates a new filter for the specified code name.
*
* @param codename the name to compare during filtering operation.
*/
- private CodeLists(final String codename) {
+ private CodeLists(final String codename, final boolean canCreate) {
this.codename = codename;
+ this.canCreate = canCreate;
+ }
+
+ /**
+ * Returns the name of the code to create, or {@code null} if no new code list shall be created.
+ *
+ * @return the name specified at construction time.
+ */
+ @Override
+ public String codename() {
+ return canCreate ? codename : null;
}
/**
@@ -56,7 +78,7 @@
* @param code the code list candidate.
*/
@Override
- public boolean test(final CodeList<?> code) {
+ public boolean accept(final CodeList<?> code) {
for (final String candidate : code.names()) {
if (accept(candidate, codename)) {
return true;
@@ -89,15 +111,7 @@
return Enum.valueOf(enumType, name);
} catch (IllegalArgumentException e) {
final T[] values = enumType.getEnumConstants();
- if (values instanceof ControlledVocabulary[]) {
- for (final ControlledVocabulary code : (ControlledVocabulary[]) values) {
- for (final String candidate : code.names()) {
- if (accept(candidate, name)) {
- return enumType.cast(code);
- }
- }
- }
- } else if (values != null) {
+ if (values != null) {
for (final Enum<?> code : values) {
if (accept(code.name(), name)) {
return enumType.cast(code);
@@ -119,7 +133,7 @@
*/
public static <E extends CodeList<E>> E forCodeName(final Class<E> codeType, String name) {
name = Strings.trimOrNull(name);
- return (name != null) ? find(codeType, new CodeLists(name)) : null;
+ return (name != null) ? CodeList.valueOf(codeType, new CodeLists(name, false)) : null;
}
/**
@@ -131,12 +145,10 @@
* @return a code matching the given name, or {@code null} if none.
*/
public static <E extends CodeList<E>> E find(final Class<E> codeType, final Predicate<? super CodeList<?>> filter) {
- for (final E code : CodeList.values(codeType)) {
- if (filter.test(code)) {
- return code;
- }
- }
- return null;
+ return CodeList.valueOf(codeType, new CodeList.Filter() {
+ @Override public boolean accept(CodeList<?> code) {return filter.test(code);}
+ @Override public String codename() {return null;}
+ });
}
/**
@@ -155,9 +167,21 @@
if (name == null) {
return null;
}
- E code = forCodeName(codeType, name);
- if (code == null) try {
- code = codeType.cast(codeType.getMethod("valueOf", String.class).invoke(null, name));
+ return CodeList.valueOf(codeType, new CodeLists(name, true));
+ }
+
+ /**
+ * Returns all known values for the given type of code list or enumeration.
+ *
+ * @param <T> the compile-time type given as the {@code codeType} parameter.
+ * @param codeType the type of code list or enumeration.
+ * @return the list of values for the given code list or enumeration, or an empty array if none.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends CodeList<?>> T[] values(final Class<T> codeType) {
+ Object values;
+ try {
+ values = codeType.getMethod("values", (Class<?>[]) null).invoke(null, (Object[]) null);
} catch (InvocationTargetException e) {
final Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
@@ -166,13 +190,10 @@
if (cause instanceof Error) {
throw (Error) cause;
}
- // `CodeList.valueOf(String)` methods are not expected to throw checked exceptions.
throw new UndeclaredThrowableException(cause);
- } catch (IllegalAccessException e) {
- throw (InaccessibleObjectException) new InaccessibleObjectException(e.getMessage()).initCause(e);
- } catch (NoSuchMethodException | NullPointerException e) {
- throw new IllegalArgumentException(Errors.format(Errors.Keys.ElementNotFound_1, name), e);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ values = Array.newInstance(codeType, 0);
}
- return code;
+ return (T[]) values;
}
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/MetadataServices.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/MetadataServices.java
index de950c7..5dcd8f5 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/MetadataServices.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/MetadataServices.java
@@ -28,8 +28,8 @@
import org.apache.sis.system.OptionalDependency;
import org.apache.sis.util.CharSequences;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -116,10 +116,10 @@
* @param locale desired locale for the title.
* @return the title.
*
- * @see org.apache.sis.util.iso.Types#getCodeTitle(ControlledVocabulary)
+ * @see org.apache.sis.util.iso.Types#getCodeTitle(CodeList)
*/
- public String getCodeTitle(final ControlledVocabulary code, final Locale locale) {
- return CharSequences.camelCaseToSentence(code.name()).toString();
+ public String getCodeTitle(final CodeList<?> code, final Locale locale) {
+ return CharSequences.camelCaseToSentence(code.identifier()).toString();
}
/**
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/PropertyFormat.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/PropertyFormat.java
index 16c5849..8a34de6 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/PropertyFormat.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/PropertyFormat.java
@@ -35,8 +35,8 @@
import org.apache.sis.util.Localized;
import org.apache.sis.util.resources.Vocabulary;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -99,12 +99,12 @@
text = freeText(((InternationalString) value).toString(getLocale()));
} else if (value instanceof CharSequence) {
text = freeText(value.toString());
- } else if (value instanceof ControlledVocabulary) {
- text = MetadataServices.getInstance().getCodeTitle((ControlledVocabulary) value, getLocale());
- } else if (value instanceof Boolean) {
- text = Vocabulary.forLocale(getLocale()).getString((Boolean) value ? Vocabulary.Keys.True : Vocabulary.Keys.False);
+ } else if (value instanceof CodeList<?>) {
+ text = MetadataServices.getInstance().getCodeTitle((CodeList<?>) value, getLocale());
} else if (value instanceof Enum<?>) {
text = CharSequences.upperCaseToSentence(((Enum<?>) value).name());
+ } else if (value instanceof Boolean) {
+ text = Vocabulary.forLocale(getLocale()).getString((Boolean) value ? Vocabulary.Keys.True : Vocabulary.Keys.False);
} else if (value instanceof Type) {
appendName(((Type) value).getTypeName());
return;
@@ -121,7 +121,7 @@
final Locale locale = getLocale();
text = (locale != Locale.ROOT) ? ((Currency) value).getDisplayName(locale) : value.toString();
} else if (value instanceof Record) {
- appendCollection(((Record) value).getFields().values(), recursive);
+ appendCollection(((Record) value).getAttributes().values(), recursive);
return;
} else if (value instanceof Iterable<?>) {
appendCollection((Iterable<?>) value, recursive);
@@ -152,7 +152,7 @@
/**
* Invoked by {@link PropertyFormat} for formatting a value which has not been recognized as one of the types
* to be handled in a special way. Some of the types handled in a special way are {@link InternationalString},
- * {@link ControlledVocabulary}, {@link Enum}, {@link Type}, {@link Locale}, {@link TimeZone}, {@link Charset},
+ * {@link CodeList}, {@link Enum}, {@link Type}, {@link Locale}, {@link TimeZone}, {@link Charset},
* {@link Currency}, {@link Record}, {@link Iterable} and arrays. Other types should be handled by this method.
* In particular, {@link Number}, {@link java.util.Date} and {@link org.apache.sis.measure.Angle}
* are <strong>not</strong> handled by default by this {@link PropertyFormat} class and should be handled here.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/IndexedResourceBundle.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/IndexedResourceBundle.java
index c1baa05..20b0682 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/IndexedResourceBundle.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/IndexedResourceBundle.java
@@ -51,9 +51,6 @@
import org.apache.sis.measure.RangeFormat;
import org.apache.sis.measure.Range;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
-
/**
* {@link ResourceBundle} implementation accepting integers instead of strings for resource keys.
@@ -416,8 +413,8 @@
replacement = ((URI) element).getSchemeSpecificPart(); // For decoding encoded characters.
} else if (element instanceof Class<?>) {
replacement = Classes.getShortName(getPublicType((Class<?>) element));
- } else if (element instanceof ControlledVocabulary) {
- replacement = MetadataServices.getInstance().getCodeTitle((ControlledVocabulary) element, getLocale());
+ } else if (element instanceof CodeList<?>) {
+ replacement = MetadataServices.getInstance().getCodeTitle((CodeList<?>) element, getLocale());
} else if (element instanceof Range<?>) {
final Range<?> range = (Range<?>) element;
replacement = new RangeFormat(getLocale(), range.getElementType()).format(range);
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/ContentVerifier.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/ContentVerifier.java
new file mode 100644
index 0000000..7b572b7
--- /dev/null
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/ContentVerifier.java
@@ -0,0 +1,57 @@
+/*
+ * 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.test;
+
+import java.util.Map;
+import java.util.function.Predicate;
+import org.opengis.metadata.Metadata;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assumptions.abort;
+
+
+/**
+ * Place-holder for a GeoAPI 3.1 class. Used only for allowing the code to compile.
+ * For real test execution, see the development branches on GeoAPI 4.0-SNAPSHOT.
+ */
+@SuppressWarnings("doclint:missing")
+public class ContentVerifier {
+ public void addPropertyToIgnore(Class<?> type, String property) {
+ abort("This test requires GeoAPI 3.1.");
+ }
+
+ public void addPropertyToIgnore(Predicate<String> ignore) {
+ abort("This test requires GeoAPI 3.1.");
+ }
+
+ public void addExpectedValue(String property, Object value) {
+ abort("This test requires GeoAPI 3.1.");
+ }
+
+ @SafeVarargs
+ public final void addExpectedValues(final Map.Entry<String,?>... properties) {
+ abort("This test requires GeoAPI 3.1.");
+ }
+
+ public void addMetadataToVerify(Metadata actual) {
+ abort("This test requires GeoAPI 3.1.");
+ }
+
+ public void assertMetadataEquals() {
+ abort("This test requires GeoAPI 3.1.");
+ }
+}
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java
new file mode 100644
index 0000000..e39b5f3
--- /dev/null
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java
@@ -0,0 +1,248 @@
+/*
+ * 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.test;
+
+import java.util.Collection;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.util.InternationalString;
+import org.apache.sis.util.Static;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assertions.*;
+import org.opengis.test.Assert;
+
+
+/**
+ * Temporary class for test methods that are expected to be provided in next GeoAPI release.
+ * Those methods are defined in a separated class in order to make easier for us to identify
+ * which methods may be removed from SIS (actually moved to GeoAPI) in a future GeoAPI release.
+ *
+ * <p>This class is needed for Apache SIS main branch, since the later is linked to GeoAPI official release.
+ * But this class can be removed on Apache SIS branches which are linked to a GeoAPI development branch.</p>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+public final class GeoapiAssert extends Static {
+ /**
+ * A flag for code that are pending next GeoAPI release before to be enabled.
+ * This flag is always set to {@code false}, except occasionally just before
+ * a GeoAPI release for testing purpose. It shall be used as below:
+ *
+ * {@snippet lang="java" :
+ * if (PENDING_NEXT_GEOAPI_RELEASE) {
+ * // Do some stuff here.
+ * }
+ * }
+ *
+ * The intend is to make easier to identify test cases that fail with the current version
+ * of the {@code geoapi-conformance} module, but should pass with the development snapshot.
+ */
+ public static final boolean PENDING_NEXT_GEOAPI_RELEASE = false;
+
+ /**
+ * The keyword for unrestricted value in {@link String} arguments.
+ */
+ private static final String UNRESTRICTED = "##unrestricted";
+
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private GeoapiAssert() {
+ }
+
+ private static String nonNull(final String message) {
+ return (message != null) ? message.trim().concat(" ") : "";
+ }
+
+ /**
+ * Returns the concatenation of the given message with the given extension.
+ * This method returns the given extension if the message is null or empty.
+ *
+ * <p>Invoking this method is equivalent to invoking {@code nonNull(message) + ext},
+ * but avoid the creation of temporary objects in the common case where the message
+ * is null.</p>
+ *
+ * @param message the message, or {@code null}.
+ * @param ext the extension to append after the message.
+ * @return the concatenated string.
+ */
+ private static String concat(String message, final String ext) {
+ if (message == null || (message = message.trim()).isEmpty()) {
+ return ext;
+ }
+ return message + ' ' + ext;
+ }
+
+ /**
+ * Verifies if we expected a null value, then returns {@code true} if the value is null as expected.
+ */
+ private static boolean isNull(final Object expected, final Object actual, final String message) {
+ final boolean isNull = (actual == null);
+ if (isNull != (expected == null)) {
+ fail(concat(message, isNull ? "Value is null." : "Expected null."));
+ }
+ return isNull;
+ }
+
+ public static void assertPositive(final int value, final String message) {
+ Assert.assertPositive(message, value);
+ }
+
+ public static void assertStrictlyPositive(final int value, final String message) {
+ Assert.assertStrictlyPositive(message, value);
+ }
+
+ public static <T> void assertValidRange(final Comparable<T> minimum, final Comparable<T> maximum, final String message) {
+ Assert.assertValidRange(message, minimum, maximum);
+ }
+
+ public static void assertValidRange(final int minimum, final int maximum, final String message) {
+ Assert.assertValidRange(message, minimum, maximum);
+ }
+
+ public static void assertValidRange(final double minimum, final double maximum, final String message) {
+ Assert.assertValidRange(message, minimum, maximum);
+ }
+
+ public static <T> void assertBetween(final Comparable<T> minimum, final Comparable<T> maximum, T value, final String message) {
+ Assert.assertBetween(message, minimum, maximum, value);
+ }
+
+ public static void assertBetween(final int minimum, final int maximum, final int value, final String message) {
+ Assert.assertBetween(message, minimum, maximum, value);
+ }
+
+ public static void assertBetween(final double minimum, final double maximum, final double value, final String message) {
+ Assert.assertBetween(message, minimum, maximum, value);
+ }
+
+ public static void assertContains(final Collection<?> collection, final Object value, final String message) {
+ Assert.assertContains(message, collection, value);
+ }
+
+ /**
+ * Asserts that the title or an alternate title of the given citation is equal to the given string.
+ * This method is typically used for testing if a citation stands for the OGC, OGP or EPSG authority
+ * for instance. Such abbreviations are often declared as {@linkplain Citation#getAlternateTitles()
+ * alternate titles} rather than the main {@linkplain Citation#getTitle() title}, but this method
+ * tests both for safety.
+ *
+ * @param expected the expected title or alternate title.
+ * @param actual the citation to test.
+ * @param message header of the exception message in case of failure, or {@code null} if none.
+ */
+ public static void assertAnyTitleEquals(final String expected, final Citation actual, final String message) {
+ if (isNull(expected, actual, message)) {
+ return;
+ }
+ InternationalString title = actual.getTitle();
+ if (title != null && expected.equals(title.toString())) {
+ return;
+ }
+ for (final InternationalString t : actual.getAlternateTitles()) {
+ if (expected.equals(t.toString())) {
+ return;
+ }
+ }
+ fail(concat(message, '"' + expected + "\" not found in title or alternate titles."));
+ }
+
+ /**
+ * Asserts that the given identifier is equal to the given authority, code space, version and code.
+ * If any of the above-cited properties is {@code ""##unrestricted"}, then it will not be verified.
+ * This flexibility is useful in the common case where a test accepts any {@code version} value.
+ *
+ * @param authority the expected authority title or alternate title (may be {@code null}), or {@code "##unrestricted"}.
+ * @param codeSpace the expected code space (may be {@code null}), or {@code "##unrestricted"}.
+ * @param version the expected version (may be {@code null}), or {@code "##unrestricted"}.
+ * @param code the expected code value (may be {@code null}), or {@code "##unrestricted"}.
+ * @param actual the identifier to test.
+ * @param message header of the exception message in case of failure, or {@code null} if none.
+ */
+ public static void assertIdentifierEquals(final String authority, final String codeSpace, final String version,
+ final String code, final ReferenceIdentifier actual, final String message)
+ {
+ if (actual == null) {
+ fail(concat(message, "Identifier is null"));
+ } else {
+ if (!UNRESTRICTED.equals(authority)) assertAnyTitleEquals(authority, actual.getAuthority(), message);
+ if (!UNRESTRICTED.equals(codeSpace)) assertEquals(codeSpace, actual.getCodeSpace(), () -> concat(message, "Wrong code space"));
+ if (!UNRESTRICTED.equals(version)) assertEquals(version, actual.getVersion(), () -> concat(message, "Wrong version"));
+ if (!UNRESTRICTED.equals(code)) assertEquals(code, actual.getCode(), () -> concat(message, "Wrong code"));
+ }
+ }
+
+ /**
+ * Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.
+ *
+ * @param cs the coordinate system to test.
+ * @param expected the expected axis directions.
+ */
+ public static void assertAxisDirectionsEqual(final CoordinateSystem cs, final AxisDirection... expected) {
+ assertAxisDirectionsEqual(cs, expected, null);
+ }
+
+ /**
+ * Asserts that all axes in the given coordinate system are pointing toward the given directions,
+ * in the same order.
+ *
+ * @param cs the coordinate system to test.
+ * @param expected the expected axis directions.
+ * @param message header of the exception message in case of failure, or {@code null} if none.
+ */
+ public static void assertAxisDirectionsEqual(final CoordinateSystem cs, final AxisDirection[] expected, final String message) {
+ assertEquals(expected.length, cs.getDimension(), () -> concat(message, "Wrong coordinate system dimension."));
+ for (int i=0; i<expected.length; i++) {
+ final int ci = i; // Because lambda expressions require final values.
+ assertEquals(expected[i], cs.getAxis(i).getDirection(),
+ () -> concat(message, "Wrong axis direction at index" + ci + '.'));
+ }
+ }
+
+ /**
+ * Asserts that the given matrix is equal to the expected one, up to the given tolerance value.
+ *
+ * @param expected the expected matrix, which may be {@code null}.
+ * @param actual the matrix to compare, or {@code null}.
+ * @param tolerance the tolerance threshold.
+ * @param message header of the exception message in case of failure, or {@code null} if none.
+ *
+ * @see org.opengis.test.referencing.TransformTestCase#assertMatrixEquals(String, Matrix, Matrix, Matrix)
+ */
+ public static void assertMatrixEquals(final Matrix expected, final Matrix actual, final double tolerance, final String message) {
+ if (isNull(expected, actual, message)) {
+ return;
+ }
+ final int numRow = actual.getNumRow();
+ final int numCol = actual.getNumCol();
+ assertEquals(expected.getNumRow(), numRow, "numRow");
+ assertEquals(expected.getNumCol(), numCol, "numCol");
+ for (int j=0; j<numRow; j++) {
+ for (int i=0; i<numCol; i++) {
+ final double e = expected.getElement(j,i);
+ final double a = actual.getElement(j,i);
+ if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a) != Double.doubleToLongBits(e)) {
+ fail(nonNull(message) + "Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a);
+ }
+ }
+ }
+ }
+}
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java
index af47237..2a14dbd 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java
@@ -52,9 +52,11 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-import org.opengis.metadata.extent.GeographicExtent;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.operation.CoordinateOperation;
/**
@@ -354,7 +356,16 @@
* @return the single scope of the given object.
*/
public static String getScope(final IdentifiedObject object) {
- InternationalString scope = getSingleton(object.getDomains()).getScope();
+ final InternationalString scope;
+ if (object instanceof ReferenceSystem) {
+ scope = ((ReferenceSystem) object).getScope();
+ } else if (object instanceof Datum) {
+ scope = ((Datum) object).getScope();
+ } else if (object instanceof CoordinateOperation) {
+ scope = ((CoordinateOperation) object).getScope();
+ } else {
+ scope = null;
+ }
assertNotNull(scope, "Missing scope.");
return scope.toString();
}
@@ -367,9 +378,18 @@
* @return the single domain of validity of the given object.
*/
public static GeographicBoundingBox getDomainOfValidity(final IdentifiedObject object) {
- ObjectDomain domain = getSingleton(object.getDomains());
- GeographicExtent extent = getSingleton(domain.getDomainOfValidity().getGeographicElements());
- return assertInstanceOf(GeographicBoundingBox.class, extent);
+ final Extent extent;
+ if (object instanceof ReferenceSystem) {
+ extent = ((ReferenceSystem) object).getDomainOfValidity();
+ } else if (object instanceof Datum) {
+ extent = ((Datum) object).getDomainOfValidity();
+ } else if (object instanceof CoordinateOperation) {
+ extent = ((CoordinateOperation) object).getDomainOfValidity();
+ } else {
+ extent = null;
+ }
+ assertNotNull(extent, "Missing extent.");
+ return assertInstanceOf(GeographicBoundingBox.class, getSingleton(extent.getGeographicElements()));
}
/**
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/ClassesTest.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/ClassesTest.java
index 90397af..1564f4f 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/ClassesTest.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/ClassesTest.java
@@ -51,8 +51,6 @@
import java.awt.geom.Point2D;
import javax.print.attribute.standard.PrinterStateReason;
import javax.print.attribute.standard.PrinterStateReasons;
-import org.opengis.util.InternationalString;
-import org.opengis.metadata.extent.Extent;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.cs.EllipsoidalCS;
@@ -147,12 +145,7 @@
/**
* Dummy class for {@link #testGetLeafInterfaces()}.
*/
- @SuppressWarnings("deprecation")
- private abstract static class T1 implements GeographicCRS {
- @Override public InternationalString getScope() {return null;}
- @Override public Extent getDomainOfValidity() {return null;}
- }
- @SuppressWarnings("deprecation")
+ private abstract static class T1 implements GeographicCRS {}
private abstract static class T2 extends T1 implements SingleCRS, CoordinateOperation {}
private abstract static class T3 extends T2 implements Transformation {}
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
index 6f449ee..5a20b6c 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
@@ -213,7 +213,7 @@
public void testFill() {
final CodeListSet<AxisDirection> c = new CodeListSet<>(AxisDirection.class, true);
assertTrue(c.size() >= 32, "Expect at least 32 elements as of GeoAPI 3.0.");
- assertTrue(c.toString().startsWith("[AxisDirection.OTHER, AxisDirection.NORTH, "));
+ assertTrue(c.toString().startsWith("[AxisDirection[OTHER], AxisDirection[NORTH], "));
/*
* Testing the full array would be too long and may change in future GeoAPI version
* anyway. Actually the main interest of this test is to ensure that the toString()
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/LargeCodeList.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/LargeCodeList.java
index 17954d3..c3841a0 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/LargeCodeList.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/LargeCodeList.java
@@ -21,6 +21,10 @@
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
+// Specific to the main branch:
+import java.util.List;
+import java.util.ArrayList;
+
/**
* A code list containing more than 64 elements. This implementation can be used by tests
@@ -29,23 +33,27 @@
* @author Martin Desruisseaux (Geomatys)
*/
@SuppressWarnings("serial")
-public final class LargeCodeList extends CodeList<LargeCodeList> {
+public final class LargeCodeList extends CodeList<LargeCodeList> {
+ /**
+ * List of all enumerations of this type.
+ */
+ private static final List<LargeCodeList> VALUES = new ArrayList<>(100);
+
/**
* Creates 100 code list elements.
- * We need to construct values with {@code valueOf(String)} instead of the constructor
- * because this package is not exported to GeoAPI. See {@link CodeList} class javadoc.
*/
static {
- for (int i=0; i<80; i++) {
- assertEquals(i, valueOf("LC#" + i).ordinal());
+ for (int i=0; i<100; i++) {
+ assertEquals(i, new LargeCodeList(i).ordinal());
}
}
/**
- * Constructs an element.
+ * Constructs an element. The new element is automatically
+ * added to the list to be returned by {@link #values}.
*/
- private LargeCodeList(String name) {
- super(name);
+ private LargeCodeList(final int i) {
+ super("LC#" + i, VALUES);
}
/**
@@ -54,7 +62,9 @@
* @return the list of codes declared in the current JVM.
*/
public static LargeCodeList[] values() {
- return values(LargeCodeList.class);
+ synchronized (VALUES) {
+ return VALUES.toArray(LargeCodeList[]::new);
+ }
}
/**
@@ -74,6 +84,6 @@
* @return a code list element matching the given name.
*/
public static LargeCodeList valueOf(final String code) {
- return valueOf(LargeCodeList.class, code, LargeCodeList::new).get();
+ return valueOf(LargeCodeList.class, code);
}
}
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/TreeTableFormatTest.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/TreeTableFormatTest.java
index 5f740a7..0befdb8 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/TreeTableFormatTest.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/TreeTableFormatTest.java
@@ -252,7 +252,7 @@
tf = new TreeTableFormat(Locale.FRENCH, null);
assertMultilinesEquals(
"Root\n" +
- " ├─CodeList…… Point de contact\n" +
+ " ├─CodeList…… Point of contact\n" + // Not yet localized.
" ├─Enum……………… Half down\n" + // No localization provided.
" └─i18n……………… Une phrase en français\n", tf.format(table));
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/resources/IndexedResourceBundleTest.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/resources/IndexedResourceBundleTest.java
index 8dfa432..4b4d794 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/resources/IndexedResourceBundleTest.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/resources/IndexedResourceBundleTest.java
@@ -158,7 +158,6 @@
/**
* Tests the {@link IndexedResourceBundle#getString(short, Object)} method with a {@code CodeList} argument.
- * The intent is to test the code list localization.
*/
@Test
public void testGetStringWithCodeList() {
diff --git a/geoapi/README.md b/geoapi/README.md
deleted file mode 100644
index 691b236..0000000
--- a/geoapi/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# GeoAPI snapshot
-
-The Apache SIS source code repository has two branches, named `geoapi-3.1` and `geoapi-4.0`,
-which depend on [GeoAPI](https://www.geoapi.org/) versions that are still in development.
-Those GeoAPI versions are not deployed on Maven Central, because they are not yet officially approved OGC releases.
-The Apache SIS branches that use those versions are never deployed on Maven Central neither.
-Official Apache SIS releases are made from the `main` branch, which depends on the standard GeoAPI 3.0.2 release only.
-
-The Apache SIS `geoapi-3.1` and `geoapi-4.0` branches are nevertheless useful for testing latest GeoAPI developments.
-The implementation experience gained is used for adjusting the GeoAPI interfaces before submission as an OGC standard.
-For making possible to compile against GeoAPI 3.1/4.0 without deployment on Maven Central, GeoAPI must be compiled locally.
-This is done in this directory with a Git sub-module, which fetch GeoAPI at a specific commit identified by a SHA1.
-The commit SHA1 is updated when needed for keeping Apache SIS `geoapi-xxx` branches in sync with the GeoAPI snapshot they implement.
-
-## Git commands
-Following command should be executed once after a fresh checkout of SIS `geoapi-3.1` or `geoapi-4.0` branch:
-
-```bash
-git submodule update --init
-```
-
-After above initialization, the usual `git pull` command should upgrade GeoAPI snapshot as well when needed.
-If a Git error message said that the SHA1 is unknown, running `git fetch --recurse-submodules` first may help.
-
-## Prerequisites
-Maven must be available on the classpath.
-The GeoAPI snapshot is built by a call to `mvn clean install`.
-This call is done automatically by the Gradle build.
diff --git a/geoapi/build.gradle.kts b/geoapi/build.gradle.kts
deleted file mode 100644
index 3ce4abe..0000000
--- a/geoapi/build.gradle.kts
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-tasks.register<Exec>("rebuild") {
- setWorkingDir(file("snapshot"))
- commandLine("mvn", "clean", "install")
- /*
- * The following are used by Gradle for deciding if the GeoAPI project needs to be rebuilt.
- * We declare only the modules of interest to Apache SIS. Changes in other modules will not
- * trigger a rebuild.
- */
- inputs.dir("snapshot/geoapi/src/main")
- inputs.dir("snapshot/geoapi-pending/src/main")
- inputs.dir("snapshot/geoapi-conformance/src/main")
-
- outputs.file("snapshot/geoapi-pending/target/geoapi-pending-3.1-SNAPSHOT.jar")
- outputs.file("snapshot/geoapi-conformance/target/geoapi-conformance-3.1-SNAPSHOT.jar")
-}
diff --git a/geoapi/snapshot b/geoapi/snapshot
deleted file mode 160000
index 8170551..0000000
--- a/geoapi/snapshot
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 8170551f45eac993404798f839e9cc5e5cbf8f75
diff --git a/gradle.properties b/gradle.properties
index e9b032a..2ee99b3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,7 +3,7 @@
# This file provides a single location where version number
# and deployment URL can be changed before new tags.
#
-version=1.x-SNAPSHOT
+version=1.5-SNAPSHOT
# Following identifiers should match <server> elements in the Maven settings.xml file.
# They are used for fetching the credentials for publishing binaries in a repository.
diff --git a/incubator/build.gradle.kts b/incubator/build.gradle.kts
index 61159ab..b0c48e4 100644
--- a/incubator/build.gradle.kts
+++ b/incubator/build.gradle.kts
@@ -48,7 +48,6 @@
api(files("../endorsed/build/classes/java/main/org.apache.sis.feature"))
api(files("../endorsed/build/classes/java/main/org.apache.sis.storage"))
api(files("../endorsed/build/classes/java/main/org.apache.sis.storage.sql"))
- api(files("../endorsed/build/classes/java/main/org.apache.sis.portrayal"))
// Test dependencies
testImplementation(tests.junit5)
@@ -76,9 +75,6 @@
* replace ANTLR generated code by hand-written code in a future version.
*/
var srcDir = file("src") // Must be the same as the hard-coded value in `BuildHelper.java`.
-tasks.generateGrammarSource {
- setOutputDirectory(file("${srcDir}/org.apache.sis.cql/main"))
-}
tasks.compileJava {
dependsOn(":endorsed:compileJava")
options.release.set(22) // The version of both Java source code and compiled byte code.
@@ -124,14 +120,8 @@
* an internal API.
*/
// ――――――――――――― Module name ――――――――――――――――――――――― Package to export ―――――――――――――――
- addExport(args, "org.apache.sis.feature", "org.apache.sis.geometry.wrapper.jts",
- "org.apache.sis.portrayal.map")
-
addExport(args, "org.apache.sis.feature", "org.apache.sis.geometry.wrapper",
"org.apache.sis.storage.geopackage")
-
- addExport(args, "org.apache.sis.storage", "org.apache.sis.storage.base",
- "org.apache.sis.portrayal.map")
}
/*
@@ -142,7 +132,6 @@
args.add("--enable-native-access")
args.add("org.apache.sis.storage.gsf")
addExportForTests(args)
- addExport(args, "org.apache.sis.cql", "org.apache.sis.cql", "ALL-UNNAMED")
setAllJvmArgs(args)
testLogging {
events("FAILED", "STANDARD_OUT", "STANDARD_ERROR")
@@ -159,30 +148,6 @@
*/
publishing {
publications {
- create<MavenPublication>("cql") {
- var module = "org.apache.sis.cql"
- groupId = "org.apache.sis.core"
- artifactId = "sis-cql"
- artifact(layout.buildDirectory.file("libs/${module}.jar"))
- artifact(layout.buildDirectory.file("docs/${module}-sources.jar")) {classifier = "sources"}
- artifact(layout.buildDirectory.file("docs/${module}-javadoc.jar")) {classifier = "javadoc"}
- pom {
- name = "Apache SIS CQL"
- description = "CQL parser."
- }
- }
- create<MavenPublication>("geometry") {
- var module = "org.apache.sis.geometry"
- groupId = "org.apache.sis.core"
- artifactId = "sis-geometry"
- artifact(layout.buildDirectory.file("libs/${module}.jar"))
- artifact(layout.buildDirectory.file("docs/${module}-sources.jar")) {classifier = "sources"}
- artifact(layout.buildDirectory.file("docs/${module}-javadoc.jar")) {classifier = "javadoc"}
- pom {
- name = "Apache SIS Geometry"
- description = "Geometry API."
- }
- }
create<MavenPublication>("storage.shapefile") {
var module = "org.apache.sis.storage.shapefile"
groupId = "org.apache.sis.storage"
@@ -243,18 +208,6 @@
description = "Read and write files in the JSON Coverage format."
}
}
- create<MavenPublication>("portrayal.map") {
- var module = "org.apache.sis.portrayal.map"
- groupId = "org.apache.sis.core"
- artifactId = "sis-portrayal-map"
- artifact(layout.buildDirectory.file("libs/${module}.jar"))
- artifact(layout.buildDirectory.file("docs/${module}-sources.jar")) {classifier = "sources"}
- artifact(layout.buildDirectory.file("docs/${module}-javadoc.jar")) {classifier = "javadoc"}
- pom {
- name = "Apache SIS portrayal"
- description = "Symbology and map representations, together with a rendering engine for display."
- }
- }
create<MavenPublication>("webapp") {
var module = "org.apache.sis.webapp"
groupId = "org.apache.sis.application"
diff --git a/incubator/src/main/antlr/org/apache/sis/cql/internal/CQL.g4 b/incubator/src/main/antlr/org/apache/sis/cql/internal/CQL.g4
deleted file mode 100644
index 3757b06..0000000
--- a/incubator/src/main/antlr/org/apache/sis/cql/internal/CQL.g4
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * 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.
- */
-grammar CQL;
-
-options {
- language = Java;
-}
-@header {
- package org.apache.sis.cql.internal;
-}
-
-//-----------------------------------------------------------------//
-// LEXER
-//-----------------------------------------------------------------//
-
-
-// GLOBAL STUFF ---------------------------------------
-
-COMMA : ',' ;
-WS : ( ' ' | '\t' | '\r'| '\n' ) -> skip;
-UNARY : '+' | '-' ;
-MULT : '*' ;
-DIV : '/' ;
-fragment DIGIT : '0'..'9' ;
-
-// caseinsensitive , possible alternative solution ?
-fragment A: ('a'|'A');
-fragment B: ('b'|'B');
-fragment C: ('c'|'C');
-fragment D: ('d'|'D');
-fragment E: ('e'|'E');
-fragment F: ('f'|'F');
-fragment G: ('g'|'G');
-fragment H: ('h'|'H');
-fragment I: ('i'|'I');
-fragment J: ('j'|'J');
-fragment K: ('k'|'K');
-fragment L: ('l'|'L');
-fragment M: ('m'|'M');
-fragment N: ('n'|'N');
-fragment O: ('o'|'O');
-fragment P: ('p'|'P');
-fragment Q: ('q'|'Q');
-fragment R: ('r'|'R');
-fragment S: ('s'|'S');
-fragment T: ('t'|'T');
-fragment U: ('u'|'U');
-fragment V: ('v'|'V');
-fragment W: ('w'|'W');
-fragment X: ('x'|'X');
-fragment Y: ('y'|'Y');
-fragment Z: ('z'|'Z');
-fragment LETTER : ~('0'..'9' | ' ' | '\t' | '\r'| '\n' | ',' | '-' | '+' | '*' | '/' | '(' | ')' | '=' | '>' | '<');
-
-LPAREN : '(';
-RPAREN : ')';
-
-
-//LITERALS ----------------------------------------------
-
-TEXT : '\'' ( ESC_SEQ | ~('\'') )* '\'' ;
-INT : DIGIT+ ;
-
-FLOAT
- : ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
- | '.' ('0'..'9')+ EXPONENT?
- | ('0'..'9')+ EXPONENT
- ;
-
-
-// FILTERING OPERAND -----------------------------------
-COMPARE
- : EQUALABOVE
- | EQUALUNDER
- | NOTEQUAL
- | EQUAL
- | ABOVE
- | UNDER
- ;
-fragment EQUALABOVE : '>=' ;
-fragment EQUALUNDER : '<=' ;
-fragment NOTEQUAL : '<>' ;
-fragment EQUAL : '=' ;
-fragment ABOVE : '>' ;
-fragment UNDER : '<' ;
-LIKE : L I K E;
-ILIKE : I L I K E;
-
-IS : I S ;
-NULL : N U L L ;
-BETWEEN : B E T W E E N;
-IN : I N;
-
-
-
-// LOGIC ----------------------------------------------
-AND : A N D;
-OR : O R ;
-NOT : N O T ;
-
-// GEOMETRIC TYPES AND FILTERS ------------------------
-POINT : P O I N T ;
-LINESTRING : L I N E S T R I N G ;
-POLYGON : P O L Y G O N ;
-MPOINT : M U L T I P O I N T ;
-MLINESTRING : M U L T I L I N E S T R I N G ;
-MPOLYGON : M U L T I P O L Y G O N ;
-GEOMETRYCOLLECTION : G E O M E T R Y C O L L E C T I O N ;
-ENVELOPE : E N V E L O P E ;
-EMPTY : E M P T Y ;
-
-BBOX : B B O X ;
-BEYOND : B E Y O N D ;
-CONTAINS : C O N T A I N S ;
-CROSSES : C R O S S E S;
-DISJOINT : D I S J O I N T ;
-DWITHIN : D W I T H I N ;
-EQUALS : E Q U A L S ;
-INTERSECTS : I N T E R S E C T S;
-OVERLAPS : O V E R L A P S;
-TOUCHES : T O U C H E S;
-WITHIN : W I T H I N ;
-
-// TEMPORAL TYPES AND FILTERS
-
-DATETIME : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT 'T' DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ('.' DIGIT+)? 'Z';
-DATE : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT;
-DURATION_P : P (INT 'Y')? (INT 'M')? (INT 'D')? (INT 'H')? (INT 'M')? (INT 'S')?;
-DURATION_T : P T (INT 'H')? (INT 'M')? (INT 'S')?;
-
-AFTER : A F T E R ;
-ANYINTERACTS : A N Y I N T E R A C T S ;
-BEFORE : B E F O R E ;
-BEGINS : B E G I N S ;
-BEGUNBY : B E G U N B Y ;
-DURING : D U R I N G ;
-ENDEDBY : E N D E D B Y ;
-ENDS : E N D S ;
-MEETS : M E E T S ;
-METBY : M E T B Y ;
-OVERLAPPEDBY : O V E R L A P P E D B Y ;
-TCONTAINS : T C O N T A I N S ;
-TEQUALS : T E Q U A L S ;
-TOVERLAPS : T O V E R L A P S ;
-
-// QUERY ---------------------------------------------
-
-SELECT : S E L E C T ;
-WHERE : W H E R E ;
-LIMIT : L I M I T ;
-OFFSET : O F F S E T ;
-AS : A S ;
-ORDER : O R D E R ;
-BY : B Y ;
-ASC : A S C ;
-DESC : D E S C ;
-
-// PROPERTY NAME -------------------------------------
-PROPERTY_NAME : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ;
-NAME : LETTER (DIGIT|LETTER)* ;
-
-
-// FRAGMENT -------------------------------------------
-
-fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
-fragment HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
-
-fragment
-ESC_SEQ
- : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')
- | UNICODE_ESC
- | OCTAL_ESC
- ;
-
-fragment
-OCTAL_ESC
- : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7')
- ;
-
-fragment
-UNICODE_ESC
- : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- ;
-
-
-
-
-//-----------------------------------------------------------------//
-// PARSER
-//-----------------------------------------------------------------//
-
-expressionNum : INT | FLOAT ;
-expressionUnary : UNARY? expressionNum ;
-
-coordinate : expressionUnary expressionUnary ;
-coordinateSerie : LPAREN coordinate (COMMA coordinate)* RPAREN ;
-coordinateSeries : LPAREN coordinateSerie (COMMA coordinateSerie)* RPAREN;
-
-expressionGeometry
- : POINT ( EMPTY | coordinateSerie )
- | LINESTRING ( EMPTY | coordinateSerie )
- | POLYGON ( EMPTY | coordinateSeries )
- | MPOINT ( EMPTY | coordinateSerie )
- | MLINESTRING ( EMPTY | coordinateSeries )
- | MPOLYGON ( EMPTY | LPAREN coordinateSeries (COMMA coordinateSeries)* RPAREN )
- | GEOMETRYCOLLECTION ( EMPTY | (LPAREN expressionGeometry (COMMA expressionGeometry)* RPAREN) )
- | ENVELOPE ( EMPTY | (LPAREN expressionUnary COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary RPAREN) )
- ;
-
-expressionFctParam
- : expression (COMMA expression)*
- ;
-
-expressionTerm
- : TEXT
- | expressionUnary
- | PROPERTY_NAME
- | DATETIME
- | DATE
- | DURATION_P
- | DURATION_T
- | NAME (LPAREN expressionFctParam? RPAREN)?
- | expressionGeometry
- | LPAREN expression RPAREN
- ;
-
-expression : expression (MULT|DIV) expression
- | expression UNARY expression
- | expressionTerm
- ;
-
-filterGeometry
- : BBOX LPAREN expression COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary (COMMA TEXT)? RPAREN
- | BEYOND LPAREN expression COMMA expression COMMA expression COMMA expression RPAREN
- | CONTAINS LPAREN expression COMMA expression RPAREN
- | CROSSES LPAREN expression COMMA expression RPAREN
- | DISJOINT LPAREN expression COMMA expression RPAREN
- | DWITHIN LPAREN expression COMMA expression COMMA expression COMMA expression RPAREN
- | EQUALS LPAREN expression COMMA expression RPAREN
- | INTERSECTS LPAREN expression COMMA expression RPAREN
- | OVERLAPS LPAREN expression COMMA expression RPAREN
- | TOUCHES LPAREN expression COMMA expression RPAREN
- | WITHIN LPAREN expression COMMA expression RPAREN
- ;
-
-filterTerm : expression
- (
- COMPARE expression
- | NOT? IN LPAREN (expressionFctParam )? RPAREN
- | BETWEEN expression AND expression
- | NOT? LIKE expression
- | NOT? ILIKE expression
- | IS NOT? NULL
- | AFTER expression
- | ANYINTERACTS expression
- | BEFORE expression
- | BEGINS expression
- | BEGUNBY expression
- | DURING expression
- | ENDEDBY expression
- | ENDS expression
- | MEETS expression
- | METBY expression
- | OVERLAPPEDBY expression
- | TCONTAINS expression
- | TEQUALS expression
- | TOVERLAPS expression
- )
- | filterGeometry
- ;
-
-filter : filter (AND filter)+
- | filter (OR filter )+
- | LPAREN filter RPAREN
- | NOT (filterTerm | (LPAREN filter RPAREN) )
- | filterTerm
- ;
-
-filterOrExpression : filter | expression ;
-
-sortprop : expression (ASC | DESC)? ;
-orderby : ORDER BY sortprop (COMMA sortprop)* ;
-limit : LIMIT INT ;
-offset : OFFSET INT ;
-where : WHERE filter ;
-projection : expression (AS TEXT)? ;
-query : SELECT (MULT | (projection (COMMA projection)*)) where? orderby? offset? limit?;
diff --git a/incubator/src/org.apache.sis.cql/main/module-info.java b/incubator/src/org.apache.sis.cql/main/module-info.java
deleted file mode 100644
index 4307e9c..0000000
--- a/incubator/src/org.apache.sis.cql/main/module-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * CQL parser.
- *
- * @author Johann Sorel (Geomatys)
- */
-module org.apache.sis.cql {
- requires transitive org.apache.sis.feature;
- requires org.locationtech.jts;
- requires org.antlr.antlr4.runtime;
-}
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java
deleted file mode 100644
index 6577e57..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
- * 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.cql;
-
-import java.time.Duration;
-import java.time.Period;
-import java.util.List;
-import java.util.ArrayList;
-import java.time.temporal.TemporalAccessor;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.CoordinateSequence;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.LineString;
-import org.locationtech.jts.geom.LinearRing;
-import org.locationtech.jts.geom.Polygon;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.runtime.tree.TerminalNode;
-import javax.measure.Unit;
-import javax.measure.quantity.Length;
-import org.opengis.util.FactoryException;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.Literal;
-import org.opengis.filter.SortOrder;
-import org.opengis.filter.SortProperty;
-import org.apache.sis.measure.Units;
-import org.apache.sis.measure.Quantities;
-import org.apache.sis.filter.DefaultFilterFactory;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.cql.internal.AntlrCQL;
-import org.apache.sis.cql.internal.CQLParser.CoordinateContext;
-import org.apache.sis.cql.internal.CQLParser.CoordinateSerieContext;
-import org.apache.sis.cql.internal.CQLParser.CoordinateSeriesContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionFctParamContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionGeometryContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionNumContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionTermContext;
-import org.apache.sis.cql.internal.CQLParser.ExpressionUnaryContext;
-import org.apache.sis.cql.internal.CQLParser.FilterContext;
-import org.apache.sis.cql.internal.CQLParser.FilterGeometryContext;
-import org.apache.sis.cql.internal.CQLParser.FilterTermContext;
-import org.apache.sis.temporal.LenientDateFormat;
-import static org.apache.sis.cql.internal.CQLParser.*;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class CQL {
-
- private static final GeometryFactory GF = org.apache.sis.geometry.wrapper.jts.Factory.INSTANCE.factory(false);
-
- private CQL() {
- }
-
- public static Expression<Feature,?> parseExpression(String cql) throws CQLException {
- return parseExpression(cql, null);
- }
-
- public static Expression<Feature,?> parseExpression(String cql, FilterFactory<Feature,?,?> factory) throws CQLException {
- final Object obj = AntlrCQL.compileExpression(cql);
- Expression<Feature,?> result = null;
- if (obj instanceof ExpressionContext) {
- ParseTree tree = (ParseTree) obj;
- if (factory == null) {
- factory = DefaultFilterFactory.forFeatures();
- }
- result = convertExpression(tree, factory);
- }
- return result;
- }
-
- public static Filter<Feature> parseFilter(String cql) throws CQLException {
- return parseFilter(cql, null);
- }
-
- public static Filter<Feature> parseFilter(String cql, FilterFactory<Feature,Object,Object> factory) throws CQLException {
- cql = cql.trim();
-
- // Bypass parsing for inclusive filter.
- if (cql.isEmpty() || "*".equals(cql)) {
- return Filter.include();
- }
- final Object obj = AntlrCQL.compileFilter(cql);
- Filter<Feature> result = null;
- if (obj instanceof FilterContext) {
- ParseTree tree = (ParseTree) obj;
- if (factory == null) {
- factory = DefaultFilterFactory.forFeatures();
- }
- result = convertFilter(tree, factory);
- }
- return result;
- }
-
- public static Query parseQuery(String cql) throws CQLException {
- return parseQuery(cql, null);
- }
-
- public static Query parseQuery(String cql, FilterFactory<Feature,Object,Object> factory) throws CQLException {
- final Object obj = AntlrCQL.compileQuery(cql);
- Query result = null;
- if (obj instanceof QueryContext) {
- ParseTree tree = (ParseTree) obj;
- if (factory == null) {
- factory = DefaultFilterFactory.forFeatures();
- }
- result = convertQuery(tree, factory);
- }
- return result;
- }
-
- public static String write(final Filter<Feature> filter) {
- final StringBuilder sb = new StringBuilder();
- FilterToCQLVisitor.INSTANCE.visit(filter, sb);
- return sb.toString();
- }
-
- public static String write(final Expression<Feature,?> exp) {
- final StringBuilder sb = new StringBuilder();
- FilterToCQLVisitor.INSTANCE.visit(exp, sb);
- return sb.toString();
- }
-
- public static String write(final Query query) {
- final StringBuilder sb = new StringBuilder();
- sb.append("SELECT ");
- if (query.projections.isEmpty()) {
- sb.append('*');
- } else {
- for (int i = 0, n = query.projections.size(); i < n; i++) {
- Query.Projection p = query.projections.get(i);
- if (i != 0) sb.append(", ");
- sb.append(write(p.expression));
- if (p.alias != null && !p.alias.isEmpty()) {
- sb.append(" AS '");
- sb.append(p.alias);
- sb.append('\'');
- }
- }
- }
- if (query.filter != null) {
- sb.append(" WHERE ");
- sb.append(write(query.filter));
- }
-
- if (!query.sortby.isEmpty()) {
- sb.append(" ORDER BY ");
- for (int i = 0, n = query.sortby.size(); i < n; i++) {
- SortProperty p = query.sortby.get(i);
- if (i != 0) sb.append(", ");
- sb.append(write(p.getValueReference()));
- switch (p.getSortOrder()) {
- case ASCENDING : sb.append(" ASC"); break;
- case DESCENDING : sb.append(" DESC"); break;
- }
- }
- }
-
- if (query.offset != null) {
- sb.append(" OFFSET ");
- sb.append(query.offset);
- }
- if (query.limit != null) {
- sb.append(" LIMIT ");
- sb.append(query.limit);
- }
-
- return sb.toString();
- }
-
- /**
- * Convert the given tree in an Expression.
- */
- private static Expression<Feature,?> convertExpression(ParseTree tree, FilterFactory<Feature,?,?> ff) throws CQLException {
- if (tree instanceof ExpressionContext) {
- //: expression MULT expression
- //| expression UNARY expression
- //| expressionTerm
- if (tree.getChildCount() == 3) {
- final String operand = tree.getChild(1).getText();
- // TODO: unsafe cast.
- final Expression<Feature, ? extends Number> left = (Expression<Feature, ? extends Number>) convertExpression(tree.getChild(0), ff);
- final Expression<Feature, ? extends Number> right = (Expression<Feature, ? extends Number>) convertExpression(tree.getChild(2), ff);
- if ("*".equals(operand)) {
- return ff.multiply(left, right);
- } else if ("/".equals(operand)) {
- return ff.divide(left, right);
- } else if ("+".equals(operand)) {
- return ff.add(left, right);
- } else if ("-".equals(operand)) {
- return ff.subtract(left, right);
- }
- } else {
- return convertExpression(tree.getChild(0), ff);
- }
- } // else if(tree instanceof ExpressionStringContext){
- // //strip start and end '
- // final String text = tree.getText();
- // return ff.literal(text.substring(1, text.length()-1));
- // }
- else if (tree instanceof ExpressionTermContext) {
- //: expressionString
- //| expressionUnary
- //| PROPERTY_NAME
- //| DATE
- //| DURATION_P
- //| DURATION_T
- //| NAME (LPAREN expressionFctParam? RPAREN)?
- //| expressionGeometry
- //| LPAREN expression RPAREN
-
- //: TEXT
- //| expressionUnary
- //| PROPERTY_NAME
- //| DATE
- //| DURATION_P
- //| DURATION_T
- //| expressionGeometry
- final ExpressionTermContext exp = (ExpressionTermContext) tree;
- if (exp.getChildCount() == 1) {
- return convertExpression(tree.getChild(0), ff);
- }
- // LPAREN expression RPAREN
- if (exp.expression() != null) {
- return convertExpression(exp.expression(), ff);
- }
- // NAME (LPAREN expressionFctParam? RPAREN)?
- if (exp.NAME() != null) {
- final String name = exp.NAME().getText();
- final ExpressionFctParamContext prm = exp.expressionFctParam();
- if (prm == null) {
- //handle as property name
- return ff.property(name);
- }
- // Handle as a function.
- final List<ExpressionContext> params = prm.expression();
- final List<Expression<Feature,?>> exps = new ArrayList<>();
- for (int i = 0, n = params.size(); i < n; i++) {
- exps.add(convertExpression(params.get(i), ff));
- }
- return ff.function(name, exps.toArray(new Expression[exps.size()]));
- }
- } else if (tree instanceof ExpressionUnaryContext) {
- //: UNARY? expressionNum ;
- final ExpressionUnaryContext exp = (ExpressionUnaryContext) tree;
- return ff.literal(unaryAsNumber(exp));
-
- } else if (tree instanceof ExpressionNumContext) {
- //: INT | FLOAT ;
- return convertExpression(tree.getChild(0), ff);
- } else if (tree instanceof TerminalNode) {
- final TerminalNode exp = (TerminalNode) tree;
- switch (exp.getSymbol().getType()) {
- case PROPERTY_NAME: {
- // strip start and end "
- final String text = tree.getText();
- return ff.property(text.substring(1, text.length() - 1));
- }
- case NAME: return ff.property(tree.getText());
- case INT: return ff.literal(Integer.valueOf(tree.getText()));
- case FLOAT: return ff.literal(Double.valueOf(tree.getText()));
- case DATE, DATETIME: {
- TemporalAccessor ta = LenientDateFormat.parseBest(tree.getText());
- return ff.literal(ta);
- // TODO: return ff.literal(TemporalObjects.getTimeInMillis(tree.getText()));
- }
- case TEXT: {
- // strip start and end '
- String text = tree.getText();
- text = text.replaceAll("\\\\'", "'");
- return ff.literal(text.substring(1, text.length() - 1));
- }
- case DURATION_P :
- return ff.literal(Period.parse(tree.getText()));
- case DURATION_T :
- return ff.literal(Duration.parse(tree.getText()));
- }
- } else if (tree instanceof ExpressionGeometryContext) {
- //: POINT ( EMPTY | coordinateSerie )
- //| LINESTRING ( EMPTY | coordinateSerie )
- //| POLYGON ( EMPTY | coordinateSeries )
- //| MPOINT ( EMPTY | coordinateSerie )
- //| MLINESTRING ( EMPTY | coordinateSeries )
- //| MPOLYGON ( EMPTY | LPAREN coordinateSeries (COMMA coordinateSeries)* RPAREN )
- //| GEOMETRYCOLLECTION ( EMPTY | (LPAREN expressionGeometry (COMMA expressionGeometry)* RPAREN) )
- //| ENVELOPE ( EMPTY | (LPAREN expressionUnary COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary RPAREN) )
- final ExpressionGeometryContext exp = (ExpressionGeometryContext) tree;
- switch (((TerminalNode) exp.getChild(0)).getSymbol().getType()) {
- case POINT: {
- final ParseTree st = tree.getChild(1);
- final CoordinateSequence cs;
- if (isEmptyToken(st)) {
- cs = GF.getCoordinateSequenceFactory().create(new Coordinate[0]);
- } else {
- cs = parseSequence(st);
- }
- final Geometry geom = GF.createPoint(cs);
- return ff.literal(geom);
- }
- case LINESTRING: {
- final ParseTree st = tree.getChild(1);
- final CoordinateSequence cs;
- if (isEmptyToken(st)) {
- cs = GF.getCoordinateSequenceFactory().create(new Coordinate[0]);
- } else {
- cs = parseSequence(st);
- }
- final Geometry geom = GF.createLineString(cs);
- return ff.literal(geom);
- }
- case POLYGON: {
- final ParseTree st = tree.getChild(1);
- final Geometry geom;
- if (isEmptyToken(st)) {
- geom = GF.createPolygon(GF.createLinearRing(new Coordinate[0]), new LinearRing[0]);
- } else {
- final CoordinateSeriesContext series = (CoordinateSeriesContext) st;
- final List<CoordinateSerieContext> subs = series.coordinateSerie();
- final LinearRing contour = GF.createLinearRing(parseSequence(subs.get(0)));
- final int n = subs.size();
- final LinearRing[] holes = new LinearRing[n - 1];
- for (int i = 1; i < n; i++) {
- holes[i - 1] = GF.createLinearRing(parseSequence(subs.get(i)));
- }
- geom = GF.createPolygon(contour, holes);
- }
- return ff.literal(geom);
- }
- case MPOINT: {
- final ParseTree st = tree.getChild(1);
- final CoordinateSequence cs;
- if (isEmptyToken(st)) {
- cs = GF.getCoordinateSequenceFactory().create(new Coordinate[0]);
- } else {
- cs = parseSequence(st);
- }
- final Geometry geom = GF.createMultiPoint(cs);
- return ff.literal(geom);
- }
- case MLINESTRING: {
- final ParseTree st = tree.getChild(1);
- final Geometry geom;
- if (isEmptyToken(st)) {
- geom = GF.createMultiLineString(new LineString[0]);
- } else {
- final CoordinateSeriesContext series = (CoordinateSeriesContext) st;
- final List<CoordinateSerieContext> subs = series.coordinateSerie();
- final int n = subs.size();
- final LineString[] strings = new LineString[n];
- for (int i = 0; i < n; i++) {
- strings[i] = GF.createLineString(parseSequence(subs.get(i)));
- }
- geom = GF.createMultiLineString(strings);
- }
- return ff.literal(geom);
- }
- case MPOLYGON: {
- final ParseTree st = tree.getChild(1);
- final Geometry geom;
- if (isEmptyToken(st)) {
- geom = GF.createMultiPolygon(new Polygon[0]);
- } else {
- final List<CoordinateSeriesContext> eles = exp.coordinateSeries();
- final int n = eles.size();
- final Polygon[] polygons = new Polygon[n];
- for (int i=0; i<n; i++) {
- final CoordinateSeriesContext polyTree = eles.get(i);
- final List<CoordinateSerieContext> subs = polyTree.coordinateSerie();
- final LinearRing contour = GF.createLinearRing(parseSequence(subs.get(0)));
- final int hn = subs.size();
- final LinearRing[] holes = new LinearRing[hn - 1];
- for (int j=1; j<hn; j++) {
- holes[j-1] = GF.createLinearRing(parseSequence(subs.get(j)));
- }
- final Polygon poly = GF.createPolygon(contour, holes);
- polygons[i] = poly;
- }
- geom = GF.createMultiPolygon(polygons);
- }
- return ff.literal(geom);
- }
- case GEOMETRYCOLLECTION: {
- final ParseTree st = tree.getChild(1);
- final Geometry geom;
- if (isEmptyToken(st)) {
- geom = GF.createGeometryCollection(new Geometry[0]);
- } else {
- final List<ExpressionGeometryContext> eles = exp.expressionGeometry();
- final int n = eles.size();
- final Geometry[] subs = new Geometry[n];
- for (int i=0; i<n; i++) {
- final ParseTree subTree = eles.get(i);
- final Geometry sub = (Geometry) convertExpression(subTree, ff).apply(null);
- subs[i] = sub;
- }
- geom = GF.createGeometryCollection(subs);
- }
- return ff.literal(geom);
- }
- case ENVELOPE: {
- final ParseTree st = tree.getChild(1);
- final Geometry geom;
- if (isEmptyToken(st)) {
- geom = GF.createPolygon(GF.createLinearRing(new Coordinate[0]), new LinearRing[0]);
- } else {
- final List<ExpressionUnaryContext> unaries = exp.expressionUnary();
- final double west = unaryAsNumber(unaries.get(0)).doubleValue();
- final double east = unaryAsNumber(unaries.get(1)).doubleValue();
- final double north = unaryAsNumber(unaries.get(2)).doubleValue();
- final double south = unaryAsNumber(unaries.get(3)).doubleValue();
- final LinearRing contour = GF.createLinearRing(new Coordinate[]{
- new Coordinate(west, north),
- new Coordinate(east, north),
- new Coordinate(east, south),
- new Coordinate(west, south),
- new Coordinate(west, north)
- });
- geom = GF.createPolygon(contour, new LinearRing[0]);
- }
- return ff.literal(geom);
- }
- }
- return convertExpression(tree.getChild(0), ff);
- }
- throw new CQLException("Unreconized expression : type=" + tree.getText());
- }
-
- private static boolean isEmptyToken(ParseTree tree) {
- return tree instanceof TerminalNode && ((TerminalNode) tree).getSymbol().getType() == EMPTY;
- }
-
- private static Number unaryAsNumber(ExpressionUnaryContext exp) {
- //: UNARY? expressionNum ;
- final boolean negate = (exp.UNARY() != null && exp.UNARY().getSymbol().getText().equals("-"));
- final ExpressionNumContext num = exp.expressionNum();
- if (num.INT() != null) {
- int val = Integer.valueOf(num.INT().getText());
- return negate ? -val : val;
- } else {
- double val = Double.valueOf(num.FLOAT().getText());
- return negate ? -val : val;
- }
- }
-
- private static CoordinateSequence parseSequence(ParseTree tree) {
- final CoordinateSerieContext exp = (CoordinateSerieContext) tree;
- final List<CoordinateContext> lst = exp.coordinate();
- final int size = lst.size();
- final Coordinate[] coords = new Coordinate[size];
- for (int i = 0; i < size; i++) {
- final CoordinateContext cc = lst.get(i);
- coords[i] = new Coordinate(
- unaryAsNumber(cc.expressionUnary(0)).doubleValue(),
- unaryAsNumber(cc.expressionUnary(1)).doubleValue());
- }
- return GF.getCoordinateSequenceFactory().create(coords);
- }
-
- private static Unit<Length> parseLengthUnit(final Expression<Feature,?> unitExp) {
- Object value = unitExp.apply(null);
- if (value != null) {
- return Units.ensureLinear(Units.valueOf(value.toString()));
- }
- if (unitExp instanceof ValueReference<?,?>) {
- value = ((ValueReference<?,?>) unitExp).getXPath();
- }
- throw new IllegalArgumentException("Unit `" + value + "` is not a literal.");
- }
-
- /**
- * Convert the given tree in a Filter.
- */
- private static Filter<Feature> convertFilter(ParseTree tree, FilterFactory<Feature,Object,Object> ff) throws CQLException {
- if (tree instanceof FilterContext) {
- //: filter (AND filter)+
- //| filter (OR filter)+
- //| LPAREN filter RPAREN
- //| NOT filterTerm
- //| filterTerm
-
- final FilterContext exp = (FilterContext) tree;
-
- //| filterTerm
- if (exp.getChildCount() == 1) {
- return convertFilter(tree.getChild(0), ff);
- } else if (exp.NOT() != null) {
- //| NOT (filterTerm | ( LPAREN filter RPAREN ))
- if (exp.filterTerm() != null) {
- return ff.not(convertFilter(exp.filterTerm(), ff));
- } else {
- return ff.not(convertFilter(exp.filter(0), ff));
- }
-
- } else if (!exp.AND().isEmpty()) {
- //: filter (AND filter)+
- final List<Filter<Feature>> subs = new ArrayList<>();
- for (FilterContext f : exp.filter()) {
- final Filter<Feature> sub = convertFilter(f, ff);
- if (sub.getOperatorType() == LogicalOperatorName.AND) {
- subs.addAll(((LogicalOperator<Feature>) sub).getOperands());
- } else {
- subs.add(sub);
- }
- }
- return ff.and(subs);
- } else if (!exp.OR().isEmpty()) {
- //| filter (OR filter)+
- final List<Filter<Feature>> subs = new ArrayList<>();
- for (FilterContext f : exp.filter()) {
- final Filter<Feature> sub = convertFilter(f, ff);
- if (sub.getOperatorType() == LogicalOperatorName.OR) {
- subs.addAll(((LogicalOperator<Feature>) sub).getOperands());
- } else {
- subs.add(sub);
- }
- }
- return ff.or(subs);
- } else if (exp.LPAREN() != null) {
- //| LPAREN filter RPAREN
- return convertFilter(exp.filter(0), ff);
- }
- } else if (tree instanceof FilterTermContext) {
- //: expression
- // (
- // COMPARE expression
- // | NOT? IN LPAREN (expressionFctParam )? RPAREN
- // | BETWEEN expression AND expression
- // | NOT? LIKE expression
- // | NOT? ILIKE expression
- // | IS NOT? NULL
- // | AFTER expression
- // | ANYINTERACTS expression
- // | BEFORE expression
- // | BEGINS expression
- // | BEGUNBY expression
- // | DURING expression
- // | ENDEDBY expression
- // | ENDS expression
- // | MEETS expression
- // | METBY expression
- // | OVERLAPPEDBY expression
- // | TCONTAINS expression
- // | TEQUALS expression
- // | TOVERLAPS expression
- // )
- //| filterGeometry
-
- final FilterTermContext exp = (FilterTermContext) tree;
- final List<ExpressionContext> exps = exp.expression();
- if (exp.COMPARE() != null) {
- // expression COMPARE expression
- final String text = exp.COMPARE().getText();
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- if ("=".equals(text)) {
- return ff.equal(left, right);
- } else if ("<>".equals(text)) {
- return ff.notEqual(left, right);
- } else if (">".equals(text)) {
- return ff.greater(left, right);
- } else if ("<".equals(text)) {
- return ff.less(left, right);
- } else if (">=".equals(text)) {
- return ff.greaterOrEqual(left, right);
- } else if ("<=".equals(text)) {
- return ff.lessOrEqual(left, right);
- }
- } else if (exp.IN() != null) {
- // expression NOT? IN LPAREN (expressionFctParam )? RPAREN
- final Expression<Feature,?> val = convertExpression(exps.get(0), ff);
- final ExpressionFctParamContext prm = exp.expressionFctParam();
- final List<ExpressionContext> params = prm.expression();
- final List<Expression<Feature,?>> subexps = new ArrayList<>();
- for (int i = 0, n = params.size(); i < n; i++) {
- subexps.add(convertExpression(params.get(i), ff));
- }
- final int size = subexps.size();
- final Filter<Feature> selection;
- switch (size) {
- case 0: {
- selection = Filter.exclude();
- break;
- }
- case 1: {
- selection = ff.equal(val, subexps.get(0));
- break;
- }
- default: {
- final List<Filter<Feature>> filters = new ArrayList<>();
- for (Expression<Feature,?> e : subexps) {
- filters.add(ff.equal(val, e));
- } selection = ff.or(filters);
- break;
- }
- }
- if (exp.NOT() != null) {
- return ff.not(selection);
- } else {
- return selection;
- }
- } else if (exp.BETWEEN() != null) {
- // expression BETWEEN expression AND expression
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- final Expression<Feature,?> exp3 = convertExpression(exps.get(2), ff);
- return ff.between(exp1, exp2, exp3);
- } else if (exp.LIKE() != null) {
- // expression NOT? LIKE expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- if (exp.NOT() != null) {
- return ff.not(ff.like(left, right.apply(null).toString(), '%', '_', '\\', true));
- } else {
- return ff.like(left, right.apply(null).toString(), '%', '_', '\\', true);
- }
- } else if (exp.ILIKE() != null) {
- // expression NOT? LIKE expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- if (exp.NOT() != null) {
- return ff.not(ff.like(left, right.apply(null).toString(), '%', '_', '\\', false));
- } else {
- return ff.like(left, right.apply(null).toString(), '%', '_', '\\', false);
- }
- } else if (exp.IS() != null) {
- // expression IS NOT? NULL
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- if (exp.NOT() != null) {
- return ff.not(ff.isNull(exp1));
- } else {
- return ff.isNull(exp1);
- }
- } else if (exp.AFTER() != null) {
- // expression AFTER expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.after(left, right);
- } else if (exp.ANYINTERACTS() != null) {
- // expression ANYINTERACTS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.anyInteracts(left, right);
- } else if (exp.BEFORE() != null) {
- // expression BEFORE expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.before(left, right);
- } else if (exp.BEGINS() != null) {
- // expression BEGINS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.begins(left, right);
- } else if (exp.BEGUNBY() != null) {
- // expression BEGUNBY expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.begunBy(left, right);
- } else if (exp.DURING() != null) {
- // expression DURING expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.during(left, right);
- } else if (exp.ENDEDBY() != null) {
- // expression ENDEDBY expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.endedBy(left, right);
- } else if (exp.ENDS() != null) {
- // expression ENDS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.ends(left, right);
- } else if (exp.MEETS() != null) {
- // expression MEETS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.meets(left, right);
- } else if (exp.METBY() != null) {
- // expression METBY expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.metBy(left, right);
- } else if (exp.OVERLAPPEDBY() != null) {
- // expression OVERLAPPEDBY expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.overlappedBy(left, right);
- } else if (exp.TCONTAINS() != null) {
- // expression TCONTAINS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.tcontains(left, right);
- } else if (exp.TEQUALS() != null) {
- // expression TEQUALS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.tequals(left, right);
- } else if (exp.TOVERLAPS() != null) {
- // expression TOVERLAPS expression
- final Expression<Feature,?> left = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> right = convertExpression(exps.get(1), ff);
- return ff.toverlaps(left, right);
- } else if (exp.filterGeometry() != null) {
- // expression filterGeometry
- return convertFilter(exp.filterGeometry(), ff);
- }
- } else if (tree instanceof FilterGeometryContext) {
- //: BBOX LPAREN (PROPERTY_NAME|NAME) COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary COMMA expressionUnary (COMMA TEXT)? RPAREN
- //| BEYOND LPAREN expression COMMA expression COMMA expression COMMA expression RPAREN
- //| CONTAINS LPAREN expression COMMA expression RPAREN
- //| CROSSES LPAREN expression COMMA expression RPAREN
- //| DISJOINT LPAREN expression COMMA expression RPAREN
- //| DWITHIN LPAREN expression COMMA expression COMMA expression COMMA expression RPAREN
- //| EQUALS LPAREN expression COMMA expression RPAREN
- //| INTERSECTS LPAREN expression COMMA expression RPAREN
- //| OVERLAPS LPAREN expression COMMA expression RPAREN
- //| TOUCHES LPAREN expression COMMA expression RPAREN
- //| WITHIN LPAREN expression COMMA expression RPAREN
-
- final FilterGeometryContext exp = (FilterGeometryContext) tree;
- final List<ExpressionContext> exps = exp.expression();
- if (exp.BBOX() != null) {
- final Expression<Feature,?> prop = convertExpression(exps.get(0), ff);
- final double v1 = unaryAsNumber(exp.expressionUnary(0)).doubleValue();
- final double v2 = unaryAsNumber(exp.expressionUnary(1)).doubleValue();
- final double v3 = unaryAsNumber(exp.expressionUnary(2)).doubleValue();
- final double v4 = unaryAsNumber(exp.expressionUnary(3)).doubleValue();
- GeneralEnvelope env;
- if (exp.TEXT() != null) try {
- String crs = convertExpression(exp.TEXT(), ff).apply(null).toString();
- env = new GeneralEnvelope(CRS.forCode(crs));
- } catch (FactoryException e) {
- throw new CQLException("Cannot parse CRS code.", e);
- } else {
- env = new GeneralEnvelope(2);
- }
- env.setRange(0, v1, v3);
- env.setRange(1, v2, v4);
- return ff.bbox(prop, env);
- } else if (exp.BEYOND() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- final double distance = ((Number) convertExpression(exps.get(2), ff).apply(null)).doubleValue();
- final Unit<Length> unit = parseLengthUnit(convertExpression(exps.get(3), ff));
- return ff.beyond(exp1, exp2, Quantities.create(distance, unit));
- } else if (exp.CONTAINS() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.contains(exp1, exp2);
- } else if (exp.CROSSES() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.crosses(exp1, exp2);
- } else if (exp.DISJOINT() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.disjoint(exp1, exp2);
- } else if (exp.DWITHIN() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- final double distance = ((Number) convertExpression(exps.get(2), ff).apply(null)).doubleValue();
- final Unit<Length> unit = parseLengthUnit(convertExpression(exps.get(3), ff));
- return ff.within(exp1, exp2, Quantities.create(distance, unit));
- } else if (exp.EQUALS() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.equals(exp1, exp2);
- } else if (exp.INTERSECTS() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.intersects(exp1, exp2);
- } else if (exp.OVERLAPS() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.overlaps(exp1, exp2);
- } else if (exp.TOUCHES() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.touches(exp1, exp2);
- } else if (exp.WITHIN() != null) {
- final Expression<Feature,?> exp1 = convertExpression(exps.get(0), ff);
- final Expression<Feature,?> exp2 = convertExpression(exps.get(1), ff);
- return ff.within(exp1, exp2);
- }
- }
- throw new CQLException("Unreconized filter : type=" + tree.getText());
- }
-
- /**
- * Convert the given tree in a Query.
- */
- private static Query convertQuery(ParseTree tree, FilterFactory<Feature,Object,Object> ff) throws CQLException {
- if (tree instanceof QueryContext) {
- final QueryContext context = (QueryContext) tree;
- final List<ProjectionContext> projections = context.projection();
- final WhereContext where = context.where();
- final OffsetContext offset = context.offset();
- final LimitContext limit = context.limit();
- final OrderbyContext orderby = context.orderby();
-
- final Query query = new Query();
- if (context.MULT() == null) {
- for (ProjectionContext pc : projections) {
- final Expression<Feature,?> exp = convertExpression(pc.expression(), ff);
- if (pc.AS() != null) {
- final Expression<Feature,?> alias = convertExpression(pc.TEXT(), ff);
- query.projections.add(new Query.Projection(exp, String.valueOf(( (Literal) alias).getValue())));
- } else {
- query.projections.add(new Query.Projection(exp, null));
- }
- }
- }
- if (where != null) {
- query.filter = (Filter<Feature>) convertFilter(where.filter(), ff);
- }
- if (offset != null) {
- query.offset = Integer.valueOf(offset.INT().getText());
- }
- if (limit != null) {
- query.limit = Integer.valueOf(limit.INT().getText());
- }
- if (orderby != null) {
- for (SortpropContext spc : orderby.sortprop()) {
- final Expression<Feature,?> exp = convertExpression(spc.expression(), ff);
- if (exp instanceof ValueReference) {
- query.sortby.add(ff.sort((ValueReference<Feature,?>) exp,
- spc.DESC() != null ? SortOrder.DESCENDING : SortOrder.ASCENDING));
- } else {
- throw new CQLException("Sort by may be used with property names only");
- }
- }
- }
- return query;
- }
- return null;
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQLException.java b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQLException.java
deleted file mode 100644
index 28dd5f4..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQLException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.cql;
-
-
-/**
- * Thrown when a CQL statement cannot be parsed.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class CQLException extends Exception {
- /**
- * Serial number for inter-operability with different versions.
- */
- private static final long serialVersionUID = -1494977914551289727L;
-
- /**
- * Constructs an exception with the specified detail message.
- *
- * @param message the detail message.
- */
- public CQLException(String message) {
- super(message);
- }
-
- /**
- * Constructs an exception with the specified detail message and cause.
- *
- * @param message the detail message.
- * @param cause the cause for this exception.
- */
- public CQLException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/FilterToCQLVisitor.java b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/FilterToCQLVisitor.java
deleted file mode 100644
index 98ea262..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/FilterToCQLVisitor.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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.cql;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.regex.Pattern;
-import java.time.temporal.TemporalAccessor;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.io.WKTWriter;
-import javax.measure.Unit;
-import javax.measure.Quantity;
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
-import org.opengis.filter.TemporalOperatorName;
-import org.opengis.filter.BinarySpatialOperator;
-import org.opengis.filter.ComparisonOperatorName;
-import org.opengis.filter.BetweenComparisonOperator;
-import org.opengis.filter.LikeOperator;
-import org.opengis.filter.Expression;
-import org.apache.sis.measure.UnitFormat;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.geometry.wrapper.Geometries;
-import org.apache.sis.geometry.wrapper.GeometryWrapper;
-import org.apache.sis.filter.privy.FunctionNames;
-import org.apache.sis.filter.privy.Visitor;
-import org.apache.sis.temporal.LenientDateFormat;
-
-
-/**
- * Visitor to convert a Filter in CQL.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class FilterToCQLVisitor extends Visitor<Feature,StringBuilder> {
-
- static final FilterToCQLVisitor INSTANCE = new FilterToCQLVisitor();
-
- /**
- * Pattern to check for property name to escape against regExp
- */
- private final Pattern patternPropertyName;
-
- /**
- * Formatter to use for unit symbol. Not thread-safe; usage must be synchronized.
- */
- private final UnitFormat unitFormat;
-
- /**
- * Creates a new visitor.
- */
- private FilterToCQLVisitor() {
- patternPropertyName = Pattern.compile("[,+\\-/*\\t\\n\\r\\d\\s]");
- unitFormat = new UnitFormat(Locale.US);
- unitFormat.setStyle(UnitFormat.Style.NAME);
-
- constant(Filter.exclude(), "1=0");
- constant(Filter.include(), "1=1");
- operatorBetweenValues(LogicalOperatorName.AND, "AND");
- operatorBetweenValues(LogicalOperatorName.OR, "OR");
- setFilterHandler(LogicalOperatorName.NOT, (f,sb) -> {
- final LogicalOperator<Feature> filter = (LogicalOperator<Feature>) f;
- format(sb.append("NOT "), filter.getOperands().get(0));
- });
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_BETWEEN), (f,sb) -> {
- final BetweenComparisonOperator<Feature> filter = (BetweenComparisonOperator<Feature>) f;
- format(sb, filter.getExpression());
- format(sb.append(" BETWEEN "), filter.getLowerBoundary());
- format(sb.append(" AND "), filter.getUpperBoundary());
- });
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, "=");
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_NOT_EQUAL_TO, "<>");
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN, ">");
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO, ">=");
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_LESS_THAN, "<");
- operatorBetweenValues(ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO, "<=");
- setFilterHandler(ComparisonOperatorName.valueOf(FunctionNames.PROPERTY_IS_LIKE), (f,sb) -> {
- final LikeOperator<Feature> filter = (LikeOperator<Feature>) f;
- List<Expression<Feature,?>> operands = f.getExpressions();
- format(sb, operands.get(0));
- // TODO: ILIKE is not standard SQL.
- sb.append(filter.isMatchingCase() ? " LIKE " : " ILIKE ");
- // TODO: convert wildcards and escape to SQL 92.
- format(sb, operands.get(1));
- });
- operatorAfterValue(FunctionNames.PROPERTY_IS_NULL, " IS NULL");
- operatorAfterValue(FunctionNames.PROPERTY_IS_NIL, " IS NIL");
- /*
- * Spatial filters.
- */
- setFilterHandler(SpatialOperatorName.BBOX, (f,sb) -> {
- final BinarySpatialOperator<Feature> filter = (BinarySpatialOperator<Feature>) f;
- final Expression<Feature,?> left = filter.getOperand1();
- final Expression<Feature,?> right = filter.getOperand2();
- final ValueReference<Feature,?> pName =
- (left instanceof ValueReference) ? (ValueReference<Feature,?>) left :
- (right instanceof ValueReference) ? (ValueReference<Feature,?>) right : null;
- final Object lit = ((left instanceof Literal)
- ? (Literal<Feature,?>) left
- : (Literal<Feature,?>) right).getValue(); // TODO: potential classCastException.
-
- final GeneralEnvelope e = Geometries.wrap(lit).map(GeometryWrapper::getEnvelope).orElse(null);
- if (e != null) {
- if (e.getDimension() > 2) {
- throw new UnsupportedOperationException("Only 2D envelopes accepted");
- }
- sb.append("BBOX(").append(pName.getXPath()).append(", ");
- sb.append(e.getMinimum(0)).append(", ")
- .append(e.getMaximum(0)).append(", ")
- .append(e.getMinimum(1)).append(", ")
- .append(e.getMaximum(1)).append(')');
- } else {
- // Use writing BBOX(exp1,exp2).
- format(sb.append("BBOX("), left);
- format(sb.append(','), right);
- sb.append(')');
- }
- });
- for (final SpatialOperatorName type : SpatialOperatorName.values()) {
- if (type != SpatialOperatorName.BBOX) {
- String id = type.identifier();
- if (id == null) id = type.name();
- function(type, id.toUpperCase(Locale.US));
- if (type == SpatialOperatorName.OVERLAPS) break;
- }
- }
- function(DistanceOperatorName.WITHIN, "DWITHIN");
- function(DistanceOperatorName.BEYOND, "BEYOND");
- for (final TemporalOperatorName type : TemporalOperatorName.values()) {
- String id = type.identifier();
- if (id == null) id = type.name();
- function(type, id.toUpperCase(Locale.US));
- if (type == TemporalOperatorName.ANY_INTERACTS) break;
- }
- /*
- * Expressions
- */
- setExpressionHandler(FunctionNames.Literal, (e,sb) -> {
- final Literal<Feature,?> exp = (Literal<Feature,?>) e;
- final Object value = exp.getValue();
- if (value instanceof Quantity<?>) {
- final Quantity<?> q = (Quantity<?>) value;
- final Unit<?> unit = q.getUnit();
- sb.append(q.getValue().doubleValue()).append(", '");
- try {
- synchronized (unitFormat) {
- unitFormat.format(unit, sb);
- }
- } catch (IOException ex) {
- throw new UncheckedIOException(ex); // Should never happen.
- }
- sb.append('\'');
- } else if (value instanceof Number) {
- sb.append(value);
- } else if (value instanceof Date) {
- final Date date = (Date) value;
- sb.append(LenientDateFormat.FORMAT.format(date.toInstant()));
- } else if (value instanceof TemporalAccessor) {
- final TemporalAccessor date = (TemporalAccessor) value;
- sb.append(LenientDateFormat.FORMAT.format(date));
- } else if (value instanceof Geometry) {
- final Geometry geometry = (Geometry) value;
- final WKTWriter writer = new WKTWriter();
- sb.append(writer.write(geometry));
- } else {
- sb.append('\'').append(value).append('\'');
- }
- });
- setExpressionHandler(FunctionNames.ValueReference, (e,sb) -> {
- final ValueReference<Feature,?> exp = (ValueReference<Feature,?>) e;
- final String name = exp.getXPath();
- if (patternPropertyName.matcher(name).find()) {
- // Escape for special chars
- sb.append('"').append(name).append('"');
- } else {
- sb.append(name);
- }
- });
- arithmetic(FunctionNames.Add, '+');
- arithmetic(FunctionNames.Divide, '/');
- arithmetic(FunctionNames.Multiply, '*');
- arithmetic(FunctionNames.Subtract, '-');
- }
-
- private void constant(final Filter<?> type, final String text) {
- setFilterHandler(type.getOperatorType(), (f,sb) -> sb.append(text));
- }
-
- private void operatorAfterValue(final String type, final String operator) {
- setFilterHandler(ComparisonOperatorName.valueOf(type), (f,sb) -> {
- format(sb, f.getExpressions().get(0));
- sb.append(operator);
- });
- }
-
- private void operatorBetweenValues(final ComparisonOperatorName type, final String operator) {
- setFilterHandler(type, (f,sb) -> {
- final List<Expression<Feature,?>> operands = f.getExpressions();
- format(sb, operands.get(0));
- final int n = operands.size();
- for (int i=1; i<n; i++) {
- // Should execute only once. If n>2, make the problem visible in the CQL.
- format(sb.append(' ').append(operator).append(' '), operands.get(i));
- }
- });
- }
-
- private void operatorBetweenValues(final LogicalOperatorName type, final String operator) {
- setFilterHandler(type, (f,sb) -> {
- final LogicalOperator<Feature> filter = (LogicalOperator<Feature>) f;
- final List<Filter<Feature>> operands = filter.getOperands();
- format(sb.append('('), operands.get(0));
- final int n = operands.size();
- for (int i=1; i<n; i++) {
- format(sb.append(' ').append(operator).append(' '), operands.get(i));
- }
- sb.append(')');
- });
- }
-
- private void function(final CodeList<?> type, final String operator) {
- setFilterHandler(type, (f,sb) -> {
- final List<Expression<Feature,?>> operands = f.getExpressions();
- sb.append(operator).append('(');
- final int n = operands.size();
- for (int i=0; i<n; i++) {
- if (i != 0) sb.append(", ");
- format(sb, operands.get(i));
- }
- sb.append(')');
- });
- }
-
- private void arithmetic(final String type, final char operator) {
- setExpressionHandler(type, (e,sb) -> {
- final List<Expression<Feature,?>> parameters = e.getParameters();
- format(sb, parameters.get(0));
- final int n = parameters.size();
- for (int i=1; i<n; i++) {
- format(sb.append(' ').append(operator).append(' '), parameters.get(i));
- }
- });
- }
-
- /**
- * Executes the registered action for the given filter.
- *
- * <h4>Note on type safety</h4>
- * This method signature uses {@code <? super R>} for caller's convenience because this is the type that
- * we get from {@link LogicalOperator#getOperands()}. But the {@link BiConsumer} uses exactly {@code <R>}
- * type because doing otherwise causes complications with types that cannot be expressed in Java (kinds
- * of {@code <? super ? super R>}). The cast in this method is okay if we do not invoke any {@code filter}
- * method with a return value (directly or indirectly as list elements) of exactly {@code <R>} type.
- * Such methods do not exist in the GeoAPI interfaces, so we are safe if the {@link BiConsumer}
- * does not invoke implementation-specific methods.
- *
- * @param sb where to write the result of all actions.
- * @param filter the filter for which to execute an action based on its type.
- * @throws UnsupportedOperationException if there is no action registered for the given filter.
- */
- @SuppressWarnings("unchecked")
- private void format(final StringBuilder sb, final Filter<Feature> filter) {
- visit((Filter<Feature>) filter, sb);
- }
-
- /**
- * Executes the registered action for the given expression.
- * Throws an exception if the expression did not write anything in the buffer.
- *
- * <h4>Note on type safety</h4>
- * This method signature uses {@code <? super R>} for caller's convenience because this is the type that
- * we get from {@link Expression#getParameters()}. But the {@link BiConsumer} expects exactly {@code <R>}
- * type because doing otherwise causes complications with types that cannot be expressed in Java (kinds
- * of {@code <? super ? super R>}). The cast in this method is okay if we do not invoke any {@code exp}
- * method with a return value (directly or indirectly as list elements) of exactly {@code <R>} type.
- * Such methods do not exist in the GeoAPI interfaces, so we are safe if the {@link BiConsumer}
- * does not invoke implementation-specific methods.
- *
- * @param sb where to write the result of all actions.
- * @param exp the expression for which to execute an action based on its type.
- * @throws UnsupportedOperationException if there is no action registered for the given expression.
- */
- @SuppressWarnings("unchecked")
- private void format(final StringBuilder sb, final Expression<Feature,?> expression) {
- visit((Expression<Feature,?>) expression, sb);
- }
-
- @Override
- protected void typeNotFound(final String type, final Expression<Feature,?> e, final StringBuilder sb) {
- final List<Expression<Feature,?>> exps = e.getParameters();
- sb.append(type).append('(');
- final int n = exps.size();
- for (int i=0; i<n; i++) {
- if (i != 0) sb.append(", ");
- format(sb, exps.get(i));
- }
- sb.append(')');
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/Query.java b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/Query.java
deleted file mode 100644
index 6c8794b..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/Query.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.cql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Filter;
-import org.opengis.filter.SortProperty;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Query {
-
- public final List<Projection> projections = new ArrayList<>();
- public Filter<Feature> filter;
- public Integer offset;
- public Integer limit;
- public final List<SortProperty> sortby = new ArrayList<>();
-
- public Query() {
- }
-
- public Query(List<Projection> projections, Filter filter, List<SortProperty> sortby, Integer offset, Integer limit) {
- if (projections != null) this.projections.addAll(projections);
- this.filter = filter;
- if (sortby != null) this.sortby.addAll(sortby);
- this.offset = offset;
- this.limit = limit;
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Query other = (Query) obj;
- if (!Objects.equals(this.projections, other.projections)) {
- return false;
- }
- if (!Objects.equals(this.filter, other.filter)) {
- return false;
- }
- if (!Objects.equals(this.sortby, other.sortby)) {
- return false;
- }
- if (!Objects.equals(this.offset, other.offset)) {
- return false;
- }
- if (!Objects.equals(this.limit, other.limit)) {
- return false;
- }
- return true;
- }
-
- public static class Projection {
- public Expression<Feature, ?> expression;
- public String alias;
-
- public Projection(Expression<Feature, ?> expression, String alias) {
- this.expression = expression;
- this.alias = alias;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 19 * hash + Objects.hashCode(this.expression);
- hash = 19 * hash + Objects.hashCode(this.alias);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Projection other = (Projection) obj;
- if (!Objects.equals(this.alias, other.alias)) {
- return false;
- }
- if (!Objects.equals(this.expression, other.expression)) {
- return false;
- }
- return true;
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/.gitignore b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/.gitignore
deleted file mode 100644
index 4948df6..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated by ANTLR
-*.interp
-*.tokens
-CQLLexer.java
-CQLParser.java
-CQLListener.java
-CQLBaseListener.java
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/AntlrCQL.java b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/AntlrCQL.java
deleted file mode 100644
index 64c3fa3..0000000
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/internal/AntlrCQL.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.cql.internal;
-
-import org.antlr.v4.runtime.CharStreams;
-import org.antlr.v4.runtime.CodePointCharStream;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.TokenStream;
-import org.antlr.v4.runtime.tree.ParseTree;
-
-
-/**
- * ANTLR CQL parser methods.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class AntlrCQL {
-
- private AntlrCQL() {
- }
-
- public static ParseTree compile(String cql) {
- final Object obj = compileFilterOrExpression(cql);
- ParseTree tree = null;
- if (obj instanceof ParseTree) {
- tree = (ParseTree) obj;
- }
- return tree;
- }
-
- public static Object compileExpression(String cql) {
- try {
- // Lexer splits input into tokens.
- final CodePointCharStream input = CharStreams.fromString(cql);
- final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
-
- // Parser generates abstract syntax tree.
- final CQLParser parser = new CQLParser(tokens);
- final CQLParser.ExpressionContext ctx = parser.expression();
- return ctx;
-
- } catch (RecognitionException e) {
- throw new IllegalStateException("Recognition exception is never thrown, only declared.");
- }
- }
-
- public static Object compileFilter(String cql) {
- try {
- // Lexer splits input into tokens.
- final CodePointCharStream input = CharStreams.fromString(cql);
- final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
-
- // Parser generates abstract syntax tree.
- final CQLParser parser = new CQLParser(tokens);
- final CQLParser.FilterContext retfilter = parser.filter();
-
- return retfilter;
-
- } catch (RecognitionException e) {
- throw new IllegalStateException("Recognition exception is never thrown, only declared.");
- }
- }
-
- public static Object compileFilterOrExpression(String cql) {
- try {
- // Lexer splits input into tokens.
- final CodePointCharStream input = CharStreams.fromString(cql);
- final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
-
- // Parser generates abstract syntax tree.
- final CQLParser parser = new CQLParser(tokens);
- final CQLParser.FilterOrExpressionContext retfilter = parser.filterOrExpression();
-
- return retfilter;
-
- } catch (RecognitionException e) {
- throw new IllegalStateException("Recognition exception is never thrown, only declared.");
- }
- }
-
- public static Object compileQuery(String cql) {
- try {
- // Lexer splits input into tokens.
- final CodePointCharStream input = CharStreams.fromString(cql);
- final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
-
- // Parser generates abstract syntax tree.
- final CQLParser parser = new CQLParser(tokens);
- final CQLParser.QueryContext ctx = parser.query();
- return ctx;
-
- } catch (RecognitionException e) {
- throw new IllegalStateException("Recognition exception is never thrown, only declared.");
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/CQLTestCase.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/CQLTestCase.java
deleted file mode 100644
index a29dc17..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/CQLTestCase.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.cql;
-
-import org.locationtech.jts.geom.GeometryFactory;
-import org.opengis.filter.FilterFactory;
-import org.opengis.feature.Feature;
-import org.apache.sis.filter.DefaultFilterFactory;
-
-
-/**
- * Base class of all CQL tests.
- *
- * @author Johann Sorel (Geomatys)
- */
-abstract class CQLTestCase {
- /**
- * The factory to use for creating filter and expressions.
- */
- final FilterFactory<Feature,Object,Object> FF;
-
- /**
- * The factory to use for creating Java Topology Suite (JTS) objects.
- */
- final GeometryFactory GF;
-
- /**
- * Creates a new test case.
- */
- CQLTestCase() {
- FF = DefaultFilterFactory.forFeatures();
- GF = org.apache.sis.geometry.wrapper.jts.Factory.INSTANCE.factory(false);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionReadingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionReadingTest.java
deleted file mode 100644
index e8af013..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionReadingTest.java
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * 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.cql;
-
-import java.time.Instant;
-import java.time.Duration;
-import java.time.Period;
-import java.time.LocalDate;
-import java.text.ParseException;
-import java.time.temporal.ChronoUnit;
-import java.time.temporal.TemporalAccessor;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryCollection;
-import org.locationtech.jts.geom.LineString;
-import org.locationtech.jts.geom.LinearRing;
-import org.locationtech.jts.geom.MultiLineString;
-import org.locationtech.jts.geom.MultiPoint;
-import org.locationtech.jts.geom.MultiPolygon;
-import org.locationtech.jts.geom.Point;
-import org.locationtech.jts.geom.Polygon;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
-
-// Test dependencies
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- * Test reading CQL expressions.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ExpressionReadingTest extends CQLTestCase {
- /**
- * Creates a new test case.
- */
- public ExpressionReadingTest() {
- }
-
- @Test
- public void testValueReference1() throws CQLException {
- final String cql = "geom";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof ValueReference);
- final ValueReference expression = (ValueReference) obj;
- assertEquals("geom", expression.getXPath());
- }
-
- @Test
- public void testValueReference2() throws CQLException {
- final String cql = "\"geom\"";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof ValueReference);
- final ValueReference expression = (ValueReference) obj;
- assertEquals("geom", expression.getXPath());
- }
-
- @Test
- public void testValueReference3() throws CQLException {
- final String cql = "ùthe_$uglY^_pr@perté";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof ValueReference);
- final ValueReference expression = (ValueReference) obj;
- assertEquals("ùthe_$uglY^_pr@perté", expression.getXPath());
- }
-
- @Test
- public void testInteger() throws CQLException {
- final String cql = "15";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals(Integer.valueOf(15), expression.getValue());
- }
-
- @Test
- public void testNegativeInteger() throws CQLException {
- final String cql = "-15";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals(Integer.valueOf(-15), expression.getValue());
- }
-
- @Test
- public void testDecimal1() throws CQLException {
- final String cql = "3.14";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals(Double.valueOf(3.14), expression.getValue());
- }
-
- @Test
- public void testDecimal2() throws CQLException {
- final String cql = "9e-1";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals(Double.valueOf(9e-1), expression.getValue());
- }
-
- @Test
- public void testNegativeDecimal() throws CQLException {
- final String cql = "-3.14";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals(Double.valueOf(-3.14), expression.getValue());
- }
-
- @Test
- public void testText() throws CQLException {
- final String cql = "'hello world'";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals("hello world", expression.getValue());
- }
-
- @Test
- public void testText2() throws CQLException {
- final String cql = "'Valle d\\'Aosta'";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals("Valle d'Aosta", expression.getValue());
- }
-
- @Test
- public void testText3() throws CQLException {
- final String cql = "'Valle d\\'Aosta/Vallée d\\'Aoste'";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertEquals("Valle d'Aosta/Vallée d'Aoste", expression.getValue());
- }
-
- @Test
- public void testDatetime() throws CQLException, ParseException{
- //dates are expected to be formated in ISO 8601 : yyyy-MM-dd'T'HH:mm:ss'Z'
- final String cql = "2012-03-21T05:42:36Z";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- Object value = expression.getValue();
- assertTrue(value instanceof TemporalAccessor);
- TemporalAccessor acc = (TemporalAccessor) value;
- assertEquals(Instant.parse("2012-03-21T05:42:36Z"), Instant.from(acc));
- }
-
- @Test
- public void testDate() throws CQLException, ParseException{
- final String cql = "2012-03-21";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- Object value = expression.getValue();
- assertTrue(value instanceof TemporalAccessor);
- TemporalAccessor acc = (TemporalAccessor) value;
- assertEquals(LocalDate.parse("2012-03-21"), LocalDate.from(acc));
- }
-
- @Test
- public void testDuration() throws CQLException, ParseException{
- final String cql = "P7Y6M5D";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertTrue(expression.getValue() instanceof Period);
- final Period period = (Period) expression.getValue();
- assertEquals(7, period.getYears());
- assertEquals(6, period.getMonths());
- assertEquals(5, period.getDays());
- }
-
- @Test
- public void testDuration2() throws CQLException, ParseException{
- final String cql = "PT4H3M2S";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- assertTrue(expression.getValue() instanceof Duration);
- final Duration duration = (Duration) expression.getValue();
- assertEquals(14582, duration.get(ChronoUnit.SECONDS));
- }
-
- @Test
- public void testAddition() throws CQLException {
- final String cql = "3 + 2";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- assertEquals(FF.add(FF.literal(3), FF.literal(2)), expression);
- }
-
- @Test
- @Disabled("String cannot be cast to Number.")
- public void testAddition2() throws CQLException {
- final String cql = "'test' + '23'";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- Object res = expression.apply(null);
- assertEquals("test23", res);
- }
-
- @Test
- public void testSubstract() throws CQLException {
- final String cql = "3 - 2";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- assertEquals(FF.subtract(FF.literal(3), FF.literal(2)), expression);
- }
-
- @Test
- public void testMultiply() throws CQLException {
- final String cql = "3 * 2";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- assertEquals(FF.multiply(FF.literal(3), FF.literal(2)), expression);
- }
-
- @Test
- public void testDivide() throws CQLException {
- final String cql = "3 / 2";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- assertEquals(FF.divide(FF.literal(3), FF.literal(2)), expression);
- }
-
- @Test
- @Disabled("Function `max` not yet supported.")
- public void testFunction1() throws CQLException {
- final String cql = "max(\"att\",15)";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression<Feature,?> expression = (Expression<Feature,?>) obj;
- assertEquals(FF.function("max",FF.property("att"), FF.literal(15)), expression);
- }
-
- @Test
- @Disabled("Function `min` not yet supported.")
- public void testFunction2() throws CQLException {
- final String cql = "min(\"att\",cos(3.14))";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression<Feature,?> expression = (Expression<Feature,?>) obj;
- assertEquals(FF.function("min",FF.property("att"), FF.function("cos",FF.literal(3.14d))), expression);
- }
-
- @Test
- public void testGeometryPoint() throws CQLException {
- final String cql = "POINT(15 30)";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createPoint(new Coordinate(15, 30));
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryPointEmpty() throws CQLException {
- final String cql = "POINT EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof Point);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryMPoint() throws CQLException {
- final String cql = "MULTIPOINT(15 30, 45 60)";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createMultiPoint(
- new Coordinate[]{
- new Coordinate(15, 30),
- new Coordinate(45, 60)
- });
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryMPointEmpty() throws CQLException {
- final String cql = "MULTIPOINT EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof MultiPoint);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryLineString() throws CQLException {
- final String cql = "LINESTRING(10 20, 30 40, 50 60)";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createLineString(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60)
- });
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryLineStringEmpty() throws CQLException {
- final String cql = "LINESTRING EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof LineString);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryMLineString() throws CQLException {
- final String cql = "MULTILINESTRING((10 20, 30 40, 50 60),(70 80, 90 100, 110 120))";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createMultiLineString(
- new LineString[]{
- GF.createLineString(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60)
- }),
- GF.createLineString(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120)
- })
- }
- );
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryMLineStringEmpty() throws CQLException {
- final String cql = "MULTILINESTRING EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof MultiLineString);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryPolygon() throws CQLException {
- final String cql = "POLYGON((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80))";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120),
- new Coordinate(70, 80)
- })
- }
- );
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryPolygonEmpty() throws CQLException {
- final String cql = "POLYGON EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof Polygon);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryMPolygon() throws CQLException {
- final String cql = "MULTIPOLYGON("
- + "((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80)),"
- + "((11 21, 31 41, 51 61, 11 21), (71 81, 91 101, 111 121, 71 81))"
- + ")";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Polygon geom1 = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120),
- new Coordinate(70, 80)
- })
- }
- );
- final Polygon geom2 = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(11, 21),
- new Coordinate(31, 41),
- new Coordinate(51, 61),
- new Coordinate(11, 21)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(71, 81),
- new Coordinate(91, 101),
- new Coordinate(111, 121),
- new Coordinate(71, 81)
- })
- }
- );
- final Geometry geom = GF.createMultiPolygon(new Polygon[]{geom1,geom2});
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryMPolygonEmpty() throws CQLException {
- final String cql = "MULTIPOLYGON EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof MultiPolygon);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryCollection() throws CQLException {
- final String cql = "GEOMETRYCOLLECTION( POINT(15 30), LINESTRING(10 20, 30 40, 50 60) )";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom1 = GF.createPoint(new Coordinate(15, 30));
- final Geometry geom2 = GF.createLineString(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60)
- });
- final GeometryCollection geom = GF.createGeometryCollection(new Geometry[]{geom1,geom2});
- final GeometryCollection returned = (GeometryCollection)expression.getValue();
- assertEquals(geom.getNumGeometries(), returned.getNumGeometries());
- assertEquals(geom.getGeometryN(0), returned.getGeometryN(0));
- assertEquals(geom.getGeometryN(1), returned.getGeometryN(1));
- }
-
- @Test
- public void testGeometryCollectionEmpty() throws CQLException {
- final String cql = "GEOMETRYCOLLECTION EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof GeometryCollection);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testGeometryEnvelope() throws CQLException {
- final String cql = "ENVELOPE(10, 20, 40, 30)";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 40),
- new Coordinate(20, 40),
- new Coordinate(20, 30),
- new Coordinate(10, 30),
- new Coordinate(10, 40)
- }),
- new LinearRing[0]
- );
- assertTrue(geom.equals((Geometry)expression.getValue()));
- }
-
- @Test
- public void testGeometryEnvelopeEmpty() throws CQLException {
- final String cql = "ENVELOPE EMPTY";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Literal);
- final Literal expression = (Literal) obj;
- final Geometry geom = (Geometry)expression.getValue();
- assertTrue(geom instanceof Polygon);
- assertTrue(geom.isEmpty());
- }
-
- @Test
- public void testCombine1() throws CQLException {
- final String cql = "((3*1)+(2-6))/4";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression expression = (Expression) obj;
- assertEquals(
- FF.divide(
- FF.add(
- FF.multiply(FF.literal(3), FF.literal(1)),
- FF.subtract(FF.literal(2), FF.literal(6))
- ),
- FF.literal(4))
- , expression);
- }
-
- @Test
- public void testCombine2() throws CQLException {
- final String cql = "3*1+2/4";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression rootAdd = (Expression) obj;
- assertEquals(
- FF.add(
- FF.multiply(FF.literal(3), FF.literal(1)),
- FF.divide(FF.literal(2), FF.literal(4))
- )
- , rootAdd);
- }
-
- @Test
- @Disabled("Function `max` not yet supported.")
- public void testCombine3() throws CQLException {
- final String cql = "3*max(val,15)+2/4";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression rootAdd = (Expression) obj;
- assertEquals(
- FF.add(
- FF.multiply(
- FF.literal(3),
- FF.function("max", FF.property("val"), FF.literal(15)).toValueType(Number.class)
- ),
- FF.divide(FF.literal(2), FF.literal(4))
- )
- , rootAdd);
- }
-
- @Test
- @Disabled("Function `max` not yet supported.")
- public void testCombine4() throws CQLException {
- final String cql = "3 * max ( val , 15 ) + 2 / 4";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression rootAdd = (Expression) obj;
- assertEquals(
- FF.add(
- FF.multiply(
- FF.literal(3),
- FF.function("max", FF.property("val", Number.class), FF.literal(15)).toValueType(Number.class)
- ),
- FF.divide(FF.literal(2), FF.literal(4))
- )
- , rootAdd);
- }
-
- @Test
- @Disabled("Difference in the class argument of `property(…)`.")
- public void testCombine5() throws CQLException {
- final String cql = "(\"NB-Curistes\"*50)/12000";
- final Object obj = CQL.parseExpression(cql);
- assertTrue(obj instanceof Expression);
- final Expression result = (Expression) obj;
- assertEquals(
- FF.divide(
- FF.multiply(
- FF.property("NB-Curistes", Number.class),
- FF.literal(50)
- ),
- FF.literal(12000)
- )
- , result);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionWritingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionWritingTest.java
deleted file mode 100644
index 9c1293d..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/ExpressionWritingTest.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * 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.cql;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.text.ParseException;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.LineString;
-import org.locationtech.jts.geom.LinearRing;
-import org.locationtech.jts.geom.Polygon;
-import org.opengis.filter.Expression;
-import org.opengis.feature.Feature;
-
-// Test dependencies
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- * Test writing in CQL expressions.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ExpressionWritingTest extends CQLTestCase {
- /**
- * Creates a new test case.
- */
- public ExpressionWritingTest() {
- }
-
- @Test
- public void testValueReference1() throws CQLException {
- final Expression<Feature,?> exp = FF.property("geom");
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("geom", cql);
- }
-
- @Test
- public void testValueReference2() throws CQLException {
- final Expression<Feature,?> exp = FF.property("the geom");
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("\"the geom\"", cql);
- }
-
- @Test
- public void testInteger() throws CQLException {
- final Expression<Feature,?> exp = FF.literal(15);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("15", cql);
- }
-
- @Test
- public void testNegativeInteger() throws CQLException {
- final Expression<Feature,?> exp = FF.literal(-15);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("-15", cql);
- }
-
- @Test
- public void testDecimal1() throws CQLException {
- final Expression<Feature,?> exp = FF.literal(3.14);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3.14", cql);
- }
-
- @Test
- public void testDecimal2() throws CQLException {
- final Expression<Feature,?> exp = FF.literal(9.0E-21);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("9.0E-21", cql);
- }
-
- @Test
- @Disabled("Unsupported temporal field: Year")
- public void testDateTime() throws CQLException, ParseException{
- final Expression<Feature,?> exp = FF.literal(Instant.parse("2012-03-21T05:42:36Z"));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("2012-03-21T05:42:36Z", cql);
- }
-
- @Test
- public void testDate() throws CQLException, ParseException{
- final Expression<Feature,?> exp = FF.literal(LocalDate.parse("2012-03-21"));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("2012-03-21", cql);
- }
-
-
- @Test
- public void testNegativeDecimal() throws CQLException {
- final Expression<Feature,?> exp = FF.literal(-3.14);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("-3.14", cql);
- }
-
- @Test
- public void testText() throws CQLException {
- final Expression<Feature,?> exp = FF.literal("hello world");
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("'hello world'", cql);
- }
-
- @Test
- public void testAdd() throws CQLException {
- final Expression<Feature,?> exp = FF.add(FF.literal(3),FF.literal(2));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 + 2", cql);
- }
-
- @Test
- public void testSubtract() throws CQLException {
- final Expression<Feature,?> exp = FF.subtract(FF.literal(3),FF.literal(2));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 - 2", cql);
- }
-
- @Test
- public void testMultiply() throws CQLException {
- final Expression<Feature,?> exp = FF.multiply(FF.literal(3),FF.literal(2));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 * 2", cql);
- }
-
- @Test
- public void testDivide() throws CQLException {
- final Expression<Feature,?> exp = FF.divide(FF.literal(3),FF.literal(2));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 / 2", cql);
- }
-
- @Test
- @Disabled("Function `max` not yet supported.")
- public void testFunction1() throws CQLException {
- final Expression<Feature,?> exp = FF.function("max", FF.property("att"), FF.literal(15));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("max(att , 15)", cql);
- }
-
- @Test
- @Disabled("Function `min` not yet supported.")
- public void testFunction2() throws CQLException {
- final Expression<Feature,?> exp = FF.function("min",FF.property("att"), FF.function("cos", FF.literal(3.14d)));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("min(att , cos(3.14))", cql);
- }
-
- @Test
- public void testCombine1() throws CQLException {
- final Expression<Feature,?> exp =
- FF.divide(
- FF.add(
- FF.multiply(FF.literal(3), FF.literal(1)),
- FF.subtract(FF.literal(2), FF.literal(6))
- ),
- FF.literal(4));
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 * 1 + 2 - 6 / 4", cql);
- }
-
- @Test
- public void testCombine2() throws CQLException {
- final Expression<Feature,?> exp =
- FF.add(
- FF.multiply(FF.literal(3), FF.literal(1)),
- FF.divide(FF.literal(2), FF.literal(4))
- );
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 * 1 + 2 / 4", cql);
-
- }
-
- @Test
- @Disabled("Function `max` not yet supported.")
- public void testCombine3() throws CQLException {
- final Expression<Feature,?> exp =
- FF.add(
- FF.multiply(
- FF.literal(3),
- FF.function("max", FF.property("val"), FF.literal(15)).toValueType(Number.class)
- ),
- FF.divide(FF.literal(2), FF.literal(4))
- );
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("3 * max(val , 15) + 2 / 4", cql);
- }
-
- @Test
- public void testPoint() throws CQLException {
- final Geometry geom = GF.createPoint(new Coordinate(15, 30));
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("POINT (15 30)", cql);
- }
-
- @Test
- public void testMPoint() throws CQLException {
- final Geometry geom = GF.createMultiPoint(
- new Coordinate[]{
- new Coordinate(15, 30),
- new Coordinate(45, 60)
- });
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("MULTIPOINT ((15 30), (45 60))", cql);
- }
-
- @Test
- public void testLineString() throws CQLException {
- final Geometry geom = GF.createLineString(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60)
- });
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("LINESTRING (10 20, 30 40, 50 60)", cql);
- }
-
- @Test
- public void testMLineString() throws CQLException {
- final Geometry geom = GF.createMultiLineString(
- new LineString[]{
- GF.createLineString(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60)
- }),
- GF.createLineString(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120)
- })
- }
- );
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("MULTILINESTRING ((10 20, 30 40, 50 60), (70 80, 90 100, 110 120))", cql);
- }
-
- @Test
- public void testPolygon() throws CQLException {
- final Geometry geom = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120),
- new Coordinate(70, 80)
- })
- }
- );
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("POLYGON ((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80))", cql);
- }
-
- @Test
- public void testMPolygon() throws CQLException {
- final Polygon geom1 = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(70, 80),
- new Coordinate(90, 100),
- new Coordinate(110, 120),
- new Coordinate(70, 80)
- })
- }
- );
- final Polygon geom2 = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(11, 21),
- new Coordinate(31, 41),
- new Coordinate(51, 61),
- new Coordinate(11, 21)
- }),
- new LinearRing[]{
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(71, 81),
- new Coordinate(91, 101),
- new Coordinate(111, 121),
- new Coordinate(71, 81)
- })
- }
- );
- final Geometry geom = GF.createMultiPolygon(new Polygon[]{geom1,geom2});
- final Expression<Feature,?> exp = FF.literal(geom);
- final String cql = CQL.write(exp);
- assertNotNull(cql);
- assertEquals("MULTIPOLYGON (((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80)), ((11 21, 31 41, 51 61, 11 21), (71 81, 91 101, 111 121, 71 81)))", cql);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterReadingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterReadingTest.java
deleted file mode 100644
index fcedc82..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterReadingTest.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * 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.cql;
-
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.Iterator;
-import java.time.Instant;
-import java.time.temporal.TemporalAccessor;
-import java.text.ParseException;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.LinearRing;
-import javax.measure.Quantity;
-import javax.measure.quantity.Length;
-import org.opengis.geometry.Envelope;
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.filter.*;
-import org.apache.sis.measure.Units;
-import org.apache.sis.measure.Quantities;
-import org.apache.sis.geometry.AbstractEnvelope;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.geometry.Envelope2D;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.util.privy.UnmodifiableArrayList;
-
-// Test dependencies
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- * Test reading CQL filters.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class FilterReadingTest extends CQLTestCase {
-
- private static final double DELTA = 0.00000001;
-
- private final Geometry baseGeometry;
-
- private final Geometry baseGeometryPoint;
-
- /**
- * Creates a new test case.
- */
- public FilterReadingTest() {
- baseGeometry = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[0]);
-
- baseGeometryPoint = GF.createPoint(
- new Coordinate(12.1, 28.9));
- }
-
- @Test
- public void testNullFilter() throws CQLException {
- //this is not true cql but is since in commun use cases.
- String cql = "";
- Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(Filter.include(), filter);
-
- cql = "*";
- filter = CQL.parseFilter(cql);
- assertEquals(Filter.include(), filter);
- }
-
- @Test
- public void testAnd() throws CQLException {
- final String cql = "att1 = 15 AND att2 = 30 AND att3 = 50";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(
- FF.and(
- UnmodifiableArrayList.<Filter<? super Feature>>wrap(new Filter[] {(Filter)
- FF.equal(FF.property("att1"), FF.literal(15)),
- FF.equal(FF.property("att2"), FF.literal(30)),
- FF.equal(FF.property("att3"), FF.literal(50))
- })),
- filter);
- }
-
- @Test
- public void testOr() throws CQLException {
- final String cql = "att1 = 15 OR att2 = 30 OR att3 = 50";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(
- FF.or(
- UnmodifiableArrayList.<Filter<? super Feature>>wrap(new Filter[] {(Filter)
- FF.equal(FF.property("att1"), FF.literal(15)),
- FF.equal(FF.property("att2"), FF.literal(30)),
- FF.equal(FF.property("att3"), FF.literal(50))
- })),
- filter);
- }
-
- @Test
- public void testOrAnd1() throws CQLException {
- final String cql = "Title = 'VMAI' OR (Title ILIKE '!$Pa_tt%ern?' AND DWITHIN(BoundingBox, POINT(12.1 28.9), 10, 'meter'))";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(
- FF.or(
- FF.equal(FF.property("Title"), FF.literal("VMAI")),
- FF.and(
- FF.like(FF.property("Title"), "!$Pa_tt%ern?", '%', '_', '\\', false),
- FF.within(FF.property("BoundingBox"), FF.literal(baseGeometryPoint), Quantities.create(10, Units.METRE))
- )
- ),
- filter);
- }
-
- @Test
- public void testOrAnd2() throws CQLException {
- final Geometry geom = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 40),
- new Coordinate(20, 40),
- new Coordinate(20, 30),
- new Coordinate(10, 30),
- new Coordinate(10, 40)
- }),
- new LinearRing[0]
- );
-
- final String cql = "NOT (INTERSECTS(BoundingBox, ENVELOPE(10, 20, 40, 30)) "
- + "OR CONTAINS(BoundingBox, POINT(12.1 28.9))) AND BBOX(BoundingBox, 10,20,30,40)";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(
- FF.and(
- FF.not(
- FF.or(
- FF.intersects(FF.property("BoundingBox"), FF.literal(geom)),
- FF.contains(FF.property("BoundingBox"), FF.literal(baseGeometryPoint))
- )
- ),
- FF.bbox(FF.property("BoundingBox"), new GeneralEnvelope(new Envelope2D(null, 10, 20, 30-10, 40-20)))
- ),
- filter);
- }
-
- @Test
- public void testNot() throws CQLException {
- final String cql = "NOT att = 15";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(FF.not(FF.equal(FF.property("att"), FF.literal(15))), filter);
- }
-
- @Test
- public void testPropertyIsBetween() throws CQLException {
- final String cql = "att BETWEEN 15 AND 30";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertEquals(FF.between(FF.property("att"), FF.literal(15), FF.literal(30)), filter);
- }
-
- @Test
- public void testIn() throws CQLException {
- verifyIn((LogicalOperator<?>) CQL.parseFilter("att IN ( 15, 30, 'hello')"));
- }
-
- @Test
- public void testNotIn() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att NOT IN ( 15, 30, 'hello')");
- assertEquals(LogicalOperatorName.NOT, filter.getOperatorType());
- LogicalOperator<?> logical = assertInstanceOf(LogicalOperator.class, filter);
- logical = assertInstanceOf(LogicalOperator.class, logical.getOperands().get(0));
- verifyIn(logical);
- }
-
- private void verifyIn(final LogicalOperator<?> filter) {
- assertInstanceOf(LogicalOperator.class, filter);
- assertEquals(LogicalOperatorName.OR, filter.getOperatorType());
- final Iterator<?> expected = Arrays.asList(15, 30, "hello").iterator();
- for (final Filter<?> operand : filter.getOperands()) {
- assertEquals(FF.equal(FF.property("att"), FF.literal(expected.next())), operand);
- }
- assertFalse(expected.hasNext());
- }
-
- @Test
- public void testPropertyIsEqualTo1() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att=15");
- assertEquals(FF.equal(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsEqualTo2() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att = 15");
- assertEquals(FF.equal(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsNotEqualTo() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att <> 15");
- assertEquals(FF.notEqual(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsNotEqualTo2() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att <>'15'");
- assertEquals(FF.notEqual(FF.property("att"), FF.literal("15")), filter);
- }
-
- @Test
- public void testPropertyIsGreaterThan() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att > 15");
- assertEquals(FF.greater(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsGreaterThanOrEqualTo() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att >= 15");
- assertEquals(FF.greaterOrEqual(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsLessThan() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att < 15");
- assertEquals(FF.less(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsLessThanOrEqualTo() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att <= 15");
- assertEquals(FF.lessOrEqual(FF.property("att"), FF.literal(15)), filter);
- }
-
- @Test
- public void testPropertyIsLike() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att LIKE '%hello_'");
- assertEquals(FF.like(FF.property("att"), "%hello_", '%', '_', '\\', true), filter);
- }
-
- @Test
- public void testPropertyIsNotLike() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att NOT LIKE '%hello_'");
- assertEquals(FF.not(FF.like(FF.property("att"), "%hello_", '%', '_', '\\', true)), filter);
- }
-
- @Test
- public void testPropertyIsLikeInsensitive() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att ILIKE '%hello_'");
- assertEquals(FF.like(FF.property("att"),"%hello_", '%', '_', '\\', false), filter);
- }
-
- @Test
- public void testPropertyIsNull() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att IS NULL");
- assertEquals(FF.isNull(FF.property("att")), filter);
- }
-
- @Test
- public void testPropertyIsNotNull() throws CQLException {
- final Filter<?> filter = CQL.parseFilter("att IS NOT NULL");
- assertEquals(FF.not(FF.isNull(FF.property("att"))), filter);
- }
-
- @Test
- public void testBBOX1() throws CQLException {
- final Envelope2D env = new Envelope2D(null, 10, 20, 30-10, 40-20);
- testBBOX("BBOX(\"att\", 10, 20, 30, 40)", "att", env);
- }
-
- @Test
- public void testBBOX2() throws CQLException {
- final Envelope2D env = new Envelope2D(CommonCRS.WGS84.normalizedGeographic(), 10, 20, 30-10, 40-20);
- testBBOX("BBOX(\"att\", 10, 20, 30, 40, 'CRS:84')", "att", env);
- }
-
- @Test
- public void testBBOX3() throws CQLException {
- final Envelope2D env = new Envelope2D(CommonCRS.WGS84.normalizedGeographic(), 10, 20, 30-10, 40-20);
- testBBOX("BBOX(att, 10, 20, 30, 40, 'CRS:84')", "att", env);
- }
-
- @Test
- public void testBBOX4() throws CQLException {
- final Envelope2D env = new Envelope2D(null, -10, -20, 10 - -10, 20 - -20);
- testBBOX("BBOX(geometry,-10,-20,10,20)", "geometry", env);
- }
-
- private void testBBOX(final String cql, final String att, final Envelope env) throws CQLException {
- final Filter<?> filter = CQL.parseFilter(cql);
- final BinarySpatialOperator<?> bsp = assertInstanceOf(BinarySpatialOperator.class, filter);
- assertEquals(SpatialOperatorName.BBOX, filter.getOperatorType());
- assertEquals(FF.property(att), bsp.getOperand1());
- final Literal<?,?> literal = assertInstanceOf(Literal.class, bsp.getOperand2());
- final Envelope value = assertInstanceOf(Envelope.class, literal.getValue());
- assertTrue(AbstractEnvelope.castOrCopy(value).equals(env, 1e-2, false));
- }
-
- /**
- * Tests {@code DWITHIN}.
- */
- @Test
- public void testDWithin() throws CQLException {
- final String cql = "DWITHIN(BoundingBox, POINT(12.1 28.9), 10, 'meters')";
- final DistanceOperator<?> filter = assertInstanceOf(DistanceOperator.class, CQL.parseFilter(cql));
- assertEquals(DistanceOperatorName.WITHIN, filter.getOperatorType());
-
- final var expressions = filter.getExpressions();
- assertEquals(FF.property("BoundingBox"), expressions.get(0));
- final Quantity<Length> distance = filter.getDistance();
- assertEquals(10.0, distance.getValue().doubleValue(), DELTA);
- assertEquals(Units.METRE, distance.getUnit());
-
- final Literal<?,?> literal = assertInstanceOf(Literal.class, expressions.get(1));
- final Geometry value = assertInstanceOf(Geometry.class, literal.getValue());
- assertTrue(baseGeometryPoint.equalsExact(value));
- }
-
- @Test
- public void testBinarySpatialOperators() throws CQLException {
- for (final SpatialOperatorName operator : SpatialOperatorName.values()) {
- if (operator == SpatialOperatorName.BBOX) continue;
- testSpatialOperators(operator, "");
- if (operator == SpatialOperatorName.OVERLAPS) break;
- }
- }
-
- @Test
- public void testDistanceOperators() throws CQLException {
- for (final DistanceOperatorName operator : DistanceOperatorName.values()) {
- final DistanceOperator<?> filter = (DistanceOperator<?>) testSpatialOperators(operator, ", 10, 'meters'");
- final Quantity<Length> distance = filter.getDistance();
- assertEquals(10.0, distance.getValue().doubleValue(), DELTA);
- assertEquals(Units.METRE, distance.getUnit());
- if (operator == DistanceOperatorName.WITHIN) break;
- }
- }
-
- private Filter<?> testSpatialOperators(final CodeList<?> operator, final String suffix) throws CQLException {
- final String name = operator.identifier().toUpperCase(Locale.US);
- final String cql = name + "(\"att\", POLYGON((10 20, 30 40, 50 60, 10 20))" + suffix + ')';
- final Filter<?> filter = CQL.parseFilter(cql);
- assertInstanceOf(SpatialOperator.class, filter, name);
- assertEquals(operator, filter.getOperatorType(), name);
-
- final var expressions = filter.getExpressions();
- assertEquals(FF.property("att"), expressions.get(0));
- final Literal<?,?> literal = assertInstanceOf(Literal.class, expressions.get(1));
- final Geometry value = assertInstanceOf(Geometry.class, literal.getValue());
- assertTrue(baseGeometry.equalsExact(value));
- return filter;
- }
-
- @Test
- public void testCombine1() throws CQLException {
- testCombine("NOT att = 15 OR att BETWEEN 15 AND 30");
- }
-
- @Test
- public void testCombine2() throws CQLException {
- testCombine("(NOT att = 15) OR (att BETWEEN 15 AND 30)");
- }
-
- private void testCombine(final String cql) throws CQLException {
- final Filter<?> filter = CQL.parseFilter(cql);
- assertInstanceOf(LogicalOperator.class, filter);
- assertEquals(LogicalOperatorName.OR, filter.getOperatorType());
- assertEquals(
- FF.or(
- FF.not(FF.equal(FF.property("att"), FF.literal(15))),
- FF.between(FF.property("att"), FF.literal(15), FF.literal(30))
- ),
- filter
- );
- }
-
- @Test
- public void testCombine3() throws CQLException {
- final String cql = "(NOT att1 = 15) AND (att2 = 15 OR att3 BETWEEN 15 AND 30) AND (att4 BETWEEN 1 AND 2)";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertInstanceOf(LogicalOperator.class, filter);
- assertEquals(LogicalOperatorName.AND, filter.getOperatorType());
- assertEquals(
- FF.and(
- UnmodifiableArrayList.<Filter<? super Feature>>wrap(new Filter[] {(Filter)
- FF.not(FF.equal(FF.property("att1"), FF.literal(15))),
- FF.or(
- FF.equal(FF.property("att2"), FF.literal(15)),
- FF.between(FF.property("att3"), FF.literal(15), FF.literal(30))
- ),
- FF.between(FF.property("att4"), FF.literal(1), FF.literal(2))
- })
- ),
- filter
- );
- }
-
- @Test
- @Disabled("Mismatched type in `property(…, type)`.")
- public void testCombine4() throws CQLException {
- final String cql = "(x+7) <= (y-9)";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertInstanceOf(BinaryComparisonOperator.class, filter);
- assertEquals(ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO, filter.getOperatorType());
- assertEquals(
- FF.lessOrEqual(
- FF.add(FF.property("x", Number.class), FF.literal(7)),
- FF.subtract(FF.property("y", Number.class), FF.literal(9))
- ),
- filter
- );
- }
-
- @Test
- public void testTemporalOperators() throws CQLException, ParseException {
- for (final TemporalOperatorName operator : TemporalOperatorName.values()) {
- final String name = operator.identifier().toUpperCase(Locale.US);
- final String cql = "att " + name + " 2012-03-21T05:42:36Z";
- final Filter<?> filter = CQL.parseFilter(cql);
- assertInstanceOf(TemporalOperator.class, filter, name);
- assertEquals(operator, filter.getOperatorType(),name);
- final var expressions = filter.getExpressions();
-
- assertEquals(FF.property("att"), expressions.get(0), name);
- final Literal<?,?> literal = assertInstanceOf(Literal.class, expressions.get(1));
- final TemporalAccessor time = assertInstanceOf(TemporalAccessor.class, literal.getValue());
- assertEquals(Instant.parse("2012-03-21T05:42:36Z"), Instant.from(time), name);
-
- // Skip any non-standard operators added by user.
- if (operator == TemporalOperatorName.ANY_INTERACTS) break;
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterWritingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterWritingTest.java
deleted file mode 100644
index ee75c69..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/FilterWritingTest.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * 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.cql;
-
-import java.time.Instant;
-import java.text.ParseException;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.LinearRing;
-import org.opengis.filter.Filter;
-import org.opengis.feature.Feature;
-import org.apache.sis.geometry.Envelope2D;
-import org.apache.sis.util.privy.UnmodifiableArrayList;
-import org.apache.sis.measure.Quantities;
-import org.apache.sis.measure.Units;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Disabled;
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- * Test writing in CQL filters.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class FilterWritingTest extends CQLTestCase {
-
- private final Geometry baseGeometry;
-
- /**
- * Creates a new test case.
- */
- public FilterWritingTest() {
- baseGeometry = GF.createPolygon(
- GF.createLinearRing(
- new Coordinate[]{
- new Coordinate(10, 20),
- new Coordinate(30, 40),
- new Coordinate(50, 60),
- new Coordinate(10, 20)
- }),
- new LinearRing[0]);
- }
-
- @Test
- public void testExcludeFilter() throws CQLException {
- final Filter filter = Filter.exclude();
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("1=0", cql);
- }
-
- @Test
- public void testIncludeFilter() throws CQLException {
- final Filter filter = Filter.include();
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("1=1", cql);
- }
-
- @Test
- public void testAnd() throws CQLException {
- final Filter filter = FF.and(
- UnmodifiableArrayList.<Filter<? super Feature>>wrap(new Filter[] {(Filter)
- FF.equal(FF.property("att1"), FF.literal(15)),
- FF.equal(FF.property("att2"), FF.literal(30)),
- FF.equal(FF.property("att3"), FF.literal(50))
- }));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("(\"att1\" = 15 AND \"att2\" = 30 AND \"att3\" = 50)", cql);
- }
-
- @Test
- public void testOr() throws CQLException {
- final Filter filter = FF.or(
- UnmodifiableArrayList.<Filter<? super Feature>>wrap(new Filter[] {(Filter)
- FF.equal(FF.property("att1"), FF.literal(15)),
- FF.equal(FF.property("att2"), FF.literal(30)),
- FF.equal(FF.property("att3"), FF.literal(50))
- }));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("(\"att1\" = 15 OR \"att2\" = 30 OR \"att3\" = 50)", cql);
- }
-
- @Test
- public void testId() throws CQLException {
- final Filter filter = FF.resourceId("test-1");
- try {
- CQL.write(filter);
- fail("ID filter does not exist in CQL");
- } catch (UnsupportedOperationException ex) {
- assertTrue(ex.getMessage().contains("ID"));
- }
- }
-
- @Test
- public void testNot() throws CQLException {
- final Filter filter = FF.not(FF.equal(FF.property("att"), FF.literal(15)));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("NOT att = 15", cql);
- }
-
- @Test
- public void testPropertyIsBetween() throws CQLException {
- final Filter filter = FF.between(FF.property("att"), FF.literal(15), FF.literal(30));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att BETWEEN 15 AND 30", cql);
- }
-
- @Test
- public void testPropertyIsEqualTo() throws CQLException {
- final Filter filter = FF.equal(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att = 15", cql);
- }
-
- @Test
- public void testPropertyIsNotEqualTo() throws CQLException {
- final Filter filter = FF.notEqual(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att <> 15", cql);
- }
-
- @Test
- public void testPropertyIsGreaterThan() throws CQLException {
- final Filter filter = FF.greater(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att > 15", cql);
- }
-
- @Test
- public void testPropertyIsGreaterThanOrEqualTo() throws CQLException {
- final Filter filter = FF.greaterOrEqual(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att >= 15", cql);
- }
-
- @Test
- public void testPropertyIsLessThan() throws CQLException {
- final Filter filter = FF.less(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att < 15", cql);
- }
-
- @Test
- public void testPropertyIsLessThanOrEqualTo() throws CQLException {
- final Filter filter = FF.lessOrEqual(FF.property("att"), FF.literal(15));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att <= 15", cql);
- }
-
- @Disabled
- @Test
- public void testPropertyIsLike() throws CQLException {
- final Filter filter = FF.like(FF.property("att"),"%hello");
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att ILIKE '%hello'", cql);
- }
-
- @Test
- public void testPropertyIsNull() throws CQLException {
- final Filter filter = FF.isNull(FF.property("att"));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att IS NULL", cql);
- }
-
- @Test
- public void testBBOX() throws CQLException {
- final Filter filter = FF.bbox(FF.property("att"), new Envelope2D(null, 10, 20, 30-10, 40-20));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("BBOX(att, 10.0, 30.0, 20.0, 40.0)", cql);
- }
-
- @Test
- public void testBeyond() throws CQLException {
- final Filter filter = FF.beyond(FF.property("att"), FF.literal(baseGeometry), Quantities.create(3, Units.METRE));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("BEYOND(att, POLYGON ((10 20, 30 40, 50 60, 10 20)), 3.0, 'meter')", cql);
- }
-
- @Test
- public void testContains() throws CQLException {
- final Filter filter = FF.contains(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("CONTAINS(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testCrosses() throws CQLException {
- final Filter filter = FF.crosses(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("CROSSES(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testDisjoint() throws CQLException {
- final Filter filter = FF.disjoint(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("DISJOINT(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testDWithin() throws CQLException {
- final Filter filter = FF.within(FF.property("att"), FF.literal(baseGeometry), Quantities.create(2, Units.METRE));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("DWITHIN(att, POLYGON ((10 20, 30 40, 50 60, 10 20)), 2.0, 'meter')", cql);
- }
-
- @Test
- public void testEquals() throws CQLException {
- final Filter filter = FF.equals(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("EQUALS(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testIntersects() throws CQLException {
- final Filter filter = FF.intersects(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("INTERSECTS(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testOverlaps() throws CQLException {
- final Filter filter = FF.overlaps(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("OVERLAPS(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testTouches() throws CQLException {
- final Filter filter = FF.touches(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("TOUCHES(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Test
- public void testWithin() throws CQLException {
- final Filter filter = FF.within(FF.property("att"), FF.literal(baseGeometry));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("WITHIN(att, POLYGON ((10 20, 30 40, 50 60, 10 20)))", cql);
- }
-
- @Disabled
- @Test
- public void testAfter() throws CQLException, ParseException {
- final Filter filter = FF.after(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att AFTER 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testAnyInteracts() throws CQLException, ParseException {
- final Filter filter = FF.anyInteracts(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att ANYINTERACTS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testBefore() throws CQLException, ParseException {
- final Filter filter = FF.before(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att BEFORE 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testBegins() throws CQLException, ParseException {
- final Filter filter = FF.begins(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att BEGINS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testBegunBy() throws CQLException, ParseException {
- final Filter filter = FF.begunBy(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att BEGUNBY 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testDuring() throws CQLException, ParseException {
- final Filter filter = FF.during(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att DURING 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testEndedBy() throws CQLException, ParseException {
- final Filter filter = FF.endedBy(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att ENDEDBY 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testEnds() throws CQLException, ParseException {
- final Filter filter = FF.ends(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att ENDS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testMeets() throws CQLException, ParseException {
- final Filter filter = FF.meets(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att MEETS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testMetBy() throws CQLException, ParseException {
- final Filter filter = FF.metBy(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att METBY 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testOverlappedBy() throws CQLException, ParseException {
- final Filter filter = FF.overlappedBy(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att OVERLAPPEDBY 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testTcontains() throws CQLException, ParseException {
- final Filter filter = FF.tcontains(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att TCONTAINS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testTequals() throws CQLException, ParseException {
- final Filter filter = FF.tequals(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att TEQUALS 2012-03-21T05:42:36Z", cql);
- }
-
- @Disabled
- @Test
- public void testToverlaps() throws CQLException, ParseException {
- final Filter filter = FF.toverlaps(FF.property("att"), FF.literal(Instant.parse("2012-03-21T05:42:36Z")));
- final String cql = CQL.write(filter);
- assertNotNull(cql);
- assertEquals("att TOVERLAPS 2012-03-21T05:42:36Z", cql);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryReadingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryReadingTest.java
deleted file mode 100644
index 57c0026..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryReadingTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.cql;
-
-import java.util.Arrays;
-import org.opengis.filter.SortOrder;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class QueryReadingTest extends CQLTestCase {
- /**
- * Creates a new test case.
- */
- public QueryReadingTest() {
- }
-
- @Test
- public void testEmpty() throws CQLException {
- String cql = "SELECT *";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(), query);
- }
-
- @Test
- public void testProjections() throws CQLException {
- String cql = "SELECT \"name\", 4 as 'col1'";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(Arrays.asList(new Query.Projection(FF.property("name"), null), new Query.Projection(FF.literal(4),"col1")), null, null, null, null), query);
- }
-
- @Test
- public void testWhere() throws CQLException {
- String cql = "SELECT * WHERE \"id\" = 'a'";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(null, FF.equal(FF.property("id"), FF.literal("a")), null, null, null), query);
- }
-
- @Test
- public void testOffset() throws CQLException {
- String cql = "SELECT * OFFSET 5";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(null, null, null, 5, null), query);
- }
-
- @Test
- public void testLimit() throws CQLException {
- String cql = "SELECT * LIMIT 10";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(null, null, null, null, 10), query);
- }
-
- @Test
- public void testOrderBy() throws CQLException {
- String cql = "SELECT * ORDER BY \"name\" ASC, \"age\" DESC";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(null, null, Arrays.asList(
- FF.sort(FF.property("name"), SortOrder.ASCENDING),
- FF.sort(FF.property("age"), SortOrder.DESCENDING)),
- null, null), query);
- }
-
- @Test
- public void testOrderByDefault() throws CQLException {
- String cql = "SELECT * ORDER BY \"name\", \"age\"";
- Query query = CQL.parseQuery(cql);
- assertEquals(new Query(null, null, Arrays.asList(
- FF.sort(FF.property("name"), SortOrder.ASCENDING),
- FF.sort(FF.property("age"), SortOrder.ASCENDING)),
- null, null), query);
- }
-
- @Test
- public void testComplete() throws CQLException {
- String cql = "SELECT \"name\", 4 as 'col1' WHERE \"id\" = 'a' ORDER BY \"name\" ASC, \"age\" DESC OFFSET 5 LIMIT 10";
- Query query = CQL.parseQuery(cql);
- assertEquals(
- new Query(
- Arrays.asList(new Query.Projection(FF.property("name"), null), new Query.Projection(FF.literal(4),"col1")),
- FF.equal(FF.property("id"), FF.literal("a")),
- Arrays.asList(
- FF.sort(FF.property("name"), SortOrder.ASCENDING),
- FF.sort(FF.property("age"), SortOrder.DESCENDING)),
- 5,
- 10),
- query);
- }
-}
diff --git a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryWritingTest.java b/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryWritingTest.java
deleted file mode 100644
index 464d4e9..0000000
--- a/incubator/src/org.apache.sis.cql/test/org/apache/sis/cql/QueryWritingTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.cql;
-
-import java.util.Arrays;
-import org.opengis.filter.SortOrder;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class QueryWritingTest extends CQLTestCase {
- /**
- * Creates a new test case.
- */
- public QueryWritingTest() {
- }
-
- @Test
- public void testWrite() throws CQLException {
- final Query query = new Query(
- Arrays.asList(new Query.Projection(FF.property("name"), null), new Query.Projection(FF.literal(4),"col1")),
- FF.equal(FF.property("id"), FF.literal("a")),
- Arrays.asList(
- FF.sort(FF.property("name"), SortOrder.ASCENDING),
- FF.sort(FF.property("age"), SortOrder.DESCENDING)),
- 5,
- 10);
-
- String cql = CQL.write(query);
- assertEquals("SELECT name, 4 AS 'col1' WHERE id = 'a' ORDER BY name ASC, age DESC OFFSET 5 LIMIT 10", cql);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/META-INF/services/org.apache.sis.geometries.processor.Processor b/incubator/src/org.apache.sis.geometry/main/META-INF/services/org.apache.sis.geometries.processor.Processor
deleted file mode 100644
index 7489f1c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/META-INF/services/org.apache.sis.geometries.processor.Processor
+++ /dev/null
@@ -1,28 +0,0 @@
-org.apache.sis.geometries.processor.spatialanalysis2d.Distance$PointPoint
-
-org.apache.sis.geometries.processor.spatialanalysis2d.Intersection$PrimitiveTrianglesPrimitivePoints
-org.apache.sis.geometries.processor.spatialanalysis2d.Intersection$PrimitiveTrianglesPrimitiveLines
-
-org.apache.sis.geometries.processor.spatialedition.To3D$Point
-org.apache.sis.geometries.processor.spatialedition.To3D$LineString
-org.apache.sis.geometries.processor.spatialedition.To3D$Primitive
-
-org.apache.sis.geometries.processor.spatialedition.ComputeAttribute$Primitive
-org.apache.sis.geometries.processor.spatialedition.ComputeAttribute$MultiPrimitive
-
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$Point
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$LineString
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$Polygon
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$MultiLineString
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$MultiPoint
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$MultiPrimitive
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$Primitive
-org.apache.sis.geometries.processor.spatialedition.ToPrimitive$GeometryCollection
-
-org.apache.sis.geometries.processor.spatialedition.Transform$LinearRing
-org.apache.sis.geometries.processor.spatialedition.Transform$Polygon
-org.apache.sis.geometries.processor.spatialedition.Transform$MultiPrimitive
-org.apache.sis.geometries.processor.spatialedition.Transform$Primitive
-org.apache.sis.geometries.processor.spatialedition.Transform$Triangle
-
-org.apache.sis.geometries.processor.spatialrelations2d.Contains$PolygonPoint
diff --git a/incubator/src/org.apache.sis.geometry/main/module-info.java b/incubator/src/org.apache.sis.geometry/main/module-info.java
deleted file mode 100644
index 2c58c63..0000000
--- a/incubator/src/org.apache.sis.geometry/main/module-info.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Geometries.
- *
- * @author Johann Sorel (Geomatys)
- */
-module org.apache.sis.geometry {
- requires esri.geometry.api; // TODO: remove (this is for tests).
- requires org.apache.sis.feature;
- requires org.apache.sis.util;
- requires transitive org.apache.sis.storage;
-
-
- exports org.apache.sis.geometries;
- exports org.apache.sis.geometries.operation;
- exports org.apache.sis.geometries.processor;
- exports org.apache.sis.geometries.math;
-
- uses org.apache.sis.geometries.processor.Processor;
- provides org.apache.sis.geometries.processor.Processor
- with org.apache.sis.geometries.processor.spatialanalysis2d.Distance.PointPoint,
- org.apache.sis.geometries.processor.spatialanalysis2d.Intersection.PrimitiveTrianglesPrimitivePoints,
- org.apache.sis.geometries.processor.spatialanalysis2d.Intersection.PrimitiveTrianglesPrimitiveLines,
- org.apache.sis.geometries.processor.spatialedition.To3D.Point,
- org.apache.sis.geometries.processor.spatialedition.To3D.LineString,
- org.apache.sis.geometries.processor.spatialedition.To3D.Primitive,
- org.apache.sis.geometries.processor.spatialedition.ComputeAttribute.Primitive,
- org.apache.sis.geometries.processor.spatialedition.ComputeAttribute.MultiPrimitive,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.Point,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.LineString,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.Polygon,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.MultiLineString,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.MultiPoint,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.MultiPrimitive,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.Primitive,
- org.apache.sis.geometries.processor.spatialedition.ToPrimitive.GeometryCollection,
- org.apache.sis.geometries.processor.spatialedition.Transform.MultiPrimitive,
- org.apache.sis.geometries.processor.spatialedition.Transform.Primitive,
- org.apache.sis.geometries.processor.spatialedition.Transform.Triangle,
- org.apache.sis.geometries.processor.spatialrelations2d.Contains.PolygonPoint;
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/AttributesType.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/AttributesType.java
deleted file mode 100644
index b9aeefc..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/AttributesType.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-
-
-/**
- * 3D Engine decompose draw calls by primitive types.
- * Each indexed primitives are forwarded with a set of Attributes.
- *
- * In common GIS, a single ordinate has been defined as 'M'.
- * It is a very limited capability compared to 3D engine geometry properties.
- *
- * @author Johann Sorel (Geomatys
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#bb_measures
- */
-public interface AttributesType {
-
- public static final String ATT_POSITION = "POSITION";
- public static final String ATT_NORMAL = "NORMAL";
- public static final String ATT_TANGENT = "TANGENT";
- public static final String ATT_TEXCOORD_0 = "TEXCOORD_0";
-
- //indexed attributes
- public static final String ATT_TEXCOORD = "TEXCOORD";
- public static final String ATT_COLOR = "COLOR";
- public static final String ATT_JOINTS = "JOINTS";
- public static final String ATT_WEIGHTS = "WEIGHTS";
-
- /**
- * Attribute from OGC 3D Tiles.
- * To link primitives to features/batch tables.
- */
- public static final String ATT_BATCH_ID = "_BATCHID";
-
- /**
- * Returns attribute system for given name.
- *
- * @param name seached attribute name
- * @return system or null.
- */
- SampleSystem getAttributeSystem(String name);
-
- /**
- * Returns attribute type for given name.
- *
- * @param name seached attribute name
- * @return type or null.
- */
- DataType getAttributeType(String name);
-
- /**
- * Returns attribute names.
- *
- * @return names, never null, can be empty
- */
- List<String> getAttributeNames();
-
-
- /**
- * Empty attributes type.
- */
- public static AttributesType EMPTY = new AttributesType() {
- @Override
- public SampleSystem getAttributeSystem(String name) {
- return null;
- }
-
- @Override
- public DataType getAttributeType(String name) {
- return null;
- }
-
- @Override
- public List<String> getAttributeNames() {
- return Collections.EMPTY_LIST;
- }
- };
-
- /**
- * Modifiable AttributesType implementation.
- */
- public static final class Template implements AttributesType {
-
- private final Map<String,DataType> datatypes = new HashMap<>();
- private final Map<String,SampleSystem> sampleSystems = new HashMap<>();
-
- public Template() {}
-
- public void addOrReplaceAttribute(String name, SampleSystem system, DataType type) {
- datatypes.put(name, type);
- sampleSystems.put(name, system);
- }
-
- @Override
- public SampleSystem getAttributeSystem(String name) {
- return sampleSystems.get(name);
- }
-
- @Override
- public DataType getAttributeType(String name) {
- return datatypes.get(name);
- }
-
- @Override
- public List<String> getAttributeNames() {
- return new ArrayList(datatypes.keySet());
- }
- }
-
- /**
- * Retains only the elements in this AttributesType that are contained in the
- * specified AttributesType. In other words, removes from
- * this AttributesType all of its elements that are not contained in the
- * specified AttributesType.
- *
- * @param other not null
- * @return new AttributesType or this instance if unchanged.
- */
- default AttributesType retainAll(AttributesType other) throws IllegalArgumentException {
- List<String> attributeNames = new ArrayList<>(getAttributeNames());
- attributeNames.retainAll(other.getAttributeNames());
-
- final Template template = new Template();
- for (String name : getAttributeNames()) {
- SampleSystem system = other.getAttributeSystem(name);
- if (system == null) continue;
- if (!system.equals(getAttributeSystem(name))) {
- throw new IllegalArgumentException("Both attribute types contain " + name + " but sample system differ");
- }
- DataType type = DataType.largest(getAttributeType(name), other.getAttributeType(name));
- template.addOrReplaceAttribute(name, system, type);
- }
-
- return template;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BBox.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BBox.java
deleted file mode 100644
index 37e858d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BBox.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- * A BBOx geometry defined by lower and upper corners.
- * This is not an axis oriented bounding box, see OBBox for the oriented counterpart.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class BBox extends GeneralEnvelope implements Geometry {
-
- private Map<String,Object> properties;
-
- /**
- * @param dimension number of dimensions of the bbox, must be positive.
- */
- public BBox(int dimension) {
- super(dimension);
- }
-
- /**
- * @param dimension number of dimensions of the bbox, must be positive.
- * @param corners lower corner and higher corner, in crs axis order
- */
- public BBox(int dimension, double ... corners) {
- super(dimension);
- setEnvelope(corners);
- }
-
- /**
- * @param lower lower corner
- * @param upper upper corner
- */
- public BBox(Tuple lower, Tuple upper) {
- super(Vectors.asDirectPostion(lower), Vectors.asDirectPostion(upper));
- }
-
- /**
- * @param crs sphere coordinate system, not null.
- */
- public BBox(CoordinateReferenceSystem crs) {
- super(crs);
- }
-
- /**
- * @param crs sphere coordinate system, not null.
- * @param corners lower corner and higher corner, in crs axis order
- */
- public BBox(CoordinateReferenceSystem crs, double ... corners) {
- super(crs);
- setEnvelope(corners);
- }
-
- /**
- * @param env Envelope to copy crs and coordinates from.
- */
- public BBox(Envelope env) {
- super(env);
- }
-
- @Override
- public String getGeometryType() {
- return "POLYGON"; //TODO not in OGC SFA.
- }
-
- public void add(Tuple<?> position) throws MismatchedDimensionException {
- add(Vectors.asDirectPostion(position));
- }
-
- /**
- * {@inheritDoc }
- */
- public Tuple<?> getLower() {
- return Vectors.castOrWrap(super.getLowerCorner());
- }
-
- /**
- * {@inheritDoc }
- */
- public Tuple<?> getUpper() {
- return Vectors.castOrWrap(super.getUpperCorner());
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public Envelope getEnvelope() {
- return this.clone();
- }
-
- @Override
- public synchronized Map<String, Object> userProperties() {
- if (properties == null) {
- properties = new HashMap<>();
- }
- return properties;
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Bearing.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Bearing.java
deleted file mode 100644
index 5709e06..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Bearing.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Bearing", specification=ISO_19107) // section 6.2.22
-public interface Bearing {
-
- //TODO
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BoundaryType.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BoundaryType.java
deleted file mode 100644
index 5b621e1..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/BoundaryType.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.geometries;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public enum BoundaryType {
- METRIC,
- MOD_2,
- AT_LEAST_2,
- SPIRAL
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Curve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Curve.java
deleted file mode 100644
index 663c59e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Curve.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- * A Curve is a 1-dimensional geometric object usually stored as a sequence of Points, with the subtype of Curve
- * specifying the form of the interpolation between Points.
- * This standard defines only one subclass of Curve, LineString, which uses linear interpolation between Points.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Curve", specification=ISO_19107) // section 6.4.18
-public interface Curve extends Orientable {
-
- /**
- * The length of this Curve in its associated spatial reference.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.6.2
- * @return length of the curve.
- */
- @UML(identifier="length", specification=ISO_19107) // section 6.4.18.9
- default double getLength() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * The start Point of this Curve.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.6.2
- * @return start Point of this Curve.
- */
- @UML(identifier="startPoint", specification=ISO_19107) // section 6.4.18.6
- default Point getStartPoint() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * The end Point of this Curve.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.6.2
- * @return end Point of this Curve.
- */
- @UML(identifier="endPoint", specification=ISO_19107) // section 6.4.18.7
- default Point getEndPoint() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns TRUE if this Curve is closed [StartPoint() = EndPoint()].
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.6.2
- * @return true if curve is closed.
- */
- default boolean isClosed() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns TRUE if this Curve is closed [StartPoint () = EndPoint ()]
- * and this Curve is simple (does not pass through the same Point more than once).
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.6.2
- * @return true if curve is a ring.
- */
- @UML(identifier="isRing", specification=ISO_19107) // section 6.4.18.8
- default boolean isRing() {
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="controlPoint", specification=ISO_19107) // section 6.4.18.2
- default List<DirectPosition> getControlPoints() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="dataPoint", specification=ISO_19107) // section 6.4.18.3
- default List<DirectPosition> getDataPoints() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="knot", specification=ISO_19107) // section 6.4.18.4
- default List<Knot> getKnots() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 6.4.18.5
- default CurveInterpolation getInterpolation() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="startConstrParam,", specification=ISO_19107) // section 6.4.18.15
- default double getStartConstrParam() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="endConstrParam", specification=ISO_19107) // section 6.4.18.15
- default double getEndConstrParam() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="startParam,", specification=ISO_19107) // section 6.4.18.13
- default Length getStartParam() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="endParam", specification=ISO_19107) // section 6.4.18.13
- default Length getEndParam() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="numDerivativesInterior", specification=ISO_19107) // section 6.4.18.10
- default Integer getNumDerivativeInterior() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="numDerivativesStart", specification=ISO_19107) // section 6.4.18.11
- default Integer getNumDerivativesStart() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="numDerivativesEnd", specification=ISO_19107) // section 6.4.18.12
- default Integer getNumDerivativesEnd() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="reverse", specification=ISO_19107) // section 6.4.18.14
- @Override
- default Curve getReverse() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="asLine", specification=ISO_19107) // section 6.4.18.17
- default LineString asLine(Length spacing, Length offset) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="constrParam", specification=ISO_19107) // section 6.4.18.18
- default DirectPosition constrParam(double cp) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="length", specification=ISO_19107) // section 6.4.18.19
- default Length getLength(DirectPosition point1, DirectPosition point2) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="length", specification=ISO_19107) // section 6.4.18.19
- default Length getLength(double cparam1, double cparam2) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="param", specification=ISO_19107) // section 6.4.18.20
- default DirectPosition param(Length s) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="paramForPoint", specification=ISO_19107) // section 6.4.18.21
- default List<Length> paramForPoint(List<DirectPosition> p) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="tangent", specification=ISO_19107) // section 6.4.18.22
- default Vector tangent(Length s) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="tangent", specification=ISO_19107) // section 6.4.18.22
- default Vector tangent(double knotParameter) {
- //TODO
- throw new UnsupportedOperationException();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurveInterpolation.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurveInterpolation.java
deleted file mode 100644
index 2d76080..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurveInterpolation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="CurveInterpolation", specification=ISO_19107) // section 6.4.24
-public enum CurveInterpolation {
- COMPOSITE_CURVE,
- PRODUCT_CURVE,
- LINEAR,
- GEODESIC,
- RHUMB,
- CIRCULAR,
- SPIRAL,
- CLOTHOID,
- ELLIPTICAL,
- CONIC,
- POLYNOMIAL_SPLINE,
- BEZIER_SPLINE,
- BSPLINE,
- NURBS,
- PRODUCT,
- COMPOSITE,
-
- SOLID //TODO : not in the table but in the uml, recheck
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurvePolygon.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurvePolygon.java
deleted file mode 100644
index a026e5e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/CurvePolygon.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.coordinate.GriddedSurface;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-
-
-/**
- * A curve polygon is a surface where each ring is a closed line string, circular string, or compound curve.
- * The first ring is the exterior boundary and, all other rings are interior boundaries.
- *
- * @todo is Polygon a subclass of CurvePolygon ?
- * ISO-19107 use the name Polygon for CurvePolygon
- * OGC Features and Geometries JSON separates them
- * In practice most geometry library have only polygon with straight lines
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#curve_polygon
- */
-@UML(identifier="Polygon", specification=ISO_19107) // section 8.1.2
-public interface CurvePolygon extends Surface {
-
- public static final String TYPE = "CURVEPOLYGON";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- public default AttributesType getAttributesType() {
- return getExteriorRing().getAttributesType();
- }
-
- @UML(identifier="rings", specification=ISO_19107) // section 8.1 figure 28
- List<Curve> getInteriorRings();
-
- /**
- * Returns the exterior ring of this Polygon.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @return exterior ring of this Polygon.
- */
- @UML(identifier="exteriorRing", specification=ISO_19107) // section 8.1 figure 28
- Curve getExteriorRing();
-
- /**
- * Returns the number of interior rings in this Polygon.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @return number of interior rings in this Polygon.
- */
- @UML(identifier="numInteriorRing", specification=ISO_19107) // section 8.1 figure 28
- default int getNumInteriorRing() {
- return getInteriorRings().size();
- }
-
- /**
- * Returns the Nth interior ring for this Polygon as a LineString.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @param n ring index
- * @return interior ring for this Polygon.
- */
- @UML(identifier="interiorRingN", specification=ISO_19107) // section 8.1 figure 28
- default Curve getInteriorRingN(int n) {
- return getInteriorRings().get(n);
- }
-
- @UML(identifier="spanningSurface", specification=ISO_19107) // section 8.1.2.3
- default GriddedSurface getSpanningSurface() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("POLYGON ((");
- AbstractGeometry.toText(sb, getExteriorRing().asLine(null, null).getPoints());
- sb.append(')');
- for (int i = 0, n = getNumInteriorRing(); i < n; i++) {
- if (i != 0) sb.append(',');
- sb.append('(');
- AbstractGeometry.toText(sb, getInteriorRingN(i).asLine(null, null).getPoints());
- sb.append(')');
- }
- sb.append(')');
- return sb.toString();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java
deleted file mode 100644
index 157cd5d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java
+++ /dev/null
@@ -1,812 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.CoordinateSequence;
-import javax.measure.Unit;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.IdentifiedObject;
-import static org.opengis.referencing.IdentifiedObject.ALIAS_KEY;
-import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.datum.EngineeringDatum;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.Matrix;
-import org.opengis.util.FactoryException;
-import org.opengis.util.InternationalString;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vector3D;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MultiMeshPrimitive;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.apache.sis.geometry.wrapper.jts.JTS;
-import org.apache.sis.measure.Units;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.crs.DefaultEngineeringCRS;
-import org.apache.sis.referencing.cs.DefaultCartesianCS;
-import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
-import org.apache.sis.referencing.cs.DefaultLinearCS;
-import org.apache.sis.referencing.datum.DefaultEngineeringDatum;
-import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
-import org.apache.sis.referencing.privy.AxisDirections;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.SimpleInternationalString;
-import org.apache.sis.util.Static;
-import org.apache.sis.util.Utilities;
-
-
-/**
- * Mesh geometry utilities.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Geometries extends Static {
-
- private static final CoordinateReferenceSystem UNDEFINED_CRS_1D = createUndefined(1);
- private static final CoordinateReferenceSystem UNDEFINED_CRS_2D = createUndefined(2);
- private static final CoordinateReferenceSystem UNDEFINED_CRS_3D = createUndefined(3);
- private static final CoordinateReferenceSystem UNDEFINED_CRS_4D = createUndefined(4);
- private static CoordinateReferenceSystem[] UNDEFINED = new CoordinateReferenceSystem[0];
-
- private static final DefaultEngineeringDatum DATUM;
- static {
- final Map<String,Object> properties = new HashMap<>(4);
- properties.put(NAME_KEY, "Display");
- properties.put(ALIAS_KEY, "Display");
- DATUM = new DefaultEngineeringDatum(properties);
- }
-
- public static final AxisDirection UP = AxisDirection.valueOf("UP");
- public static final AxisDirection DOWN = AxisDirection.valueOf("DOWN");
- public static final AxisDirection LEFT = AxisDirections.valueOf("WEST"); //TODO fix me when SIS has the appropriate axis
- public static final AxisDirection RIGHT = AxisDirection.valueOf("EAST"); //TODO fix me when SIS has the appropriate axis
- public static final AxisDirection FORWARD = AxisDirection.valueOf("NORTH"); //TODO fix me when SIS has the appropriate axis
- public static final AxisDirection BACKWARD = AxisDirection.valueOf("SOUTH"); //TODO fix me when SIS has the appropriate axis
- public static final DefaultCoordinateSystemAxis X_RIGHT = create("Right", "x", RIGHT, Units.METRE);
- public static final DefaultCoordinateSystemAxis X_LEFT = create("Left", "x", LEFT, Units.METRE);
- public static final DefaultCoordinateSystemAxis Y_UP = create("Up", "y", UP, Units.METRE);
- public static final DefaultCoordinateSystemAxis Y_DOWN = create("Down", "y", DOWN, Units.METRE);
- public static final DefaultCoordinateSystemAxis Y_FORWARD = create("Unknown", "y", FORWARD, Units.METRE);
- public static final DefaultCoordinateSystemAxis Y_BACKWARD = create("Unknown", "y", BACKWARD, Units.METRE);
- public static final DefaultCoordinateSystemAxis Z_FORWARD = create("Unknown", "z", FORWARD, Units.METRE);
- public static final DefaultCoordinateSystemAxis Z_BACKWARD = create("Unknown", "z", BACKWARD, Units.METRE);
- public static final DefaultCoordinateSystemAxis Z_UP = create("Up", "z", UP, Units.METRE);
- public static final DefaultCoordinateSystemAxis Z_DOWN = create("Down", "z", DOWN, Units.METRE);
- /**
- * Right hand CRS, X(right), Y(up)
- */
- public static final CoordinateReferenceSystem RIGHT_HAND_2D = createCartesianCRS2D(X_RIGHT, Y_UP);
- /**
- * Right hand CRS, X(right), Y(up), Z(forward)
- */
- public static final CoordinateReferenceSystem RIGHT_HAND_3D = createCartesianCRS3D(X_LEFT, Y_UP, Z_FORWARD);
- /**
- * Left hand CRS, X(right), Y(up), Z(backward)
- */
- public static final CoordinateReferenceSystem LEFT_HAND_3D = createCartesianCRS3D(X_RIGHT, Y_UP, Z_BACKWARD);
- /**
- * Planar geographic crs with an aditional elevation axis.
- * X(right), Y(forward), Z(up)
- */
- public static final CoordinateReferenceSystem PSEUDOGEO_3D = createCartesianCRS3D(X_RIGHT, Y_FORWARD, Z_UP);
-
- /**
- * Get an undefined CRS whic can not be converted to any other CRS.
- * @param nbDim CRS dimension
- * @return created CRS.
- */
- public static CoordinateReferenceSystem getUndefinedCRS(int nbDim) {
- switch (nbDim) {
- case 1 : return UNDEFINED_CRS_1D;
- case 2 : return UNDEFINED_CRS_2D;
- case 3 : return UNDEFINED_CRS_3D;
- case 4 : return UNDEFINED_CRS_4D;
- default: {
- ArgumentChecks.ensureStrictlyPositive("nbDim", nbDim);
- final int idx = nbDim - 4;
- synchronized (DATUM) {
- if (idx >= UNDEFINED.length) {
- UNDEFINED = Arrays.copyOf(UNDEFINED, idx+1);
- }
- if (UNDEFINED[idx] == null) {
- UNDEFINED[idx] = createUndefined(nbDim);
- }
- return UNDEFINED[idx];
- }
- }
- }
- }
-
- private static CoordinateReferenceSystem createUndefined(int nbDim) {
- try {
- final String name = "Undefined";
- final List<CoordinateReferenceSystem> crss = new ArrayList<>();
- for (int i=0;i<nbDim;i++) {
- final EngineeringDatum datum = new DefaultEngineeringDatum(Collections.singletonMap("name", name + i + "D Datum"));
- final CoordinateSystemAxis axis = new DefaultCoordinateSystemAxis(Collections.singletonMap("name", name + i + "Axis"),
- name, AxisDirection.UNSPECIFIED, Units.UNITY);
- final CoordinateSystem cs = new DefaultLinearCS(Collections.singletonMap("name", name + i + "CS"), axis);
- DefaultEngineeringCRS crs = new DefaultEngineeringCRS(Collections.singletonMap("name", name), datum, cs);
- crss.add(crs);
- }
- return CRS.compound(crss.toArray(new CoordinateReferenceSystem[crss.size()]));
- } catch (FactoryException ex) {
- //should not happen
- throw new IllegalStateException(ex.getMessage(), ex);
- }
- }
-
- /**
- * Constructs an axis with a name and an abbreviation as a resource bundle key.
- * To be used for construction of pre-defined constants only.
- *
- * @param name The name.
- * @param abbreviation The {@linkplain #getAbbreviation abbreviation} used for this
- * coordinate system axes.
- * @param direction The {@linkplain #getDirection direction} of this coordinate system axis.
- * @param unit The {@linkplain #getUnit unit of measure} used for this coordinate
- * system axis.
- */
- private static DefaultCoordinateSystemAxis create(final String name,
- final String abbreviation,
- final AxisDirection direction,
- final Unit<?> unit) {
- final Map<String,Object> properties = new HashMap<>(4);
- if (name.length() > 0) {
- final InternationalString n = new SimpleInternationalString(name);
- properties.put(IdentifiedObject.NAME_KEY, n.toString(null));
- properties.put(IdentifiedObject.ALIAS_KEY, n);
- } else {
- properties.put(IdentifiedObject.NAME_KEY, abbreviation);
- }
- final DefaultCoordinateSystemAxis axis = new DefaultCoordinateSystemAxis(properties, abbreviation, direction, unit);
- return axis;
- }
- /**
- * Use the unlocalized name (usually in English locale), because the name is part of the elements
- * compared by the {@link #equals} method.
- */
- private static Map<String,Object> name(final String name) {
- final Map<String,Object> properties = new HashMap<>(4);
- final InternationalString sname = new SimpleInternationalString(name);
- properties.put(NAME_KEY, sname.toString(Locale.ROOT));
- properties.put(ALIAS_KEY, sname);
- return properties;
- }
-
- public static CoordinateReferenceSystem createCartesianCRS2D(CoordinateSystemAxis axis1, CoordinateSystemAxis axis2) {
- final DefaultCartesianCS cs = new DefaultCartesianCS(
- name("Cartesian2d"),
- axis1, axis2);
-
- return new DefaultEngineeringCRS(name("Cartesian2d"), DATUM, cs);
- }
-
- public static CoordinateReferenceSystem createCartesianCRS3D(CoordinateSystemAxis axis1, CoordinateSystemAxis axis2, CoordinateSystemAxis axis3) {
- final DefaultCartesianCS cs = new DefaultCartesianCS(
- name("Cartesian3d"),
- axis1, axis2, axis3);
-
- return new DefaultEngineeringCRS(name("Cartesian3d"), DATUM, cs);
- }
-
- /**
- * Get rotation matrix from Geometry crs to another.
- */
- public static Matrix3 createRotation(CoordinateReferenceSystem crs1, CoordinateReferenceSystem crs2) throws FactoryException {
- final MathTransform trs = CRS.findOperation(crs1, crs2, null).getMathTransform();
- final LinearTransform lt = (LinearTransform) trs;
- final Matrix m = lt.getMatrix();
- final Matrix3 rotation = new Matrix3();
- rotation.m00 = m.getElement(0, 0);
- rotation.m01 = m.getElement(0, 1);
- rotation.m02 = m.getElement(0, 2);
- rotation.m10 = m.getElement(1, 0);
- rotation.m11 = m.getElement(1, 1);
- rotation.m12 = m.getElement(1, 2);
- rotation.m20 = m.getElement(2, 0);
- rotation.m21 = m.getElement(2, 1);
- rotation.m22 = m.getElement(2, 2);
- return rotation;
- }
-
- /**
- *
- * @param crs to evaluate, not null
- * @return true if given crs is an undefined crs
- */
- public static boolean isUndefined(CoordinateReferenceSystem crs) {
- return crs.getName().toString().contains("Undefined");
- }
-
- public static MeshPrimitive createBox(Envelope geom) {
-
- final Vector lower = Vectors.castOrCopy(geom.getLowerCorner());
- final Vector upper = Vectors.castOrCopy(geom.getUpperCorner());
-
- final int dim = lower.getDimension();
-
- if (dim == 2) {
- /*
- 2 3
- +--+
- |\ |
- | \|
- +--+
- 0 1
- */
- double minx = lower.get(0);
- double miny = lower.get(1);
- double maxx = upper.get(0);
- double maxy = upper.get(1);
- final double[] values = new double[]{
- minx,miny,
- maxx,miny,
- minx,maxy,
- maxx,maxy
- };
-
- final TupleArray positions = TupleArrays.of(SampleSystem.of(lower.getCoordinateReferenceSystem()), values);
- final TupleArray index = TupleArrays.ofUnsigned(1, new int[]{0,1,2,3});
-
- final MeshPrimitive primitive = new MeshPrimitive.TriangleStrip();
- primitive.setPositions(positions);
- primitive.setIndex(index);
-
- return primitive;
- } else if (dim == 3) {
- double minx = lower.get(0);
- double miny = lower.get(1);
- double minz = lower.get(2);
- double maxx = upper.get(0);
- double maxy = upper.get(1);
- double maxz = upper.get(2);
-
- final Vector3D.Double lll = new Vector3D.Double(minx, miny, minz);
- final Vector3D.Double ull = new Vector3D.Double(maxx, miny, minz);
- final Vector3D.Double uul = new Vector3D.Double(maxx, maxy, minz);
- final Vector3D.Double lul = new Vector3D.Double(minx, maxy, minz);
- final Vector3D.Double ulu = new Vector3D.Double(maxx, miny, maxz);
- final Vector3D.Double llu = new Vector3D.Double(minx, miny, maxz);
- final Vector3D.Double uuu = new Vector3D.Double(maxx, maxy, maxz);
- final Vector3D.Double luu = new Vector3D.Double(minx, maxy, maxz);
-
- final TupleArray positions = TupleArrays.of(SampleSystem.of(lower.getCoordinateReferenceSystem()), new double[24*3]);
- //back
- positions.set(0, lll);
- positions.set(1, ull);
- positions.set(2, uul);
- positions.set(3, lul);
-
- //front
- positions.set(4, ulu);
- positions.set(5, llu);
- positions.set(6, luu);
- positions.set(7, uuu);
-
- //right
- positions.set(8, ull);
- positions.set(9, ulu);
- positions.set(10, uuu);
- positions.set(11, uul);
-
- //left
- positions.set(12, llu);
- positions.set(13, lll);
- positions.set(14, lul);
- positions.set(15, luu);
-
- //up
- positions.set(16, uul);
- positions.set(17, uuu);
- positions.set(18, luu);
- positions.set(19, lul);
-
- //down
- positions.set(20, lll);
- positions.set(21, llu);
- positions.set(22, ulu);
- positions.set(23, ull);
-
- final int[] indices = {
- 2, 1, 0, //back
- 3, 2, 0,
-
- 6, 5, 4, //front
- 7, 6, 4,
-
- 10, 9, 8, //sides
- 11, 10, 8,
-
- 14, 13, 12,
- 15, 14, 12,
-
- 18, 17, 16,
- 19, 18, 16,
-
- 22, 21, 20,
- 23, 22, 20 };
-
- final TupleArray index = TupleArrays.ofUnsigned(1, indices);
-
- final MeshPrimitive primitive = new MeshPrimitive.Triangles();
- primitive.setPositions(positions);
- primitive.setIndex(index);
- return primitive;
- } else {
- throw new IllegalArgumentException("Only 2D and 3D BBOX supported.");
- }
- }
-
- /**
- * Removes any duplicated vertice coordinate.
- * Limitation :
- * - This method can be used only when positions and index are defined.
- * - Single index range of type triangles
- *
- * @param mesh not null
- */
- public static void smoothVertices(MultiMeshPrimitive<?> mesh) {
- ArgumentChecks.ensureNonNull("mesh", mesh);
- for (MeshPrimitive p : mesh.getComponents()) {
- p.removeDuplicatesByPosition();
- }
- }
-
- /**
- * Regroup all primitives as one.
- * Preserves all attributes.
- *
- * Types which can not be concatenated :
- * - LINE_LOOP
- * - LINE_STRIP
- * - TRIANGLE_FAN
- *
- * @param primitives to concatenate, they must all be of the same type.
- * @return concatenanted primitives
- * throws IllegalArgumentException if type is LINE_LOOP, LINE_STRIP, TRIANGLE_FAN
- */
- public static MeshPrimitive concatenate(Collection<? extends MeshPrimitive> primitives) {
-
- final Iterator<? extends MeshPrimitive> iterator = primitives.iterator();
- MeshPrimitive primitive = iterator.next();
- final MeshPrimitive.Type type = primitive.getType();
- final CoordinateReferenceSystem crs = primitive.getCoordinateReferenceSystem();
-
- int maxIndexSize = 0;
- int attSize = 0;
- final Map<String,TupleArray> resultAttributes = new HashMap<>();
- for (MeshPrimitive p : primitives) {
- TupleArray index = p.getIndex();
- maxIndexSize += index.getLength() + 3; //+1 for winding reset, +2 for degenerated triangle
- attSize += p.getPositions().getLength();
- }
- for (String name : primitive.getAttributesType().getAttributeNames()) {
- final TupleArray model = primitive.getAttribute(name);
- resultAttributes.put(name, TupleArrays.of(model.getSampleSystem(), model.getDataType(), attSize));
- }
- int[] resultIndex = new int[maxIndexSize -3]; //no degenerate triangles for the first strip
-
- //add the first primitive
- int[] primIndex = primitive.getIndex().toArrayInt();
- System.arraycopy(primIndex, 0, resultIndex, 0, primIndex.length);
- for (Entry<String,TupleArray> entry : resultAttributes.entrySet()) {
- final TupleArray resultArray = entry.getValue();
- final TupleArray primAtt = primitive.getAttribute(entry.getKey());
- resultArray.set(0, primAtt, 0, primAtt.getLength());
- }
-
- int attOffset = primitive.getPositions().getLength();
- int idOffset = primIndex.length;
-
-
- while (iterator.hasNext()) {
- primitive = iterator.next();
- if (!primitive.getType().equals(type)) {
- throw new IllegalArgumentException("All primitives must have the same type");
- }
- if (!Utilities.equalsIgnoreMetadata(crs, primitive.getCoordinateReferenceSystem())) {
- throw new IllegalArgumentException("All primitives must have the same CRS, found \n" + crs +"\n and \n" + primitive.getCoordinateReferenceSystem());
- }
- if (resultAttributes.size() != primitive.getAttributesType().getAttributeNames().size()) {
- throw new IllegalArgumentException("All primitives must have the same attributes."
- + "\n Found " + Arrays.toString(resultAttributes.keySet().toArray())
- + "\n Found " + Arrays.toString(primitive.getAttributesType().getAttributeNames().toArray()));
- }
-
- primIndex = primitive.getIndex().toArrayInt();
-
- switch (type) {
- case LINE_LOOP :
- case LINE_STRIP :
- throw new IllegalArgumentException("Line Strip and Loop can not be concatenate, unlike triangles which can have a degenerated triangle to link them");
- case TRIANGLE_FAN :
- throw new IllegalArgumentException("Triangle fan can not be concatenate, unlike triangles which can have a degenerated triangle to link them");
- case TRIANGLE_STRIP : {
- //we must have even size trips otherwise next concatenated strip will have reversed winding
- if (idOffset % 2 != 0) {
- //repeat the last index to reset winding
- resultIndex[idOffset] = resultIndex[idOffset-1]; //duplicate last index
- idOffset++;
- }
-
- for (int i = 0; i < primIndex.length; i++) {
- primIndex[i] += attOffset;
- }
- System.arraycopy(primIndex, 0, resultIndex, idOffset + 2, primIndex.length);
-
- //add a degenerated triangle between strips
- resultIndex[idOffset] = resultIndex[idOffset-1];
- resultIndex[idOffset+1] = resultIndex[idOffset+2];
- idOffset += primIndex.length + 2;
-
- for (Entry<String,TupleArray> entry : resultAttributes.entrySet()) {
- final TupleArray resultArray = entry.getValue();
- final TupleArray primAtt = primitive.getAttribute(entry.getKey());
- resultArray.set(attOffset, primAtt, 0, primAtt.getLength());
- }
- attOffset += primitive.getPositions().getLength();
- } break;
- case POINTS :
- case LINES :
- case TRIANGLES : {
- System.arraycopy(primIndex, 0, resultIndex, idOffset, primIndex.length);
- for (int i = idOffset, end = idOffset + primIndex.length; i < end; i++) {
- resultIndex[i] += attOffset;
- }
- idOffset += primIndex.length;
- for (Entry<String,TupleArray> entry : resultAttributes.entrySet()) {
- final TupleArray resultArray = entry.getValue();
- final TupleArray primAtt = primitive.getAttribute(entry.getKey());
- resultArray.set(attOffset, primAtt, 0, primAtt.getLength());
- }
- attOffset += primitive.getPositions().getLength();
- }break;
- default : throw new IllegalArgumentException("Unexpected type " + type);
- }
- }
-
- //build result primitive
- final MeshPrimitive result = MeshPrimitive.create(type);
- if (idOffset != resultIndex.length) resultIndex = Arrays.copyOf(resultIndex, idOffset);
- final TupleArray allIndex = TupleArrays.ofUnsigned(1, resultIndex);
- result.setIndex(allIndex);
- for (Entry<String,TupleArray> entry : resultAttributes.entrySet()) {
- result.setAttribute(entry.getKey(), entry.getValue());
- }
- return result;
- }
-
- /**
- * Search similar primitives in the multi-primitive and regroup them when possible.
- * To be regrouped primitives must have the same type and same attributes.
- *
- * @param primitives not null
- * @return collection of concatenated promitives
- */
- public static Collection<? extends MeshPrimitive> tryConcatenate(Collection<? extends MeshPrimitive> primitives) {
- ArgumentChecks.ensureNonNull("primitives", primitives);
-
- if (primitives.size() <= 1) {
- //nothing to concatenate
- return primitives;
- }
-
- final Map<MeshPrimitive.Type, List<MeshPrimitive>> groups = new HashMap<>();
-
- for (MeshPrimitive p : primitives) {
- final MeshPrimitive.Type type = p.getType();
- List<MeshPrimitive> group = groups.get(type);
- if (group == null) {
- group = new ArrayList<>();
- groups.put(type, group);
- }
- group.add(p);
- }
-
- final List<MeshPrimitive> newPrimitives = new ArrayList<>(groups.size());
- for (List<MeshPrimitive> group : groups.values()) {
- if (group.size() > 1) {
- try {
- MeshPrimitive p = concatenate(group);
- newPrimitives.add(p);
- } catch (IllegalArgumentException ex) {
- //we have try
- newPrimitives.addAll(group);
- }
- } else {
- newPrimitives.add(group.get(0));
- }
- }
-
- return newPrimitives;
- }
-
- /**
- * Cut the primitive in smaller primitives of at most MaxSize positions.
- *
- * If primitive has less positions then given size it is returned unchanged
- * as single element in the list.
- *
- * @param primitive Primitive to cut
- * @param maxSize maximum number of elements by primitive.
- * @return splitted primitive.
- */
- public static List<MeshPrimitive> split(MeshPrimitive primitive, int maxSize) {
- if ( primitive.getPositions().getLength() <= maxSize
- && primitive.getIndex().getLength() <= maxSize) {
- return Arrays.asList(primitive);
- }
-
- final MeshPrimitive.Type type = primitive.getType();
- final TupleArray index = primitive.getIndex();
-
- final List<MeshPrimitive> primitives = new ArrayList<>(2);
- switch (type) {
- case TRIANGLES : {
- //split by packs of 3
- final int batchSize = (maxSize / 3) * 3;
- final int[] array = index.toArrayInt();
- for (int i = 0; i < array.length; i+= batchSize) {
- int end = i + batchSize;
- if (end > array.length) end = array.length;
- final int[] subRange = Arrays.copyOfRange(array, i, end);
- final MeshPrimitive copy = primitive.deepCopy();
- copy.setIndex(TupleArrays.ofUnsigned(1, subRange));
- if (copy.getIndex().getLength() > maxSize) {
- throw new UnsupportedOperationException("ARG 1");
- }
- compact(copy);
- if (copy.getIndex().getLength() > maxSize || copy.getPositions().getLength() > maxSize) {
- throw new UnsupportedOperationException("ARG 2");
- }
- primitives.add(copy);
- }
- } break;
- default : throw new UnsupportedOperationException("Type " + type + "not supported yet.");
- }
- return primitives;
- }
-
- /**
- * Remove all points which are not used in the index.
- */
- public static void compact(MeshPrimitive primitive) {
-
- final TupleArray indexArray = primitive.getIndex();
- if (indexArray == null) {
- //all attributes are used
- return;
- }
-
- int inc = -1;
- final Map<Integer, Integer> mapping = new HashMap<>();
- final Map<String,List<Tuple>> rebuild = new IdentityHashMap<>();
- final int[] index = indexArray.toArrayInt();
-
- for (String name : primitive.getAttributesType().getAttributeNames()) {
- rebuild.put(name, new ArrayList<>());
- }
-
- for (int i = 0; i < index.length; i++) {
- final int oldIndex = index[i];
- Integer newIndex = mapping.get(oldIndex);
- if (newIndex == null) {
- newIndex = ++inc;
- mapping.put(oldIndex, newIndex);
-
- for (String name : rebuild.keySet()) {
- final TupleArray oldTa = primitive.getAttribute(name);
- final List<Tuple> newTa = rebuild.get(name);
- newTa.add(newIndex, oldTa.get(oldIndex));
- }
- }
- index[i] = newIndex;
- }
-
- //rebuild attributes arrays
- for (String name : rebuild.keySet()) {
- final TupleArray oldTa = primitive.getAttribute(name);
- final List<Tuple> newTa = rebuild.get(name);
- final TupleArray ta = TupleArrays.of(newTa, oldTa.getSampleSystem(), oldTa.getDataType());
- primitive.setAttribute(name, ta);
- }
- //new index
- primitive.setIndex(TupleArrays.ofUnsigned(primitive.getIndex().getSampleSystem(), index));
- }
-
- public static MeshPrimitive.Triangles toPrimitive(List<org.locationtech.jts.geom.Polygon> triangles, CoordinateReferenceSystem crs) {
- final int dimension = crs.getCoordinateSystem().getDimension();
- final float[] values = new float[Math.multiplyExact(triangles.size(), 3 * dimension)];
- final int[] index = new int[triangles.size()*3];
- int k = -1;
- final Coordinate coord = new Coordinate();
- for (int i = 0, n = triangles.size(); i < n; i++) {
- org.locationtech.jts.geom.Polygon p = triangles.get(i);
- //counter clockwise to ensure up direction
- p = JTS.ensureWinding(p, false);
- final CoordinateSequence ring = p.getExteriorRing().getCoordinateSequence();
- int idx = i*3*dimension;
- switch (dimension) {
- case 2 :
- values[idx+0] = (float) ring.getX(0);
- values[idx+1] = (float) ring.getY(0);
- ring.getCoordinate(1, coord);
- values[idx+2] = (float) ring.getX(1);
- values[idx+3] = (float) ring.getY(1);
- ring.getCoordinate(2, coord);
- values[idx+4] = (float) ring.getX(2);
- values[idx+5] = (float) ring.getY(2);
- break;
- case 3 :
- values[idx+0] = (float) ring.getX(0);
- values[idx+1] = (float) ring.getY(0);
- values[idx+2] = (float) ring.getZ(0);
- ring.getCoordinate(1, coord);
- values[idx+3] = (float) ring.getX(1);
- values[idx+4] = (float) ring.getY(1);
- values[idx+5] = (float) ring.getZ(1);
- ring.getCoordinate(2, coord);
- values[idx+6] = (float) ring.getX(2);
- values[idx+7] = (float) ring.getY(2);
- values[idx+8] = (float) ring.getZ(2);
- break;
- default: throw new UnsupportedOperationException();
- }
- index[i*3+0] = ++k;
- index[i*3+1] = ++k;
- index[i*3+2] = ++k;
- }
-
- final TupleArray positions = TupleArrays.of(SampleSystem.of(crs), values);
- TupleArray idx = TupleArrays.of(1, index);
- idx = TupleArrays.packIntegerDataType(idx);
-
- final MeshPrimitive.Triangles primitive = new MeshPrimitive.Triangles();
- primitive.setPositions(positions);
- primitive.setIndex(idx);
- return primitive;
- }
-
- /**
- * Ensure two geometries declare the same attributes.
- */
- public static void ensureSameAttributes(AttributesType att1, AttributesType att2) {
- final List<String> names1 = att1.getAttributeNames();
- final List<String> names2 = att2.getAttributeNames();
- if (names1.size() != names2.size() || !names1.containsAll(names2)) {
- throw new IllegalArgumentException("Attributes are different. found " + Arrays.toString(names1.toArray()) +" and " + Arrays.toString(names2.toArray()));
- }
- for (String name : names1) {
- if (!att1.getAttributeSystem(name).equals(att2.getAttributeSystem(name))) {
- throw new IllegalArgumentException("Attribute systems are different for name " + name);
- }
- if (!att1.getAttributeType(name).equals(att2.getAttributeType(name))) {
- throw new IllegalArgumentException("Attribute types are different for name " + name);
- }
- }
- }
-
- /**
- * Convert given JTS geometry to SIS Geometry.
- */
- public static Geometry fromJTS(org.locationtech.jts.geom.Geometry jts) {
- if (jts == null) {
- return null;
- }
- CoordinateReferenceSystem crs = org.apache.sis.geometry.wrapper.Geometries.wrap(jts).get().getCoordinateReferenceSystem();
- if (crs == null) crs = Geometries.getUndefinedCRS(2);
- return fromJTS(jts, crs);
- }
-
- /**
- * Convert given JTS geometry to SIS Geometry.
- */
- private static Geometry fromJTS(org.locationtech.jts.geom.Geometry jts, CoordinateReferenceSystem crs) {
- if (jts == null) {
- return null;
- } else if (jts instanceof org.locationtech.jts.geom.Point cdt) {
- return GeometryFactory.createPoint(toPointSequence(cdt.getCoordinateSequence(), crs));
-
- } else if (jts instanceof org.locationtech.jts.geom.MultiPoint cdt) {
- return GeometryFactory.createMultiPoint(toPointSequence(jts.getFactory().getCoordinateSequenceFactory().create(cdt.getCoordinates()), crs));
-
- } else if (jts instanceof org.locationtech.jts.geom.LinearRing cdt) {
- return GeometryFactory.createLinearRing(toPointSequence(cdt.getCoordinateSequence(), crs));
-
- } else if (jts instanceof org.locationtech.jts.geom.LineString cdt) {
- return GeometryFactory.createLineString(toPointSequence(cdt.getCoordinateSequence(), crs));
-
- } else if (jts instanceof org.locationtech.jts.geom.MultiLineString cdt) {
- final LineString[] strings = new LineString[cdt.getNumGeometries()];
- for (int i = 0; i < strings.length; i++) {
- strings[i] = (LineString) fromJTS(cdt.getGeometryN(i), crs);
- }
- return GeometryFactory.createMultiLineString(strings);
- } else if (jts instanceof org.locationtech.jts.geom.Polygon cdt) {
- final LinearRing exterior = (LinearRing) fromJTS(cdt.getExteriorRing(), crs);
- final List<LinearRing> interiors = new ArrayList<>(cdt.getNumInteriorRing());
- for (int i = 0, n = cdt.getNumInteriorRing(); i < n; i++) {
- interiors.add((LinearRing) fromJTS(cdt.getInteriorRingN(i), crs));
- }
- return GeometryFactory.createPolygon(exterior, interiors);
-
- } else if (jts instanceof org.locationtech.jts.geom.MultiPolygon cdt) {
- final Surface[] geoms = new Surface[cdt.getNumGeometries()];
- for (int i = 0; i < geoms.length; i++) {
- geoms[i] = (Surface) fromJTS(cdt.getGeometryN(i), crs);
- }
- return GeometryFactory.createMultiSurface(geoms);
-
- } else if (jts instanceof org.locationtech.jts.geom.GeometryCollection cdt) {
- final Geometry[] geoms = new Geometry[cdt.getNumGeometries()];
- for (int i = 0; i < geoms.length; i++) {
- geoms[i] = fromJTS(cdt.getGeometryN(i), crs);
- }
- return GeometryFactory.createGeometryCollection(geoms);
-
- } else {
- throw new IllegalArgumentException("Unknown JTS geometry type");
- }
- }
-
- /**
- * Convert JTS coordinate sequence to SIS PointSequence.
- */
- private static PointSequence toPointSequence(CoordinateSequence cs, CoordinateReferenceSystem crs) {
- final int size = cs.size();
- final int dimension = crs.getCoordinateSystem().getDimension();
- final TupleArray positions = TupleArrays.of(SampleSystem.of(crs), DataType.DOUBLE, size);
- final TupleArrayCursor cursor = positions.cursor();
- int i = 0;
- while (cursor.next()) {
- final Tuple samples = cursor.samples();
- samples.set(0, cs.getOrdinate(i, 0));
- samples.set(1, cs.getOrdinate(i, 1));
- if (dimension > 2) {
- //JTS only goes up to 3 dimensions
- samples.set(2, cs.getOrdinate(i, 2));
- }
- i++;
- }
- return new ArraySequence(positions);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometry.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometry.java
deleted file mode 100644
index 7d1799e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometry.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import java.util.Map;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.metadata.Metadata;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-
-/**
- * Parent interface of any geometry.
- * <p>
- * Based on specification :
- * <ul>
- * <li>ISO 19107</li>
- * <li>OGC Simple Feature Access - https://www.ogc.org/standards/sfa</li>
- * <li>Khronos GLTF-2 - https://github.com/KhronosGroup/glTF/tree/main/specification/2.0</li>
- * <li>Khronos ANARI-1 - https://www.khronos.org/anari/</li>
- * </ul>
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Geometry", specification=ISO_19107) // section 6.4.4
-public interface Geometry extends TransfiniteSet {
-
- /**
- * Get geometry coordinate system.
- *
- * Difference with ISO 19107 :
- * In 19107 their may be multiple RSID, the folloing RSID are used in special
- * kind of curves, for the sake of simplicity we only store the first rsid until
- * implementations of such curves will happen.
- *
- * @return never null
- */
- @UML(identifier="rsid", specification=ISO_19107) // section 6.4.4.20
- CoordinateReferenceSystem getCoordinateReferenceSystem();
-
- /**
- * Set coordinate system in which the coordinates are declared.
- * This method does not transform the coordinates.
- *
- * @param crs , not null
- * @Throws IllegalArgumentException if coordinate system is not compatible with geometrie.
- */
- void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) throws IllegalArgumentException;
-
- /**
- * Difference with ISO 19107 :
- * we return a single Metadata instead of a list of URI.
- */
- @UML(identifier="metadata", specification=ISO_19107) // section 6.4.4.18
- default Metadata getMetadata() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Get geometry attributes type.
- *
- * @return attributes type, never null
- */
- AttributesType getAttributesType();
-
- /**
- * Get the geometry number of dimensions.<br>
- * This is the same as coordinate system dimension.
- *
- * @return number of dimension
- */
- @UML(identifier="coordinateDimension", specification=ISO_19107) // section 6.4.4.11
- default int getDimension() {
- return getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
- }
-
- @UML(identifier="dimension", specification=ISO_19107) // section 6.4.4.25
- default int getDimension(DirectPosition point) {
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="is3D", specification=ISO_19107) // section 6.4.4.13
- default boolean is3D() {
- return getDimension() == 3;
- }
-
- @UML(identifier="spatialDimension", specification=ISO_19107) // section 6.4.4.21
- default int getSpatialDimension() {
- return getDimension();
- }
-
- @UML(identifier="topologicalDimension", specification=ISO_19107) // section 6.4.4.22
- default int getTopologicDimension() {
- if (this instanceof Empty) {
- return -1;
- } else if (this instanceof Point) {
- return 0;
- } else if (this instanceof Curve) {
- return 1;
- } else if (this instanceof Surface) {
- return 2;
- } else if (this instanceof Solid) {
- return 3;
- }
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="boundaryType", specification=ISO_19107) // section 6.4.8
- default BoundaryType getBoundaryType() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns the name of the instantiable subtype of Geometry of which this geometric object is an instantiable member.<br>
- * The name of the subtype of Geometry is returned as a string.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return geometry subtype name.
- */
- String getGeometryType();
-
- @UML(identifier="type", specification=ISO_19107) // section 6.4.4.23
- default List<GeometryType> getGeometryType2() {
- //TODO merge with getGeometryType
- throw new UnsupportedOperationException();
- }
-
- /**
- * The minimum bounding box for this Geometry, returned as a Geometry.<br>
- * The polygon is defined by the corner points of the bounding box [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].<br>
- * Minimums for Z and M may be added.<br>
- * The simplest representation of an Envelope is as two direct positions, one containing all the minimums, and another all the maximums.<br>
- * In some cases, this coordinate will be outside the range of validity for the Spatial Reference System.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return Envelope in geometry coordinate reference system.
- */
- @UML(identifier="envelope", specification=ISO_19107) // section 6.4.4.12
- Envelope getEnvelope();
-
- /**
- * The mathematical centroid for this Geometry as a Point.
- * The result is not guaranteed to be on this Geometry.
- *
- * Difference from OGC SFA : this method in declared on Surface and MultiSurface
- * but in ISO 19107 it is on Geometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.10.2
- * @return centroid for this Geometry
- */
- @UML(identifier="centroid", specification=ISO_19107) // section 6.4.4.8
- default Point getCentroid() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="representativePoint", specification=ISO_19107) // section 6.4.4.19
- default Point getRepresentativePoint() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="convexHull", specification=ISO_19107) // section 6.4.4.10
- default Geometry getConvexHull() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="closure", specification=ISO_19107) // section 6.4.4.9
- default Geometry getClosure() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- /**
- * Exports this geometric object to a specific Well-known Text Representation of Geometry.
- *
- * Difference with ISO 19107 :
- * - this method is located on Encoding sub interface in the standard, it is placed
- * on Geometry to match OGC SFA.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return this geometry in Well-known Text
- */
- @UML(identifier="asText", specification=ISO_19107) // section 6.4.4.5
- default String asText() {
- //TODO remove this method default when all classes implement it.
- return this.getClass().getSimpleName();
- }
-
- /**
- * Exports this geometric object to a specific Well-known Binary Representation of Geometry.
- *
- * Difference with ISO 19107 :
- * - this method is located on Encoding sub interface in the standard, it is placed
- * on Geometry to match OGC SFA.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return this geometry in Well-known Binary
- */
- @UML(identifier="asBinary", specification=ISO_19107) // section 6.4.4.3
- default byte[] asBinary() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns TRUE if this geometric object is the empty Geometry.
- * If true, then this geometric object represents the empty point set ∅ for the coordinate space.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return true if empty.
- */
- @UML(identifier="isEmpty", specification=ISO_19107) // section 6.4.4.2
- boolean isEmpty();
-
- /**
- * Returns TRUE if this geometric object has no anomalous geometric points, such as self intersection or self tangency.
- * The description of each instantiable geometric class will include the specific conditions that cause an instance
- * of that class to be classified as not simple.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return true if geometry is simple
- */
- @UML(identifier="isSimple", specification=ISO_19107) // section 6.4.4.15
- default boolean isSimple() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="isCycle", specification=ISO_19107) // section 6.4.4.14
- default boolean isCycle() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="isValid", specification=ISO_19107) // section 6.4.4.16
- default boolean isValid() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns the closure of the combinatorial boundary of this geometric object (Reference [1], section 3.12.2).
- * Because the result of this function is a closure, and hence topologically closed, the resulting boundary can be
- * represented using representational Geometry primitives (Reference [1], section 3.12.2).
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.2
- * @return boundary of the geometry
- */
- @UML(identifier="boundary", specification=ISO_19107) // section 6.4.4.7
- default Geometry boundary() {
- //TODO remove this method default when all classes implement it.
- throw new UnsupportedOperationException();
- }
-
- /**
- * Map of properties for user needs.
- * Those informations may be lost in geometry processes.
- *
- * @return Map, can be null if the geometry can not store additional informations.
- */
- default Map<String,Object> userProperties() {
- return null;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryCollection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryCollection.java
deleted file mode 100644
index 7f58353..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryCollection.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.Set;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.Envelope;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- * A GeometryCollection is a geometric object that is a collection of some number of geometric objects.
- * All the elements in a GeometryCollection shall be in the same Spatial Reference System.
- * This is also the Spatial Reference System for the GeometryCollection.
- * GeometryCollection places no other constraints on its elements.
- *
- * Subclasses of GeometryCollection may restrict membership based on dimension and may also place
- * other constraints on the degree of spatial overlap between elements.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Collection", specification=ISO_19107) // section 6.4.31
-public interface GeometryCollection<T extends Geometry> extends Geometry {
-
- public static final String TYPE = "GEOMETRYCOLLECTION";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @UML(identifier="elementType", specification=ISO_19107) // section 6.4.31.2
- default Set<GeometryType> getElementType() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @Override
- default boolean isEmpty() {
- return getNumGeometries() == 0;
- }
-
- /**
- * Returns the number of geometries in this GeometryCollection.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.3.2
- * @return the number of geometries in this GeometryCollection.
- */
- @UML(identifier="numElement", specification=ISO_19107) // section 6.4.31.3
- int getNumGeometries();
-
- /**
- * Returns the Nth geometry in this GeometryCollection.
- *
- * Difference with ISO 19107 :
- * - for add as defined by ISO 19107, use GeometryOperations union operator.
- * - for remove as defined by ISO 19107, use GeometryOperations difference operator.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.3.2
- * @param n geometry index.
- * @return the Nth geometr in this GeometryCollection.
- */
- @UML(identifier="element", specification=ISO_19107) // section 6.4.32
- T getGeometryN(int n);
-
- @Override
- public default Envelope getEnvelope() {
- GeneralEnvelope e = null;
- for (int i = 0, n = getNumGeometries(); i < n; i++) {
- T sn = getGeometryN(i);
- Envelope envelope = sn.getEnvelope();
- if (envelope != null) {
- if (e == null) {
- e = new GeneralEnvelope(envelope);
- } else {
- e.add(envelope);
- }
- }
- }
- if (e == null) {
- e = new GeneralEnvelope(getCoordinateReferenceSystem());
- e.setToNaN();
- }
- return e;
- }
-
- @Override
- public default AttributesType getAttributesType() {
- if (getNumGeometries() == 0) return null;
- return getGeometryN(0).getAttributesType();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
deleted file mode 100644
index 628413d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.geometries;
-
-import java.nio.ByteBuffer;
-import java.nio.DoubleBuffer;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.sis.geometries.conics.Circle;
-import org.apache.sis.geometries.conics.CircularString;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.apache.sis.geometries.privy.DefaultGeometryCollection;
-import org.apache.sis.geometries.privy.DefaultLineString;
-import org.apache.sis.geometries.privy.DefaultLinearRing;
-import org.apache.sis.geometries.privy.DefaultMultiLineString;
-import org.apache.sis.geometries.privy.DefaultMultiPoint;
-import org.apache.sis.geometries.privy.DefaultMultiPolygon;
-import org.apache.sis.geometries.privy.DefaultMultiSurface;
-import org.apache.sis.geometries.privy.DefaultPoint;
-import org.apache.sis.geometries.privy.DefaultPolygon;
-import org.apache.sis.geometries.privy.DefaultTriangle;
-import org.apache.sis.geometries.spirals.Clothoid;
-import org.apache.sis.geometry.wrapper.Capability;
-import org.apache.sis.geometry.wrapper.Dimensions;
-import org.apache.sis.geometry.wrapper.GeometryType;
-import org.apache.sis.geometry.wrapper.GeometryWrapper;
-import org.apache.sis.setup.GeometryLibrary;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class GeometryFactory extends org.apache.sis.geometry.wrapper.Geometries<Geometry> {
-
- public static GeometryFactory INSTANCE = new GeometryFactory();
-
- private GeometryFactory(){
- super(GeometryLibrary.SIS, Geometry.class, Point.class);
- }
-
- public static Point createPoint(CoordinateReferenceSystem crs) {
- return new DefaultPoint(crs);
- }
-
- public static Point createPoint(CoordinateReferenceSystem crs, double ... position) {
- return new DefaultPoint(crs, position);
- }
-
- public static Point createPoint(SampleSystem ss, double ... position) {
- return new DefaultPoint(ss, position);
- }
-
- public static Point createPoint(PointSequence sequence) {
- return new DefaultPoint(sequence);
- }
-
- public static LineString createLineString(PointSequence sequence) {
- return new DefaultLineString(sequence);
- }
-
- public static LinearRing createLinearRing(PointSequence sequence) {
- return new DefaultLinearRing(sequence);
- }
-
- public static Polygon createPolygon(LinearRing exterior, List<LinearRing> interiors) {
- return new DefaultPolygon(exterior, interiors);
- }
-
- public static Triangle createTriangle(LinearRing exterior) {
- return new DefaultTriangle(exterior);
- }
-
- public static MultiPoint createMultiPoint(PointSequence sequence) {
- return new DefaultMultiPoint(sequence);
- }
-
- public static MultiLineString createMultiLineString(LineString ... geometries) {
- return new DefaultMultiLineString(geometries);
- }
-
- public static MultiPolygon createMultiPolygon(Polygon ... geometries) {
- return new DefaultMultiPolygon(geometries);
- }
-
- public static <T extends Surface> MultiSurface<T> createMultiSurface(T ... geometries) {
- return new DefaultMultiSurface<>(geometries);
- }
-
- public static <T extends Geometry> GeometryCollection<T> createGeometryCollection(T ... geometries) {
- return new DefaultGeometryCollection<>(geometries);
- }
-
- public static PointSequence createSequence(TupleArray positions) {
- return createSequence(Collections.singletonMap(AttributesType.ATT_POSITION, positions));
- }
-
- public static PointSequence createSequence(Map<String, TupleArray> attributes) {
- return new ArraySequence(attributes);
- }
-
- // ////////////////////////////////////////////////////////////////////////
- // org.apache.sis.geometry.wrapper.Geometries methods /////////////////////
- // ////////////////////////////////////////////////////////////////////////
-
-
- @Override
- public Class<?> getGeometryClass(GeometryType type) {
- switch (type) {
- case CIRCLE : return Circle.class;
- case CIRCULARSTRING : return CircularString.class;
- case CLOTHOID : return Clothoid.class;
- case COMPOUNDCURVE : return CompoundCurve.class;
- case CURVE : return Curve.class;
- case CURVEPOLYGON : return CurvePolygon.class;
- case GEOMETRY : return Geometry.class;
- case GEOMETRYCOLLECTION : return GeometryCollection.class;
- case LINESTRING : return LineString.class;
- case MULTICURVE : return MultiCurve.class;
- case MULTILINESTRING : return MultiLineString.class;
- case MULTIPOINT : return MultiPoint.class;
- case MULTIPOLYGON : return MultiPolygon.class;
- case MULTISURFACE : return MultiSurface.class;
- case POINT : return Point.class;
- case POLYGON : return Polygon.class;
- case POLYHEDRALSURFACE : return PolyhedralSurface.class;
- case SURFACE : return Surface.class;
- case TIN : return TIN.class;
- case TRIANGLE : return Triangle.class;
- //todo
- case BREPSOLID :
- case COMPOUNDSURFACE :
- case ELLIPTICALCURVE :
- case GEODESICSTRING :
- case NURBSCURVE :
- case SPIRALCURVE :
- default: return Geometry.class;
- }
- }
-
- @Override
- public GeometryType getGeometryType(Class<?> type) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public GeometryWrapper castOrWrap(Object geometry) {
- if (geometry instanceof Wrapper) return (GeometryWrapper) geometry;
- return new Wrapper((Geometry) geometry);
- }
-
- @Override
- public GeometryWrapper parseWKT(String wkt) throws Exception {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public GeometryWrapper parseWKB(ByteBuffer data) throws Exception {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean supports(Capability feature) {
- switch (feature) {
- case Z_COORDINATE : return true;
- case M_COORDINATE : return true;
- case SINGLE_PRECISION : return true;
- default: return false;
- }
- }
-
- @Override
- public Point createPoint(double x, double y) {
- return new DefaultPoint(SampleSystem.ofSize(2), x, y);
- }
-
- @Override
- public Point createPoint(double x, double y, double z) {
- return new DefaultPoint(SampleSystem.ofSize(3), x ,y, z);
- }
-
- @Override
- public Point createPoint(boolean isFloat, Dimensions dimensions, DoubleBuffer coordinates) {
- final ArraySequence points;
-
- if (!dimensions.hasZ) {
- final SampleSystem ss = SampleSystem.ofSize(2);
- if (isFloat) {
- points = new ArraySequence(TupleArrays.of(ss, (float) coordinates.get(0), (float) coordinates.get(1)));
- } else {
- points = new ArraySequence(TupleArrays.of(ss, coordinates.get(0), coordinates.get(1)));
- }
- } else {
- final SampleSystem ss = SampleSystem.ofSize(3);
- if (isFloat) {
- points = new ArraySequence(TupleArrays.of(ss, (float) coordinates.get(0), (float) coordinates.get(1), (float) coordinates.get(2)));
- } else {
- points = new ArraySequence(TupleArrays.of(ss, coordinates.get(0), coordinates.get(1), coordinates.get(2)));
- }
- }
-
- if (dimensions.hasM) {
- final TupleArray marray;
- if (isFloat) {
- marray = TupleArrays.of(SampleSystem.ofSize(1), (float) coordinates.get(dimensions.hasZ ? 3 : 2));
- } else {
- marray = TupleArrays.of(SampleSystem.ofSize(1), coordinates.get(dimensions.hasZ ? 3 : 2));
- }
- points.setAttribute("m", marray);
- }
-
- return new DefaultPoint(points);
- }
-
- @Override
- public MultiPoint<?> createMultiPoint(boolean isFloat, Dimensions dimensions, DoubleBuffer coordinates) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Geometry createPolyline(boolean polygon, boolean isFloat, Dimensions dimensions, DoubleBuffer... coordinates) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public GeometryWrapper createMultiPolygon(Object[] geometries) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public GeometryWrapper createFromComponents(GeometryType type, Object components) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected GeometryWrapper createWrapper(Geometry geometry) {
- return new Wrapper(geometry);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryType.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryType.java
deleted file mode 100644
index e9b4d1e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryType.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="GeometryType", specification=ISO_19107) // section 6.4.6
-public enum GeometryType {
- EMPTY,
- GEOMETRY,
- POINT,
- CURVE,
- SURFACE,
- LINE,
- GEODESIC,
- POLYGON,
- COLLECTION,
- SPLINECURVE,
- SPLINESURFACE,
- SPLINESOLID,
- RHUMB
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryVisitor.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryVisitor.java
deleted file mode 100644
index deac5db..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryVisitor.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.geometries;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class GeometryVisitor {
-
- public void visit(Geometry geometry) {
- if (geometry instanceof Point candidate) visit(candidate);
-
- else if (geometry instanceof LinearRing candidate) visit(candidate);
- else if (geometry instanceof LineString candidate) visit(candidate);
- else if (geometry instanceof Curve candidate) visit(candidate);
-
- else if (geometry instanceof Triangle candidate) visit(candidate);
- else if (geometry instanceof Polygon candidate) visit(candidate);
- else if (geometry instanceof Surface candidate) visit(candidate);
- else if (geometry instanceof TIN candidate) visit(candidate);
- else if (geometry instanceof PolyhedralSurface candidate) visit(candidate);
-
- else if (geometry instanceof MultiPolygon candidate) visit(candidate);
- else if (geometry instanceof MultiLineString candidate) visit(candidate);
- else if (geometry instanceof MultiSurface candidate) visit(candidate);
- else if (geometry instanceof MultiCurve candidate) visit(candidate);
- else if (geometry instanceof MultiPoint candidate) visit(candidate);
- else if (geometry instanceof GeometryCollection candidate) visit(candidate);
-
- else throw new IllegalArgumentException("Unknown geometry type " + geometry.getClass().getName());
- }
-
- public void visit(Point geometry) {
- }
-
- public void visit(Curve geometry) {
- }
-
- public void visit(Surface geometry) {
- }
-
- public void visit(LineString geometry) {
- visit(geometry.getPoints());
- }
-
- public void visit(Polygon geometry) {
- visit(geometry.getExteriorRing());
- geometry.getInteriorRings().stream().forEach(this::visit);
- }
-
- public void visit(Triangle geometry) {
- visit(geometry.getExteriorRing());
- }
-
- public void visit(LinearRing geometry) {
- visit(geometry.getPoints());
- }
-
- public void visit(TIN geometry) {
- for (int i = 0, n = geometry.getNumPatches(); i < n; i++) {
- visit(geometry.getPatchN(i));
- }
- }
-
- public void visit(PolyhedralSurface geometry) {
- for (int i = 0, n = geometry.getNumPatches(); i < n; i++) {
- visit(geometry.getPatchN(i));
- }
- }
-
- public void visit(GeometryCollection geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(MultiPolygon geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(MultiLineString geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(MultiSurface geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(MultiCurve geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(MultiPoint geometry) {
- for (int i = 0, n = geometry.getNumGeometries(); i < n; i++) {
- visit(geometry.getGeometryN(i));
- }
- }
-
- public void visit(PointSequence sequence) {
- for (int i = 0, n = sequence.size(); i < n; i++) {
- visit(sequence.getPoint(i));
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Knot.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Knot.java
deleted file mode 100644
index 4044b66..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Knot.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Knot", specification=ISO_19107) // section 6.4.17
-public class Knot {
-
- @UML(identifier="value", specification=ISO_19107) // section 6.4.17.2
- public double[] value;
- @UML(identifier="multiplicity", specification=ISO_19107) // section 6.4.17.3
- public int[] multiplicity;
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LineString.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LineString.java
deleted file mode 100644
index e4e5e36..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LineString.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.geometries;
-
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- * A LineString is a Curve with linear interpolation between Points.
- * Each consecutive pair of Points defines a Line segment.
- *
- * A Line is a LineString with exactly 2 Points.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Line", specification=ISO_19107) // section 7.1.2
-public interface LineString extends Curve {
-
- public static final String TYPE = "LINESTRING";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 7.1.2.2
- @Override
- public default CurveInterpolation getInterpolation() {
- return CurveInterpolation.LINEAR;
- }
-
- PointSequence getPoints();
-
- @Override
- public default LineString asLine(Length spacing, Length offset) {
- return this;
- }
-
- /**
- * The number of Points in this LineString.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.7.2
- * @return number of Points in this LineString.
- */
- default int getNumPoints() {
- return getPoints().size();
- }
-
- /**
- * Returns the specified Point N in this LineString.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.7.2
- * @return the specified Point N in this LineString.
- */
- default Point getPointN(int n) {
- return getPoints().getPoint(n);
- }
-
- @Override
- default CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return getPoints().getCoordinateReferenceSystem();
- }
-
- @Override
- default void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- getPoints().setCoordinateReferenceSystem(cs);
- }
-
- @Override
- public default AttributesType getAttributesType() {
- return getPoints().getAttributesType();
- }
-
- /**
- * A Line is a LineString with exactly 2 Points.
- *
- * @return true if lineString is a line.
- */
- default boolean isLine() {
- return getPoints().size() == 2;
- }
-
- @Override
- default Envelope getEnvelope() {
- PointSequence points = getPoints();
- if (points.isEmpty()) {
- return null;
- }
- return points.getEnvelope();
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("LINESTRING (");
- final PointSequence points = getPoints();
- AbstractGeometry.toText(sb, points);
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LinearRing.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LinearRing.java
deleted file mode 100644
index 7d30951..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/LinearRing.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.geometries;
-
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * A LinearRing is a LineString that is both closed and simple.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface LinearRing extends LineString {
-
- public static final String TYPE = "LINEARRING";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("LINEARRING (");
- final PointSequence points = getPoints();
- for (int i = 0, n = points.size() ; i < n; i++) {
- final Tuple pt = points.getPosition(i);
- if (i > 0) sb.append(',');
- AbstractGeometry.toText(sb, pt);
- }
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiCurve.java
deleted file mode 100644
index 1c5d5e6..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiCurve.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.geometries;
-
-
-/**
- * A MultiCurve is a 1-dimensional GeometryCollection whose elements are Curves
- *
- * MultiCurve is a non-instantiable class in this standard; it defines a set of methods for its subclasses and is
- * included for reasons of extensibility.
- *
- * A MultiCurve is simple if and only if all of its elements are simple and the only intersections between any
- * two elements occur at Points that are on the boundaries of both elements.
- *
- * The boundary of a MultiCurve is obtained by applying the “mod 2” union rule: A Point is in the boundary of a
- * MultiCurve if it is in the boundaries of an odd number of elements of the MultiCurve (Reference [1], section 3.12.3.2).
- *
- * A MultiCurve is closed if all of its elements are closed.
- *
- * The boundary of a closed MultiCurve is always empty.
- *
- * A MultiCurve is defined as topologically closed.
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#multi_curve
- */
-public interface MultiCurve<T extends Curve> extends GeometryCollection<T>{
-
- public static final String TYPE = "MULTICURVE";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- /**
- * Returns TRUE if this MultiCurve is closed [StartPoint () = EndPoint () for each Curve in this MultiCurve].
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.8.2
- * @return true if multicurve is closed.
- */
- default boolean isClosed() {
- for (int i = 0, n = getNumGeometries(); i < n; i++) {
- if (!getGeometryN(i).isClosed()) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * The Length of this MultiCurve which is equal to the sum of the lengths of the element Curves.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.8.2
- * @return length of the multicurve.
- */
- default double getLength() {
- double length = 0.0;
- for (int i = 0, n = getNumGeometries(); i < n; i++) {
- length += getGeometryN(i).getLength();
- }
- return length;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiLineString.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiLineString.java
deleted file mode 100644
index 3a31c9a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiLineString.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.geometries;
-
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * A MultiLineString is a MultiCurve whose elements are LineStrings.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface MultiLineString extends MultiCurve<LineString> {
-
- public static final String TYPE = "MULTILINESTRING";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("MULTILINESTRING (");
- for (int k = 0, kn = getNumGeometries(); k < kn; k++){
- if (k > 0) sb.append(',');
- sb.append('(');
- final LineString line = getGeometryN(k);
- final PointSequence points = line.getPoints();
- for (int i = 0, n = points.size() ; i < n; i++) {
- final Tuple pos = points.getPosition(i);
- if (i > 0) sb.append(',');
- AbstractGeometry.toText(sb, pos);
- }
- sb.append(')');
- }
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPoint.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPoint.java
deleted file mode 100644
index cb2b7db..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPoint.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * A MultiPoint is a 0-dimensional GeometryCollection.
- * The elements of a MultiPoint are restricted to Points.
- * The Points are not connected or ordered in any semantically important way (see the discussion at GeometryCollection).
- * A MultiPoint is simple if no two Points in the MultiPoint are equal (have identical coordinate values in X and Y).
- * Every MultiPoint is spatially equal under the definition in Clause 6.1.15.3 to a simple Multipoint.
- * The boundary of a MultiPoint is the empty set.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface MultiPoint<T extends Point> extends GeometryCollection<T>{
-
- public static final String TYPE = "MULTIPOINT";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- /**
- * View this multipoint as a point sequence
- */
- default PointSequence asPointSequence() {
- return new PointSequence() {
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return MultiPoint.this.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- MultiPoint.this.setCoordinateReferenceSystem(cs);
- }
-
- @Override
- public int size() {
- return getNumGeometries();
- }
-
- @Override
- public Point getPoint(int index) {
- return MultiPoint.this.getGeometryN(index);
- }
-
- @Override
- public Tuple getPosition(int index) {
- return MultiPoint.this.getGeometryN(index).getPosition();
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- MultiPoint.this.getGeometryN(index).getPosition().set(value);
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- return MultiPoint.this.getGeometryN(index).getAttribute(name);
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- MultiPoint.this.getGeometryN(index).setAttribute(name, value);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return MultiPoint.this.getAttributesType();
- }
- };
- }
-
- @Override
- default String asText() { int dimension = getDimension();
- final StringBuilder sb = new StringBuilder(TYPE);
- sb.append('(');
- for (int i = 0, n = getNumGeometries(); i < n; i++) {
- T point = getGeometryN(i);
- if (i > 0) sb.append(',');
- AbstractGeometry.toText(sb, point.getPosition());
- }
- sb.append(')');
- return sb.toString();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolygon.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolygon.java
deleted file mode 100644
index dfadb5e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolygon.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.geometries;
-
-import org.apache.sis.geometries.privy.AbstractGeometry;
-
-
-/**
- * A MultiPolygon is a MultiSurface whose elements are Polygons.
- *
- * The assertions for MultiPolygons are as follows.
- *
- * a) The interiors of 2 Polygons that are elements of a MultiPolygon may not intersect.
- * b) The boundaries of any 2 Polygons that are elements of a MultiPolygon may not “cross” and may touch at only a
- * finite number of Points.
- * c) A MultiPolygon is defined as topologically closed.
- * d) A MultiPolygon may not have cut lines, spikes or punctures, a MultiPolygon is a regular closed Point set.
- * e) The interior of a MultiPolygon with more than 1 Polygon is not connected; the number of connected components
- * of the interior of a MultiPolygon is equal to the number of Polygons in the MultiPolygon.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface MultiPolygon extends MultiSurface<Polygon> {
-
- public static final String TYPE = "MULTIPOLYGON";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("MULTIPOLYGON (");
- for (int k = 0, kn = getNumGeometries(); k < kn; k++){
- if (k > 0) sb.append(',');
- final Polygon polygon = getGeometryN(k);
- sb.append("((");
- AbstractGeometry.toText(sb, polygon.getExteriorRing().asLine(null, null).getPoints());
- sb.append(')');
- for (int i = 0, n = polygon.getNumInteriorRing(); i < n; i++) {
- if (i != 0) sb.append(',');
- sb.append('(');
- AbstractGeometry.toText(sb, polygon.getInteriorRingN(i).getPoints());
- sb.append(')');
- }
- sb.append(')');
- }
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolyhedron.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolyhedron.java
deleted file mode 100644
index e4fb4cf..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiPolyhedron.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries;
-
-
-/**
- * A multi-polyhedron is a collection of polyhedron objects. These are arbitrary aggregations.
- * There is no assumption regarding the topological relationships between the polyhedron objects,
- * but in most cases the polyhedron objects will not intersect each other.
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#multi_polyhedron
- */
-public interface MultiPolyhedron extends GeometryCollection<Polyhedron> {
-
- public static final String TYPE = "MULTIPOLYHEDRON";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiSurface.java
deleted file mode 100644
index 069f454..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/MultiSurface.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.geometries;
-
-
-/**
- * A MultiSurface is a 2-dimensional GeometryCollection whose elements are Surfaces, all using coordinates from
- * the same coordinate reference system. The geometric interiors of any two Surfaces in a MultiSurface may not intersect
- * in the full coordinate system. The boundaries of any two coplanar elements in a MultiSurface may intersect, at most,
- * at a finite number of Points. If they were to meet along a curve, they could be merged into a single surface.
- *
- * MultiSurface is an instantiable class in this Standard, and may be used to represent heterogeneous surfaces
- * collections of polygons and polyhedral surfaces. It defines a set of methods for its subclasses. The subclass of
- * MultiSurface is MultiPolygon corresponding to a collection of Polygons only. Other collections shall use MultiSurface.
- *
- * NOTE: The geometric relationships and sets are the common geometric ones in the full coordinate systems.
- * The use of the 2D map operations defined Clause 6.1.15 may classify the elements of a valid 3D MultiSurface as
- * having overlapping interiors in their 2D projections.
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#multi_surface
- */
-public interface MultiSurface<T extends Surface> extends GeometryCollection<T>{
-
- /**
- * The area of this MultiSurface, as measured in the spatial reference system of this MultiSurface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.13.2
- * @return area of the surface.
- */
- default double getArea() {
- double area = 0.0;
- for (int i = 0, n = getNumGeometries(); i < n; i++) {
- area += getGeometryN(n).getArea();
- }
- return area;
- }
-
- /**
- * The mathematical centroid for this MultiSurface.
- * The result is not guaranteed to be on this MultiSurface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.13.2
- * @return centroid for this MultiSurface
- */
- @Override
- default Point getCentroid() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * A Point guaranteed to be on this MultiSurface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.13.2
- * @return point guaranteed to be on this MultiSurface.
- */
- default double getPointOnSurface() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OBBox.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OBBox.java
deleted file mode 100644
index 61d25fa..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OBBox.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- * An oriented BBox geometry defined by a center and half length axis.
- * This is an axis oriented bounding box, see OBBox for the oriented counterpart.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class OBBox extends AbstractGeometry {
-
- private Vector<?> center;
- private final Vector<?> xAxis;
- private final Vector<?> yAxis;
- private final Vector<?> zAxis;
-
- /**
- * @param dimension number of dimensions of the bbox, must be 3.
- */
- public OBBox(int dimension) {
- this(Geometries.getUndefinedCRS(dimension));
- }
-
- /**
- * @param crs obbox coordinate system with three dimensions, not null.
- */
- public OBBox(CoordinateReferenceSystem crs) {
- if (crs.getCoordinateSystem().getDimension() != 3) {
- throw new IllegalArgumentException("Oriented BBox only support 3 dimensions.");
- }
- center = Vectors.createDouble(crs);
- xAxis = Vectors.createDouble(3);
- yAxis = Vectors.createDouble(3);
- zAxis = Vectors.createDouble(3);
- }
-
- @Override
- public String getGeometryType() {
- return "BBOX"; //TODO not in OGC SFA.
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return center.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- if (cs.getCoordinateSystem().getDimension() != getCoordinateReferenceSystem().getCoordinateSystem().getDimension()) {
- throw new IllegalArgumentException("New CRS dimension must be the same as previous CRS");
- }
- Vector v = Vectors.create(cs, center.getDataType());
- v.set(center);
- center = v;
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
- /**
- * @return center of the bounding box.
- */
- public Tuple getCenter() {
- return center;
- }
-
- /**
- * @return half length vector on X axis.
- */
- public Tuple getXAxis() {
- return xAxis;
- }
-
- /**
- * @return half length vector on Y axis.
- */
- public Tuple getYAxis() {
- return yAxis;
- }
-
- /**
- * @return half length vector on Z axis.
- */
- public Tuple getZAxis() {
- return zAxis;
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public Envelope getEnvelope() {
- final Tuple<?> nxAxis = xAxis.copy().scale(-1);
- final Tuple<?> nyAxis = yAxis.copy().scale(-1);
- final Tuple<?> nzAxis = zAxis.copy().scale(-1);
- final BBox env = new BBox(center,center);
- final Vector<?> corner = center.copy();
- env.add(corner.set(center).add( xAxis).add( yAxis).add( zAxis));
- env.add(corner.set(center).add( xAxis).add( yAxis).add(nzAxis));
- env.add(corner.set(center).add( xAxis).add(nyAxis).add( zAxis));
- env.add(corner.set(center).add( xAxis).add(nyAxis).add(nzAxis));
- env.add(corner.set(center).add(nxAxis).add( yAxis).add( zAxis));
- env.add(corner.set(center).add(nxAxis).add( yAxis).add(nzAxis));
- env.add(corner.set(center).add(nxAxis).add(nyAxis).add( zAxis));
- env.add(corner.set(center).add(nxAxis).add(nyAxis).add(nzAxis));
- return env;
- }
-
- /**
- * Build oriented bbox from given envelope.
- * @param env
- */
- public void fromEnvelope(Envelope env) {
- setCoordinateReferenceSystem(env.getCoordinateReferenceSystem());
- center.set(0, env.getMedian(0));
- center.set(1, env.getMedian(1));
- center.set(2, env.getMedian(2));
- xAxis.setAll(0.0);
- yAxis.setAll(0.0);
- zAxis.setAll(0.0);
- xAxis.set(0, env.getSpan(0) / 2.0);
- yAxis.set(1, env.getSpan(1) / 2.0);
- zAxis.set(2, env.getSpan(2) / 2.0);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OffsetCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OffsetCurve.java
deleted file mode 100644
index 131ee86..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/OffsetCurve.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.geometries;
-
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="OffsetCurve", specification=ISO_19107) // section 6.4.20
-public interface OffsetCurve extends Curve{
-
- @UML(identifier="distance", specification=ISO_19107) // section 6.4.20.2
- Length getDistance();
-
- @UML(identifier="refDirection", specification=ISO_19107) // section 6.4.20.3
- Bearing getRefDirection();
-
- @UML(identifier="baseCurve", specification=ISO_19107) // section 6.4.20.4
- Curve getBaseCurve();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Orientable.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Orientable.java
deleted file mode 100644
index 6f821aa..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Orientable.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Orientable", specification=ISO_19107) // section 6.4.15
-public interface Orientable extends Primitive {
-
- public static enum Sign {
- POSITIVE,
- NEGATIVE
- }
-
- @UML(identifier="orientation", specification=ISO_19107) // section 6.4.15.2
- default Sign getOrientationSign(){
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="proxy", specification=ISO_19107) // section 6.4.15.3
- default Orientable getProxy(){
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="primitive", specification=ISO_19107) // section 6.4.15.3
- default Primitive getPrimitive(){
- //TODO
- throw new UnsupportedOperationException();
- }
-
- // called opposite on figure 16
- @UML(identifier="reverse", specification=ISO_19107) // section 6.4.15.3
- default Orientable getReverse(){
- //TODO
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Point.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Point.java
deleted file mode 100644
index f943d47..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Point.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- * A Point is a 0-dimensional geometric object and represents a single location in coordinate space.
- * A Point has an x-coordinate value, a y-coordinate value.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Point", specification=ISO_19107) // section 6.4.13
-public interface Point extends Primitive {
-
- public static final String TYPE = "POINT";
-
- /**
- * @return point coordinate
- */
- @UML(identifier="position", specification=ISO_19107) // section 6.4.13.2
- Tuple getPosition();
-
- /**
- * Returns tuple for given name.
- *
- * @param name seached attribute name
- * @return attribute or null.
- */
- Tuple getAttribute(String name);
-
- void setAttribute(String name, Tuple tuple);
-
- /**
- * View this point as a single point sequence
- */
- default PointSequence asPointSequence() {
- return new PointSequence() {
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return Point.this.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- Point.this.setCoordinateReferenceSystem(cs);
- }
-
- @Override
- public int size() {
- return 1;
- }
-
- @Override
- public Point getPoint(int index) {
- if (index != 0) throw new IndexOutOfBoundsException();
- return Point.this;
- }
-
- @Override
- public Tuple getPosition(int index) {
- if (index != 0) throw new IndexOutOfBoundsException();
- return Point.this.getPosition();
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- if (index != 0) throw new IndexOutOfBoundsException();
- Point.this.getPosition().set(value);
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- if (index != 0) throw new IndexOutOfBoundsException();
- return Point.this.getAttribute(name);
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- if (index != 0) throw new IndexOutOfBoundsException();
- Point.this.setAttribute(name, value);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return Point.this.getAttributesType();
- }
- };
- }
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- default Envelope getEnvelope() {
- final Tuple first = getPosition();
- final BBox env = new BBox(first, first);
- env.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
- return env;
- }
-
- @Override
- default String asText() {
- final Tuple crd = getPosition();
- final StringBuilder sb = new StringBuilder("POINT (");
- AbstractGeometry.toText(sb, crd);
- sb.append(')');
- return sb.toString();
- }
-
- @UML(identifier="vectorToPoint", specification=ISO_19107) // section 6.4.13.4
- default Vector vectorToPoint(DirectPosition toPoint) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="bearing", specification=ISO_19107) // section 6.4.13.5
- default Bearing bearing(DirectPosition toPoint) {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="pointAtDistance", specification=ISO_19107) // section 6.4.13.6
- default DirectPosition pointAtDistance(Vector bearing){
- //TODO
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PointSequence.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PointSequence.java
deleted file mode 100644
index ee6f70c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PointSequence.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface PointSequence {
-
- /**
- * Get geometry coordinate system.
- * @return never null
- */
- CoordinateReferenceSystem getCoordinateReferenceSystem();
-
- /**
- * Set coordinate system in which the coordinates are declared.
- * This method does not transform the coordinates.
- *
- * @param cs , not null
- * @Throws IllegalArgumentException if coordinate system is not compatible with geometrie.
- */
- void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException;
-
- /**
- * Get the geometry number of dimensions.
- * This is the same as coordinate system dimension.
- *
- * @return number of dimension
- */
- default int getDimension() {
- return getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
- }
-
- /**
- * Get geometry attributes type.
- * @return attributes type, never null
- */
- AttributesType getAttributesType();
-
- /**
- * Get the geometry bounding envelope.
- *
- * @return Envelope in geometry coordinate reference system.
- */
- default Envelope getEnvelope() {
- return getAttributeRange(AttributesType.ATT_POSITION);
- }
-
- default boolean isEmpty() {
- return size() == 0;
- }
-
- int size();
-
- Point getPoint(int index);
-
- /**
- * Get position attribute value.
- *
- * @param index searched index
- * @return copy of the position
- */
- Tuple getPosition(int index);
-
- /**
- * Set position attribute value.
- *
- * @param index searched index
- * @param value new attribute value
- */
- void setPosition(int index, Tuple value);
-
- /**
- * Get attribute value.
- *
- * @param index searched index
- * @param name attribute name
- * @return copy of the attribute
- */
- Tuple getAttribute(int index, String name);
-
- /**
- * Set attribute value.
- *
- * @param index searched index
- * @param name attribute name
- * @param value new attribute value
- */
- void setAttribute(int index, String name, Tuple value);
-
- /**
- * Get all attribute values as a TupleArray.
- *
- * @param name attribute name
- * @return copy of all attribute values
- */
- default TupleArray getAttributeArray(String name) {
- final AttributesType at = getAttributesType();
- final SampleSystem ss = at.getAttributeSystem(name);
- final DataType type = at.getAttributeType(name);
- final int size = size();
- final TupleArray ta = TupleArrays.of(ss, type, size);
- for (int i = 0; i < size; i++) {
- ta.set(i, getAttribute(i, name));
- }
- return ta;
- }
-
- /**
- * Get attribute values range
- *
- * @return BBox in attribute sample system
- */
- default BBox getAttributeRange(String name) {
- if (isEmpty()) {
- return null;
- }
- final Tuple<?> start = getAttribute(0, name);
- final BBox env = new BBox(start, start);
- for (int i = 1, n = size(); i < n; i++) {
- env.add(getAttribute(i, name));
- }
- env.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
- return env;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polygon.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polygon.java
deleted file mode 100644
index 7ae7832..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polygon.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.coordinate.GriddedSurface;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-
-
-/**
- * A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries.
- * Each interior boundary defines a hole in the Polygon. A Triangle is a polygon with 3 distinct, non-collinear
- * vertices and no interior boundary.
- *
- * The exterior boundary LinearRing defines the “top” of the surface which is the side of the surface from which
- * the exterior boundary appears to traverse the boundary in a counter clockwise direction.
- * The interior LinearRings will have the opposite orientation, and appear as clockwise when viewed from the “top”,
- *
- * The assertions for Polygons (the rules that define valid Polygons) are as follows:
- *
- * a) Polygons are topologically closed;
- * b) The boundary of a Polygon consists of a set of LinearRings that make up its exterior and interior boundaries;
- * c) No two Rings in the boundary cross and the Rings in the boundary of a Polygon may intersect at a Point but only as a tangent.
- * d) A Polygon may not have cut lines, spikes or punctures
- * e) The interior of every Polygon is a connected point set;
- * f) The exterior of a Polygon with 1 or more holes is not connected. Each hole defines a connected component of the exterior.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Polygon", specification=ISO_19107) // section 8.1.2
-public interface Polygon extends Surface {
-
- public static final String TYPE = "POLYGON";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- public default AttributesType getAttributesType() {
- return getExteriorRing().getAttributesType();
- }
-
- @UML(identifier="rings", specification=ISO_19107) // section 8.1 figure 28
- List<LinearRing> getInteriorRings();
-
- /**
- * Returns the exterior ring of this Polygon.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @return exterior ring of this Polygon.
- */
- @UML(identifier="exteriorRing", specification=ISO_19107) // section 8.1 figure 28
- LinearRing getExteriorRing();
-
- /**
- * Returns the number of interior rings in this Polygon.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @return number of interior rings in this Polygon.
- */
- @UML(identifier="numInteriorRing", specification=ISO_19107) // section 8.1 figure 28
- default int getNumInteriorRing() {
- return getInteriorRings().size();
- }
-
- /**
- * Returns the Nth interior ring for this Polygon as a LineString.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.11.2
- * @param n ring index
- * @return interior ring for this Polygon.
- */
- @UML(identifier="interiorRingN", specification=ISO_19107) // section 8.1 figure 28
- default LinearRing getInteriorRingN(int n) {
- return getInteriorRings().get(n);
- }
-
- @UML(identifier="spanningSurface", specification=ISO_19107) // section 8.1.2.3
- default GriddedSurface getSpanningSurface() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @Override
- default String asText() {
- final StringBuilder sb = new StringBuilder("POLYGON ((");
- AbstractGeometry.toText(sb, getExteriorRing().asLine(null, null).getPoints());
- sb.append(')');
- for (int i = 0, n = getNumInteriorRing(); i < n; i++) {
- if (i != 0) sb.append(',');
- sb.append('(');
- AbstractGeometry.toText(sb, getInteriorRingN(i).getPoints());
- sb.append(')');
- }
- sb.append(')');
- return sb.toString();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PolyhedralSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PolyhedralSurface.java
deleted file mode 100644
index 170acde..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PolyhedralSurface.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- * A PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments.
- *
- * For each pair of polygons that “touch”, the common boundary shall be expressible as a finite collection of LineStrings.
- * Each such LineString shall be part of the boundary of at most 2 Polygon patches.
- * A TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches.
- * For any two polygons that share a common boundary, the
- * “top” of the polygon shall be consistent. This means that when two LinearRings from these two Polygons traverse the
- * common boundary segment, they do so in opposite directions. Since the Polyhedral surface is contiguous, all polygons
- * will be thus consistently oriented. This means that a non-oriented surface (such as Möbius band) shall not have
- * single surface representations. They may be represented by a MultiSurface.
- *
- * If each such LineString is the boundary of exactly 2 Polygon patches, then the PolyhedralSurface is a simple, closed
- * polyhedron and is topologically isomorphic to the surface of a sphere. By the Jordan Surface Theorem
- * (Jordan’s Theorem for 2-spheres), such polyhedrons enclose a solid topologically isomorphic to the interior of a
- * sphere; the ball. In this case, the “top” of the surface will either point inward or outward of the enclosed finite
- * solid. If outward, the surface is the exterior boundary of the enclosed surface. If inward, the surface is the
- * interior of the infinite complement of the enclosed solid. A Ball with some number of voids (holes) inside can
- * thus be presented as one exterior boundary shell, and some number in interior boundary shells.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="PolyhedralSurface", specification=ISO_19107) // section 8.1.4 TODO extends geometry collection is ISO 19107
-public interface PolyhedralSurface<T extends Polygon> extends /*GeometryCollection<org.apache.sis.geometries.Polygon>,*/ Surface {
-
- public static final String TYPE = "POLYHEDRALSURFACE";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
-// @UML(identifier="segment", specification=ISO_19107) // section 8.1.4.3
-// @Override
-// public List<Primitive> getSegments();
-
- /**
- * Returns the number of including polygons
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.12.2
- * @return number of including polygons
- */
- int getNumPatches();
-
- /**
- * Returns a polygon in this surface, the order is arbitrary
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.12.2
- * @param n patch index
- * @return polygon in this surface, the order is arbitrary
- */
- T getPatchN(int n);
-
- /**
- * Returns the collection of polygons in this surface that bounds the given polygon “p” for any polygon “p” in the surface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.12.2
- * @param p searched polygons.
- * @return collection of polygons in this surface that bounds the given polygon
- */
- default MultiPolygon getBoundingPolygons(Polygon p) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns TRUE if the polygon closes on itself, and thus has no boundary and encloses a solid.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.12.2
- * @return true polygon closes on itself
- */
- default boolean isClosed() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polyhedron.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polyhedron.java
deleted file mode 100644
index 4c6562e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Polyhedron.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-
-
-/**
- * A solid is defined by its bounding surfaces. Each bounding surface is a closed, simple surface, also called a shell.
- *
- * Each solid has a unique exterior shell and any number of shells that are inside the exterior shell
- * and that describe voids. The interior shells do not intersect each other and cannot contain another interior shell.
- *
- * A polyhedron is a solid where each shell is a multi-polygon. 'Closed' means that the multi-polygon
- * shell is watertight, it splits space into two distinct regions: inside and outside of the shell. 'Simple' means
- * that the polygons that make up the shell do not intersect, they only touch each other along their common boundaries.
- *
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#polyhedron
- */
-public interface Polyhedron extends Geometry {
-
- public static final String TYPE = "POLYHEDRON";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- public default AttributesType getAttributesType() {
- return getExteriorShell().getAttributesType();
- }
-
- /**
- * Returns the exterior shell of this polyhedron.
- *
- * @return exterior shell of this polyhedron.
- */
- MultiPolygon getExteriorShell();
-
- /**
- * Returns a list of void shell inside the polyhedron.
- *
- * @return all void shell inside the polyhedron
- */
- List<MultiPolygon> getInteriorShells();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java
deleted file mode 100644
index 587cb78..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Stream;
-import org.locationtech.jts.index.quadtree.Quadtree;
-import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vector2D;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometry.Envelopes;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
-
-
-/**
- * Decorate a TIN, adding optimized search capabilities.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface PreparedTIN extends TIN {
-
- /**
- * Triangles intersecting given area.
- * @param env searched area, null for all triangles.
- * @throws org.opengis.referencing.operation.TransformException if envelope transform to TIN crs fails
- */
- Stream<Triangle> getPatches(org.opengis.geometry.Envelope env) throws TransformException;
-
- public static PreparedTIN create(Collection<TIN> tin) {
- return create(tin.toArray(TIN[]::new));
- }
-
- public static PreparedTIN create(TIN... tin) {
- if (tin.length == 0) throw new IllegalArgumentException("At least one TIN must be provided");
- if (tin.length == 1) return new Single(tin[0]);
- final Single[] singles = new Single[tin.length];
- for (int i = 0; i < tin.length; i++) singles[i] = new Single(tin[i]);
- return new Multi(singles);
- }
-
- final class Single implements PreparedTIN {
-
- private final TIN base;
- private final CoordinateReferenceSystem crs;
- private final CoordinateReferenceSystem crs2d;
- private Quadtree quadTree = new Quadtree();
-
- public Single(TIN base) {
- ArgumentChecks.ensureNonNull("tin", base);
- this.base = base;
- this.crs = base.getCoordinateReferenceSystem();
- this.crs2d = CRS.getHorizontalComponent(this.crs);
- ArgumentChecks.ensureNonNull("Horizontal CRS", crs2d);
- buildQuadTree();
- }
-
- private void buildQuadTree() {
- this.quadTree = new Quadtree();
- for (int i = 0, n = base.getNumPatches(); i < n; i++) {
- final Triangle triangle = base.getPatchN(i);
- final Envelope env = triangle.getEnvelope();
- final org.locationtech.jts.geom.Envelope e = new org.locationtech.jts.geom.Envelope(
- env.getMinimum(0),
- env.getMaximum(0),
- env.getMinimum(1),
- env.getMaximum(1));
- quadTree.insert(e, triangle);
- }
- }
-
- @Override
- public Stream<Triangle> getPatches(org.opengis.geometry.Envelope env) throws TransformException {
- final Stream<Triangle> stream;
- if (env == null) {
- stream = ((List<Triangle>) quadTree.queryAll()).stream();
- } else {
- final CoordinateReferenceSystem envCrs = env.getCoordinateReferenceSystem();
- final org.locationtech.jts.geom.Envelope e;
- if (Utilities.equalsIgnoreMetadata(envCrs, crs)
- || Utilities.equalsIgnoreMetadata(envCrs, crs2d)) {
- //compatible crs
- } else {
- env = Envelopes.transform(env, crs2d);
- }
- e = new org.locationtech.jts.geom.Envelope(
- env.getMinimum(0),
- env.getMaximum(0),
- env.getMinimum(1),
- env.getMaximum(1));
- stream = ((List<Triangle>) quadTree.query(e)).stream();
- }
- return stream;
- }
-
- @Override
- public int getNumPatches() {
- return base.getNumPatches();
- }
-
- @Override
- public Triangle getPatchN(int n) {
- return base.getPatchN(n);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return base.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new IllegalArgumentException("CoordinateReferenceSystem can not be changed on PreparedTIN");
- }
-
- @Override
- public Envelope getEnvelope() {
- return base.getEnvelope();
- }
-
- @Override
- public boolean isEmpty() {
- return base.isEmpty();
- }
-
- @Override
- public AttributesType getAttributesType() {
- return base.getAttributesType();
- }
- }
-
- final class Multi implements PreparedTIN {
-
- private final Single[] base;
- private Quadtree quadTree = new Quadtree();
- private GeneralEnvelope all;
- private boolean empty;
- private int nbPatches;
- private int[] offsets;
-
- public Multi(Single... base) {
- this.base = base;
- buildQuadTree();
- }
-
- private void buildQuadTree() {
- this.quadTree = new Quadtree();
- this.offsets = new int[base.length];
- for (int i = 0; i < base.length; i++) {
- final Envelope env = base[i].getEnvelope();
- final org.locationtech.jts.geom.Envelope e = new org.locationtech.jts.geom.Envelope(
- env.getMinimum(0),
- env.getMaximum(0),
- env.getMinimum(1),
- env.getMaximum(1));
- quadTree.insert(e, base[i]);
-
- if (all == null) all = new GeneralEnvelope(env);
- else all.add(env);
- empty &= base[i].isEmpty();
- offsets[i] = nbPatches;
- nbPatches += base[i].getNumPatches();
- }
- }
-
- @Override
- public Stream<Triangle> getPatches(org.opengis.geometry.Envelope env) throws TransformException {
- final Stream<Single> stream;
- if (env == null) {
- stream = ((List<Single>) quadTree.queryAll()).stream();
- } else {
- final CoordinateReferenceSystem envCrs = env.getCoordinateReferenceSystem();
- final org.locationtech.jts.geom.Envelope e;
- if (Utilities.equalsIgnoreMetadata(envCrs, base[0].crs)
- || Utilities.equalsIgnoreMetadata(envCrs, base[0].crs2d)) {
- //compatible crs
- } else {
- env = Envelopes.transform(env, base[0].crs2d);
- }
- e = new org.locationtech.jts.geom.Envelope(
- env.getMinimum(0),
- env.getMaximum(0),
- env.getMinimum(1),
- env.getMaximum(1));
- stream = ((List<Single>) quadTree.query(e)).stream();
- }
- final org.opengis.geometry.Envelope fenv = env;
- return stream.flatMap((Single t) -> {
- try {
- return t.getPatches(fenv);
- } catch (TransformException ex) {
- //won't happen
- throw new RuntimeException(ex);
- }
- });
- }
-
- @Override
- public int getNumPatches() {
- return nbPatches;
- }
-
- @Override
- public Triangle getPatchN(int n) {
- int idx = Arrays.binarySearch(offsets, n);
- if (idx < 0) idx = (-(idx) - 1) -1;
- return base[idx].getPatchN(n - offsets[idx]);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return base[0].getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new IllegalArgumentException("CoordinateReferenceSystem can not be changed on PreparedTIN");
- }
-
- @Override
- public Envelope getEnvelope() {
- return all;
- }
-
- @Override
- public boolean isEmpty() {
- return empty;
- }
-
- @Override
- public AttributesType getAttributesType() {
- return base[0].getAttributesType();
- }
- }
-
- default Evaluator evaluator() {
- return new Evaluator(this);
- }
-
- public static final class Evaluator {
-
- private final PreparedTIN tin;
- private double epsilon = Double.NaN;
- private final CoordinateReferenceSystem tincrs;
- //cache last position crs
- private CoordinateReferenceSystem lastCrs;
- private MathTransform lastTransform;
- private final Vector<?> target;
- private final Vector2D.Double p = new Vector2D.Double();
- private final GeneralEnvelope env;
-
- private Evaluator(PreparedTIN tin) {
- this.tin = tin;
- this.tincrs = tin.getCoordinateReferenceSystem();
- target = Vectors.createDouble(tincrs);
- env = new GeneralEnvelope(tincrs);
- }
-
- public double getEpsilon() {
- return epsilon;
- }
-
- public void setEpsilon(double epsilon) {
- this.epsilon = epsilon;
- }
-
- public Optional<Point> evaluate(Tuple<?> dp) throws CannotEvaluateException {
- final CoordinateReferenceSystem dpCrs = dp.getCoordinateReferenceSystem();
- final MathTransform transform;
- if (dpCrs == null) {
- //do nothing, we expect the same crs as the surface
- transform = null;
- } else if (dpCrs == lastCrs) {
- transform = lastTransform;
- } else {
- lastCrs = dpCrs;
- if (Geometries.isUndefined(dpCrs)) {
- //expecting the same crs as the surface, no transform
- lastTransform = null;
- } else if (Utilities.equalsIgnoreMetadata(tincrs, dpCrs)) {
- //equivalent crs, no transform
- lastTransform = null;
- } else {
- try {
- lastTransform = CRS.findOperation(dpCrs, tincrs, null).getMathTransform();
- } catch (FactoryException ex) {
- throw new CannotEvaluateException(ex.getMessage(), ex);
- }
- }
- transform = lastTransform;
- }
-
- if (transform != null) {
- try {
- dp.transformTo(transform, target);
- dp = target;
- } catch (TransformException ex) {
- throw new CannotEvaluateException(ex.getMessage(), ex);
- }
- }
- p.x = dp.get(0);
- p.y = dp.get(1);
-
- //use a local coordinate epsilon if undefined
- double epsilon = this.epsilon;
- if (!Double.isFinite(epsilon)) epsilon = Math.max(Math.ulp(p.x), Math.ulp(p.y)) * 10;
-
- double margin = epsilon;
- env.setRange(0, p.x - margin, p.x + margin);
- env.setRange(1, p.y - margin, p.y + margin);
-
- try (final Stream<Triangle> triangles = tin.getPatches(env)) {
- final Iterator<Triangle> iterator = triangles.iterator();
- while (iterator.hasNext()) {
- final Triangle triangle = iterator.next();
- final PointSequence points = triangle.getExteriorRing().getPoints();
- final Tuple a = points.getPosition(0);
- final Tuple b = points.getPosition(1);
- final Tuple c = points.getPosition(2);
- final double[] bary = Triangle.getBarycentricValue2D(
- a.get(0), a.get(1),
- b.get(0), b.get(1),
- c.get(0), c.get(1),
- p.get(0), p.get(1),
- epsilon, true);
- if (bary != null) {
- return Optional.of(triangle.interpolate(bary));
- }
- }
- } catch (TransformException e) {
- throw new CannotEvaluateException(e.getMessage(), e);
- }
- return Optional.empty();
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Primitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Primitive.java
deleted file mode 100644
index beae947..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Primitive.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Primitive", specification=ISO_19107) // section 6.4.11
-public interface Primitive extends Geometry {
-
- default List<Primitive> getSegments() {
- //TODO
- throw new UnsupportedOperationException();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Prism.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Prism.java
deleted file mode 100644
index 23ffa4e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Prism.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.referencing.crs.SingleCRS;
-import org.apache.sis.measure.NumberRange;
-
-
-/**
- * A prism is defined by a base shape (e.g. Polygon or Circle) that is then extruded from some optional lower limit to an upper limit.
- *
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#prism
- */
-public interface Prism extends Geometry {
-
- public static final String TYPE = "PRISM";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- @Override
- public default AttributesType getAttributesType() {
- return getBase().getAttributesType();
- }
-
- /**
- * @return base shape of the prism.
- */
- Geometry getBase();
-
- /**
- * @return lower and upper limits of the extrusion
- */
- NumberRange<?> getExtrusionRange();
-
- /**
- * @return the extrusion crs
- */
- SingleCRS getExtrusionCrs();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/ProductCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/ProductCurve.java
deleted file mode 100644
index 199ad7b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/ProductCurve.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.cs.Projection;
-import org.apache.sis.measure.Range;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="ProductCurve", specification=ISO_19107) // section 6.4.22
-public interface ProductCurve extends Curve, GeometryCollection<Curve> {
-
- @UML(identifier="parameterRange", specification=ISO_19107) // section 6.4.22.2
- Range<?> getParameterRange();
-
- @UML(identifier="projection", specification=ISO_19107) // section 6.4.22.3
- List<Projection> getProjection();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Solid.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Solid.java
deleted file mode 100644
index fd9c662..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Solid.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import javax.measure.quantity.Area;
-import javax.measure.quantity.Volume;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys
- */
-@UML(identifier="Solid", specification=ISO_19107) // section 6.4.28
-public interface Solid extends Primitive {
-
- @UML(identifier="boundary", specification=ISO_19107) // section 6.4.28.2
- Geometry getBoundary();
-
- @UML(identifier="area", specification=ISO_19107) // section 6.4.28.3
- Area getArea();
-
- @UML(identifier="volume", specification=ISO_19107) // section 6.4.28.4
- Volume getVolume();
-
- @UML(identifier="dataPoint", specification=ISO_19107) // section 6.4.28.5
- List<DirectPosition> getDataPoints();
-
- @UML(identifier="controlPoint", specification=ISO_19107) // section 6.4.28.6
- List<DirectPosition> getControlPoints();
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 6.4.28.7
- SolidInterpolation getInterpolation();
-
- @UML(identifier="knot", specification=ISO_19107) // section 6.4.28.8
- List<Knot> getKnots();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SolidInterpolation.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SolidInterpolation.java
deleted file mode 100644
index 2786071..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SolidInterpolation.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="SolidInterpolation", specification=ISO_19107) // section 6.4.30
-public enum SolidInterpolation {
- NONE,
- LINEAR,
- TETRAHEDRON,
- PARAMETRIC_CURVE,
- SPLINE,
- BEZIER,
- BSPLINE,
- NURBS
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Sphere.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Sphere.java
deleted file mode 100644
index f1e18d1..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Sphere.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * A sphere geometry defined by a center and a radius.
- * Even if it is called a Sphere this class can handle 2 to N dimensions.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Sphere extends AbstractGeometry {
-
- private Tuple center;
- private double radius = 1.0;
-
- /**
- * @param dimension number of dimensions of the sphere, must be positive.
- */
- public Sphere(int dimension) {
- this(Geometries.getUndefinedCRS(dimension));
- }
-
- /**
- * @param crs sphere coordinate system, not null.
- */
- public Sphere(CoordinateReferenceSystem crs) {
- center = Vectors.createDouble(crs);
- }
-
- @Override
- public String getGeometryType() {
- return "SPHERE";
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- if (cs.getCoordinateSystem().getDimension() != getCoordinateReferenceSystem().getCoordinateSystem().getDimension()) {
- throw new IllegalArgumentException("New CRS dimension must be the same as previous CRS");
- }
- Vector v = Vectors.create(cs, center.getDataType());
- v.set(center);
- center = v;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return center.getCoordinateReferenceSystem();
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
- /**
- * @return radius of the sphere.
- */
- public double getRadius() {
- return radius;
- }
-
- /**
- * @param radius new sphere radius, must be positive.
- */
- public void setRadius(double radius) {
- ArgumentChecks.ensurePositive("radius", radius);
- this.radius = radius;
- }
-
- /**
- * @return sphere center, modifiable.
- */
- public Tuple getCenter() {
- return center;
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public Envelope getEnvelope() {
- final Tuple center = getCenter();
- final BBox env = new BBox(center, center);
- env.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
- if (radius > 0) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- double c = center.get(i);
- env.setRange(0, c-radius, c+radius);
- }
- }
- return env;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Surface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Surface.java
deleted file mode 100644
index 1116292..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Surface.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.List;
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- * A Surface is a 2-dimensional geometric object.
- *
- * A simple Surface may consists of a single “patch” that is associated with one “exterior boundary” and 0 or more
- * “interior” boundaries. A single such Surface patch in 3-dimensional space is isometric to planar Surfaces,
- * by a simple affine rotation matrix that rotates the patch onto the plane z = 0. If the patch is not vertical, the
- * projection onto the same plane is an isomorphism, and can be represented as a linear transformation, i.e. an affine.
- *
- * Polyhedral Surfaces are formed by “stitching” together such simple Surfaces patches along their common boundaries.
- * Such polyhedral Surfaces in a 3-dimensional space may not be planar as a whole, depending on the orientation of
- * their planar normals (Reference [1], sections 3.12.9.1, and 3.12.9.3). If all the patches are in alignment
- * (their normals are parallel), then the whole stitched polyhedral surface is co-planar and can be represented
- * as a single patch if it is connected.
- *
- * The boundary of a simple Surface is the set of closed Curves corresponding to its “exterior” and “interior”
- * boundaries (Reference [1], section 3.12.9.4).
- *
- * The only instantiable subclasses of Surface defined in this standard are Polygon and PolyhedralSurface.
- * A Polygon is a simple Surface that is planar. A PolyhedralSurface is a simple surface, consisting of some number
- * of Polygon patches or facets. If a PolyhedralSurface is closed, then it bounds a solid.
- * A MultiSurface containing a set of closed PolyhedralSurfaces can be used to represent a Solid object with holes.
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Surface", specification=ISO_19107) // section 6.4.25
-public interface Surface extends Orientable {
-
- /**
- * The area of this Surface, as measured in the spatial reference system of this Surface.
- *
- * Difference with ISO 19107 : should return an Area instance.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.10.2
- * @return area of the surface.
- */
- @UML(identifier="area", specification=ISO_19107) // section 6.4.25.7
- default double getArea() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * The mathematical centroid for this Surface as a Point.
- * The result is not guaranteed to be on this Surface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.10.2
- * @return centroid for this Surface
- */
- @Override
- default Point getCentroid() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * A Point guaranteed to be on this Surface.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.10.2
- * @return point guaranteed to be on this Surface.
- */
- default Point getPointOnSurface() {
- throw new UnsupportedOperationException();
- }
-
-
- @UML(identifier="boundary", specification=ISO_19107) // section 6.4.25.2
- default Geometry getBoundary() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 6.4.25.3
- default List<SurfaceInterpolation> getInterpolation() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="numDerivativesBoundary", specification=ISO_19107) // section 6.4.25.4
- default Integer getNumDerivativesBoundary() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="numDerivativeInterior", specification=ISO_19107) // section 6.4.25.5
- default Integer getNumDerivativeInterior() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="perimeter", specification=ISO_19107) // section 6.4.25.6
- default Length getPerimeter() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="dataPoint", specification=ISO_19107) // section 6.4.25.8
- default List<DirectPosition> getDataPoints() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="controlPoint", specification=ISO_19107) // section 6.4.25.9
- default List<DirectPosition> getControlPoints() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="knot", specification=ISO_19107) // section 6.4.25.10
- default List<Knot> getKnots() {
- //TODO
- throw new UnsupportedOperationException();
- }
-
- @UML(identifier="upNormal", specification=ISO_19107) // section 6.4.25.11
- default Vector upNormal(DirectPosition point) {
- //TODO
- throw new UnsupportedOperationException();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SurfaceInterpolation.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SurfaceInterpolation.java
deleted file mode 100644
index 1fc5979..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/SurfaceInterpolation.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="SurfaceInterpolation", specification=ISO_19107) // section 6.4.27
-public enum SurfaceInterpolation {
- //TODO french spec name hell ! need the english spec.
- NONE,
- PLANAR,
- LINEAR,
- SPHERICAL,
- ELLIPTICAL,
- CONIC,
- TRIANGULAR,
- PARAMETRIC_CURVE,
- POLYNOMIAL_SPLINE,
- NURBS,
- BEZIER_SPLINE,
- TIN,
- TRIANGULATED_SPLINE
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TIN.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TIN.java
deleted file mode 100644
index b949ac0..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TIN.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.geometries;
-
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * A TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface TIN extends TriangulatedSurface<Triangle> {
-
- public static final String TYPE = "TIN";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-
- /**
- * Produce a Well Known Text representation of this TIN.
- *
- * @return WKT string
- */
- default String asText() {
- final StringBuilder sb = new StringBuilder("TIN(");
- boolean first = true;
- Tuple corner;
- for (int i = 0, n = getNumPatches(); i < n; i++) {
- Triangle triangle = getPatchN(i);
- if (first) {
- first = false;
- } else {
- sb.append(',');
- }
- sb.append("((");
- final PointSequence points = triangle.getExteriorRing().getPoints();
- corner = points.getPosition(0);
- AbstractGeometry.toText(sb, corner);
-
- sb.append(',');
- corner = points.getPosition(1);
- AbstractGeometry.toText(sb, corner);
-
- sb.append(',');
- corner = points.getPosition(2);
- AbstractGeometry.toText(sb, corner);
-
- sb.append(',');
- corner = points.getPosition(0);
- AbstractGeometry.toText(sb, corner);
-
- sb.append("))");
- }
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TransfiniteSet.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TransfiniteSet.java
deleted file mode 100644
index 04d7374..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TransfiniteSet.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="TransfiniteSetOfDirectPositions", specification=ISO_19107) // section 6.4.2
-public interface TransfiniteSet {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Triangle.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Triangle.java
deleted file mode 100644
index a5345f6..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Triangle.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * 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.geometries;
-
-import java.util.Collections;
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vector2D;
-import org.apache.sis.geometries.math.Vector3D;
-import org.apache.sis.geometries.math.Vectors;
-
-
-/**
- * A triangle geometry.
- *
- * TODO : declare and implement all methods from OGC Simple Feature Access
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Triangle", specification=ISO_19107) // section 8.1.6
-public interface Triangle extends Polygon {
-
- @Override
- default String getGeometryType() {
- return "TRIANGLE";
- }
-
- /**
- * Triangles points.
- * First and last point are identical.
- *
- * @return empty if triangle is empty, or of size 4.
- */
- @Override
- LinearRing getExteriorRing();
-
- @Override
- default List<LinearRing> getInteriorRings() {
- return Collections.emptyList();
- }
-
- @Override
- default CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return getExteriorRing().getCoordinateReferenceSystem();
- }
-
- @Override
- default void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- getExteriorRing().setCoordinateReferenceSystem(cs);
- }
-
- @Override
- default Envelope getEnvelope() {
- final PointSequence exterior = getExteriorRing().getPoints();
- final Tuple<?> first = exterior.getPosition(0);
- final BBox env = new BBox(first, first);
- env.add(exterior.getPosition(1));
- env.add(exterior.getPosition(2));
- env.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
- return env;
- }
-
- @Override
- default double getArea() {
- final PointSequence points = getExteriorRing().getPoints();
- final Tuple<?> a = points.getPosition(0);
- final Tuple<?> b = points.getPosition(1);
- final Tuple<?> c = points.getPosition(2);
- final double area = (
- a.get(0) * (b.get(1) - c.get(1))
- + b.get(0) * (c.get(1) - a.get(1))
- + c.get(0) * (a.get(1) - b.get(1))
- ) / 2.0;
- return Math.abs(area);
- }
-
- /**
- * Compute point distance to triangle.
- * @param pt point to evaluate
- * @return point distance to triangle
- */
- default double distance(Tuple pt) {
- final PointSequence exterior = getExteriorRing().getPoints();
- final Tuple<?> p0 = exterior.getPosition(0);
- final Tuple<?> p1 = exterior.getPosition(1);
- final Tuple<?> p2 = exterior.getPosition(2);
- Vector<?> normal = Maths.calculateNormal(p0, p1, p2);
- double planD = normal.dot(p0);
- return Maths.distance(pt, normal, planD);
- }
-
- /**
- * Interpolate a point in the triangle.
- *
- * @param weights each corner barycentric weights
- * @return interpolated record
- */
- default Point interpolate(double[] weights) {
- return new InterpolatedPoint(this, weights);
- }
-
- /**
- * Test if point is inside triangle and return it's barycentric weights.
- * This method first test a bounding box intersection then using side algorithm
- * and finally segment distant using given tolerance.
- *
- * Explications provided here :
- * https://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @param epsilon bounding box margin
- * @param nullIfOutside return null if point is outside the triangle
- * @return [a,b,c] weights
- */
- public static double[] getBarycentricValue2D(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y, double epsilon, boolean nullIfOutside) {
- if (nullIfOutside) {
- if (!Maths.isPointInTriangle_BoundingBox(x1, y1, x2, y2, x3, y3, x, y, epsilon)) {
- return null;
- }
- final double[] bary = Maths.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y);
- final boolean inTriangle = (bary[1] >= 0.0 && bary[2] >= 0.0 && (bary[1] + bary[2]) <= 1.0);
- if (inTriangle) {
- return bary;
- }
-
- if (epsilon > 0.0) {
- //point might be very close to segments
- if (Maths.distanceSquare(x1, y1, x2, y2, x, y) <= epsilon) {
- //compute weights based on distance, clamp to ends
- double ratio = Maths.clamp(Maths.projectionRatio(x1, y1, x2, y2, x, y), 0.0, 1.0);
- bary[0] = 1.0 - ratio;
- bary[1] = ratio;
- bary[2] = 0.0;
- return bary;
- }
- if (Maths.distanceSquare(x2, y2, x3, y3, x, y) <= epsilon) {
- //compute weights based on distance, clamp to ends
- double ratio = Maths.clamp(Maths.projectionRatio(x2, y2, x3, y3, x, y), 0.0, 1.0);
- bary[0] = 0.0;
- bary[1] = 1.0 - ratio;
- bary[2] = ratio;
- return bary;
- }
- if (Maths.distanceSquare(x3, y3, x1, y1, x, y) <= epsilon) {
- //compute weights based on distance, clamp to ends
- double ratio = Maths.clamp(Maths.projectionRatio(x3, y3, x1, y1, x, y), 0.0, 1.0);
- bary[0] = ratio;
- bary[1] = 0.0;
- bary[2] = 1.0 - ratio;
- return bary;
- }
- }
-
- //point is outside triangle
- return null;
- } else {
- return Maths.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y);
- }
- }
-
- public static Double interpolate2D(Vector3D.Double a, Vector3D.Double b, Vector3D.Double c, Vector2D.Double p){
- final double v0x = b.x-a.x;
- final double v0y = b.y-a.y;
- final double v1x = c.x-a.x;
- final double v1y = c.y-a.y;
- final double v2x = p.x-a.x;
- final double v2y = p.y-a.y;
- final double d00 = v0x * v0x + v0y * v0y;
- final double d01 = v0x * v1x + v0y * v1y;
- final double d11 = v1x * v1x + v1y * v1y;
- final double d20 = v2x * v0x + v2y * v0y;
- final double d21 = v2x * v1x + v2y * v1y;
- final double denom = d00 * d11 - d01 * d01;
- final double v = (d11 * d20 - d01 * d21) / denom;
- final double w = (d00 * d21 - d01 * d20) / denom;
- final double u = 1.0 - v - w;
-
- if (v >= 0.0 && w >= 0.0 && (v + w) <= 1.0) {
- //point is in this triangle, interpolate Z
- return u * a.z
- + v * b.z
- + w * c.z;
- }
- return null;
- }
-
- @Override
- default String asText() {
- final PointSequence exterior = getExteriorRing().getPoints();
- final StringBuilder sb = new StringBuilder("TRIANGLE ((");
- AbstractGeometry.toText(sb, exterior.getPosition(0));
- sb.append(',');
- AbstractGeometry.toText(sb, exterior.getPosition(1));
- sb.append(',');
- AbstractGeometry.toText(sb, exterior.getPosition(2));
- sb.append("))");
- return sb.toString();
- }
-
- /**
- */
- default String asTextPolygon() {
- return Polygon.super.asText();
- }
-
- public static final class InterpolatedPoint implements Point {
-
- private static final double[][] CORNERS = new double[][]{
- {1,0,0},
- {0,1,0},
- {0,0,1}};
-
- private final Triangle triangle;
- private final double[] weights;
- private final int cornerIdx;
-
- InterpolatedPoint(Triangle triangle, int cornerIdx) {
- this.triangle = triangle;
- this.cornerIdx = cornerIdx;
- this.weights = CORNERS[cornerIdx];
- }
-
- public InterpolatedPoint(Triangle triangle, double[] weights) {
- this.triangle = triangle;
- this.weights = weights;
- this.cornerIdx = -1;
- }
-
- public Triangle getTriangle() {
- return triangle;
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public Tuple getPosition() {
- final PointSequence points = triangle.getExteriorRing().getPoints();
- switch (cornerIdx) {
- case -1 :
- return interpolate(
- points.getPosition(0),
- points.getPosition(1),
- points.getPosition(2),
- false);
- default :
- return points.getPosition(cornerIdx);
- }
- }
-
- /**
- * NORMAL and TANGENT attributes interpolation will be normalized.
- *
- * @param name attribute name, must be one of the sample dimension names
- * @return triangle corner attribute.
- */
- @Override
- public Tuple getAttribute(String name) {
- final PointSequence points = triangle.getExteriorRing().getPoints();
- switch (cornerIdx) {
- case -1 :
- return interpolate(
- points.getAttribute(0,name),
- points.getAttribute(1,name),
- points.getAttribute(2,name),
- AttributesType.ATT_NORMAL.equals(name) || AttributesType.ATT_TANGENT.equals(name));
- default :
- return points.getAttribute(cornerIdx, name);
- }
- }
-
- @Override
- public void setAttribute(String name, Tuple tuple) {
- throw new UnsupportedOperationException("Not supported on interpolated points.");
- }
-
- private Tuple interpolate(Tuple a, Tuple b, Tuple c, boolean normalize) {
- if (a == null) {
- //may happen if TIN has 0 sample dimensions.
- return null;
- }
- Tuple buffer = a.copy();
- final int dimension = a.getDimension();
- switch (dimension) {
- default :
- for (int i = 3; i < dimension; i++) {
- buffer.set(i, a.get(i) * weights[0] + b.get(i) * weights[1] + c.get(i) * weights[2]);
- }
- case 3 :
- buffer.set(2, a.get(2) * weights[0] + b.get(2) * weights[1] + c.get(2) * weights[2]);
- case 2 :
- buffer.set(1, a.get(1) * weights[0] + b.get(1) * weights[1] + c.get(1) * weights[2]);
- case 1 :
- buffer.set(0, a.get(0) * weights[0] + b.get(0) * weights[1] + c.get(0) * weights[2]);
- case 0 : //do nothing
- }
-
- if (normalize) Vectors.castOrWrap(buffer).normalize();
- return buffer;
- }
-
- @Override
- public AttributesType getAttributesType() {
- return triangle.getAttributesType();
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return triangle.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TriangulatedSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TriangulatedSurface.java
deleted file mode 100644
index f1367e2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/TriangulatedSurface.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="TriangulatedSurface", specification=ISO_19107) // section 8.1.8
-public interface TriangulatedSurface<T extends Polygon> extends PolyhedralSurface<T> {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Vocabulary.properties b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Vocabulary.properties
deleted file mode 100644
index 84c38b4..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Vocabulary.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-Right=Right
-Left=Left
-Up=Up
-Down=Down
\ No newline at end of file
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Wrapper.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Wrapper.java
deleted file mode 100644
index e902842..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Wrapper.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * 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.geometries;
-
-import java.awt.Shape;
-import java.util.Iterator;
-import java.util.OptionalInt;
-import org.apache.sis.filter.sqlmm.SQLMM;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.opengis.util.FactoryException;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.CoordinateOperation;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.geometry.wrapper.Geometries;
-import org.apache.sis.geometry.wrapper.GeometryType;
-import org.apache.sis.geometry.wrapper.GeometryWrapper;
-import org.apache.sis.util.Debug;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.CoordinateSequence;
-import org.locationtech.jts.geom.Envelope;
-
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.DistanceOperatorName;
-
-
-/**
- * The wrapper of SIS geometries.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Wrapper extends GeometryWrapper {
- /**
- * The wrapped implementation.
- */
- private final Geometry geometry;
-
- /**
- * Creates a new wrapper around the given geometry.
- *
- * @param geometry the geometry to wrap.
- */
- Wrapper(final Geometry geometry) {
- this.geometry = geometry;
- crs = geometry.getCoordinateReferenceSystem();
- }
-
- /**
- * Creates a new wrapper with the same <abbr>CRS</abbr> than the given wrapper.
- *
- * @param source the source wrapper from which is derived the geometry.
- * @param geometry the geometry to wrap.
- */
- private Wrapper(final Wrapper source, final Geometry geometry) {
- this.geometry = geometry;
- this.crs = source.crs;
- }
-
- /**
- * Returns the implementation-dependent factory of geometric object.
- */
- @Override
- protected Geometries<Geometry> factory() {
- return GeometryFactory.INSTANCE;
- }
-
- /**
- * Returns the geometry specified at construction time.
- */
- @Override
- protected Object implementation() {
- return geometry;
- }
-
- /**
- * Returns the Spatial Reference System Identifier (SRID) if available.
- * This is <em>not</em> necessarily an EPSG code, even it is common practice to use
- * the same numerical values as EPSG. Note that the absence of SRID does not mean
- * that {@link #getCoordinateReferenceSystem()} would return no CRS.
- */
- @Override
- public OptionalInt getSRID() {
- return OptionalInt.empty();
- }
-
- /**
- * Sets the coordinate reference system. This method overwrites any previous user object.
- * This is okay for the context in which Apache SIS uses this method, which is only for
- * newly created geometries.
- */
- @Override
- public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs) {
- super.setCoordinateReferenceSystem(crs);
- geometry.setCoordinateReferenceSystem(crs);
- }
-
- /**
- * Returns the dimension of the coordinates that define this geometry.
- */
- @Override
- public int getCoordinateDimension() {
- return getCoordinatesDimension(geometry);
- }
-
- /**
- * Gets the number of dimensions of geometry vertex (sequence of coordinate tuples), which can be 2 or 3.
- *
- * @param geometry the geometry for which to get <em>vertex</em> (not topological) dimension.
- * @return vertex dimension of the given geometry.
- */
- private static int getCoordinatesDimension(final Geometry geometry) {
- return geometry.getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
- }
-
- /**
- * Returns the envelope of SIS geometry. Never null, but may be empty.
- */
- @Override
- public GeneralEnvelope getEnvelope() {
- return new GeneralEnvelope(geometry.getEnvelope());
- }
-
- /**
- * Returns the centroid of the wrapped geometry as a direct position.
- */
- @Override
- public DirectPosition getCentroid() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * If the wrapped geometry is a point, returns its coordinates. Otherwise returns {@code null}.
- * If non-null, the returned array may have a length of 2 or 3.
- */
- @Override
- public double[] getPointCoordinates() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Returns all coordinate tuples in the wrapped geometry.
- * This method is currently used for testing purpose only.
- */
- @Debug
- @Override
- public double[] getAllCoordinates() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Merges a sequence of points or paths after the wrapped geometry.
- *
- * @throws ClassCastException if an element in the iterator is not a SIS geometry.
- */
- @Override
- public Geometry mergePolylines(final Iterator<?> polylines) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Applies a filter predicate between this geometry and another geometry.
- * This method assumes that the two geometries are in the same CRS (this is not verified).
- *
- * <p><b>Note:</b> No operations are supported at this time.</p>
- *
- * @throws ClassCastException if the given wrapper is not for the same geometry library.
- */
- @Override
- protected boolean predicateSameCRS(final SpatialOperatorName type, final GeometryWrapper other) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Applies a filter predicate between this geometry and another geometry within a given distance.
- * This method assumes that the two geometries are in the same CRS and that the unit of measurement
- * is the same for {@code distance} than for axes (this is not verified).
- *
- * @throws ClassCastException if the given wrapper is not for the same geometry library.
- */
- @Override
- protected boolean predicateSameCRS(final DistanceOperatorName type,
- final GeometryWrapper other, final double distance)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Applies a SQLMM operation on this geometry.
- *
- * @param operation the SQLMM operation to apply.
- * @param other the other geometry, or {@code null} if the operation requires only one geometry.
- * @param argument an operation-specific argument, or {@code null} if not applicable.
- * @return result of the specified operation.
- * @throws ClassCastException if the operation can only be executed on some specific argument types
- * (for example geometries that are polylines) and one of the argument is not of that type.
- */
- @Override
- protected Object operationSameCRS(final SQLMM operation, final GeometryWrapper other, final Object argument) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Converts the wrapped geometry to the specified type.
- * If the geometry is already of that type, it is returned unchanged.
- * Otherwise coordinates are copied in a new geometry of the requested type.
- *
- * <p>The following conversions are illegal and will cause an {@link IllegalArgumentException} to be thrown:</p>
- * <ul>
- * <li>From point to polyline or polygon.</li>
- * <li>From geometry collection (except multi-point) to polyline.</li>
- * <li>From geometry collection (except multi-point and multi-line string) to polygon.</li>
- * <li>From geometry collection containing nested collections.</li>
- * </ul>
- *
- * The conversion from {@link MultiLineString} to {@link Polygon} is defined as following:
- * the first {@link LineString} is taken as the exterior {@link LinearRing} and all others
- * {@link LineString}s are interior {@link LinearRing}s.
- * This rule is defined by some SQLMM operations.
- *
- * @param target the desired type.
- * @return the converted geometry.
- * @throws IllegalArgumentException if the geometry cannot be converted to the specified type.
- */
- @Override
- public GeometryWrapper toGeometryType(final GeometryType target) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Transforms this geometry using the given coordinate operation.
- * If the operation is {@code null}, then the geometry is returned unchanged.
- * If the geometry uses a different CRS than the source CRS of the given operation
- * and {@code validate} is {@code true},
- * then a new operation to the target CRS will be automatically computed.
- *
- * @param operation the coordinate operation to apply, or {@code null}.
- * @param validate whether to validate the operation source CRS.
- * @throws FactoryException if transformation to the target CRS cannot be found.
- * @throws TransformException if the geometry cannot be transformed.
- */
- @Override
- public GeometryWrapper transform(final CoordinateOperation operation, final boolean validate)
- throws FactoryException, TransformException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Transforms this geometry to the specified Coordinate Reference System (CRS).
- * If the given CRS is null or is the same CRS as current one, the geometry is returned unchanged.
- *
- * @param targetCRS the target coordinate reference system, or {@code null}.
- * @return the transformed geometry (may be the same geometry instance), or {@code null}.
- * @throws TransformException if this geometry cannot be transformed.
- */
- @Override
- public GeometryWrapper transform(final CoordinateReferenceSystem targetCRS) throws TransformException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Transforms this geometry using the given transform.
- * If the transform is {@code null}, then the geometry is returned unchanged.
- *
- * @param transform the math transform to apply, or {@code null}.
- * @return the transformed geometry (may be the same geometry instance, but never {@code null}).
- * @throws TransformException if the geometry cannot be transformed.
- */
- @Override
- public GeometryWrapper transform(final MathTransform transform) throws FactoryException, TransformException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Returns a view over the SIS geometry as a Java2D shape. Changes in the SIS geometry
- * after this method call may be reflected in the returned shape in an unspecified way.
- *
- * @return a view over the geometry as a Java2D shape.
- */
- @Override
- public Shape toJava2D() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Returns the WKT representation of the wrapped geometry.
- */
- @Override
- public String formatWKT(final double flatness) {
- return geometry.asText();
- }
-
- /**
- * View SIS Geometry as a JTS Geometry.
- * Only the matching JTS geometry types are supported.
- * The created geometry references the original geometry PointSequences, so modifications
- * are forwarded to the original but all metadata change, like the CRS, will not be preserved if changed
- * after the JTS view has been made.
- *
- * @param gf optional creation factory.
- * @return JTS geometry view of the given geometry
- */
- public org.locationtech.jts.geom.Geometry asJTS(org.locationtech.jts.geom.GeometryFactory gf) {
- return asJTS(geometry, gf);
- }
-
- /**
- * View SIS Geometry as a JTS Geometry.
- * Only the matching JTS geometry types are supported.
- * The created geometry references the original geometry PointSequences, so modifications
- * are forwarded to the original but all metadata change, like the CRS, will not be preserved if changed
- * after the JTS view has been made.
- *
- * @param geometry to convert
- * @param gf optional creation factory.
- * @return JTS geometry view of the given geometry
- */
- public static org.locationtech.jts.geom.Geometry asJTS(Geometry geometry, org.locationtech.jts.geom.GeometryFactory gf) {
- if (gf == null) gf = new org.locationtech.jts.geom.GeometryFactory();
- final org.locationtech.jts.geom.Geometry jts;
-
- if (geometry instanceof Point cdt){
- jts = gf.createPoint(new JTSSequence(cdt.asPointSequence()));
- } else if (geometry instanceof LinearRing cdt) {
- jts = gf.createLinearRing(new JTSSequence(cdt.getPoints()));
- } else if (geometry instanceof LineString cdt) {
- jts = gf.createLineString(new JTSSequence(cdt.getPoints()));
- } else if (geometry instanceof Polygon cdt) {
- final org.locationtech.jts.geom.LinearRing exterior = (org.locationtech.jts.geom.LinearRing) asJTS(cdt.getExteriorRing(), gf);
- final org.locationtech.jts.geom.LinearRing[] inners = new org.locationtech.jts.geom.LinearRing[cdt.getNumInteriorRing()];
- for (int i = 0; i < inners.length; i++) {
- inners[i] = (org.locationtech.jts.geom.LinearRing) asJTS(cdt.getInteriorRingN(i), gf);
- }
- jts = gf.createPolygon(exterior, inners);
- } else if (geometry instanceof MultiPoint<?> cdt) {
- jts = gf.createMultiPoint(new JTSSequence(cdt.asPointSequence()));
- } else if (geometry instanceof MultiLineString cdt) {
- final org.locationtech.jts.geom.LineString[] children = new org.locationtech.jts.geom.LineString[cdt.getNumGeometries()];
- for (int i = 0; i < children.length; i++) {
- children[i] = (org.locationtech.jts.geom.LineString) asJTS(cdt.getGeometryN(i), gf);
- }
- jts = gf.createMultiLineString(children);
- } else if (geometry instanceof MultiPolygon cdt) {
- final org.locationtech.jts.geom.Polygon[] children = new org.locationtech.jts.geom.Polygon[cdt.getNumGeometries()];
- for (int i = 0; i < children.length; i++) {
- children[i] = (org.locationtech.jts.geom.Polygon) asJTS(cdt.getGeometryN(i), gf);
- }
- jts = gf.createMultiPolygon(children);
- } else if (geometry instanceof MultiPolygon cdt) {
- final org.locationtech.jts.geom.Geometry[] children = new org.locationtech.jts.geom.Geometry[cdt.getNumGeometries()];
- for (int i = 0; i < children.length; i++) {
- children[i] = (org.locationtech.jts.geom.Geometry) asJTS(cdt.getGeometryN(i), gf);
- }
- jts = gf.createGeometryCollection(children);
- } else {
- throw new UnsupportedOperationException("Geometry type " + geometry.getClass().getName() + " has no match in JTS library");
- }
-
- jts.setUserData(geometry.getCoordinateReferenceSystem());
- return jts;
- }
- /**
- * Decorate a PointSequence as a JTS CoordinateSequence
- */
- private static class JTSSequence implements CoordinateSequence {
-
- private final PointSequence ps;
-
- public JTSSequence(PointSequence ps) {
- this.ps = ps;
- }
-
- @Override
- public int getDimension() {
- return ps.getDimension();
- }
-
- @Override
- public Coordinate getCoordinate(int i) {
- return getCoordinateCopy(i);
- }
-
- @Override
- public Coordinate getCoordinateCopy(int i) {
- final Coordinate crd = createCoordinate();
- getCoordinate(i, crd);
- return crd;
- }
-
- @Override
- public void getCoordinate(int idx, Coordinate crdnt) {
- Tuple tuple = ps.getPosition(idx);
- for (int i = 0; i < tuple.getDimension(); i++) {
- crdnt.setOrdinate(i, tuple.get(i));
- }
- }
-
- @Override
- public double getX(int i) {
- return ps.getPosition(i).get(0);
- }
-
- @Override
- public double getY(int i) {
- return ps.getPosition(i).get(1);
- }
-
- @Override
- public double getOrdinate(int i, int i1) {
- return ps.getPosition(i).get(i1);
- }
-
- @Override
- public int size() {
- return ps.size();
- }
-
- @Override
- public void setOrdinate(int i, int i1, double d) {
- Tuple position = ps.getPosition(i);
- position.set(i1, d);
- ps.setPosition(i, position);
- }
-
- @Override
- public Coordinate[] toCoordinateArray() {
- final Coordinate[] coords = new Coordinate[ps.size()];
- for (int i = 0; i < coords.length; i++) {
- coords[i] = getCoordinateCopy(i);
- }
- return coords;
- }
-
- @Override
- public Envelope expandEnvelope(Envelope envlp) {
- final org.opengis.geometry.Envelope env = ps.getEnvelope();
- envlp.expandToInclude(new Envelope(env.getMinimum(0), env.getMaximum(0), env.getMinimum(1), env.getMaximum(1)));
- return envlp;
- }
-
- @Override
- public CoordinateSequence copy() {
- final PointSequence cp = new ArraySequence(ps.getAttributeArray(AttributesType.ATT_POSITION));
- return new JTSSequence(cp);
- }
-
- public Object clone(){
- return copy();
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Arc.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Arc.java
deleted file mode 100644
index f6c2c6d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Arc.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.geometries.conics;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Arc", specification=ISO_19107) // section 7.9.2
-public interface Arc extends Conic {
-
- @UML(identifier="numArc", specification=ISO_19107) // section 7.9.2.2
- int getNumArc();
-
- @UML(identifier="controlPoints", specification=ISO_19107) // section 7.9.2.3
- @Override
- List<DirectPosition> getControlPoints();
-
- @UML(identifier="dataPoints", specification=ISO_19107) // section 7.9.2.4
- @Override
- List<DirectPosition> getDataPoints();
-
- @UML(identifier="radius", specification=ISO_19107) // section 7.9.2.5
- List<Vector> getRadius();
-
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Circle.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Circle.java
deleted file mode 100644
index 5d5326e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Circle.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.conics;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Circle", specification=ISO_19107) // section 7.9.4
-public interface Circle extends Arc{
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/CircularString.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/CircularString.java
deleted file mode 100644
index b7f1973..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/CircularString.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.geometries.conics;
-
-import org.apache.sis.geometries.Curve;
-
-
-/**
- * @todo
- * @author Johann Sorel (Geomatys)
- * @see https://docs.ogc.org/DRAFTS/21-045r1.html#circular_string
- */
-public interface CircularString extends Curve {
-
- public static final String TYPE = "CIRCULARSTRING";
-
- @Override
- public default String getGeometryType() {
- return TYPE;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Conic.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Conic.java
deleted file mode 100644
index e51f9f7..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/Conic.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.geometries.conics;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.Curve;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Conic", specification=ISO_19107) // section 7.9.5
-public interface Conic extends Curve {
-
- @UML(identifier="controlPoints", specification=ISO_19107) // section 7.9.5.2
- @Override
- List<DirectPosition> getControlPoints();
-
- @UML(identifier="dataPoints", specification=ISO_19107) // section 7.9.5.2
- @Override
- List<DirectPosition> getDataPoints();
-
- @UML(identifier="isCycle", specification=ISO_19107) // section 7.9.5.2
- boolean isCycle();
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/ConicArc.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/ConicArc.java
deleted file mode 100644
index 43c40d2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/ConicArc.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.geometries.conics;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface ConicArc {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/EllipticArc.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/EllipticArc.java
deleted file mode 100644
index 1e9136a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conics/EllipticArc.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.conics;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="EllipticArc", specification=ISO_19107) // section 7.9.6
-public interface EllipticArc extends Conic {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cone.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cone.java
deleted file mode 100644
index bec2719..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cone.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.geometries.conicsurfaces;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Cone {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cylinder.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cylinder.java
deleted file mode 100644
index 21402d0..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Cylinder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.geometries.conicsurfaces;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Cylinder {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Sphere.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Sphere.java
deleted file mode 100644
index ad9320e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/conicsurfaces/Sphere.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.geometries.conicsurfaces;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Sphere {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/CurveRelativeDirection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/CurveRelativeDirection.java
deleted file mode 100644
index be06486..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/CurveRelativeDirection.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="CurveRelativeDirection", specification=ISO_19107) // section 6.2.26
-public enum CurveRelativeDirection {
- TANGENT,
- REVERSE_TANGENT,
- NORMAL,
- REVERSE_NORMAL,
- BINORMAL,
- REVERSE_BINORMAL,
- LEFT_NORMAL,
- RIGHT_NORMAL,
- UP_NORMAL,
- DOWN_NORMAL
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/FixedDirection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/FixedDirection.java
deleted file mode 100644
index b2b1003..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/FixedDirection.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="FixedDirection", specification=ISO_19107) // section 6.2.25
-public interface FixedDirection {
-
- //TODO
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/GeometricCoordinateSystem.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/GeometricCoordinateSystem.java
deleted file mode 100644
index b3c821b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/GeometricCoordinateSystem.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.Bearing;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="GeometricCoordinateSystem", specification=ISO_19107) // section 6.2.8
-public interface GeometricCoordinateSystem {
-
- @UML(identifier="name", specification=ISO_19107) // section 6.2.8.2
- String getName();
-
- @UML(identifier="spatialDimension", specification=ISO_19107) // section 6.2.8.3
- int getSpatialDimension();
-
- @UML(identifier="temporalDimension", specification=ISO_19107) // section 6.2.8.4
- int getTemporalDimension();
-
- @UML(identifier="parametricDimension", specification=ISO_19107) // section 6.2.8.5
- int getParametricDimension();
-
- @UML(identifier="permutation", specification=ISO_19107) // section 6.2.8.6
- int[] getPermutation();
-
- @UML(identifier="spatialProjection", specification=ISO_19107) // section 6.2.8.7
- Projection getSpatialProjection();
-
- @UML(identifier="temporalProjection", specification=ISO_19107) // section 6.2.8.8
- Projection getTemporalProjection();
-
- @UML(identifier="csDistance", specification=ISO_19107) // section 6.2.8.9
- Number csDistance(DirectPosition p1, DirectPosition p2);
-
- @UML(identifier="distance", specification=ISO_19107) // section 6.2.8.10
- Length distance(DirectPosition p1, DirectPosition p2);
-
- @UML(identifier="pointAtDistance", specification=ISO_19107) // section 6.2.8.11
- DirectPosition pointAtDistance(DirectPosition center, Vector vector);
-
- @UML(identifier="geoLocate", specification=ISO_19107) // section 6.2.8.12
- DirectPosition geoLocate(DirectPosition pos);
-
- @UML(identifier="bearing", specification=ISO_19107) // section 6.2.8.13
- Bearing bearing(DirectPosition center, DirectPosition target);
-
- @UML(identifier="csInnerProduct", specification=ISO_19107) // section 6.2.8.14
- Number csInnerProduct(DirectPosition center, Vector v1, Vector v2);
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Projection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Projection.java
deleted file mode 100644
index c406b52..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Projection.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.geometries.cs;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Projection {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/ReferenceDirection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/ReferenceDirection.java
deleted file mode 100644
index 7a0ad44..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/ReferenceDirection.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="ReferenceDirection", specification=ISO_19107) // section 6.2.22.4
-public interface ReferenceDirection {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/RelativeDirection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/RelativeDirection.java
deleted file mode 100644
index 5c097ff..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/RelativeDirection.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="RelativeDirection", specification=ISO_19107) // section 6.2.24
-public enum RelativeDirection {
- FORWARD, //FORE
- BACKWARD, //AFT
- LEFT, //PORT
- RIGHT //STARBOARD
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Rotation.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Rotation.java
deleted file mode 100644
index a007564..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/Rotation.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.geometries.cs;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Rotation", specification=ISO_19107) // section 6.2.23
-public enum Rotation {
- CLOCKWISE,
- COUNTER_CLOCKWISE
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/package-info.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/package-info.java
deleted file mode 100644
index 66d0a3b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/cs/package-info.java
+++ /dev/null
@@ -1,13 +0,0 @@
-
-/**
- *
- * <h2>Remaining work to be done</h2>
- *
- * <ul>
- * <li>Complete package is draft and needs to be reviewed with Apache SIS and GeoAPI</li>
- * <li>Review GeoAPI DirectPosition, section 6.2.9</li>
- * <li>Implement Vector, section 6.2.27</li>
- * </ul>
- *
- */
-package org.apache.sis.geometries.cs;
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/geodesics/Geodesic.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/geodesics/Geodesic.java
deleted file mode 100644
index 1368fbb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/geodesics/Geodesic.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.geodesics;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.CurveInterpolation;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Geodesic", specification=ISO_19107) // section 7.3.2
-public interface Geodesic extends Curve {
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 7.3.2.2
- @Override
- public default CurveInterpolation getInterpolation() {
- return CurveInterpolation.GEODESIC;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/BSolidSpline.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/BSolidSpline.java
deleted file mode 100644
index df95e24..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/BSolidSpline.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.griddedsolid;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="BSolidSpline", specification=ISO_19107) // section 9.3.2
-public interface BSolidSpline extends ParametricCurveSolid {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/ParametricCurveSolid.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/ParametricCurveSolid.java
deleted file mode 100644
index 458414b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/griddedsolid/ParametricCurveSolid.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.geometries.griddedsolid;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.GeometryType;
-import org.apache.sis.geometries.Solid;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="ParametricCurveSolid", specification=ISO_19107) // section 9.3.1
-public interface ParametricCurveSolid extends Solid {
-
- @UML(identifier="horizontalCurveType", specification=ISO_19107) // section 9.3.1.2
- GeometryType getHorizontalCurveType();
-
- @UML(identifier="verticalCurveType", specification=ISO_19107) // section 9.3.1.2
- GeometryType getVerticalCurveType();
-
- @UML(identifier="depthCurveType", specification=ISO_19107) // section 9.3.1.2
- GeometryType getDepthCurveType();
-
- @UML(identifier="rows", specification=ISO_19107) // section 9.3.1.2
- int getRows();
-
- @UML(identifier="columns", specification=ISO_19107) // section 9.3.1.2
- int getColumns();
-
- @UML(identifier="files", specification=ISO_19107) // section 9.3.1.2
- int getFiles();
-
- @UML(identifier="dataPoints", specification=ISO_19107) // section 9.3.1.3
- @Override
- List<DirectPosition> getDataPoints();
-
- @UML(identifier="controlPoints", specification=ISO_19107) // section 9.3.1.3
- @Override
- List<DirectPosition> getControlPoints();
-
- Curve getHorizontalCurve(double b, double c);
-
- Curve getVerticalCurve(double a, double c);
-
- Curve getDepthCurve(double a, double b);
-
- DirectPosition getSurface(double a, double b, double c);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/KdTree.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/KdTree.java
deleted file mode 100644
index 41b5072..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/KdTree.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * 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.geometries.index;
-
-import java.awt.geom.Point2D;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * Adapted version of KdTree from :
- * https://stackoverflow.com/questions/253767/kdtree-implementation-in-java
- *
- * @author Johann Sorel (Geomatys)
- * @param <T>
- */
-public final class KdTree<T> {
-
- private Node<T> root = null;
-
- /**
- * @return true if tree is empty
- */
- public boolean isEmpty() {
- return root == null;
- }
-
- /**
- * @return number of objects in the tree
- */
- public int size() {
- return rechnenSize(root);
- }
-
- private static int rechnenSize(Node<?> node) {
- if (node == null) {
- return 0;
- } else {
- return node.getSize();
- }
- }
-
- /**
- * @param position only X/Y ordinates will be used by the tree, not null
- * @param value to insert in the tree, not null
- */
- public void insert(Tuple position, T value) {
- insertInternal(new TuplePoint2D<>(position), value);
- }
-
- /**
- * @param x X ordinate
- * @param y Y ordinate
- * @param value to insert in the tree, not null
- */
- public void insert(double x, double y, T value) {
- insertInternal(new TuplePoint2D<>(x, y), value);
- }
-
- /**
- * Insert the given tuple in the tree, but do not copy it's values.
- * This allows to reduce memory usage but will reduce performances.
- * The tuple values MUST remain unchanged while the tree is being used
- * otherwise the tree will be broken.
- *
- * @param position only X/Y ordinates will be used by the tree, not null
- * @param value to insert in the tree, not null
- */
- public void insertNoCopy(Tuple position, T value) {
- insertInternal(position, value);
- }
-
- private void insertInternal(Tuple p, T payload) {
- if (isEmpty()) {
- root = insertInternal(p, payload, root, 0);
- } else {
- root = insertInternal(p, payload, root, 1);
- }
- }
-
- /**
- * At odd level we will compare x coordinate, and at even level we will
- * compare y coordinate
- */
- private Node<T> insertInternal(Tuple pointToInsert, T payload, Node<T> node, int level) {
- if (node == null) {
- final Node<T> newNode;
- if (payload == null) {
- newNode = new Node<>(pointToInsert, null, null);
- } else {
- newNode = new NodeWithPayload<>(pointToInsert, payload, null, null);
- }
- return newNode;
- }
- if (level % 2 == 0) {
- //Horizontal partition line
- if (pointToInsert.get(1) < node.getY()) {
- //Traverse in bottom area of partition
- node.lb = insertInternal(pointToInsert, payload, node.lb, level + 1);
- } else {
- //Traverse in top area of partition
- if (!node.point.equals(pointToInsert)) {
- node.rt = insertInternal(pointToInsert, payload, node.rt, level + 1);
- }
- }
-
- } else {
- //Vertical partition line
- if (pointToInsert.get(0) < node.getX()) {
- //Traverse in left area of partition
- node.lb = insertInternal(pointToInsert, payload, node.lb, level + 1);
- } else {
- //Traverse in right area of partition
- if (!node.point.equals(pointToInsert)) {
- node.rt = insertInternal(pointToInsert, payload, node.rt, level + 1);
- }
- }
- }
- return node;
- }
-
- /**
- * @param p not null
- * @return true if point in in the tree
- */
- public boolean contains(Tuple p) {
- return containsInternal(new Point2D.Double(p.get(0), p.get(1)), root, 1);
- }
-
- /**
- * @param p not null
- * @return true if point in in the tree
- */
- public boolean contains(Point2D.Double p) {
- return containsInternal(p, root, 1);
- }
-
- private boolean containsInternal(Point2D.Double pointToSearch, Node<T> node, int level) {
- if (node == null) {
- return false;
- }
- if (level % 2 == 0) {
- //Horizontal partition line
- if (pointToSearch.y < node.getY()) {
- return containsInternal(pointToSearch, node.lb, level + 1);
- } else {
- if (node.point.equals(pointToSearch)) {
- return true;
- }
- return containsInternal(pointToSearch, node.rt, level + 1);
- }
- } else {
- //Vertical partition line
- if (pointToSearch.x < node.getX()) {
- return containsInternal(pointToSearch, node.lb, level + 1);
- } else {
- if (node.point.equals(pointToSearch)) {
- return true;
- }
- return containsInternal(pointToSearch, node.rt, level + 1);
- }
- }
- }
-
- /**
- * @param p searched position, not null
- * @return nearest entry in the tree
- */
- public Entry<Tuple,T> nearest(Tuple p) {
- if (root == null) {
- return null;
- }
- final BestMatch champion = new BestMatch(root, Double.MAX_VALUE);
- nearestInternal(p, champion, root, 1, false);
- return champion.champion;
- }
-
- /**
- * @param p searched position, not null
- * @return nearest entry in the tree
- */
- public Entry<Tuple,T> nearest(Point2D.Double p) {
- if (root == null) {
- return null;
- }
- return nearest((Tuple)new TuplePoint2D(p.x, p.y));
- }
-
- /**
- * Search nearest point but must be distinct from given point.
- *
- * @param p searched position, not null
- * @return nearest entry in the tree
- */
- public Entry<Tuple,T> nearestDistinct(Tuple p) {
- if (root == null) {
- return null;
- }
- final BestMatch champion = new BestMatch(root, Double.MAX_VALUE);
- nearestInternal(p, champion, root, 1, true);
- return champion.champion;
- }
-
- /**
- * Search nearest point but must be distinct from given point.
- *
- * @param p searched position, not null
- * @return nearest entry in the tree
- */
- public Entry<Tuple,T> nearestDistinct(Point2D.Double p) {
- if (root == null) {
- return null;
- }
- return nearestDistinct((Tuple)new TuplePoint2D(p.x, p.y));
- }
-
- /**
- * @return true if perfect match (distance == 0)
- */
- private boolean nearestInternal(final Tuple targetPoint, final BestMatch champion,
- Node node, int level, boolean distinct) {
-
-
- final double dist = distanceSq(targetPoint, node.point);
- if (dist < champion.championDist) {
- if (distinct && dist == 0){
- //same point, ignore it
- } else {
- champion.champion = node;
- champion.championDist = dist;
- if (dist == 0) return true;
- }
- }
-
- //We will decide which part to be visited first, based upon in which part point lies.
- //If point is towards left or bottom part, we traverse in that area first, and later on decide
- //if we need to search in other part too.
- final boolean goLeftOrBottom;
- if (level % 2 == 0) {
- goLeftOrBottom = (targetPoint.get(1) < node.getY());
- } else {
- goLeftOrBottom = (targetPoint.get(0) < node.getX());
- }
- if (goLeftOrBottom) {
- if (node.lb != null && nearestInternal(targetPoint, champion, node.lb, level+1, distinct)) {
- return true;
- }
- if (node.rt != null) {
- final Point2D orientationPoint = createOrientationPoint(node.getX(), node.getY(), targetPoint, level);
- final double orientationDist = orientationPoint.distanceSq(targetPoint.get(0), targetPoint.get(1));
- //We will search on the other part only, if the point is very near to partitioned line
- //and champion point found so far is far away from the partitioned line.
- if (orientationDist < champion.championDist && nearestInternal(targetPoint, champion, node.rt, level+1, distinct)) {
- return true;
- }
- }
-
- } else {
- if (node.rt != null && nearestInternal(targetPoint, champion, node.rt, level+1, distinct)) {
- return true;
- }
- if (node.lb != null) {
- final Point2D orientationPoint = createOrientationPoint(node.getX(), node.getY(), targetPoint, level);
- //We will search on the other part only, if the point is very near to partitioned line
- //and champion point found so far is far away from the partitioned line.
- final double orientationDist = orientationPoint.distanceSq(targetPoint.get(0), targetPoint.get(1));
- if (orientationDist < champion.championDist && nearestInternal(targetPoint, champion, node.lb, level+1, distinct)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Returns the point from a partitioned line, which can be directly used to
- * calculate distance between partitioned line and the target point for
- * which neighbours are to be searched.
- *
- * @param linePointX
- * @param linePointY
- * @param targetPoint
- * @param level
- * @return
- */
- private Point2D.Double createOrientationPoint(double linePointX, double linePointY, Tuple targetPoint, int level) {
- if (level % 2 == 0) {
- return new Point2D.Double(targetPoint.get(0), linePointY);
- } else {
- return new Point2D.Double(linePointX, targetPoint.get(1));
- }
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("KdTree");
- if (root != null) sb.append("\n").append(root.toString(1));
- return sb.toString();
- }
-
- private static double distanceSq(Tuple p0, Tuple p1) {
- double px = p1.get(0) - p0.get(0);
- double py = p1.get(1) - p0.get(1);
- return (px * px + py * py);
- }
-
- private static class BestMatch {
-
- public Node champion;
- public double championDist;
-
- public BestMatch(Node c, double d) {
- champion = c;
- championDist = d;
- }
- }
-
- private static class TuplePoint2D<T> extends Point2D.Double implements Tuple{
-
- public TuplePoint2D(Tuple position) {
- this.x = position.get(0);
- this.y = position.get(1);
- }
-
- public TuplePoint2D(double x, double y) {
- super(x, y);
- }
-
- @Override
- public double getX() {
- return x;
- }
-
- @Override
- public double getY() {
- return y;
- }
-
- @Override
- public String toString() {
- return x + "/" + y;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return SampleSystem.ofSize(2);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) throws IndexOutOfBoundsException {
- return indice == 0 ? x : y;
- }
-
- @Override
- public void set(int indice, double value) throws IndexOutOfBoundsException {
- if (indice == 0) x = value;
- else y = value;
- }
- }
-
- private static class Node<T> implements Entry<Tuple, T>{
- // the point
- private final Tuple point;
- // the left/bottom subtree
- private Node<T> lb;
- // the right/top subtree
- private Node<T> rt;
-
- public Node(Tuple point, Node<T> lb, Node<T> rt) {
- this.point = point;
- this.lb = lb;
- this.rt = rt;
- }
-
- public double getX() {
- return point.get(0);
- }
-
- public double getY() {
- return point.get(1);
- }
-
- @Override
- public Tuple getKey() {
- return point;
- }
-
- @Override
- public T getValue() {
- return null;
- }
-
- public int getSize() {
- return 1 + rechnenSize(lb) + rechnenSize(rt);
- }
-
- @Override
- public T setValue(T value) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public String toString() {
- return toStringTree(point.toString() + " size :" + getSize(),
- Arrays.asList("left/bot : " + lb, "right/top : " + rt));
- }
-
- public String toString(int level) {
-
- if (level % 2 == 0) {
- //Horizontal partition
- final List<String> children = new ArrayList<>();
- children.add("top: " + ((rt == null) ? "null" : rt.toString(level+1)));
- children.add("bot: " + ((lb == null) ? "null" : lb.toString(level+1)));
- return toStringTree("X:" + getX() + " Y:" + getY() + " size:" + getSize(), children);
- } else {
- //Vertical partition
- final List<String> children = new ArrayList<>();
- children.add("left: " + ((lb == null) ? "null" : lb.toString(level+1)));
- children.add("right: " + ((rt == null) ? "null" : rt.toString(level+1)));
- return toStringTree("X:" + getX() + " Y:" + getY() + " size:" + getSize(), children);
- }
- }
- }
-
- private static class NodeWithPayload<T> extends Node<T>{
- private final T payload;
-
- public NodeWithPayload(Tuple point, T payload, Node<T> lb, Node<T> rt) {
- super(point,lb,rt);
- this.payload = payload;
- }
-
- @Override
- public T getValue() {
- return payload;
- }
-
- }
-
- /**
- * Returns a graphical representation of the specified objects. This representation can be
- * printed to the {@linkplain System#out standard output stream} (for example) if it uses
- * a monospaced font and supports unicode.
- *
- * @param root The root name of the tree to format.
- * @param objects The objects to format as root children.
- * @return A string representation of the tree.
- */
- private static String toStringTree(String root, final Iterable<?> objects) {
- final StringBuilder sb = new StringBuilder();
- if (root != null) {
- sb.append(root);
- }
- if (objects != null) {
- final Iterator<?> ite = objects.iterator();
- while (ite.hasNext()) {
- sb.append('\n');
- final Object next = ite.next();
- final boolean last = !ite.hasNext();
- sb.append(last ? "\u2514\u2500 " : "\u251C\u2500 ");
-
- final String[] parts = String.valueOf(next).split("\n");
- sb.append(parts[0]);
- for (int k=1;k<parts.length;k++) {
- sb.append('\n');
- sb.append(last ? ' ' : '\u2502');
- sb.append(" ");
- sb.append(parts[k]);
- }
- }
- }
- return sb.toString();
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/MortonIterator.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/MortonIterator.java
deleted file mode 100644
index f683097..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/index/MortonIterator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.geometries.index;
-
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Morton iterator utilities.
- *
- * Resources :
- * - https://en.wikipedia.org/wiki/Z-order_curve
- * - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#appendix-a-availability-indexing
- * - https://stackoverflow.com/questions/58979713/interleave-2-32-bit-integers-into-64-integer
- * - https://stackoverflow.com/questions/1024754/how-to-compute-a-3d-morton-number-interleave-the-bits-of-3-ints
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class MortonIterator {
-
- private MortonIterator(){}
-
- public static long index(long x, long y) {
- return space1bit(x) | (space1bit(y) << 1);
- }
-
- public static long index(long x, long y, long z) {
- return space2bit(x) | (space2bit(y) << 1) | (space2bit(z) << 2);
- }
-
- /**
- * Separate bits of given number, a 0 bit is inserted between each bits.
- * @param x must be inferior to 0xFFFFFFFF;
- * @return spaced long
- */
- public static long space1bit(long x) {
- ArgumentChecks.ensureBetween("x", 0, 0b11111111_11111111_11111111_11111111L, x);
- long s = x & 0b00000000_00000000_00000000_00000000_11111111_11111111_11111111_11111111L; //0x00000000FFFFFFFF
- s = (s | (s << 16)) & 0b00000000_00000000_11111111_11111111_00000000_00000000_11111111_11111111L; //0x0000FFFF0000FFFF
- s = (s | (s << 8)) & 0b00000000_11111111_00000000_11111111_00000000_11111111_00000000_11111111L; //0x00FF00FF00FF00FF
- s = (s | (s << 4)) & 0b00001111_00001111_00001111_00001111_00001111_00001111_00001111_00001111L; //0x0F0F0F0F0F0F0F0F
- s = (s | (s << 2)) & 0b00110011_00110011_00110011_00110011_00110011_00110011_00110011_00110011L; //0x3333333333333333
- s = (s | (s << 1)) & 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101L; //0x5555555555555555
- return s;
- }
-
- /**
- * Separate bits of given number, two 0 bit are inserted between each bits.
- * @param x must be inferior to 1FFFFF;
- * @return spaced long
- */
- public static long space2bit(long x) {
- ArgumentChecks.ensureBetween("x", 0, 0b00011111_11111111_11111111L, x);
- long s = x & 0b00000000_00000000_00000000_00000000_00000000_00011111_11111111_11111111L; //0x00000000001FFFFF
- s = (s | (s << 32)) & 0b00000000_00011111_00000000_00000000_00000000_00000000_11111111_11111111L; //0X001F00000000FFFF
- s = (s | (s << 16)) & 0b00000000_00011111_00000000_00000000_11111111_00000000_00000000_11111111L; //0X001F0000FF0000FF
- s = (s | (s << 8)) & 0b00010000_00001111_00000000_11110000_00001111_00000000_11110000_00001111L; //0X100F00F00F00F00F
- s = (s | (s << 4)) & 0b00010000_11000011_00001100_00110000_11000011_00001100_00110000_11000011L; //0X10C30C30C30C30C3
- s = (s | (s << 2)) & 0b00010010_01001001_00100100_10010010_01001001_00100100_10010010_01001001L; //0x1249249249249249
- return s;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractCursor.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractCursor.java
deleted file mode 100644
index fda7093..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractCursor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-abstract class AbstractCursor extends AbstractTuple implements TupleArrayCursor {
-
- private final TupleArray array;
- protected int offset = -1;
-
- AbstractCursor(TupleArray array) {
- super(array.getSampleSystem());
- this.array = array;
- }
-
- @Override
- public Tuple samples() {
- return this;
- }
-
- @Override
- public int coordinate() {
- return offset;
- }
-
- @Override
- public void moveTo(int coordinate) {
- if (coordinate<0 || coordinate >= array.getLength()) {
- throw new ArrayIndexOutOfBoundsException("Invalid coordinate " + coordinate + ", outside of data range [0," + array.getLength() + "]. ");
- }
- offset = coordinate;
- }
-
- @Override
- public boolean next() {
- offset += 1;
- return offset < array.getLength();
- }
-
- @Override
- public DataType getDataType() {
- return array.getDataType();
- }
-
- @Override
- public int getDimension() {
- return array.getDimension();
- }
-
- @Override
- public double get(int indice) {
- return get(offset, indice);
- }
-
- @Override
- public void set(int indice, double value) {
- set(offset, indice, value);
- }
-
- public abstract double get(int tupleIndex, int sampleIndex);
-
- public abstract void set(int tupleIndex, int sampleIndex, double value);
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java
deleted file mode 100644
index a04cb79..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Arrays;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-abstract class AbstractTuple<T extends AbstractTuple<T>> implements Tuple<T> {
-
- protected final SampleSystem type;
-
- public AbstractTuple(int dimension) {
- this.type = SampleSystem.ofSize(dimension);
- }
-
- public AbstractTuple(SampleSystem type) {
- ArgumentChecks.ensureNonNull("type", type);
- this.type = type;
- }
-
- public AbstractTuple(CoordinateReferenceSystem crs) {
- ArgumentChecks.ensureNonNull("crs", crs);
- this.type = SampleSystem.of(crs);
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int hashCode() {
- int hash = 31;
- for (int i = 0, n = getDimension(); i < n; i++) {
- hash += 31 * hash + Double.hashCode(get(i));
- }
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Tuple)) {
- return false;
- }
- final Tuple other = (Tuple) obj;
-
- final int dim = getDimension();
- if (dim != other.getDimension()) {
- return false;
- }
- for (int i = 0; i < dim; i++) {
- double v1 = get(i);
- double v2 = other.get(i);
- if (v1 != v2) {
- //check for NaN equality
- if (Double.doubleToRawLongBits(v1) != Double.doubleToRawLongBits(v2)) {
- return false;
- }
- }
- }
- //checking crs is expensive, do it last
- if (!Utilities.equalsIgnoreMetadata(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+Arrays.toString(toArrayDouble());
- }
-
- /**
- * Check if given type has the expected number of dimensions.
- *
- * @param typetype to verify
- * @param dimension expected dimension
- * throws IllegalArgumentException if dimension do not match
- */
- protected static void ensureDimension(SampleSystem type, int dimension) {
- if (type.getSize() != dimension) {
- throw new IllegalArgumentException("CoordinateReferenceSystem dimension must be " + dimension);
- }
- }
-
- /**
- * Check if given CRS has the expected number of dimensions.
- *
- * @param crs Coordinate system to verify
- * @param dimension expected dimension
- * throws IllegalArgumentException if dimension do not match
- */
- protected static void ensureDimension(CoordinateReferenceSystem crs, int dimension) {
- if (crs.getCoordinateSystem().getDimension() != dimension) {
- throw new IllegalArgumentException("CoordinateReferenceSystem dimension must be " + dimension);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTupleArray.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTupleArray.java
deleted file mode 100644
index 3cac371..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTupleArray.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class AbstractTupleArray implements TupleArray {
-
- @Override
- public TupleArray resize(int newSize) {
- final TupleArray copy = TupleArrays.of(getSampleSystem(), getDataType(), newSize);
- final TupleArrayCursor cursor = cursor();
- while (cursor.next()) {
- final int idx = cursor.coordinate();
- if (idx >= newSize) break;
- copy.set(idx, cursor.samples());
- }
- return copy;
- }
-
- @Override
- public TupleArray copy() {
- return resize(getLength());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof TupleArray)) {
- return false;
- }
- final TupleArray other = (TupleArray) obj;
-
- final int dim = getDimension();
- if (dim != other.getDimension()) {
- return false;
- }
- final int length = getLength();
- if (length != other.getLength()) {
- return false;
- }
- if (!getSampleSystem().equals(other.getSampleSystem())) {
- return false;
- }
- for (int i = 0; i < length; i++) {
- if (!get(i).equals(other.get(i))) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return getDataType().hashCode() | (getDimension() * 21) | (getLength() * 7);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/DataType.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/DataType.java
deleted file mode 100644
index b7daae9..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/DataType.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.awt.image.RasterFormatException;
-import static org.apache.sis.util.privy.Numerics.MAX_INTEGER_CONVERTIBLE_TO_FLOAT;
-import org.apache.sis.measure.NumberRange;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Numbers;
-
-
-/**
- * This class is a clone of Apache SIS org.apache.sis.image.DataType.
- * But without image type restrictions.
- *
- * Normalized values definitions can be found at :
- * https://www.khronos.org/opengl/wiki/Normalized_Integer
- * https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md
- *
- * @author Martin Desruisseaux (Geomatys)
- * @author Johann Sorel (Geomatys)
- */
-public enum DataType {
-
- /**
- * Signed 8-bits data.
- */
- BYTE(0),
-
- /**
- * Unsigned 8-bits data.
- */
- UBYTE(1),
-
- /**
- * Signed 16-bits data.
- */
- SHORT(2),
-
- /**
- * Unsigned 16-bits data.
- */
- USHORT(3),
-
- /**
- * Signed 32-bits data.
- */
- INT(4),
-
- /**
- * Unsigned 32-bits data.
- */
- UINT(5),
-
- /**
- * Signed 64-bits data.
- */
- LONG(6),
-
- /**
- * Single precision (32-bits) floating point data.
- */
- FLOAT(7),
-
- /**
- * Double precision (64-bits) floating point data.
- */
- DOUBLE(8),
-
- /**
- * Signed 8-bits data interpreted as a decimal in range [-1..1]
- */
- NORMALIZED_BYTE(9),
-
- /**
- * Unsigned 8-bits data interpreted as a decimal in range [0..1]
- */
- NORMALIZED_UBYTE(10),
-
- /**
- * Signed 16-bits data interpreted as a decimal in range [-1..1]
- */
- NORMALIZED_SHORT(11),
-
- /**
- * Unsigned 16-bits data interpreted as a decimal in range [0..1]
- */
- NORMALIZED_USHORT(12);
-
- private final int order;
-
- /**
- * Creates a new enumeration.
- */
- private DataType(int order) {
- this.order = order;
- }
-
- /**
- * Returns the smallest data type capable to store the given range of values.
- * If the given range uses a floating point type, there there is a choice:
- *
- * <ul>
- * <li>If {@code asInteger} is {@code false}, then this method returns
- * {@link #FLOAT} or {@link #DOUBLE} depending on the range type.</li>
- * <li>Otherwise this method treats the floating point values as if they
- * were integers, with minimum value rounded toward negative infinity
- * and maximum value rounded toward positive infinity.</li>
- * </ul>
- *
- * @param range the range of values.
- * @param asInteger whether to handle floating point values as integers.
- * @return smallest data type for the given range of values.
- */
- public static DataType forRange(final NumberRange<?> range, final boolean asInteger) {
- ArgumentChecks.ensureNonNull("range", range);
- final byte nt = Numbers.getEnumConstant(range.getElementType());
- if (!asInteger) {
- if (nt >= Numbers.DOUBLE) return DOUBLE;
- if (nt >= Numbers.FRACTION) return FLOAT;
- }
- final double min = range.getMinDouble();
- final double max = range.getMaxDouble();
- if (nt < Numbers.BYTE || nt > Numbers.FLOAT || nt == Numbers.LONG) {
- /*
- * Value type is long, double, BigInteger, BigDecimal or unknown type.
- * If conversions to 32 bits integers would lost integer digits, or if
- * a bound is NaN, stick to the most conservative data buffer type.
- */
- if (!(min >= -MAX_INTEGER_CONVERTIBLE_TO_FLOAT - 0.5 &&
- max < MAX_INTEGER_CONVERTIBLE_TO_FLOAT + 0.5))
- {
- return DOUBLE;
- }
- }
- /*
- * Check most common types first. If the range could be both signed and unsigned short,
- * give precedence to unsigned values.
- * If a bounds is NaN, fallback on TYPE_FLOAT.
- */
- final DataType type;
- if (min >= -0.5 && max < 0xFF + 0.5) {
- type = UBYTE;
- } else if (min >= Byte.MIN_VALUE - 0.5 && max < 0xFF + 0.5) {
- type = BYTE;
- } else if (min >= -0.5 && max < 0xFFFF + 0.5) {
- type = USHORT;
- } else if (min >= Short.MIN_VALUE - 0.5 && max < Short.MAX_VALUE + 0.5) {
- type = SHORT;
- } else if (min >= - 0.5 && max < 4294967295l + 0.5) {
- type = UINT;
- } else if (min >= Integer.MIN_VALUE - 0.5 && max < Integer.MAX_VALUE + 0.5) {
- type = INT;
- } else if (min >= Long.MIN_VALUE - 0.5 && max < Long.MAX_VALUE + 0.5) {
- type = LONG;
- } else {
- type = FLOAT;
- }
- return type;
- }
-
- /**
- * Returns the data type for the given primitive type. The given {@code type} should be a primitive
- * type such as {@link Short#TYPE}, but wrappers class such as {@code Short.class} are also accepted.
- *
- * @param type the primitive type or its wrapper class.
- * @param unsigned whether the type should be considered unsigned.
- * @return the data type (never {@code null}) for the given primitive type.
- * @throws RasterFormatException if the given type is not a recognized.
- */
- public static DataType forPrimitiveType(final Class<?> type, final boolean unsigned) {
- switch (Numbers.getEnumConstant(type)) {
- case Numbers.BYTE: return unsigned ? UBYTE : BYTE;
- case Numbers.SHORT: return unsigned ? USHORT : SHORT;
- case Numbers.INTEGER: return unsigned ? UINT : INT;
- case Numbers.LONG: return LONG;
- case Numbers.FLOAT: return FLOAT;
- case Numbers.DOUBLE: return DOUBLE;
- }
- throw new RasterFormatException("Unknown data type " + type.getSimpleName());
- }
-
- /**
- * Returns the size in bits of this data type.
- *
- * @return size in bits of this data type.
- */
- public int size() {
- switch (this) {
- case BYTE :
- case UBYTE :
- return 8;
- case SHORT :
- case USHORT :
- return 16;
- case INT :
- case UINT :
- case FLOAT :
- return 32;
- case LONG :
- case DOUBLE :
- return 64;
- default :
- throw new IllegalStateException("Unexpected type " + this.name());
- }
- }
-
- /**
- * Returns whether this type is an unsigned integer type.
- * Unsigned types are {@link #UBYTE}, {@link #USHORT} and {@link #UINT}.
- *
- * @return {@code true} if this type is an unsigned integer type.
- */
- public boolean isUnsigned() {
- switch (this) {
- case UBYTE :
- case USHORT :
- case UINT :
- return true;
- default :
- return false;
- }
- }
-
- /**
- * Returns whether this type is an integer type, signed or not.
- *
- * @return {@code true} if this type is an integer type.
- */
- public boolean isInteger() {
- switch (this) {
- case BYTE :
- case UBYTE :
- case SHORT :
- case USHORT :
- case INT :
- case UINT :
- case LONG :
- return true;
- default :
- return false;
- }
- }
-
- /**
- * Returns the smallest floating point type capable to store all values of this type
- * without precision lost. This method returns:
- *
- * <ul>
- * <li>{@link #DOUBLE} if this data type is {@link #DOUBLE}, {@link #INT}, {@link #UINT} or {@link #LONG}.</li>
- * <li>{@link #FLOAT} for all other types.</li>
- * </ul>
- *
- * The promotion of integer values to floating point values is sometime necessary
- * when the image may contain {@link Float#NaN} values.
- *
- * @return the smallest of {@link #FLOAT} or {@link #DOUBLE} types
- * which can store all values of this type without any lost.
- */
- public DataType toFloat() {
- switch (this) {
- case INT :
- case UINT :
- case LONG :
- case DOUBLE :
- return DOUBLE;
- default :
- return FLOAT;
- }
- }
-
- /**
- * Get the widest datatype which may contain both types.
- */
- public static DataType largest(DataType type1, DataType type2) {
- if (type1.equals(type2)) {
- return type1;
- }
- if (type1.order > type2.order) {
- DataType t = type1;
- type1 = type2;
- type2 = t;
- }
-
- return switch (type1) {
- case BYTE ->
- switch (type2) {
- case UBYTE -> SHORT;
- case SHORT -> SHORT;
- case USHORT -> INT;
- case INT -> INT;
- case UINT -> LONG;
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case UBYTE ->
- switch (type2) {
- case SHORT -> SHORT;
- case USHORT -> USHORT;
- case INT -> INT;
- case UINT -> UINT;
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case SHORT ->
- switch (type2) {
- case USHORT -> INT;
- case INT -> INT;
- case UINT -> LONG;
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case USHORT ->
- switch (type2) {
- case INT -> INT;
- case UINT -> UINT;
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case INT ->
- switch (type2) {
- case UINT -> LONG;
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case UINT ->
- switch (type2) {
- case LONG -> LONG;
- case FLOAT -> FLOAT;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case LONG ->
- switch (type2) {
- case FLOAT -> DOUBLE;
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> DOUBLE;
- case NORMALIZED_UBYTE -> DOUBLE;
- case NORMALIZED_SHORT -> DOUBLE;
- case NORMALIZED_USHORT -> DOUBLE;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case FLOAT ->
- switch (type2) {
- case DOUBLE -> DOUBLE;
- case NORMALIZED_BYTE -> FLOAT;
- case NORMALIZED_UBYTE -> FLOAT;
- case NORMALIZED_SHORT -> FLOAT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case DOUBLE ->
- switch (type2) {
- case NORMALIZED_BYTE -> DOUBLE;
- case NORMALIZED_UBYTE -> DOUBLE;
- case NORMALIZED_SHORT -> DOUBLE;
- case NORMALIZED_USHORT -> DOUBLE;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case NORMALIZED_BYTE ->
- switch (type2) {
- case NORMALIZED_UBYTE -> NORMALIZED_SHORT;
- case NORMALIZED_SHORT -> NORMALIZED_SHORT;
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case NORMALIZED_UBYTE ->
- switch (type2) {
- case NORMALIZED_SHORT -> NORMALIZED_SHORT;
- case NORMALIZED_USHORT -> NORMALIZED_USHORT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- case NORMALIZED_SHORT ->
- switch (type2) {
- case NORMALIZED_USHORT -> FLOAT;
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
- default -> throw new IllegalArgumentException("Unexpected types " + type1 + " " + type2);
- };
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Maths.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Maths.java
deleted file mode 100644
index 074f0b5..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Maths.java
+++ /dev/null
@@ -1,1156 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.List;
-import static org.apache.sis.geometries.math.Vectors.*;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.util.Static;
-import org.apache.sis.util.privy.Numerics;
-
-
-/**
- * Origin : Adapted from Unlicense-Lib
- *
- * Math utilities.
- */
-public final class Maths extends Static {
-
- /**
- * Calculate normal of triangle made of given 3 points.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @return triangle normal
- */
- public static float[] calculateNormal(float[] a, float[] b, float[] c){
- final float[] ab = Vectors.subtract(b,a);
- final float[] ac = Vectors.subtract(c,a);
- final float[] res = cross(ab, ac);
- Vectors.normalize(res, res);
- return res;
- }
-
- /**
- * Calculate normal of triangle made of given 3 points.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @return triangle normal
- */
- public static double[] calculateNormal(double[] a, double[] b, double[] c){
- final double[] ab = Vectors.subtract(b,a);
- final double[] ac = Vectors.subtract(c,a);
- final double[] res = Vectors.cross(ab, ac);
- Vectors.normalize(res, res);
- return res;
- }
-
- public static double[] calculateNormalD(float[] a, float[] b, float[] c){
- final double[] ab = subtract(b, a);
- final double[] ac = subtract(c, a);
- final double[] res = cross(ab, ac);
- normalize(res);
- return res;
- }
-
- public static Vector calculateNormal(Tuple a, Tuple b, Tuple c){
- Vector ab = Vectors.createDouble(a.getDimension());
- ab.add(b);
- ab.subtract(a);
- Vector ac = Vectors.createDouble(a.getDimension());
- ac.add(c);
- ac.subtract(a);
- Vector res = ab.cross(ac);
- res.normalize();
- return res;
- }
-
- public static double[] subtract(float[] A, float[] B){
- return new double[] {
- A[0] - (double) B[0],
- A[1] - (double) B[1],
- A[2] - (double) B[2]
- };
- }
-
- public static double[] cross(double[] vector, double[] other){
- final double newX = (vector[1] * other[2]) - (vector[2] * other[1]);
- final double newY = (vector[2] * other[0]) - (vector[0] * other[2]);
- final double newZ = (vector[0] * other[1]) - (vector[1] * other[0]);
- return new double[]{newX,newY,newZ};
- }
-
- public static float[] cross(float[] vector, float[] other){
- final float newX = (float) ((vector[1] * (double) other[2]) - (vector[2] * (double) other[1]));
- final float newY = (float) ((vector[2] * (double) other[0]) - (vector[0] * (double) other[2]));
- final float newZ = (float) ((vector[0] * (double) other[1]) - (vector[1] * (double) other[0]));
- return new float[]{newX,newY,newZ};
- }
-
- public static void normalize(float[] vector){
- final float nlength = 1f/(float)length(vector);
- vector[0] *= nlength;
- vector[1] *= nlength;
- vector[2] *= nlength;
- }
-
- public static void normalize(double[] vector){
- final double nlength = 1d/length(vector);
- vector[0] *= nlength;
- vector[1] *= nlength;
- vector[2] *= nlength;
- }
-
- public static double length(float[] vector){
- double t;
- final double length = (t = vector[0]) * t
- + (t = vector[1]) * t
- + (t = vector[2]) * t;
- return Math.sqrt(length);
- }
-
- public static double length(double[] vector){
- final double length = vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2];
- return Math.sqrt(length);
- }
-
- /**
- * Test if the Point p is on the line porting the edge
- *
- * @param a line origin
- * @param b line end
- * @param p Point to test
- * @return true/false
- */
- public static boolean isOnLine(Tuple a, Tuple b, Tuple p) {
-// final double d = Math.abs(distanceSquare(a, b, p));
-// return d < TOLERANCE && d > -TOLERANCE;
-
- if (lineSide(a,b,p) != 0) return false;
- final double[] ab = {b.get(0) - a.get(0), b.get(1) - a.get(1)};
- final double[] ac = {p.get(0) - a.get(0), p.get(1) - a.get(1)};
- final double e = dot2D(ac, ab);
- // cases where point is outside segment
- if (e <= 0.0f) return false;
- final double f = dot2D(ab, ab);
- if (e >= f) return false;
- return true;
- }
-
- /**
- * Test if the Point p is on the line porting the edge
- *
- * @param a line origin
- * @param b line end
- * @param p Point to test
- * @return true/false
- */
- public static boolean isOnLine(float[] a, float[] b, float[] p) {
-// final double d = Math.abs(distanceSquare(a, b, p));
-// return d < TOLERANCE && d > -TOLERANCE;
-
- if (lineSide(a,b,p) != 0) return false;
- final double[] ab = subtract(b,a);
- final double[] ac = subtract(p,a);
- final double e = dot2D(ac, ab);
- // cases where point is outside segment
- if (e <= 0.0f) return false;
- final double f = dot2D(ab, ab);
- if (e >= f) return false;
- return true;
- }
-
- /**
- * Test the side of a point compare to a line.
- * Only X,Y ordinates are used.
- *
- * @param a line start
- * @param b line end
- * @param c to test
- * @return greater than 0 if point is on the left side
- * equal 0 if point is on the line
- * inferior than 0 if point is on the right side
- */
- public static double lineSide(Tuple a, Tuple b, Tuple c) {
- return lineSide(a.get(0), a.get(1), b.get(0), b.get(1), c.get(0), c.get(1));
- }
-
- /**
- * Test the side of a point compare to a line.
- * Only X,Y ordinates are used.
- *
- * @param a line start
- * @param b line end
- * @param c to test
- * @return greater than 0 if point is on the left side
- * equal 0 if point is on the line
- * inferior than 0 if point is on the right side
- */
- public static double lineSide(float[] a, float[] b, float[] c) {
- return lineSide(a[0], a[1], b[0], b[1], c[0], c[1]);
- }
-
- /**
- * Test the side of a point compare to a line.Only X,Y ordinates are used.
- *
- * @param x1 line start X
- * @param y1 line start Y
- * @param x2 line end X
- * @param y2 line end Y
- * @param x point X
- * @param y point Y
- * @return greater than 0 if point is on the left side
- * equal 0 if point is on the line
- * inferior than 0 if point is on the right side
- */
- public static double lineSide(double x1, double y1, double x2, double y2, double x, double y) {
- return (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1);
- }
-
- /**
- * Test if point is inside triangle using barycentric weights.
- * Only X,Y ordinates are used.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param p test point
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_BaryAlgo(Tuple a, Tuple b, Tuple c, Tuple p){
- return isPointInTriangle_BaryAlgo(a.get(0), a.get(1), b.get(0), b.get(1), c.get(0), c.get(1), p.get(0), p.get(1));
- }
-
- /**
- * Test if point is inside triangle using barycentric weights.
- * Only X,Y ordinates are used.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param p test point
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_BaryAlgo(float[] a, float[] b, float[] c, float[] p){
- return isPointInTriangle_BaryAlgo(a[0], a[1], b[0], b[1], c[0], c[1], p[0], p[1]);
- }
-
- /**
- * Test if point is inside triangle using barycentric weights.
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_BaryAlgo(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y){
- final double[] bary = getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y);
- return bary[1] >= 0.0 && bary[2] >= 0.0 && (bary[1] + bary[2]) <= 1.0;
- }
- /**
- * @see Maths#isPointInTriangle_SideAlgo(double, double, double, double, double, double, double, double)
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param p test point
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_SideAlgo(Tuple a, Tuple b, Tuple c, Tuple p) {
- final double x = p.get(0);
- final double y = p.get(1);
- final double x1 = a.get(0);
- final double y1 = a.get(1);
- final double x2 = b.get(0);
- final double y2 = b.get(1);
- final double x3 = c.get(0);
- final double y3 = c.get(1);
- return isPointInTriangle_SideAlgo(x1,y1, x2,y2, x3,y3, x,y);
- }
-
- /**
- * Test if point is inside triangle using line side tests (also called dot product).
- * Triangle points are expected to be ordered counterclockwise.
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_SideAlgo(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y) {
- return (lineSide(x1, y1, x2, y2, x, y) >= 0)
- && (lineSide(x2, y2, x3, y3, x, y) >= 0)
- && (lineSide(x3, y3, x1, y1, x, y) >= 0);
- }
-
- /**
- * Test if point is inside triangle using only triangle bounding box.
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @param epsilon bounding box margin
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_BoundingBox(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y, double epsilon) {
- double xMin = Math.min(x1, Math.min(x2, x3)) - epsilon;
- double xMax = Math.max(x1, Math.max(x2, x3)) + epsilon;
- double yMin = Math.min(y1, Math.min(y2, y3)) - epsilon;
- double yMax = Math.max(y1, Math.max(y2, y3)) + epsilon;
- return !(x < xMin || xMax < x || y < yMin || yMax < y);
- }
-
- /**
- * Test if point is inside triangle.
- * This method first test a bounding box intersection then using side algorithm
- * and finally segment distant using given tolerance.
- *
- * Explications provided here :
- * https://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @param epsilon bounding box margin
- * @return true if point is inside triangle
- */
- public static boolean isPointInTriangle_Accurate(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y, double epsilon) {
- if (!Maths.isPointInTriangle_BoundingBox(x1, y1, x2, y2, x3, y3, x, y, epsilon)) {
- return false;
- }
- final double epsilonSquare = epsilon * epsilon;
- return Maths.isPointInTriangle_SideAlgo(x1, y1, x2, y2, x3, y3, x, y)
- || Maths.distanceSquare(x1, y1, x2, y2, x, y) <= epsilonSquare
- || Maths.distanceSquare(x2, y2, x3, y3, x, y) <= epsilonSquare
- || Maths.distanceSquare(x3, y3, x1, y1, x, y) <= epsilonSquare;
- }
-
- /**
- * Only X,Y ordinates are used.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- */
- public static boolean isCounterClockwise(Tuple a, Tuple b, Tuple c) {
- return lineSide(a, b, c) > 0;
- }
-
- /**
- * Only X,Y ordinates are used.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- */
- public static boolean isCounterClockwise(float[] a, float[] b, float[] c) {
- return lineSide(a, b, c) > 0;
- }
-
- /**
- * Compute barycentric value of a point in a triangle.
- * Only X,Y ordinates are used.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- */
- public static double[] getBarycentricValue2D(Tuple a, Tuple b, Tuple c, Tuple p){
- return Maths.getBarycentricValue2D(a.get(0), a.get(1), b.get(0), b.get(1), c.get(0), c.get(1), p.get(0), p.get(1));
- }
-
- /**
- * Compute barycentric value of a point in a triangle.
- *
- * @param x1 triangle first point X
- * @param y1 triangle first point Y
- * @param x2 triangle second point X
- * @param y2 triangle second point Y
- * @param x3 triangle third point X
- * @param y3 triangle third point Y
- * @param x point X
- * @param y point Y
- * @return [a,b,c] weights
- */
- public static double[] getBarycentricValue2D(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y){
- final double v0x = x2-x1;
- final double v0y = y2-y1;
- final double v1x = x3-x1;
- final double v1y = y3-y1;
- final double v2x = x-x1;
- final double v2y = y-y1;
- final double d00 = v0x * v0x + v0y * v0y;
- final double d01 = v0x * v1x + v0y * v1y;
- final double d11 = v1x * v1x + v1y * v1y;
- final double d20 = v2x * v0x + v2y * v0y;
- final double d21 = v2x * v1x + v2y * v1y;
- final double denom = d00 * d11 - d01 * d01;
- final double v = (d11 * d20 - d01 * d21) / denom;
- final double w = (d00 * d21 - d01 * d20) / denom;
- final double u = 1.0 - v - w;
- return new double[]{u, v, w};
- }
-
- public static double[] getBarycentricValue2D(final float[] a, final float[] b, final float[] c, final float[] p){
- final double[] v0 = subtract(b, a);
- final double[] v1 = subtract(c, a);
- final double[] v2 = subtract(p, a);
- final double d00 = dot2D(v0,v0);
- final double d01 = dot2D(v0,v1);
- final double d11 = dot2D(v1,v1);
- final double d20 = dot2D(v2,v0);
- final double d21 = dot2D(v2,v1);
- final double denom = d00 * d11 - d01 * d01;
- final double v = (d11 * d20 - d01 * d21) / denom;
- final double w = (d00 * d21 - d01 * d20) / denom;
- final double u = 1.0f - v - w;
- return new double[]{u, v, w};
- }
-
- public static boolean inCircle(Tuple a, Tuple b, Tuple c, Tuple d) {
- return inCircle(a.get(0), a.get(1), b.get(0), b.get(1), c.get(0), c.get(1), d.get(0), d.get(1));
- }
-
- public static boolean inCircle(float[] a, float[] b, float[] c, float[] d) {
- double t;
- double a2 = (t = a[0]) * t + (t = a[1]) * t;
- double b2 = (t = b[0]) * t + (t = b[1]) * t;
- double c2 = (t = c[0]) * t + (t = c[1]) * t;
- double d2 = (t = d[0]) * t + (t = d[1]) * t;
-
- double det44 = 0;
- det44 += d2 * det33(a[0], a[1], 1, b[0], b[1], 1, c[0], c[1], 1);
- det44 -= d[0] * det33(a2, a[1], 1, b2, b[1], 1, c2, c[1], 1);
- det44 += d[1] * det33(a2, a[0], 1, b2, b[0], 1, c2, c[0], 1);
- det44 -= 1 * det33(a2, a[0], a[1], b2, b[0], b[1], c2, c[0], c[1]);
-
- if (det44 < 0) {
- return true;
- }
- return false;
- }
-
- public static boolean inCircle(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
- final double a2 = ax*ax + ay*ay;
- final double b2 = bx*bx + by*by;
- final double c2 = cx*cx + cy*cy;
- final double d2 = dx*dx + dy*dy;
-
- double det44 = (d2 * det33(ax, ay, 1, bx, by, 1, cx, cy, 1))
- - (dx * det33(a2, ay, 1, b2, by, 1, c2, cy, 1))
- + (dy * det33(a2, ax, 1, b2, bx, 1, c2, cx, 1))
- - ( 1 * det33(a2, ax, ay, b2, bx, by, c2, cx, cy));
- return det44 < 0;
- }
-
- private static double det33(double... m) {
- return (m[0] * (m[4] * m[8] - m[5] * m[7]))
- - (m[1] * (m[3] * m[8] - m[5] * m[6]))
- + (m[2] * (m[3] * m[7] - m[4] * m[6]));
- }
-
- public static double dot2D(final float[] vector, final float[] other){
- return (double) vector[0] * (double) other[0]
- + (double) vector[1] * (double) other[1];
- }
-
- public static double dot2D(final double[] vector, final double[] other){
- return vector[0] * other[0]
- + vector[1] * other[1];
- }
-
- public static double dot2D(final double x1, double y1, double x2, double y2){
- return x1 * x2 + y1 * y2;
- }
-
- public static double distance(Tuple a, Vector planNormal, double planD){
- return planNormal.dot(a) - planD;
- }
-
- public static double distance(Vector3D.Double a, Vector3D.Double planNormal, double planD){
- return planNormal.dot(a) - planD;
- }
-
- /**
- * Compute squre distance from segment to line.
- *
- * @param segmentStart segment start
- * @param segmentEnd segment end
- * @param point test point
- * @return point distance to segment
- */
- public static double distanceSquare(final float[] segmentStart, final float[] segmentEnd, final float[] point){
- final double[] ab = subtract(segmentEnd, segmentStart);
- final double[] ac = subtract(point,segmentStart);
- final double[] bc = subtract(point,segmentEnd);
- final double e = dot2D(ac, ab);
- // cases where point is outside segment
- if (e <= 0.0) return dot2D(ac, ac);
- final double f = dot2D(ab, ab);
- if (e >= f) return dot2D(bc, bc);
- // cases where point projects onto segment
- return dot2D(ac, ac)- e*e /f;
- }
-
- /**
- * Compute squre distance from segment to line.
- *
- * @param x1 segment start X
- * @param y1 segment start Y
- * @param x2 segment end X
- * @param y2 segment end Y
- * @param x point X
- * @param y point Y
- * @return point distance to segment
- */
- public static double distanceSquare(double x1, double y1, double x2, double y2, double x, double y) {
- if (y1 == y2 && y2 == y) {
- //point on the same vertical line
- if (x2 < x1) {
- double t = x1;
- x1 = x2;
- x2 = t;
- }
- return (x < x1) ? x1 - x
- : (x > x2) ? x - x2
- : 0.0;
- } else if (x1 == x2 && x2 == x) {
- //point on the same horizontal line
- if (y2 < y1) {
- double t = y1;
- y1 = y2;
- y2 = t;
- }
- return (y < y1) ? y1 - y
- : (y > y2) ? y - y2
- : 0.0;
- }
-
- final double segLength2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
- final double dotprod = ((x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)) / segLength2;
- if (dotprod < 0) {
- return (x - x1) * (x - x1) + (y - y1) * (y - y1);
- } else if (dotprod <= 1) {
- double tarLength2 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);
- return tarLength2 - dotprod * dotprod * segLength2;
- } else {
- return (x - x2) * (x - x2) + (y - y2) * (y - y2);
- }
- }
-
- /**
- * Calculate normal of triangle made of given 3 points.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param buffer to store normal values
- * @return triangle normal
- */
- public static float[] calculateNormal(float[] a, float[] b, float[] c, float[] buffer){
- final float[] ab = Vectors.subtract(b,a);
- final float[] ac = Vectors.subtract(c,a);
- buffer = Vectors.cross(ab, ac, buffer);
- return Vectors.normalize(buffer, buffer);
- }
-
- public static double[] calculateCircleCenter(double[] a, double[] b, double[] c) {
- final double as = (b[1]-a[1]) / (b[0]-a[0]);
- final double bs = (c[1]-b[1]) / (c[0]-b[0]);
- final double[] center = new double[2];
- center[0] = (as * bs * (a[1]-c[1]) + bs * (a[0]+b[0]) - as * (b[0]+c[0])) / (2 * (bs-as));
- center[1] = -1.0 * (center[0] - (a[0]+b[0])/2.0) / as + (a[1]+b[1])/2.0;
- return center;
- }
-
- /**
- *
- * @param c symmetry center
- * @param p point to reflect
- * @return reflected point
- */
- public static double[] calculatePointSymmetry(double[] c, double[] p){
- final double[] r = new double[c.length];
- for(int i=0;i<r.length;i++) r[i] = (2*c[i])-p[i];
- return r;
- }
-
- /**
- * Test if a point is inside given triangle.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param p point to test
- * @return true if point is inside triangle
- */
- public static boolean inTriangle(double[] a, double[] b, double[] c, double[] p){
- final double[] bary = getBarycentricValue(a, b, c, p);
- return bary[1] >= 0.0 && bary[2] >= 0.0 && (bary[1] + bary[2]) <= 1.0;
- }
-
- /**
- * Calculate the barycentric value in triangle for given point.
- *
- * @param a first triangle point
- * @param b second triangle point
- * @param c third triangle point
- * @param p point to test
- * @return Vector barycentric values
- */
- public static double[] getBarycentricValue(final double[] a, final double[] b, final double[] c, final double[] p){
- final double[] v0 = Vectors.subtract(b, a);
- final double[] v1 = Vectors.subtract(c, a);
- final double[] v2 = Vectors.subtract(p, a);
- final double d00 = dot(v0, v0);
- final double d01 = dot(v0,v1);
- final double d11 = dot(v1,v1);
- final double d20 = dot(v2,v0);
- final double d21 = dot(v2,v1);
- final double denom = d00 * d11 - d01 * d01;
- final double v = (d11 * d20 - d01 * d21) / denom;
- final double w = (d00 * d21 - d01 * d20) / denom;
- final double u = 1.0f - v - w;
- return new double[]{u, v, w};
- }
-
- /**
- * Calculate constant D of a plan.
- * Same as normal.dot(point).
- *
- * @param normal plan normal
- * @param pointOnPlan a point in the plan
- * @return plan D constant value
- */
- public static double calculatePlanD(double[] normal, double[] pointOnPlan){
- return Vectors.dot(normal, pointOnPlan);
- }
-
- /**
- * Calculate projection of a point on a plan.
- *
- * @param point point to project
- * @param planNormal plan normal
- * @param planD plan D constant
- * @return projected point
- */
- public static double[] projectPointOnPlan(double[] point, double[] planNormal, double planD){
- double[] va = Vectors.subtract(point, Vectors.scale(planNormal,planD) );
- double d = Vectors.dot(planNormal, va);
- return Vectors.subtract(va, Vectors.scale(planNormal, d));
- }
-
- /**
- * Test if given sequence of tuple is in clockwise direction.
- * This method expect the coordinates to be a closed line.
- *
- * @param coordinates line coordinates
- * @return true if clockwise
- */
- public static boolean isClockWise(List<Tuple> coordinates){
- final double area = calculateArea(coordinates);
- return area > 0;
- }
-
- /**
- * Test if given sequence of tuple is in clockwise direction.
- * This method expect the coordinates to be a closed line.
- *
- * @param coordinates polygon outer line
- * @return area
- */
- public static double calculateArea(List<Tuple> coordinates){
- double area = 0;
- final int numPoints = coordinates.size();
- for(int i=0;i<numPoints-1;i++){
- final Tuple start = coordinates.get(i);
- final Tuple end = coordinates.get(i+1);
- area += (start.get(0)+end.get(0)) * (start.get(1)-end.get(1));
- }
- return area/2.0;
- }
-
- /**
- * Create an Affine that transform the given bbox to be centerd into target bbox.
- * The source bbox is scaled with given scale.
- *
- * @param source
- * @param target
- * @param scale wanted scale.
- * @return
- */
- public static MatrixSIS centeredScaled(GeneralEnvelope source, GeneralEnvelope target, double scale){
-
- final double[] sourceCenter = source.getMedian().getCoordinates();
- final double[] targetCenter = target.getMedian().getCoordinates();
- Vectors.scale(sourceCenter, scale, sourceCenter);
- final double[] trs = Vectors.subtract(targetCenter, sourceCenter);
-
- final MatrixSIS mt = new Matrix4();
- for (int i=0;i<trs.length;i++){
- mt.setElement(i, i, scale);
- mt.setElement(i, trs.length, trs[i]);
- }
-
- return mt;
- }
-
- /**
- * Create an Affine that transform the given bbox to fit into target bbox.
- * Dimensions ratio are preserved and will be centered in target bbox.
- *
- * @param source
- * @param target
- * @return
- */
- public static MatrixSIS scaled(GeneralEnvelope source, GeneralEnvelope target){
- //find min scale
- final int dim = source.getDimension();
- double scale = target.getSpan(0) / source.getSpan(0);
- for (int i=1;i<dim;i++){
- scale = Math.min( target.getSpan(i) / source.getSpan(i), scale);
- }
- return centeredScaled(source, target, scale);
- }
-
- /**
- * JavaScript can not read binary data such as float if they are not byte aligned.
- * Float require 4 bytes alignment and Double 8.
- * In the B3DM specification the gltf must be 8 bytes aligned.
- *
- * @param data source array
- * @param isJson is true padding will be spaces
- * @param previousDataLength length of data before data array which must be included in padding
- * @param padding wanted padding
- *
- * @return padded byte array
- */
- public static byte[] pad(byte[] data, boolean isJson, int previousDataLength, int padding) {
- if (data==null) return null;
-
- final int remaining = (previousDataLength+data.length) % padding;
- if (remaining == 0) return data;
-
- final byte[] array = new byte[data.length + (padding-remaining)];
- Arrays.fill(array, isJson ? (byte)' ' : 0x00);
- System.arraycopy(data, 0, array, 0, data.length);
- return array;
- }
-
- /**
- * Compute distance ratio of point on the segment.
- *
- * @param x1 segment start X
- * @param y1 segment start Y
- * @param x2 segment end X
- * @param y2 segment end Y
- * @param x point X
- * @param y point Y
- * @return ratio betwen 0 and 1 if point is on segment,
- * negative if before start,
- * greater then one if after end
- */
- public static double projectionRatio(double x1, double y1, double x2, double y2, double x, double y) {
- //compute weights based on distance
- final double abx = x2 - x1;
- final double aby = y2 - y1;
- final double acx = x - x1;
- final double acy = y - y1;
- final double e = Maths.dot2D(acx, acy, abx, aby);
- final double f = Maths.dot2D(abx, aby, abx, aby);
- return e / f;
- }
-
- /**
- * Normalized byte to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = max(i / 127.0, -1.0)}</pre>
- *
- * @return double in range [-1..1]
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static double normalizedByte(byte value) {
- return Math.max((double) value / 127.0, -1.0);
- }
-
- /**
- * Normalized unsigned byte to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = i / 255.0}</pre>
- *
- * @return double in range [0..1]
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static double normalizedUByte(byte value) {
- return ((double) (value & 0xFF)) / 255.0;
- }
-
- /**
- * Normalized short to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = max(i / 32767.0, -1.0)}</pre>
- *
- * @return double in range [-1..1]
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static double normalizedShort(short value) {
- return Math.max((double) value / 32767.0, -1.0);
- }
-
- /**
- * Normalized unsigned short to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = i / 65535.0}</pre>
- *
- * @return double in range [0..1]
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static double normalizedUShort(short value) {
- return ((double) (value & 0xFFFF)) / 65535.0;
- }
-
- /**
- * Normalized byte to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = max(i / 2147483647.0, -1.0)}</pre>
- *
- * @return double in range [-1..1]
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static double normalizedInt(int value) {
- return Math.max((double) value / 2147483647.0, -1.0);
- }
-
- /**
- * Normalized unsigned int to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = i / 4294967295.0}</pre>
- *
- * @return double in range [0..1]
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static double normalizedUInt(int value) {
- return ((double) (value & 0xFFFFFFFFL)) / 4294967295.0;
- }
-
- /**
- * Normalized long to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = max(i / 9223372036854775807.0, -1.0)}</pre>
- *
- * @return double in range [-1..1]
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static double normalizedLong(long value) {
- return Math.max((double) value / 9223372036854775807.0, -1.0);
- }
-
- /**
- * Normalized unsigned long to double.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code f = i / 18446744073709551615.0}</pre>
- *
- * @return double in range [0..1]
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static double normalizedULong(long value) {
- return Numerics.toUnsignedDouble(value) / 18446744073709551615.0;
- }
-
- /**
- * Double to Normalized byte.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 127.0)}</pre>
- *
- * @param value value must be in range[-1..1], value is not verified.
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static byte toNormalizedByte(double value) {
- return (byte) Math.round(value * 127.0);
- }
-
- /**
- * Double to Normalized unsigned byte.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 255.0)}</pre>
- *
- * @param value value must be in range[0..1], value is not verified.
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static byte toNormalizedUByte(double value) {
- return (byte) Math.round(value * 255.0);
- }
-
- /**
- * Double to Normalized short.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 32767.0)}</pre>
- * As consequence : -1.0 will produce : -32767
- *
- * @param value value must be in range[-1..1], value is not verified.
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static short toNormalizedShort(double value) {
- return (short) Math.round(value * 32767.0);
- }
-
- /**
- * Double to Normalized unsigned short.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 65535.0)}</pre>
- *
- * @param value value must be in range[0..1], value is not verified.
- * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#encoding-quantized-data
- */
- public static short toNormalizedUShort(double value) {
- return (short) Math.round(value * 65535.0);
- }
-
- /**
- * Double to Normalized int.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 2147483647.0)}</pre>
- *
- * @param value value must be in range[-1..1], value is not verified.
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static int toNormalizedInt(double value) {
- return (int) Math.round(value * 2147483647.0);
- }
-
- /**
- * Double to Normalized unsigned int.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 4294967295.0)}</pre>
- *
- * @param value value must be in range[0..1], value is not verified.
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static int toNormalizedUInt(double value) {
- return (int) Math.round(value * 4294967295.0);
- }
-
- /**
- * Double to Normalized long.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 9223372036854775807.0)}</pre>
- *
- * @param value value must be in range[-1..1], value is not verified.
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static long toNormalizedLong(double value) {
- return Math.round(value * 9223372036854775807.0);
- }
-
- /**
- * Double to Normalized unsigned long.
- *
- * Formula follows recommandation of Khronos KHR_mesh_quantization and 3D-Tiles Metadata :
- * <pre>{@code i = round(f * 18446744073709551615.0)}</pre>
- * Since java do not have unsigned long, BigDecimal and BigInteger are used instead.
- *
- * @param value value must be in range[0..1], value is not verified.
- * @see https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#normalized-values
- */
- public static long toNormalizedULong(double value) {
- byte[] array = new BigDecimal(value).multiply(new BigDecimal(18446744073709551615.0)).toBigInteger().toByteArray();
- if (array.length > 8 && array[0] != 0) return 0xFFFFFFFFFFFFFFFFL;
- long n = 0l;
- for (byte b : array) {
- n = (n << 8) + (b & 255);
- }
- return n;
- }
-
- /**
- * Clamps a value between min value and max value.
- *
- * @param val the value to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static int clamp(int val, int min, int max) {
- return Math.min(Math.max(val, min), max);
- }
-
- /**
- * Clamps each value of an array between min value and max value.
- *
- * @param val the array of values to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static int[] clamp(int[] val, int min, int max) {
- final int[] ret = new int[val.length];
- for (int i=0; i<val.length; i++) {
- ret[i] = clamp(val[i], min, max);
- }
- return ret;
- }
-
- /**
- * Clamps a value between min value and max value.
- *
- * @param val the value to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static long clamp(long val, long min, long max) {
- return Math.min(Math.max(val, min), max);
- }
-
- /**
- * Clamps each value of an array between min value and max value.
- *
- * @param val the array of values to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static long[] clamp(long[] val, long min, long max) {
- final long[] ret = new long[val.length];
- for (int i=0; i<val.length; i++) {
- ret[i] = clamp(val[i], min, max);
- }
- return ret;
- }
-
- /**
- * Clamps a value between min value and max value.
- *
- * @param val the value to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static float clamp(float val, float min, float max) {
- return Math.min(Math.max(val, min), max);
- }
-
- /**
- * Clamps each value of an array between min value and max value.
- *
- * @param val the array of values to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static float[] clamp(float[] val, float min, float max) {
- final float[] ret = new float[val.length];
- for (int i=0; i<val.length; i++) {
- ret[i] = clamp(val[i], min, max);
- }
- return ret;
- }
-
- /**
- * Clamps a value between min value and max value.
- *
- * @param val the value to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static double clamp(double val, double min, double max) {
- return Math.min(Math.max(val, min), max);
- }
-
- /**
- * Clamps each value of an array between min value and max value.
- *
- * @param val the array of values to clamp
- * @param min the minimum value
- * @param max the maximum value
- * @return val clamped between min and max
- */
- public static double[] clamp(double[] val, double min, double max) {
- final double[] ret = new double[val.length];
- for (int i=0; i<val.length; i++) {
- ret[i] = clamp(val[i], min, max);
- }
- return ret;
- }
-
- /**
- * Clamps each value of an array between min value and max value.
- *
- * @param val the array of values to clamp, values are modified
- * @param min the minimum value
- * @param max the maximum value
- */
- public static void applyClamp(double[] val, double min, double max) {
- switch (val.length) {
- case 4 :
- val[3] = clamp(val[3], min, max);
- case 3 :
- val[2] = clamp(val[2], min, max);
- case 2 :
- val[1] = clamp(val[1], min, max);
- case 1 :
- val[0] = clamp(val[0], min, max);
- break;
- default :
- for (int i=0; i<val.length; i++) {
- val[i] = clamp(val[i], min, max);
- }
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrices.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrices.java
deleted file mode 100644
index 85315b5..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrices.java
+++ /dev/null
@@ -1,869 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix2;
-import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.util.Static;
-
-
-/**
- * Original code from Unlicense.science
- *
- * @author Johann Sorel
- * @author Bertrand COTE
- */
-public final class Matrices extends Static {
-
- public static Matrix2 toMatrix2(double[][] m) {
- return new Matrix2(
- m[0][0], m[0][1],
- m[1][0], m[1][1]);
- }
-
- public static Matrix3 toMatrix3(double[][] m) {
- return new Matrix3(
- m[0][0], m[0][1], m[0][2],
- m[1][0], m[1][1], m[1][2],
- m[2][0], m[2][1], m[2][2]);
- }
-
- public static Matrix4 toMatrix4(double[][] m) {
- return new Matrix4(
- m[0][0], m[0][1], m[0][2], m[0][3],
- m[1][0], m[1][1], m[1][2], m[1][3],
- m[2][0], m[2][1], m[2][2], m[2][3],
- m[3][0], m[3][1], m[3][2], m[3][3]);
- }
-
- public static double[][] toArray(Matrix2 m) {
- return new double[][]
- {{m.m00, m.m01},
- {m.m10, m.m11}};
- }
-
- public static double[][] toArray(Matrix3 m) {
- return new double[][]
- {{m.m00, m.m01, m.m02},
- {m.m10, m.m11, m.m12},
- {m.m20, m.m21, m.m22}};
- }
-
- public static double[][] toArray(Matrix4 m) {
- return new double[][]
- {{m.m00, m.m01, m.m02, m.m03},
- {m.m10, m.m11, m.m12, m.m13},
- {m.m20, m.m21, m.m22, m.m13},
- {m.m30, m.m31, m.m32, m.m33}};
- }
-
- public static double[][] toArray(MatrixSIS m) {
- final double[][] array = new double[m.getNumRow()][m.getNumCol()];
- for (int r = 0; r < array.length; r++) {
- for (int c = 0; c < array[0].length; c++) {
- array[r][c] = m.getElement(r, c);
- }
- }
- return array;
- }
-
- /**
- * Checks if the given matrix is the identity matrix.
- *
- * @param m matrix to test.
- * @return true if matrix is an Identity matrix.
- */
- public static boolean isIdentity(final double[][] m){
- if ( m.length!=m[0].length ) return false; // m must be a square matrix
- for ( int x=0; x<m[0].length; x++) {
- for ( int y=0; y<m.length; y++) {
- if (x==y){
- if ( m[y][x] != 1 ) return false;
- } else {
- if ( m[y][x] != 0 ) return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Sets the given matrix to identity matrix.
- *
- * @param m a square matrix.
- * @throws IllegalArgumentException when m is not a square matrix.
- */
- public static void setToIdentity( double[][] m ){
- if (m.length != m[0].length) {
- throw new IllegalArgumentException("The m matrix must be a square matrix.");
- }
- for (int x = 0; x < m[0].length; x++) {
- for (int y = 0; y < m.length; y++) {
- if (x == y) {
- m[y][x] = 1.;
- } else {
- m[y][x] = 0.;
- }
- }
- }
- }
-
- /**
- * Creates a n*n identity matrix.
- *
- * @param n number of rows and columns.
- * @return an n*n identity matrix.
- */
- public static double[][] identity(int n) {
- double[][] identity = new double[n][n];
- for (int i = 0; i < n; i++) {
- identity[i][i] = 1.;
- }
- return identity;
- }
-
- /**
- * Adds m1 and m2, the result is stored in m1, returns m1.
- * see {@link Matrices#add(un.science.math.Matrix, un.science.math.Matrix, un.science.math.Matrix)}
- * @param m1 first matrix
- * @param m2 second matrix
- * @return m1 + m2 result in m1 matrix.
- */
- public static double[][] localAdd(final double[][] m1, final double[][] m2){
- return add(m1,m2,m1);
- }
-
- /**
- * Adds m1 and m2 matrices, the result is stored in buffer, returns buffer.
- * If buffer is null, a new matrix is created.
- * Matrices must have the same size.
- * @param m1 first matrix
- * @param m2 second matrix
- * @param buffer result buffer, can be null
- * @return m1 + m2 result in buffer matrix.
- * @throws IllegalArgumentException when matrices size differ.
- */
- public static double[][] add(final double[][] m1, final double[][] m2, double[][] buffer) throws IllegalArgumentException {
- if ( m1.length != m2.length || m1[0].length != m2[0].length ) {
- throw new IllegalArgumentException( "The two given matrix must have same dimensions." );
- }
-
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- if (buffer == null){
- buffer = new double[nbRow][nbCol];
- }
-
- for (int x=0; x<nbCol;x++){
- for (int y=0; y<nbRow; y++){
- buffer[y][x] = m1[y][x] + m2[y][x];
- }
- }
- return buffer;
- }
-
- /**
- * Subtracts m2 to m1, the result is stored in m1, returns m1.
- * see {@link Matrices#subtract(un.science.math.Matrix, un.science.math.Matrix, un.science.math.Matrix)}
- * @param m1 first matrix
- * @param m2 second matrix
- * @return m1 - m2 result in m1 matrix.
- */
- public static double[][] localSubtract(final double[][] m1, final double[][] m2){
- return subtract(m1,m2,m1);
- }
-
- /**
- * Subtracts m2 to m2 matrices, result is stored in buffer, returns buffer.
- * If buffer is null, a new matrix is created.
- * Matrices must have the same size.
- * @param m1 first matrix
- * @param m2 second matrix
- * @param buffer result buffer, can be null
- * @return m1 - m2 result in buffer matrix.
- * @throws IllegalArgumentException when matrices size differ
- */
- public static double[][] subtract(final double[][] m1, final double[][] m2, double[][] buffer) throws IllegalArgumentException {
- if ( m1.length != m2.length || m1[0].length != m2[0].length ) {
- throw new IllegalArgumentException( "The two given matrix must have same dimensions." );
- }
-
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- if (buffer == null){
- buffer = new double[nbRow][nbCol];
- }
-
- for (int x=0; x<nbCol;x++){
- for (int y=0; y<nbRow; y++){
- buffer[y][x] = m1[y][x] - m2[y][x];
- }
- }
- return buffer;
- }
-
- /**
- * Scales m1 by scaleFactor, result is stored in m1, returns m1.
- *
- * see {@link Matrices#scale(un.science.math.Matrix, un.science.math.Matrix, double)}
- * @param m1 input matrix
- * @param scaleFactor scale factor
- * @return matrix m1
- */
- public static double[][] localScale(final double[][] m1, final double scaleFactor) {
- return scale(m1,scaleFactor,m1);
- }
-
- /**
- * Scales matrix by columns.
- *
- * @param m1 input matrix
- * @param tuple scale factors (one by columns).
- * @return matrix m1
- */
- public static double[][] localScale(double[][] m1, double[] tuple) {
- return scale(m1,tuple,m1);
- }
-
- /**
- * Scales matrix by columns.
- * @param m1 input matrix
- * @param tuple scale
- * @param buffer result buffer, can be null
- * @return scaled matrix
- */
- public static double[][] scale( double[][] m1, double[] tuple, double[][] buffer) throws IllegalArgumentException {
-
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- if ( buffer != null && ( nbRow != buffer.length || nbCol != buffer[0].length ) ) {
- throw new IllegalArgumentException( "The two given matrix must have same dimensions." );
- }
- if ( nbCol != tuple.length ) {
- throw new IllegalArgumentException( "tuple's argument size is incorrect." );
- }
-
- if (buffer == null){
- buffer = new double[nbRow][nbCol];
- }
-
- for (int x=0; x<nbCol;x++){
- for (int y=0; y<nbRow; y++){
- buffer[y][x] = m1[y][x] * tuple[x];
- }
- }
- return buffer;
- }
-
- /**
- * Scale m1 by scale, result is stored in buffer.
- * if buffer is null, a new matrix is created.
- * Matrices must have the same size
- * @param m1 input matrix
- * @param scale scale
- * @param buffer result buffer, can be null
- * @return scaled matrix
- * @throws IllegalArgumentException when matrices size differ
- */
- public static double[][] scale(final double[][] m1, final double scale, double[][] buffer) throws IllegalArgumentException {
-
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- if (buffer == null){
- buffer = new double[nbRow][nbCol];
- }
-
- for (int x=0; x<nbCol;x++){
- for (int y=0; y<nbRow; y++){
- buffer[y][x] = m1[y][x] * scale;
- }
- }
- return buffer;
- }
-
- /**
- * return the transposed matrix.
- * (flips row/col values)
- * @param m1 input matrix
- * @return result matrix
- */
- public static double[][] transpose(final double[][] m1) throws IllegalArgumentException{
-
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- final double[][] res = new double[nbCol][nbRow];
-
- for (int x=0; x<nbCol;x++){
- for (int y=0; y<nbRow; y++){
- res[x][y] = m1[y][x];
- }
- }
- return res;
- }
-
- /**
- * Matrix inversion using Gauss.
- *
- * @param origValues input matrix
- * @return inverted matrix or null if not possible.
- * @author Xavier Philippeau
- */
- public static double[][] localInvert(double[][] origValues) {
- return invert(origValues, origValues);
- }
-
- /**
- * Matrix inversion using Gauss.
- *
- * @param origValues input matrix
- * @param buffer result buffer, can be null
- * @return inverted matrix or null if not possible.
- * @author Xavier Philippeau
- */
- public static double[][] invert(double[][] origValues, double[][] buffer) {
-
- final int origNbRow = origValues.length;
- final int origNbCol = origValues[0].length;
-
- //Matrix can be inverted only if it is a square matrix.
- if (origNbRow != origNbCol) {
- return null;
- }
-
- // Create a temporary work matrix T = [ this | Identity ]
- final int tNbRow = origNbCol;
- final int tNbCol = origNbCol * 2;
- final double[][] tValues = new double[tNbRow][tNbCol];
- for (int y = 0; y < origNbRow; y++) {
- for (int x = 0; x < origNbCol; x++) {
- tValues[y][x] = origValues[y][x];
- if (x == y) {
- tValues[y][origNbCol + x] = 1;
- }
- }
- }
-
- // Pour chaque ligne de la matrice T
- for (int x = 0; x < tNbRow; x++) {
-
- // Cherche la ligne avec le pivot max (en valeur absolue)
- int bestline = x;
- double pivot = tValues[bestline][x];
- for (int y = x + 1; y < tNbRow; y++) {
- if (Math.abs(tValues[y][x]) > Math.abs(pivot)) {
- bestline = y;
- pivot = tValues[bestline][x];
- }
- }
-
- if (pivot == 0) {
- System.err.println("Inversion : Le pivot est nul,inversion impossible !!");
- return null;
- }
-
- // Echange des lignes (si necessaire)
- if (bestline != x) {
- double tmp;
- for (int t = 0; t < tNbCol; t++) {
- tmp = tValues[x][t];
- tValues[x][t] = tValues[bestline][t];
- tValues[bestline][t] = tmp;
- }
- }
-
- // Normalisation de la ligne du pivot
- for (int t = 0; t < tNbCol; t++) {
- tValues[x][t] /= pivot;
- }
-
- // elimination des autres lignes
- for (int y = 0; y < tNbRow; y++) {
- if (y == x) {
- continue;
- }
- double coef = tValues[y][x];
- for (int t = 0; t < tNbCol; t++) {
- tValues[y][t] -= coef * tValues[x][t];
- }
- }
- }
-
- // recupere la partie droite de T qui contient l'inverse de la matrice
- // (la partie gauche devrait contenir l'identité)
- if (buffer==null){
- buffer = new double[origNbRow][origNbCol];
- }
- for (int y = 0; y < origNbRow; y++) {
- for (int x = 0; x < origNbCol; x++) {
- buffer[y][x] = tValues[y][origNbCol + x];
- }
- }
-
- return buffer;
- }
-
- /**
- * Matrices dot product.
- *
- * @param m1 first matrix
- * @param m2 second matrix
- * @return dot product
- */
- public static double dot(double[][] m1, double[][] m2){
- final int nbRow = m1.length;
- final int nbCol = m1[0].length;
-
- double sum = 0;
- for (int r=0; r<nbRow; r++){
- for (int c=0; c<nbCol; c++){
- sum += m1[r][c] * m2[r][c];
- }
- }
-
- return sum;
- }
-
- /**
- * replace valeus close to 0 with zero, removing -0 if present
- * @param matrix
- * @param epsilon
- */
- public static void roundZeros(double[][] matrix, double epsilon){
- for (int x=0;x<matrix.length;x++){
- for (int y=0;y<matrix[0].length;y++){
- if (!(matrix[x][y]>epsilon || matrix[x][y]<-epsilon)){
- matrix[x][y] = 0.0;
- }
- }
- }
- }
-
- public static Tuple transformLocal(final double[][] matrix, final Tuple vector) {
- return transform(matrix, vector, vector);
- }
-
- public static Tuple transform(final double[][] matrix, final Tuple vector, Tuple buffer) {
- if (buffer==null) buffer = Vectors.createDouble(matrix.length);
- final double[] array = new double[matrix.length];
- transform(matrix, vector.toArrayDouble(), array);
- buffer.set(array);
- return buffer;
- }
-
- /**
- * Transform given vector.
- *
- * @param matrix input matrix
- * @param vector vector to transform
- * @param buffer result vector buffer, can be null
- * @return the product of matrix and vector.
- */
- public static double[] transform(final double[][] matrix, final double[] vector, double[] buffer) {
- if (vector.length != matrix[0].length){
- throw new IllegalArgumentException("matrix column size and vector size differ : "+matrix[0].length+","+vector.length);
- }
-
- final int nbRow = matrix.length;
- final int nbCol = matrix[0].length;
- final double[] res = new double[nbRow];
-
- for (int r = 0; r < nbRow; r++) {
- double s = 0;
- for (int c = 0; c < nbCol; c++) {
- s += matrix[r][c] * vector[c];
- }
- res[r] = s;
- }
-
- if ( buffer == null ) {
- buffer = new double[matrix.length];
- }
- System.arraycopy(res, 0, buffer, 0, res.length);
-
- return buffer;
- }
-
- /**
- * Transforms given vector.
- *
- * @param matrix transformation matrix.
- * @param vector considered as a column matrix.
- * @param buffer result vector buffer, can be null
- * @return the product of matrix and vector.
- */
- public static float[] transform(final double[][] matrix, final float[] vector, float[] buffer) {
- if (vector.length != matrix[0].length){
- throw new IllegalArgumentException("matrix column size and vector size differ : "+matrix[0].length+","+vector.length);
- }
-
- if (buffer == null) {
- buffer = new float[matrix.length];
- }
-
- final int nbRow = matrix.length;
- final int nbCol = matrix[0].length;
- final float[] res = new float[nbRow];
-
- for (int r = 0; r < nbRow; r++) {
- double s = 0;
- for (int c = 0; c < nbCol; c++) {
- s += matrix[r][c] * vector[c];
- }
- res[r] = (float) s;
- }
-
- System.arraycopy(res, 0, buffer, 0, res.length);
- return buffer;
- }
-
- /**
- * Multiply m1 by m2, result is stored in m1, returns m1.
- * see {@link Matrices#multiply(un.science.math.Matrix, un.science.math.Matrix, un.science.math.Matrix)}
- */
- public static double[][] localMultiply(final double[][] m1, final double[][] m2){
- //
- if ( (m1.length != m1[0].length) || (m2.length != m2[0].length) || (m1.length != m2.length) ){
- throw new IllegalArgumentException("Matrices must both be square and have same size.");
- }
- return multiply(m1,m2, m1);
- }
-
- /**
- * Multiply m1 by m2 matrices, result is stored in buffer.
- * If buffer is null, a new matrix is created.
- */
- public static double[][] multiply(final double[][] m1, final double[][] m2, double[][] buffer) {
-
- final int m1r = m1.length;
- final int m1c = m1[0].length;
- final int m2r = m2.length;
- final int m2c = m2[0].length;
-
- if (m1c != m2r){
- throw new IllegalArgumentException("m1.nbCol is not equal to m2.nbRow");
- }
-
- if (buffer == null) {
- buffer = new double[m1r][m2c];
- } else {
- //check buffer size
- if (buffer.length != m1r || buffer[0].length != m2[0].length){
- throw new IllegalArgumentException("buffer.nbRow is not equal to m1.nbRow or buffer.nbCol is not equal to m2.nbCol");
- }
- }
-
- final double[][] temp = new double[m1r][m2c];
- for (int r=0; r<m1r; r++) {
- for (int c=0; c<m2c; c++) {
- temp[r][c] = 0.0;
- for (int k = 0; k < m1c; k++) {
- temp[r][c] += m1[r][k] * m2[k][c];
- }
- }
- }
-
- for (int r=0; r<m1r; r++) {
- for (int c=0; c<m2c; c++) {
- buffer[r][c] = temp[r][c];
- }
- }
-
- return buffer;
- }
-
- /**
- * Create a rotation matrix from given angle and axis.
- *
- * http://en.wikipedia.org/wiki/Rotation_matrix
- *
- * @param angle rotation angle in radians
- * @param rotationAxis Tuple 3
- * @param buffer Matrix 3x3
- * @return rotation matrix
- */
- public static double[][] createRotation3(final double angle, final Tuple<?> rotationAxis, double[][] buffer) {
-
- if (buffer == null){
- buffer = new double[3][3];
- }
-
- final double fCos = Math.cos(angle);
- final double fSin = Math.sin(angle);
- final double fOneMinusCos = (1.0) - fCos;
- final double fX2 = rotationAxis.get(0) * rotationAxis.get(0);
- final double fY2 = rotationAxis.get(1) * rotationAxis.get(1);
- final double fZ2 = rotationAxis.get(2) * rotationAxis.get(2);
- final double fXYM = rotationAxis.get(0) * rotationAxis.get(1) * fOneMinusCos;
- final double fXZM = rotationAxis.get(0) * rotationAxis.get(2) * fOneMinusCos;
- final double fYZM = rotationAxis.get(1) * rotationAxis.get(2) * fOneMinusCos;
- final double fXSin = rotationAxis.get(0) * fSin;
- final double fYSin = rotationAxis.get(1) * fSin;
- final double fZSin = rotationAxis.get(2) * fSin;
-
- buffer[0][0] = fX2 * fOneMinusCos + fCos;
- buffer[0][1] = fXYM - fZSin;
- buffer[0][2] = fXZM + fYSin;
- buffer[1][0] = fXYM + fZSin;
- buffer[1][1] = fY2 * fOneMinusCos + fCos;
- buffer[1][2] = fYZM - fXSin;
- buffer[2][0] = fXZM - fYSin;
- buffer[2][1] = fYZM + fXSin;
- buffer[2][2] = fZ2 * fOneMinusCos + fCos;
-
- return buffer;
- }
-
- /**
- * Create a rotation matrix from given angle and axis.
- *
- * http://en.wikipedia.org/wiki/Rotation_matrix
- *
- * @param angle rotation angle in radians
- * @param rotationAxis Tuple 3
- * @param buffer Matrix 4x4
- * @return rotation matrix
- */
- public static double[][] createRotation4(final double angle, final Tuple<?> rotationAxis, double[][] buffer) {
-
- if (buffer == null){
- buffer = new double[4][4];
- }
-
- final double fCos = Math.cos(angle);
- final double fSin = Math.sin(angle);
- final double fOneMinusCos = (1.0) - fCos;
- final double fX2 = rotationAxis.get(0) * rotationAxis.get(0);
- final double fY2 = rotationAxis.get(1) * rotationAxis.get(1);
- final double fZ2 = rotationAxis.get(2) * rotationAxis.get(2);
- final double fXYM = rotationAxis.get(0) * rotationAxis.get(1) * fOneMinusCos;
- final double fXZM = rotationAxis.get(0) * rotationAxis.get(2) * fOneMinusCos;
- final double fYZM = rotationAxis.get(1) * rotationAxis.get(2) * fOneMinusCos;
- final double fXSin = rotationAxis.get(0) * fSin;
- final double fYSin = rotationAxis.get(1) * fSin;
- final double fZSin = rotationAxis.get(2) * fSin;
-
- buffer[0][0] = fX2 * fOneMinusCos + fCos;
- buffer[0][1] = fXYM - fZSin;
- buffer[0][2] = fXZM + fYSin;
- buffer[0][3] = 0;
- buffer[1][0] = fXYM + fZSin;
- buffer[1][1] = fY2 * fOneMinusCos + fCos;
- buffer[1][2] = fYZM - fXSin;
- buffer[1][3] = 0;
- buffer[2][0] = fXZM - fYSin;
- buffer[2][1] = fYZM + fXSin;
- buffer[2][2] = fZ2 * fOneMinusCos + fCos;
- buffer[2][3] = 0;
- buffer[3][0] = 0;
- buffer[3][1] = 0;
- buffer[3][2] = 0;
- buffer[3][3] = 1;
-
- return buffer;
- }
-
- /**
- * Create rotation matrix to move v1 on v2.
- *
- * @param v1
- * @param v2
- * @return
- */
- public static Matrix4 createRotation(Vector<?> v1, Vector<?> v2){
- v1 = v1.normalize();
- v2 = v2.normalize();
- final double angle = Math.acos(v1.dot(v2));
- if (angle==0){
- //vectors are colinear
- Matrix4 identity = new Matrix4();
- return identity;
- }
- final Vector axis = v1.copy().cross(v2).normalize();
- double[][] m = Matrices.createRotation4(angle, axis, null);
- return Matrices.toMatrix4(m);
- }
-
- /**
- * Build rotation matrix from Euler angle.
- * Sources :
- * http://en.wikipedia.org/wiki/Axes_conventions
- * http://jeux.developpez.com/faq/math/?page=transformations#Q36
- * http://en.wikipedia.org/wiki/Euler_angles
- * http://mathworld.wolfram.com/EulerAngles.html
- * http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/
- *
- * Euler angle convention is : (Z-Y’-X’’) ISO 1151–2:1985
- * - Heading (yaw) [-180°...+180°]
- * - Elevation (pitch) [ -90°... +90°]
- * - Bank (roll) [-180°...+180°]
- *
- * @param euler angles in radians (heading/yaw , elevation/pitch , bank/roll)
- * @param buffer size 4x4 or 3x3
- * @return matrix, never null
- */
- public static double[][] fromEuler(final double[] euler, double[][] buffer) {
-
- if (buffer == null){
- buffer = new double[4][4];
- }
-
- final double angle_x = euler[2];
- final double angle_y = euler[1];
- final double angle_z = euler[0];
- //check the given values are valid
- //CObjects.ensureBetween(angle_x, -Maths.PI, +Maths.PI);
- //CObjects.ensureBetween(angle_y, -Maths.HALF_PI, +Maths.HALF_PI);
- //CObjects.ensureBetween(angle_z, -Maths.PI, +Maths.PI);
-
- final double cx = Math.cos(angle_x);
- final double sx = Math.sin(angle_x);
- final double cy = Math.cos(angle_y);
- final double sy = Math.sin(angle_y);
- final double cz = Math.cos(angle_z);
- final double sz = Math.sin(angle_z);
-
-
- // cy*cz sx*sy*cz - cx*sz cx*sy*cz + sx*sz
- // cy*sz sx*sy*sz + cx*cz cx*sy*sz - sx*cz
- // -sy sx*cy cx*cy
-
- buffer[0][0] = cy*cz;
- buffer[0][1] = sx*sy*cz - cx*sz;
- buffer[0][2] = cx*sy*cz + sx*sz;
-
- buffer[1][0] = cy*sz;
- buffer[1][1] = sx*sy*sz + cx*cz;
- buffer[1][2] = cx*sy*sz - sx*cz;
-
- buffer[2][0] = -sy;
- buffer[2][1] = sx*cy;
- buffer[2][2] = cx*cy;
-
- //fill 4 dimension
- if (buffer.length>3){
- buffer[0][3] = 0;
- buffer[1][3] = 0;
- buffer[2][3] = 0;
-
- buffer[3][0] = 0;
- buffer[3][1] = 0;
- buffer[3][2] = 0;
- buffer[3][3] = 1;
- }
-
- return buffer;
- }
-
- /**
- * Calculate Euler angle of given matrix.
- * Source :
- * http://www.soi.city.ac.uk/~sbbh653/publications/euler.pdf
- * http://jeux.developpez.com/faq/math/?page=transformations#Q37
- *
- * @param mat input matrix
- * @param buffer euler buffer, can be null
- * @return euler angle in radians (heading/yaw , elevation/pitch , bank/roll)
- */
- public static double[] toEuler(double[][] mat, double[] buffer){
-
- if (buffer == null){
- buffer = new double[3];
- }
-
- double angle_x;
- double angle_y;
- double angle_z;
-
- if (mat[2][0] != -1 && mat[2][0] != +1){
- //first possible solution
- angle_y = -Math.asin(mat[2][0]);
- double cosy1 = Math.cos(angle_y);
- angle_x = Math.atan2(mat[2][1]/cosy1, mat[2][2]/cosy1);
- angle_z = Math.atan2(mat[1][0]/cosy1, mat[0][0]/cosy1);
-
- //second possible solution
- //angle_y = Angles.PI - y1;
- //double cosy2 = Math.cos(angle_y);
- //angle_x = Math.atan2(mat[2][1]/cosy2, mat[2][2]/cosy2);
- //angle_z = Math.atan2(mat[1][0]/cosy2, mat[0][0]/cosy2);
-
- } else {
- // Gimbal lock
- angle_z = 0;
- if (mat[2][0] == -1){
- angle_y = Math.PI / 2.0;
- angle_x = angle_z + Math.atan2(mat[0][1], mat[0][2]);
- } else {
- angle_y = -Math.PI / 2.0;
- angle_x = -angle_z + Math.atan2(-mat[0][1], -mat[0][2]);
- }
- }
-
-
- buffer[0] = angle_z;
- buffer[1] = angle_y;
- buffer[2] = angle_x;
- return buffer;
- }
-
- public static Matrix3 createFromUpAndRight(Vector<?> v, Vector<?> u) {
- v = v.copy();
- u = u.copy();
- v.normalize();
- u.normalize();
-
- //W = Normalized(Cross(V,U))
- Vector w = v.cross(u);
- w.normalize();
-
- //to ensure it is correctly perpendicular
- //U = Normalized(Cross(W,V))
- u = w.cross(v);
- u.normalize();
-
- return new Matrix3(
- u.get(0), w.get(0), v.get(0),
- u.get(1), w.get(1), v.get(1),
- u.get(2), w.get(2), v.get(2));
- }
-
- /**
- * Decompose a matrix in rotation, scale and translation.
- */
- public static void decomposeMatrix(Matrix4 trs, Matrix3 rotation, Tuple scale, Tuple translation){
- final double scaleX = Math.sqrt(trs.m00 * trs.m00 + trs.m10 * trs.m10 + trs.m20 * trs.m20);
- final double scaleY = Math.sqrt(trs.m01 * trs.m01 + trs.m11 * trs.m11 + trs.m21 * trs.m21);
- final double scaleZ = Math.sqrt(trs.m02 * trs.m02 + trs.m12 * trs.m12 + trs.m22 * trs.m22);
- final double[] invertScale = new double[]{1d / scaleX, 1d / scaleY, 1d / scaleZ};
- rotation.m00 = trs.m00 * invertScale[0]; rotation.m01 = trs.m01 * invertScale[1]; rotation.m02 = trs.m02 * invertScale[2];
- rotation.m10 = trs.m10 * invertScale[0]; rotation.m11 = trs.m11 * invertScale[1]; rotation.m12 = trs.m12 * invertScale[2];
- rotation.m20 = trs.m20 * invertScale[0]; rotation.m21 = trs.m21 * invertScale[1]; rotation.m22 = trs.m22 * invertScale[2];
- scale.set(0, scaleX);
- scale.set(1, scaleY);
- scale.set(2, scaleZ);
- translation.set(0,trs.getElement(0,3));
- translation.set(1,trs.getElement(1,3));
- translation.set(2,trs.getElement(2,3));
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix.java
deleted file mode 100644
index 4b48b4a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- * @todo Remove this class when all elements are merged in MatrixSIS
- */
-public abstract class Matrix extends MatrixSIS {
-
- public abstract void transform(Tuple tuple, Tuple result);
-
- public Tuple transformLocal(Tuple tuple) {
- transform(tuple, tuple);
- return tuple;
- }
-
- public abstract Matrix inverse() throws NoninvertibleMatrixException;
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix2D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix2D.java
deleted file mode 100644
index 54ea6b5..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix2D.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix2;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Matrix2D extends Matrix2{
-
- public Matrix2D() {
- }
-
- public Matrix2D(double m00, double m01, double m10, double m11) {
- super(m00, m01, m10, m11);
- }
-
- public Matrix2D(double[] elements) {
- super(elements);
- }
-
-
- public void transform(Tuple tuple, Tuple result) {
- //TODO not efficient
- result.set(multiply(tuple.toArrayDouble()));
- }
-
- /**
- * Casts or copies the given matrix to a {@code Matrix2D} implementation. If the given {@code matrix}
- * is already an instance of {@code Matrix2D}, then it is returned unchanged. Otherwise this method
- * verifies the matrix size, then copies all elements in a new {@code Matrix2D} object.
- *
- * @param matrix the matrix to cast or copy, or {@code null}.
- * @return the matrix argument if it can be safely cast (including {@code null} argument),
- * or a copy of the given matrix otherwise.
- * @throws IllegalArgumentException if the size of the given matrix is not {@value #SIZE}×{@value #SIZE}.
- */
- public static Matrix2D castOrCopy(final org.opengis.referencing.operation.Matrix matrix) throws IllegalArgumentException {
- if (matrix == null || matrix instanceof Matrix2D) {
- return (Matrix2D) matrix;
- }
- if (matrix.getNumCol() != 2 || matrix.getNumRow() != 2) {
- throw new IllegalArgumentException("Matrix is not of size 2x2");
- }
- return new Matrix2D(Matrix2.castOrCopy(matrix).getElements());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix3D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix3D.java
deleted file mode 100644
index cf18ff1..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix3D.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix3;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- * @todo Remove this class when all elements are merged in Matrix3
- */
-public class Matrix3D extends Matrix3{
-
- public Matrix3D() {
- }
-
- public Matrix3D(
- double m00, double m01, double m02,
- double m10, double m11, double m12,
- double m20, double m21, double m22
- ) {
- super( m00, m01, m02,
- m10, m11, m12,
- m20, m21, m22);
- }
-
- public Matrix3D(double[] elements) {
- super(elements);
- }
-
- public void transform(Tuple tuple, Tuple result) {
- //TODO not efficient
- result.set(multiply(tuple.toArrayDouble()));
- }
-
- /**
- * Casts or copies the given matrix to a {@code Matrix3D} implementation. If the given {@code matrix}
- * is already an instance of {@code Matrix3D}, then it is returned unchanged. Otherwise this method
- * verifies the matrix size, then copies all elements in a new {@code Matrix3D} object.
- *
- * @param matrix the matrix to cast or copy, or {@code null}.
- * @return the matrix argument if it can be safely cast (including {@code null} argument),
- * or a copy of the given matrix otherwise.
- * @throws IllegalArgumentException if the size of the given matrix is not {@value #SIZE}×{@value #SIZE}.
- */
- public static Matrix3D castOrCopy(final org.opengis.referencing.operation.Matrix matrix) throws IllegalArgumentException {
- if (matrix == null || matrix instanceof Matrix3D) {
- return (Matrix3D) matrix;
- }
- if (matrix.getNumCol() != 3 || matrix.getNumRow() != 3) {
- throw new IllegalArgumentException("Matrix is not of size 3x3");
- }
- return new Matrix3D(Matrix3.castOrCopy(matrix).getElements());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix4D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix4D.java
deleted file mode 100644
index 1b64ed3..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Matrix4D.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- * @todo Remove this class when all elements are merged in Matrix4
- */
-public class Matrix4D extends Matrix4 {
-
-
- public Matrix4D() {
- }
-
- public Matrix4D(
- double m00, double m01, double m02, double m03,
- double m10, double m11, double m12, double m13,
- double m20, double m21, double m22, double m23,
- double m30, double m31, double m32, double m33
- ) {
- super(
- m00, m01, m02, m03,
- m10, m11, m12, m13,
- m20, m21, m22, m23,
- m30, m31, m32, m33
- );
- }
-
- public Matrix4D(double[] elements) {
- super(elements);
- }
-
- public void transform(Tuple tuple, Tuple result) {
- //TODO not efficient
- result.set(multiply(tuple.toArrayDouble()));
- }
-
- /**
- * Casts or copies the given matrix to a {@code Matrix4D} implementation. If the given {@code matrix}
- * is already an instance of {@code Matrix4D}, then it is returned unchanged. Otherwise this method
- * verifies the matrix size, then copies all elements in a new {@code Matrix4D} object.
- *
- * @param matrix the matrix to cast or copy, or {@code null}.
- * @return the matrix argument if it can be safely cast (including {@code null} argument),
- * or a copy of the given matrix otherwise.
- * @throws IllegalArgumentException if the size of the given matrix is not {@value #SIZE}×{@value #SIZE}.
- */
- public static Matrix4D castOrCopy(final org.opengis.referencing.operation.Matrix matrix) throws IllegalArgumentException {
- if (matrix == null || matrix instanceof Matrix4D) {
- return (Matrix4D) matrix;
- }
- if (matrix.getNumCol() != 4 || matrix.getNumRow() != 4) {
- throw new IllegalArgumentException("Matrix is not of size 4x4");
- }
- return new Matrix4D(Matrix4.castOrCopy(matrix).getElements());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternion.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternion.java
deleted file mode 100644
index 9f9f991..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternion.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-
-
-/**
- * Quaternion object.
- *
- * Definition : http://en.wikipedia.org/wiki/Quaternion
- *
- * Original code from Unlicense.science
- */
-public class Quaternion extends VectorND.Double {
-
- private static final Vector3D.Double UNIT_X = new Vector3D.Double(1,0,0);
- private static final Vector3D.Double UNIT_Y = new Vector3D.Double(0,1,0);
-
- /**
- * Default quaternion with values [0,0,0,1] .
- */
- public Quaternion() {
- super(new double[]{0,0,0,1});
- }
-
- /**
- * Quaternion from 4 values.
- * @param x quaternion first value
- * @param y quaternion second value
- * @param z quaternion third value
- * @param w quaternion fourth value
- */
- public Quaternion(double x, double y, double z, double w) {
- super(new double[]{x,y,z,w});
- }
-
- /**
- * Expected an array of size 4.
- * Warning : no copy of the array is made.
- * @param values no copy of the array is made.
- */
- public Quaternion(double[] values) {
- super(values);
- }
-
- /**
- * Expect an array of size 4.
- * Warning : a copy of the array is made.
- * @param values a copy of the array is made.
- */
- public Quaternion(float[] values) {
- super(values);
- }
-
- /**
- * Expect an tuple of size 4.
- * @param v quaternion values to copy from
- */
- public Quaternion(Tuple<?> v) {
- super(v);
- if (v.getDimension()!= 4){
- throw new IllegalArgumentException("Tuple must be of size 4");
- }
- }
-
- /**
- * Convenient method to get value at ordinate 0.
- *
- * @throws IndexOutOfBoundsException if indice is out of range
- * @return double
- */
- public double getX() throws IndexOutOfBoundsException {
- return get(0);
- }
-
- /**
- * Convenient method to get value at ordinate 1.
- *
- * @throws IndexOutOfBoundsException if indice is out of range
- * @return double
- */
- public double getY() throws IndexOutOfBoundsException {
- return get(1);
- }
-
- /**
- * Convenient method to get value at ordinate 2.
- *
- * @throws IndexOutOfBoundsException if indice is out of range
- * @return double
- */
- public double getZ() throws IndexOutOfBoundsException {
- return get(2);
- }
-
- /**
- * Convenient method to get value at ordinate 3.
- *
- * @throws IndexOutOfBoundsException if indice is out of range
- * @return double
- */
- public double getW() throws IndexOutOfBoundsException {
- return get(3);
- }
-
- /**
- * Convenient method to set value at ordinate 0.
- *
- * @param x first ordinate value
- * @throws IndexOutOfBoundsException if indice is out of range
- */
- public void setX(double x) throws IndexOutOfBoundsException {
- set(0, x);
- }
-
- /**
- * Convenient method to set value at ordinate 1.
- *
- * @param y second ordinate value
- * @throws IndexOutOfBoundsException if indice is out of range
- */
- public void setY(double y) throws IndexOutOfBoundsException {
- set(1, y);
- }
-
- /**
- * Convenient method to set value at ordinate 2.
- *
- * @param z third ordinate value
- * @throws IndexOutOfBoundsException if indice is out of range
- */
- public void setZ(double z) throws IndexOutOfBoundsException {
- set(2, z);
- }
-
- /**
- * Convenient method to set value at ordinate 3.
- *
- * @param w fourth ordinate value
- * @throws InvalidIndexException if indice is out of range
- */
- public void setW(double w) throws IndexOutOfBoundsException {
- set(3, w);
- }
-
- /**
- * Normalize this quaternion.
- * @return this quaternion
- */
- @Override
- public Quaternion normalize(){
- Quaternions.normalize(values, values);
- return this;
- }
-
- /**
- * Calculate quaternion norm.
- * @return norm
- */
- public double norm() {
- return Quaternions.length(values);
- }
-
- /**
- * Calculate quaternion conjugate.
- * @return this quaternion
- */
- public Quaternion conjugate() {
- set(Quaternions.conjugate(values, null));
- return this;
- }
-
- /**
- * Add two quaternions.
- * @param other
- * @return this quaternion
- */
- public Quaternion add(Quaternion other) {
- set(Quaternions.add(values, other.values, null));
- return this;
- }
-
- /**
- * Multiply two quaternions. store result in this quaternion.
- * @param other
- * @return this Quaternion
- */
- public Quaternion multiply(Quaternion other) {
- Quaternions.multiplyQuaternion(values, other.values, values);
- return this;
- }
-
- /**
- * Calculate inverse quaternion.
- * @return this quaternion
- */
- public Quaternion inverse() {
- set(Quaternions.inverse(values, null));
- return this;
- }
-
- /**
- * Create a copy of this quaternion.
- * @return Quaternion, never null
- */
- @Override
- public Quaternion copy() {
- return new Quaternion(this);
- }
-
- /**
- * Rotate the given vector, store the result in buffer.
- * @param v vector to rotate
- * @param buffer can be null
- * @return rotated vector
- */
- public Vector<?> rotate(Vector<?> v, Vector<?> buffer){
- if (buffer == null) buffer = v.copy();
- Matrix3 m = toMatrix3();
- double[] r = m.multiply(v.toArrayDouble());
- buffer.set(r);
- return buffer;
- }
-
- /**
- * Rotate the given vector, store the result in buffer.
- * @param v vector to rotate
- * @param buffer can be null
- * @return rotated vector
- */
- public Vector rotate(Vector3D.Double v, Vector<?> buffer) {
- if (buffer == null) buffer = v.copy();
- double qx = values[0];
- double qy = values[1];
- double qz = values[2];
- double qw = values[3];
- // var qvec = [qx, qy, qz];
- // var uv = vec3.cross([], qvec, a);
- double uvx = qy * v.z - qz * v.y;
- double uvy = qz * v.x - qx * v.z;
- double uvz = qx * v.y - qy * v.x;
- // var uuv = vec3.cross([], qvec, uv);
- double uuvx = qy * uvz - qz * uvy;
- double uuvy = qz * uvx - qx * uvz;
- double uuvz = qx * uvy - qy * uvx;
- // vec3.scale(uv, uv, 2 * w);
- double w2 = qw * 2;
- uvx *= w2;
- uvy *= w2;
- uvz *= w2;
- // vec3.scale(uuv, uuv, 2);
- uuvx *= 2;
- uuvy *= 2;
- uuvz *= 2;
- // return vec3.add(out, a, vec3.add(out, uv, uuv));
- buffer.set(0, v.x + uvx + uuvx);
- buffer.set(1, v.y + uvy + uuvy);
- buffer.set(2, v.z + uvz + uuvz);
- return buffer;
- }
-
- /**
- * Create an linear interpolated quaternion.
- * A ratio of 0 while return the same values as this quaternion
- * A ratio of 1 while return the same values as other quaternion
- *
- * @param other not null
- * @param ratio range [0...1]
- * @param buffer can be null
- * @return this interpolated quaternion
- */
- public Quaternion lerp(final Quaternion other, final double ratio){
- final double[] lerp = Quaternions.lerp(values, other.toArrayDouble(), ratio, new double[4]);
- set(lerp);
- return this;
- }
-
- /**
- * Create a spherical interpolated quaternion.
- * A ratio of 0 while return the same values as this quaternion
- * A ratio of 1 while return the same values as other quaternion
- *
- * @param other not null
- * @param ratio range [0...1]
- * @param buffer can be null
- * @return this interpolated quaternion
- */
- public Quaternion slerp(final Quaternion other, final double ratio){
- final double[] slerp = Quaternions.slerp(values, other.toArrayDouble(), ratio, new double[4]);
- set(slerp);
- return this;
- }
-
- /**
- * Transform quaternion in a rotation matrix 3x3.
- * Source : http://jeux.developpez.com/faq/math/?page=quaternions#Q54
- *
- * @return Matrix3
- */
- public Matrix3 toMatrix3() {
- return Matrices.toMatrix3(Quaternions.toMatrix(values, null));
- }
-
- /**
- * Transform quaternion in a rotation matrix 4x4.
- * @return Matrix4
- */
- public Matrix4 toMatrix4() {
- final double[][] matrix = new double[4][4];
- Quaternions.toMatrix(values, matrix);
- matrix[3][3] = 1;
- return Matrices.toMatrix4(matrix);
- }
-
- /**
- * Convert to euler angles.
- * @return euler angle in radians (heading/yaw , elevation/pitch , bank/roll)
- */
- public VectorND.Double toEuler(){
- return new VectorND.Double(Matrices.toEuler(Matrices.toArray(toMatrix3()), null));
- }
-
- /**
- * Convert quaternion to axis angle.
- * @param axisBuffer
- * @return angle in radians
- */
- public double toAxisAngle(Tuple axisBuffer){
- final double[] values = Vectors.normalize(this.values);
- final double[] array = new double[4];
- final double angle = Quaternions.toAxisAngle(values,array);
- axisBuffer.set(array);
- return angle;
- }
-
- /**
- * Extract rotation from matrix.
- * http://jeux.developpez.com/faq/math/?page=quaternions#Q55
- *
- * @param matrix
- * @return Quaternion
- */
- public Quaternion fromMatrix(final MatrixSIS matrix){
- final double[][] m = Matrices.toArray(matrix);
- final double trace = m[0][0] + m[1][1] + m[2][2] + 1;
-
- final double s,x,y,z,w;
- if (trace>0){
- s = 0.5 / Math.sqrt(trace);
- x = ( m[2][1] - m[1][2] ) * s;
- y = ( m[0][2] - m[2][0] ) * s;
- z = ( m[1][0] - m[0][1] ) * s;
- w = 0.25 / s;
- } else if ((m[0][0] >= m[1][1]) && (m[0][0] >= m[2][2])) {
- s = Math.sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]) * 2.0;
- x = 0.25 * s;
- y = (m[0][1] + m[1][0]) / s;
- z = (m[0][2] + m[2][0]) / s;
- w = (m[1][2] - m[2][1]) / s;
- } else if (m[1][1] >= m[2][2]) {
- s = Math.sqrt(1.0 - m[0][0] + m[1][1] - m[2][2]) * 2;
- x = (m[0][1] + m[1][0]) / s;
- y = 0.25 * s;
- z = (m[1][2] + m[2][1]) / s;
- w = (m[0][2] - m[2][0]) / s;
- } else {
- s = Math.sqrt(1.0 - m[0][0] - m[1][1] + m[2][2]) * 2;
- x = (m[0][2] + m[2][0]) / s;
- y = (m[1][2] + m[2][1]) / s;
- z = 0.25 * s;
- w = (m[0][1] - m[1][0]) / s;
- }
- set(new double[]{x,y,z,w});
- return this;
- }
-
- /**
- * Set quaternion values from rotation axis and angle.
- * @param axis rotation axis, not null
- * @param angle rotation angle, in radians
- * @return this quaternion
- */
- public Quaternion fromAngle(Tuple axis, double angle) {
- Quaternions.fromAngle(axis, angle, values);
- return this;
- }
-
- /**
- * Set quaternion values from euler angles.
- *
- * @param euler angles in radians (heading/yaw , elevation/pitch , bank/roll)
- * @return this quaternion
- */
- public Quaternion fromEuler(Vector euler) {
- double[][] matrix = Matrices.fromEuler(euler.toArrayDouble(), new double[3][3]); //row / col
- return fromMatrix(Matrices.toMatrix3(matrix));
- }
-
- /**
- * Set quaternion values to shortest rotation between the two unit vectors.
- *
- * @param base starting vector of unit length
- * @param target target vector of unit length
- * @return this quaternion
- */
- public Quaternion fromUnitVectors(Vector base, Vector target) {
- final double dot = base.dot(target);
- if (dot < -0.999999) {
- //try to find a better value on other axis
- Vector tmpvec3 = UNIT_X.cross(base);
- if (tmpvec3.length() < 0.000001) {
- tmpvec3 = UNIT_Y.cross(base);
- }
- tmpvec3.normalize();
- fromAngle(tmpvec3, Math.PI);
- } else if (dot > 0.999999) {
- //no rotation
- values[0] = 0;
- values[1] = 0;
- values[2] = 0;
- values[3] = 1;
- } else {
- final Vector cross = base.cross(target);
- values[0] = cross.get(0);
- values[1] = cross.get(1);
- values[2] = cross.get(2);
- values[3] = 1 + dot;
- normalize();
- }
- return this;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternions.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternions.java
deleted file mode 100644
index da9a100..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Quaternions.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.util.Static;
-
-
-/**
- *
- * Original code from Unlicense.science
- */
-public final class Quaternions extends Static {
-
- private static final double DELTA = 0.00001;
-
- public static double[] add(final double[] quaternion, final double[] other, double[] buffer){
- return Vectors.add(quaternion, other, buffer);
- }
-
- public static double[] subtract(final double[] quaternion, final double[] other, double[] buffer){
- return Vectors.subtract(quaternion, other, buffer);
- }
-
- public static double dot(final double[] q1, final double[] q2){
- return Vectors.dot(q1, q2);
- }
-
- /**
- * Normalize quaternion, result is stored in buffer.
- * if buffer is null, a new quaternion is created.
- * Arrays must have the same size
- * @param quaternion input quaternion
- * @param buffer result buffer, can be null
- * @return normalized quaternion
- */
- public static double[] normalize(final double[] quaternion, double[] buffer){
- return Vectors.normalize(quaternion, buffer);
- }
-
- public static double[] conjugate(final double[] quaternion, double[] buffer){
- if (buffer == null){
- buffer = new double[4];
- }
- buffer[0] = -quaternion[0];
- buffer[1] = -quaternion[1];
- buffer[2] = -quaternion[2];
- buffer[3] = quaternion[3];
- return buffer;
- }
-
- public static double[] scale(final double[] quaternion, final double scale, double[] buffer){
- return Vectors.scale(quaternion, scale, buffer);
- }
-
- public static double length(final double[] quaternion){
- return Vectors.length(quaternion);
- }
-
- public static double[] multiplyQuaternion(double[] l, double[] r, double[] buffer){
- if (buffer == null){
- buffer = new double[4];
- }
-
- double w = (l[3] * r[3]) - (l[0] * r[0]) - (l[1] * r[1]) - (l[2] * r[2]);
- double x = (l[0] * r[3]) + (l[3] * r[0]) + (l[1] * r[2]) - (l[2] * r[1]);
- double y = (l[1] * r[3]) + (l[3] * r[1]) + (l[2] * r[0]) - (l[0] * r[2]);
- double z = (l[2] * r[3]) + (l[3] * r[2]) + (l[0] * r[1]) - (l[1] * r[0]);
-
- buffer[0] = x;
- buffer[1] = y;
- buffer[2] = z;
- buffer[3] = w;
-
- return buffer;
- }
-
- public static double[] multiplyVector(double[] q, double[] v, double[] buffer){
- if (buffer == null){
- buffer = new double[v.length];
- }
-
- double w = - (q[0] * v[0]) - (q[1] * v[1]) - (q[2] * v[2]);
- double x = (q[3] * v[0]) + (q[1] * v[2]) - (q[2] * v[1]);
- double y = (q[3] * v[1]) + (q[2] * v[0]) - (q[0] * v[2]);
- double z = (q[3] * v[2]) + (q[0] * v[1]) - (q[1] * v[0]);
-
- buffer[0] = x;
- buffer[1] = y;
- buffer[2] = z;
- if (v.length>3){
- buffer[3] = w;
- }
-
- return buffer;
- }
-
- public static double[] inverse(double[] values, double[] buffer){
- if (buffer == null){
- buffer = new double[4];
- }
- final double k = values[0]*values[0] + values[1]*values[1] + values[2]*values[2] + values[3]*values[3];
- buffer[0] = -values[0]/k;
- buffer[1] = -values[1]/k;
- buffer[2] = -values[2]/k;
- buffer[3] = values[3]/k;
- return buffer;
- }
-
- /**
- * Linear quaternion interpolation.
- *
- * @param q1 first quaternion
- * @param q2 second quaternion
- * @param ratio : 0 is close to first vector, 1 is on second vector
- * @param buffer result buffer, not null
- * @return interpolated quaternion
- */
- public static double[] lerp(final double[] q1, final double[] q2, double ratio, double[] buffer){
- buffer = scale(q1, 1-ratio, buffer);
- final double[] p2 = scale(q2, ratio, null);
- add(buffer, p2, buffer);
- normalize(buffer, buffer);
- return buffer;
- }
-
- /**
- * Spherical linear interpolation.
- *
- * @param q1 first quaternion
- * @param q2 second quaternion
- * @param ratio : 0 is close to first vector, 1 is on second vector
- * @param buffer result buffer, can be null
- * @return interpolated quaternion
- */
- public static double[] slerp(final double[] q1, final double[] q2, double ratio, double[] buffer){
- if (buffer==null) buffer = new double[4];
-
- //quick shortcuts, avoid several math operations and buffer creations
- if (ratio<=0.0){
- System.arraycopy(q1, 0, buffer, 0, q1.length);
- return buffer;
- } else if (ratio>=1.0){
- System.arraycopy(q2, 0, buffer, 0, q2.length);
- return buffer;
- }
-
- double dot = dot(q1, q2);
- final double[] q3;
- if (dot < 0){
- dot = -dot;
- q3 = scale(q2, -1, null);
- } else {
- q3 = q2;
- }
-
- //set ratio using lerp
- double ratio1 = 1.0-ratio;
- double ratio2 = ratio;
- if ((1.0-dot) > 0.00001) {
- //if angle is big enough use slerp, otherwise use the lerp values
- final double angle = Math.acos(dot);
- final double sinAngle = Math.sin(angle);
- ratio1 = Math.sin(angle*ratio1) / sinAngle;
- ratio2 = Math.sin(angle*ratio2) / sinAngle;
- }
-
- buffer = scale(q1, ratio1, buffer);
- final double[] b = scale(q3, ratio2, null);
- return add(buffer, b, buffer);
- }
-
- /**
- * Create quaternion from axe and angle.
- * Source : http://jeux.developpez.com/faq/math/?page=quaternions#Q56
- *
- * @param axis rotation axis
- * @param angle rotation angle
- * @param buffer result buffer
- * @return quaternion, never null
- */
- public static double[] fromAngle(Tuple axis, double angle, double[] buffer){
-
- if (buffer == null){
- buffer = new double[4];
- }
-
- final double sin_a = Math.sin(angle / 2);
- final double cos_a = Math.cos(angle / 2);
-
- buffer[0] = axis.get(0) * sin_a;
- buffer[1] = axis.get(1) * sin_a;
- buffer[2] = axis.get(2) * sin_a;
- buffer[3] = cos_a;
-
- normalize(buffer, buffer);
- return buffer;
- }
-
- /**
- * Quaternion to matrix.
- * Source : http://jeux.developpez.com/faq/math/?page=quaternions#Q54
- *
- * @param quaternion input quaternion
- * @param matrix result buffer, can be null
- * @return result matrix
- */
- public static double[][] toMatrix(double[] quaternion, double[][] matrix){
-
- if (matrix==null){
- matrix = new double[3][3];
- }
-
- final double xx = quaternion[0] * quaternion[0];
- final double xy = quaternion[0] * quaternion[1];
- final double xz = quaternion[0] * quaternion[2];
- final double xw = quaternion[0] * quaternion[3];
- final double yy = quaternion[1] * quaternion[1];
- final double yz = quaternion[1] * quaternion[2];
- final double yw = quaternion[1] * quaternion[3];
- final double zz = quaternion[2] * quaternion[2];
- final double zw = quaternion[2] * quaternion[3];
-
- matrix[0][0] = 1 - 2 * (yy + zz);
- matrix[0][1] = 2 * (xy - zw);
- matrix[0][2] = 2 * (xz + yw);
-
- matrix[1][0] = 2 * (xy + zw);
- matrix[1][1] = 1 - 2 * (xx + zz);
- matrix[1][2] = 2 * (yz - xw);
-
- matrix[2][0] = 2 * (xz - yw);
- matrix[2][1] = 2 * (yz + xw);
- matrix[2][2] = 1 - 2 * (xx + yy);
-
- return matrix;
- }
-
- /**
- *
- * @param quaternion must be normalized
- * @param axis axis will be written in this buffer
- * @return angle in radians
- */
- public static double toAxisAngle(double[] quaternion, double[] axis){
- final double w = quaternion[3];
- final double angle = 2.0 * Math.acos(w);
- final double s = Math.sqrt(1-w*w);
-
- axis[0] = quaternion[0];
- axis[1] = quaternion[1];
- axis[2] = quaternion[2];
-
- if (s>=DELTA){
- Vectors.scale(axis, 1.0/s, axis);
- }
-
- return angle;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/SampleSystem.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/SampleSystem.java
deleted file mode 100644
index 85b7ccd..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/SampleSystem.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.GenericName;
-import org.apache.sis.coverage.SampleDimension;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.collection.BackingStoreException;
-import org.apache.sis.util.collection.Cache;
-import org.apache.sis.util.iso.Names;
-
-
-/**
- * Experimental class to store multisamples dimensions.
- *
- * This serves an identical purpose as SampleDimension but usable with GPU primitive attributes.
- * This class contains a CRS but conceptualy a CoordinateReferenceSystem should be a subtype of SampleSystem.
- *
- * Waiting for a proper implementation in SIS when reviewing ISO 19123 / 2153.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SampleSystem {
-
- private static final GenericName UNNAMED = Names.createLocalName(null, null, "unnamed");
- private static final SampleSystem UNDEFINED_1S = new SampleSystem(1);
- private static final SampleSystem UNDEFINED_2S = new SampleSystem(2);
- private static final SampleSystem UNDEFINED_3S = new SampleSystem(3);
- private static final SampleSystem UNDEFINED_4S = new SampleSystem(4);
- private static SampleSystem[] UNDEFINED = new SampleSystem[0];
- private static Cache<CoordinateReferenceSystem, SampleSystem> CACHE = new Cache<>();
-
- private final GenericName name;
- private final CoordinateReferenceSystem crs;
- private final List<SampleDimension> sampleDimensions;
-
- private SampleSystem(int size) {
- ArgumentChecks.ensureStrictlyPositive("size", size);
- this.name = UNNAMED;
- this.crs = null;
- SampleDimension[] sampleDimensions = new SampleDimension[size];
- for (int i = 0; i < size; i++) {
- sampleDimensions[i] = new SampleDimension.Builder().setName(name + "." + i).build();
- }
- this.sampleDimensions = List.of(sampleDimensions);
- }
-
- private SampleSystem(CoordinateReferenceSystem crs) {
- this(UNNAMED, crs);
- }
-
- private SampleSystem(GenericName name, CoordinateReferenceSystem crs) {
- ArgumentChecks.ensureNonNull("name", name);
- ArgumentChecks.ensureNonNull("crs", crs);
- final int dim = crs.getCoordinateSystem().getDimension();
- SampleDimension[] sampleDimensions = new SampleDimension[dim];
- if (dim == 1) {
- sampleDimensions[0] = new SampleDimension.Builder().setName(name).build();
- } else {
- for (int i = 0; i < dim; i++) {
- sampleDimensions[i] = new SampleDimension.Builder().setName(name + "." + i).build();
- }
- }
- this.sampleDimensions = List.of(sampleDimensions);
- this.name = name;
- this.crs = crs;
- }
-
- public SampleSystem(DataType dataType, SampleDimension ... sampleDimensions) {
- this(UNNAMED, dataType, sampleDimensions);
- }
-
- public SampleSystem(GenericName name, DataType dataType, SampleDimension ... sampleDimensions) {
- ArgumentChecks.ensureNonNull("name", name);
- ArgumentChecks.ensureNonNull("data type", dataType);
- ArgumentChecks.ensureNonNull("sampleDimensions", sampleDimensions);
- ArgumentChecks.ensureStrictlyPositive("sampleDimensions", sampleDimensions.length);
- this.sampleDimensions = List.of(sampleDimensions);
- this.name = name;
- this.crs = null;
- }
-
- public static SampleSystem ofSize(int nbDim) {
- ArgumentChecks.ensureStrictlyPositive("nbDim", nbDim);
- switch (nbDim) {
- case 1 : return UNDEFINED_1S;
- case 2 : return UNDEFINED_2S;
- case 3 : return UNDEFINED_3S;
- case 4 : return UNDEFINED_4S;
- default: {
- final int idx = nbDim - 4;
- synchronized (UNNAMED) {
- if (idx >= UNDEFINED.length) {
- UNDEFINED = Arrays.copyOf(UNDEFINED, idx+1);
- }
- if (UNDEFINED[idx] == null) {
- UNDEFINED[idx] = new SampleSystem(nbDim);
- }
- return UNDEFINED[idx];
- }
- }
- }
- }
-
- public static SampleSystem of(CoordinateReferenceSystem crs) {
- ArgumentChecks.ensureNonNull("crs", crs);
- try {
- return CACHE.getOrCreate(crs, () -> new SampleSystem(crs));
- } catch (Exception ex) {
- throw new BackingStoreException(ex.getMessage(), ex);
- }
- }
-
- /**
- * Returns an identification for this dimension. This is typically used as a way to perform a band select
- * by using human comprehensible descriptions instead of just numbers.
- *
- * @return an identification of this dimension, nerver null.
- */
- public GenericName getName() {
- return name;
- }
-
- /**
- * Returns the coordinate reference system for this record dimension if it is a coordinate system.
- *
- * @return can be null.
- */
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return crs;
- }
-
- /**
- * @return list of sample dimensions, never null, contains at least one entry.
- */
- public List<SampleDimension> getSampleDimensions() {
- return sampleDimensions;
- }
-
- /**
- * Returns the size in number of samples in this dimension.
- *
- * @return dimension size
- */
- public int getSize() {
- return sampleDimensions.size();
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 67 * hash + Objects.hashCode(this.name);
- hash = 67 * hash + Objects.hashCode(this.crs);
- hash = 67 * hash + Objects.hashCode(this.sampleDimensions);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final SampleSystem other = (SampleSystem) obj;
- if (!Objects.equals(this.name, other.name)) {
- return false;
- }
- if (!Objects.equals(this.crs, other.crs)) {
- return false;
- }
- return Objects.equals(this.sampleDimensions, other.sampleDimensions);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java
deleted file mode 100644
index cbee7c1..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.util.Utilities;
-
-
-/**
- * A tuple is an array of values.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Tuple<T extends Tuple <T>> {
-
- /**
- * @return sample system, never null.
- */
- SampleSystem getSampleSystem();
-
- /**
- * @return sample system size.
- */
- default int getDimension() {
- return getSampleSystem().getSize();
- }
-
- /**
- * @return sample system CRS, may be null.
- */
- default CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return getSampleSystem().getCoordinateReferenceSystem();
- }
-
- /**
- * @return data type of primitives in this array
- */
- DataType getDataType();
-
- /**
- * Get sample at index.
- *
- * @param indice sample index
- * @return value at index
- * @throws IndexOutOfBoundsException if index is not valid
- */
- double get(int indice) throws IndexOutOfBoundsException;
-
- /**
- * Set sample value at index.
- *
- * @param indice sample index
- * @param value sample value
- * @throws IndexOutOfBoundsException if index is not valid
- */
- void set(int indice, double value) throws IndexOutOfBoundsException;
-
- /**
- * Copy values from given direct position to this tuple.
- *
- * @param values to copy from
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(DirectPosition values) throws IndexOutOfBoundsException{
- for (int i = 0, n = getDimension(); i < n; i++) {
- set(i, values.getCoordinate(i));
- }
- return (T) this;
- }
-
- /**
- * Set tuple values.
- * @param values array to copy values from.
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(double[] values) throws IndexOutOfBoundsException {
- return set(values, 0);
- }
-
- /**
- * Set tuple values.
- * @param values array to copy values from.
- * @param offset offset to start copy from
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(double[] values, int offset) throws IndexOutOfBoundsException {
- for (int i = 0, n = getDimension(); i < n; i++) {
- set(i, values[i+offset]);
- }
- return (T) this;
- }
-
- /**
- * Set tuple values.
- * @param values array to copy values from.
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(float[] values) throws IndexOutOfBoundsException {
- return set(values, 0);
- }
-
- /**
- * Set tuple values.
- * @param values array to copy values from.
- * @param offset offset to start copy from
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(float[] values, int offset) throws IndexOutOfBoundsException {
- for (int i = 0, n = getDimension(); i < n; i++) {
- set(i, values[i+offset]);
- }
- return (T) this;
- }
-
- /**
- * Set tuple values.
- * @param values array to copy values from.
- * @return this tuple
- * @throws IndexOutOfBoundsException if dimension is smaller then this tuple
- */
- default T set(Tuple<?> values) throws IndexOutOfBoundsException {
- for (int i = 0, n = getDimension(); i < n; i++) {
- set(i, values.get(i));
- }
- return (T) this;
- }
-
- /**
- * Set tuple values.
- * @param value value to set on each ordinate
- * @return this tuple
- */
- default T setAll(double value) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- set(i, value);
- }
- return (T) this;
- }
-
- /**
- * Tuple to array.
- *
- * @return values as cast byte array
- */
- default byte[] toArrayByte() {
- byte[] buffer = new byte[getDimension()];
- toArrayByte(buffer, 0);
- return buffer;
- }
-
- /**
- * Tuple to array.
- *
- * @return values as cast short array
- */
- default short[] toArrayShort() {
- short[] buffer = new short[getDimension()];
- toArrayShort(buffer, 0);
- return buffer;
- }
-
- /**
- * Tuple to array.
- *
- * @return values as cast integer array
- */
- default int[] toArrayInt() {
- int[] buffer = new int[getDimension()];
- toArrayInt(buffer, 0);
- return buffer;
- }
-
- /**
- * Tuple to array.
- *
- * @return values as cast float array
- */
- default float[] toArrayFloat() {
- float[] buffer = new float[getDimension()];
- toArrayFloat(buffer, 0);
- return buffer;
- }
-
- /**
- * Tuple to array.
- *
- * @return values as double array
- */
- default double[] toArrayDouble() {
- double[] buffer = new double[getDimension()];
- toArrayDouble(buffer, 0);
- return buffer;
- }
-
- /**
- * Tuple to array.
- *
- * @param buffer array to write into
- * @param offset offset at which to write
- */
- default void toArrayByte(byte[] buffer, int offset) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- buffer[offset+i] = (byte) get(i);
- }
- }
-
- /**
- * Tuple to array.
- *
- * @param buffer array to write into
- * @param offset offset at which to write
- */
- default void toArrayShort(short[] buffer, int offset) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- buffer[offset+i] = (short) get(i);
- }
- }
-
- /**
- * Tuple to array.
- *
- * @param buffer array to write into
- * @param offset offset at which to write
- */
- default void toArrayInt(int[] buffer, int offset) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- buffer[offset+i] = (int) get(i);
- }
- }
-
- /**
- * Tuple to array.
- *
- * @param buffer array to write into
- * @param offset offset at which to write
- */
- default void toArrayFloat(float[] buffer, int offset) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- buffer[offset+i] = (float) get(i);
- }
- }
-
- /**
- * Tuple to array.
- *
- * @param buffer array to write into
- * @param offset offset at which to write
- */
- default void toArrayDouble(double[] buffer, int offset) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- buffer[offset+i] = get(i);
- }
- }
-
- /**
- * Apply given transform on this tuple.
- *
- * @param trs not null
- * @return this tuple
- * @throws TransformException
- */
- default T transform(MathTransform trs) throws TransformException {
- final double[] array = toArrayDouble();
- trs.transform(array, 0, array, 0, 1);
- return set(array);
- }
-
- /**
- * Transform this tuple and store the result in given tuple.
- *
- * @param trs not null
- * @param target not null to store transform result
- * @return this tuple
- * @throws TransformException
- */
- default void transformTo(MathTransform trs, Tuple<?> target) throws TransformException {
- final double[] array = toArrayDouble();
- trs.transform(array, 0, array, 0, 1);
- target.set(array);
- }
-
- /**
- * Create a copy of this tuple.
- *
- * @return tuple copy.
- */
- default T copy() {
- T tuple = (T) Vectors.create(getSampleSystem(), getDataType());
- tuple.set(this);
- return tuple;
- }
-
- /**
- * @return true if all values are finite (not infinite or NaN)
- */
- default boolean isFinite(){
- for (int i = 0, n = getDimension(); i < n; i++) {
- if (!Double.isFinite(get(i))) return false;
- }
- return true;
- }
-
- /**
- * @return true if all samples match given value.
- */
- default boolean isAll(double value) {
- for (int i = 0, n = getDimension(); i < n; i++) {
- if (value != get(i)) return false;
- }
- return true;
- }
-
- /**
- * Tuples are equal when all samples and CRS match.
- */
- @Override
- boolean equals(Object candidate);
-
- /**
- * Test tuples equality.
- *
- * Tuples are a key element in OpenGL and GPU which have variable bits representation of numbers
- * including half-floats, oct-compression, normalisation, quantization, unsigned values and more.
- *
- * This equality test checks values and CRS but does not verify that data types are identical.
- * This behavior allows to compare Tuple following their contract ignoring the storage backend.
- *
- * @param obj second tuple to test against
- * @param tolerance tolerance value for compare operation
- * @return true if tuples are value equal
- */
- default boolean equals(Tuple<?> other, double tolerance) {
- if (this == other) {
- return true;
- }
- if (other == null) {
- return false;
- }
-
- final int dim = getDimension();
- if (dim != other.getDimension()) {
- return false;
- }
- for (int i = 0; i < dim; i++) {
- double v1 = get(i);
- double v2 = other.get(i);
- if (v1 != v2) {
- //check with tolerance
- if (Math.abs(v1 - v2) <= tolerance) {
- continue;
- }
- //check for NaN equality
- if (Double.doubleToRawLongBits(v1) != Double.doubleToRawLongBits(v2)) {
- return false;
- }
- }
- }
- //checking crs is expensive, do it last
- if (!Utilities.equalsIgnoreMetadata(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArray.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArray.java
deleted file mode 100644
index e390aca..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArray.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * A tuple array is fixed size array of tuples.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface TupleArray {
-
- /**
- * @return if length is zero.
- */
- default boolean isEmpty() {
- return getLength() == 0;
- }
-
- /**
- * @return number of tuples in the array.
- */
- int getLength();
-
- /**
- * @return sample system, never null.
- */
- SampleSystem getSampleSystem();
-
- /**
- * Set sample system.
- * @param type
- * @throws IllegalArgumentException if new system dimension are different.
- */
- void setSampleSystem(SampleSystem type);
-
- /**
- * @return tuple coordinate reference system.
- */
- CoordinateReferenceSystem getCoordinateReferenceSystem();
-
- /**
- * @return dimension of each tuple.
- */
- int getDimension();
-
- /**
- * @return number of samples in the array, which is dimension mupliply by length.
- */
- default long getSampleCount() {
- return ((long) getLength()) * getDimension();
- }
-
- /**
- *
- * @return data type of primitives in this array
- */
- DataType getDataType();
-
- /**
- * Get tuple.
- * Returned tuple is a copy.
- *
- * @param index tuple index.
- * @return tuple values, tuple is a copy.
- */
- default Tuple get(int index) {
- Tuple tuple = Vectors.create(getSampleSystem(), getDataType());
- get(index, tuple);
- return tuple;
- }
-
- /**
- * Get tuple.
- *
- * @param index tuple index.
- * @param buffer tuple to write into.
- */
- void get(int index, Tuple buffer);
-
- /**
- * Set tuple.
- *
- * @param index tuple index
- * @param buffer new tuple values.
- */
- void set(int index, Tuple buffer);
-
- /**
- * Set a range on tuple from given array.
- * @param index starting index in this array
- * @param array arry to copy from
- * @param offset starting offset in given array
- * @param nb number of tuples to copy
- */
- default void set(int index, TupleArray array, int offset, int nb) {
- final Vector v = Vectors.create(array.getDimension(), array.getDataType());
- for (int i = 0; i < nb; i++) {
- array.get(offset + i, v);
- set(index + i, v);
- }
- }
-
- /**
- * Efficient swap tuple at given indexes.
- * @param i
- * @param j
- */
- default void swap(int i, int j) {
- final Tuple ti = get(i);
- final Tuple tj = get(j);
- set(i, tj);
- set(j, ti);
- }
-
- /**
- * @return this array tuples as an interleaved array cast to bytes.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default byte[] toArrayByte() {
- return toArrayByte(0, getLength());
- }
-
- /**
- * @return this array tuples as an interleaved array cast to shorts.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default short[] toArrayShort() {
- return toArrayShort(0, getLength());
- }
-
- /**
- * @return this array tuples as an interleaved array cast to integers.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default int[] toArrayInt() {
- return toArrayInt(0, getLength());
- }
-
- /**
- * @return this array tuples as an interleaved array cast to floats.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default float[] toArrayFloat() {
- return toArrayFloat(0, getLength());
- }
-
- /**
- * @return this array tuples as an interleaved array cast to doubles.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default double[] toArrayDouble() {
- return toArrayDouble(0, getLength());
- }
-
- /**
- * @param offset index of the first tuple to copy
- * @param nbTuple number of tuples to copy
- * @return this array tuples as an interleaved array cast to bytes.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default byte[] toArrayByte(int offset, int nbTuple) {
- final int dimension = getDimension();
- final byte[] array = new byte[nbTuple*dimension];
- final Tuple v = Vectors.createByte(dimension);
- for (int i = 0, k = offset; i < nbTuple; i++, k++) {
- get(k, v);
- v.toArrayByte(array, i*dimension);
- }
- return array;
- }
-
- /**
- * @param offset index of the first tuple to copy
- * @param nbTuple number of tuples to copy
- * @return this array tuples as an interleaved array cast to shorts.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default short[] toArrayShort(int offset, int nbTuple) {
- final int dimension = getDimension();
- final short[] array = new short[nbTuple*dimension];
- final Tuple v = Vectors.createShort(dimension);
- for (int i = 0, k = offset; i < nbTuple; i++, k++) {
- get(k, v);
- v.toArrayShort(array, i*dimension);
- }
- return array;
- }
-
- /**
- * @param offset index of the first tuple to copy
- * @param nbTuple number of tuples to copy
- * @return this array tuples as an interleaved array cast to integers.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default int[] toArrayInt(int offset, int nbTuple) {
- final int dimension = getDimension();
- final int[] array = new int[nbTuple*dimension];
- final Tuple v = Vectors.createInt(dimension);
- for (int i = 0, k = offset; i < nbTuple; i++, k++) {
- get(k, v);
- v.toArrayInt(array, i*dimension);
- }
- return array;
- }
-
- /**
- * @param offset index of the first tuple to copy
- * @param nbTuple number of tuples to copy
- * @return this array tuples as an interleaved array cast to floats.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default float[] toArrayFloat(int offset, int nbTuple) {
- final int dimension = getDimension();
- final float[] array = new float[nbTuple*dimension];
- final Vector v = Vectors.createFloat(dimension);
- for (int i = 0, k = offset; i < nbTuple; i++, k++) {
- get(k, v);
- v.toArrayFloat(array, i*dimension);
- }
- return array;
- }
-
- /**
- * @param offset index of the first tuple to copy
- * @param nbTuple number of tuples to copy
- * @return this array tuples as an interleaved array cast to doubles.
- * Example : [x1,x2,x3, y1,y2,y3, ... z1, z2,z3]
- */
- default double[] toArrayDouble(int offset, int nbTuple) {
- final int dimension = getDimension();
- final double[] array = new double[nbTuple*dimension];
- final TupleArrayCursor cursor = cursor();
- for (int i = 0, k = offset; i < nbTuple; i++, k++) {
- cursor.moveTo(k);
- cursor.samples().toArrayDouble(array, i*dimension);
- }
- return array;
- }
-
- /**
- * Apply given transformation to all tuples.
- *
- * @param trs not null
- */
- default void transform(MathTransform trs) throws TransformException {
- final Vector v = Vectors.createDouble(getDimension());
- for (int i=0,n=getLength();i<n;i++) {
- get(i, v);
- v.transform(trs);
- set(i,v);
- }
- }
-
- /**
- * Transform coordinates to target crs and change tuple array crs.
- *
- * @param crs target CRS
- * @throws FactoryException
- */
- default void transform(CoordinateReferenceSystem crs) throws FactoryException, TransformException {
- ArgumentChecks.ensureNonNull("crs", crs);
- final CoordinateReferenceSystem baseCrs = getCoordinateReferenceSystem();
- if (baseCrs == null) {
- throw new TransformException("This TupleArray do not have a SampleSystem with a CRS");
- }
- final MathTransform trs = CRS.findOperation(baseCrs, crs, null).getMathTransform();
- setSampleSystem(SampleSystem.of(crs));
- transform(trs);
- }
-
- /**
- * Create a new TupleArray with a different datatype.
- * @param type new data type, not null
- * @return retyped array, if the type is the same a copy is returned
- */
- default TupleArray retype(DataType type) {
- TupleArray formated = TupleArrays.of(getSampleSystem(), type, getLength());
- formated.set(0, this, 0, formated.getLength());
- return formated;
- }
- /**
- * Create a new array with given size.
- * Values are copied from this array, zero values are used to fill the new tuples.
- *
- * @param newSize new array size
- * @return resized array
- */
- TupleArray resize(int newSize);
-
- /**
- * @return copy of this array
- */
- TupleArray copy();
-
- /**
- * @return tuple cursor over this array.
- */
- TupleArrayCursor cursor();
-
- /**
- * @return tuple stream over this array.
- */
- default Stream<Tuple> stream(boolean parallel) {
- return StreamSupport.stream(new TupleArraySpliterator(this), parallel);
- }
-
- /**
- * Test tuple arrays equality.
- *
- * Tuples are a key element in OpenGL and GPU which have variable bits representation of numbers
- * including half-floats, oct-compression, normalisation, quantization, unsigned values and more.
- *
- * This equality test checks values and CRS but does not verify that data types are identical.
- * This behavior allows to compare Tuple following their contract ignoring the storage backend.
- *
- * @param other second tuple array to test against
- * @param tolerance tolerance value for compare operation
- * @return true if tuples are value equal
- */
- default boolean equals(TupleArray other, double tolerance) {
- if (this == other) {
- return true;
- }
- if (other == null) {
- return false;
- }
-
- final int dim = getDimension();
- if (dim != other.getDimension()) {
- return false;
- }
- final int length = getLength();
- if (length != other.getLength()) {
- return false;
- }
- if (!getSampleSystem().equals(other.getSampleSystem())) {
- return false;
- }
- for (int i = 0; i < length; i++) {
- Tuple v1 = get(i);
- Tuple v2 = other.get(i);
- if (!v1.equals(v2, tolerance)) {
- return false;
- }
- }
- return true;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayConcatenated.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayConcatenated.java
deleted file mode 100644
index 7501ce0..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayConcatenated.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Arrays;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class TupleArrayConcatenated extends AbstractTupleArray {
-
- private final TupleArray[] arrays;
- private final int[] offsets;
- private final int length;
-
- public TupleArrayConcatenated(TupleArray[] arrays) {
- this.arrays = arrays;
- this.offsets = new int[arrays.length];
- final DataType dataType = arrays[0].getDataType();
- final SampleSystem type = arrays[0].getSampleSystem();
- for (int i = 1; i < arrays.length; i++) {
- offsets[i] = offsets[i-1] + arrays[i-1].getLength();
-
- if (dataType != arrays[i].getDataType()) {
- throw new IllegalArgumentException("Arrays must have the same data type");
- }
- if (!type.equals(arrays[i].getSampleSystem())) {
- throw new IllegalArgumentException("Arrays must have the same crs");
- }
- }
- this.length = offsets[offsets.length - 1] + arrays[arrays.length - 1].getLength();
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return arrays[0].getSampleSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- for (TupleArray ta : arrays) {
- ta.setSampleSystem(type);
- }
- }
-
- @Override
- public boolean isEmpty() {
- return length == 0;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return arrays[0].getCoordinateReferenceSystem();
- }
-
- @Override
- public int getDimension() {
- return arrays[0].getDimension();
- }
-
- @Override
- public long getSampleCount() {
- return arrays[0].getSampleCount();
- }
-
- @Override
- public DataType getDataType() {
- return arrays[0].getDataType();
- }
-
- @Override
- public Tuple get(int index) {
- final int taidx = arrayIndex(index);
- return arrays[taidx].get(index - offsets[taidx]);
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int taidx = arrayIndex(index);
- arrays[taidx].get(index - offsets[taidx], buffer);
- }
-
- @Override
- public void set(int index, Tuple buffer) {
- final int taidx = arrayIndex(index);
- arrays[taidx].set(index - offsets[taidx], buffer);
- }
-
- @Override
- public void transform(MathTransform trs) throws TransformException {
- for (TupleArray ta : arrays) {
- ta.transform(trs);
- }
- }
-
- @Override
- public void transform(CoordinateReferenceSystem crs) throws FactoryException, TransformException {
- for (TupleArray ta : arrays) {
- ta.transform(crs);
- }
- }
-
- @Override
- public TupleArray copy() {
- return resize(length);
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new Cursor();
- }
-
- private int arrayIndex(int tupleIndex) {
- ArgumentChecks.ensureBetween("Tuple index", 0, length - 1, tupleIndex);
- int p = Arrays.binarySearch(offsets, tupleIndex);
- if (p >= 0) {
- return p;
- } else {
- return -p - 2;
- }
- }
-
- private class Cursor implements TupleArrayCursor {
-
- private int coordinate = -1;
- private final TupleArrayCursor[] cursors = new TupleArrayCursor[arrays.length];
-
- @Override
- public Tuple samples() {
- final int taidx = arrayIndex(coordinate);
- if (cursors[taidx] == null) {
- cursors[taidx] = arrays[taidx].cursor();
- }
- cursors[taidx].moveTo(coordinate - offsets[taidx]);
- return cursors[taidx].samples();
- }
-
- @Override
- public int coordinate() {
- return coordinate;
- }
-
- @Override
- public void moveTo(int coordinate) {
- if (coordinate<0 || coordinate >= length) {
- throw new ArrayIndexOutOfBoundsException("Invalid coordinate " + coordinate + ", outside of data range [0," + length + "]. ");
- }
- this.coordinate = coordinate;
- }
-
- @Override
- public boolean next() {
- if (coordinate + 1 >= length) {
- return false;
- } else {
- this.coordinate++;
- return true;
- }
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursor.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursor.java
deleted file mode 100644
index 4fb57ba..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- * A cursor allows to iterate over a tuple array without copying datas.
- * Any change made to the cursor samples are made in the tuple array.
- *
- * API copied from Unlicense.science
- */
-public interface TupleArrayCursor {
-
- Tuple samples();
-
- /**
- * Get the current tuple coordinate.
- * @return Tuple, returns always the same container
- */
- int coordinate();
-
- /**
- * Move cursor to given coordinate.
- *
- * @param coordinate
- */
- void moveTo(int coordinate);
-
- /**
- * Move to next tuple.
- *
- * @return false if no more tuple
- */
- boolean next();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursorUnmodifiable.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursorUnmodifiable.java
deleted file mode 100644
index 381210b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayCursorUnmodifiable.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Unmodifiable tuple array cursor.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class TupleArrayCursorUnmodifiable implements TupleArrayCursor {
-
- private final TupleArrayCursor parent;
- private Tuple previous;
- private Tuple t;
-
- public TupleArrayCursorUnmodifiable(TupleArrayCursor parent) {
- ArgumentChecks.ensureNonNull("parent", parent);
- this.parent = parent;
- }
-
- @Override
- public Tuple samples() {
- Tuple cdt = parent.samples();
- if (t == null || previous != cdt) {
- t = new TupleUnmodifiable(cdt);
- previous = cdt;
- }
- return t;
- }
-
- @Override
- public int coordinate() {
- return parent.coordinate();
- }
-
- @Override
- public void moveTo(int coordinate) {
- parent.moveTo(coordinate);
- }
-
- @Override
- public boolean next() {
- return parent.next();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayND.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayND.java
deleted file mode 100644
index 1714b43..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayND.java
+++ /dev/null
@@ -1,1581 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Arrays;
-import java.util.List;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class TupleArrayND extends AbstractTupleArray {
-
- static final class Byte extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final byte[] array;
-
- Byte(SampleSystem type, byte[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, array[offset+i]);
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (byte) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- byte temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
- @Override
- public byte[] toArrayByte() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset * dimension, (offset+nbTuple) * dimension);
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final byte[] arr = array.toArrayByte(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public Byte resize(int newSize) {
- return new Byte(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Byte copy() {
- return new Byte(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (byte) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNb{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
- }
-
- static final class UByte extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final byte[] array;
-
- UByte(SampleSystem type, byte[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, array[offset+i] & 0xFF);
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (byte) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- byte temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public byte[] toArrayByte() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) (array[k] & 0xFF);
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFF;
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFF;
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFF;
- }
- return result;
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final byte[] arr = array.toArrayByte(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public UByte resize(int newSize) {
- return new UByte(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public UByte copy() {
- return new UByte(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex] & 0xFF;
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (byte) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNub{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
- }
-
- static final class Short extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final short[] array;
-
- Short(SampleSystem type, short[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, array[offset+i]);
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (short) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- short temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public short[] toArrayShort() {
- return array.clone();
- }
-
- @Override
- public double[] toArrayDouble() {
- final double[] result = new double[array.length];
- for (int i = 0; i < array.length; i++) {
- result[i] = (double) array[i];
- }
- return result;
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final short[] arr = array.toArrayShort(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public Short resize(int newSize) {
- return new Short(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Short copy() {
- return new Short(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (short) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNs{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
- }
-
- static final class UShort extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final short[] array;
-
- UShort(SampleSystem type, short[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, java.lang.Short.toUnsignedInt(array[offset+i]));
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (short) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- short temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public short[] toArrayShort() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFFFF;
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFFFF;
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFFFF;
- }
- return result;
- }
-
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final short[] arr = array.toArrayShort(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public UShort resize(int newSize) {
- return new UShort(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public UShort copy() {
- return new UShort(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return java.lang.Short.toUnsignedInt(array[tupleIndex*dimension + sampleIndex]);
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (short) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNus{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
- }
-
- static final class Int extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final int[] array;
-
- Int(SampleSystem type, int[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, array[offset+i]);
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (int) tuple.get(i);
- }
- }
-
- @Override
- public int[] toArrayInt() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) array[k];
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- int temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final int[] arr = array.toArrayInt(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public Int resize(int newSize) {
- return new Int(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Int copy() {
- return new Int(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (int) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNi{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
- }
-
- static final class UInt extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final int[] array;
-
- UInt(SampleSystem type, int[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- UInt(SampleSystem type, List<Integer> array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array.stream().mapToInt(Integer::intValue).toArray();
- if (array.size() % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.size());
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, Integer.toUnsignedLong(array[offset+i]));
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (int) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- int temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public int[] toArrayInt() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) (array[k] & 0xFFFFFFFFl);
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) (array[k] & 0xFFFFFFFFl);
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFFFFFFFFl;
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k] & 0xFFFFFFFFl;
- }
- return result;
- }
-
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final int[] arr = array.toArrayInt(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public UInt resize(int newSize) {
- return new UInt(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public UInt copy() {
- return new UInt(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return Integer.toUnsignedLong(array[tupleIndex*dimension + sampleIndex]);
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (int) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNui{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
- }
-
- static final class Long extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final long[] array;
-
- Long(SampleSystem type, long[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- buffer.set(i, array[offset+i]);
- }
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- final int offset = index * dimension;
- for (int i=0;i<dimension;i++) {
- array[offset+i] = (int) tuple.get(i);
- }
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- long temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) array[k];
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (int) array[k];
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public Long resize(int newSize) {
- return new Long(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Long copy() {
- return new Long(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (int) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNl{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
- }
-
- static final class Float extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final float[] array;
-
- Float(SampleSystem type, float[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public Tuple get(int index) {
- final Vector buffer = Vectors.create(type, DataType.FLOAT);
- return buffer.set(array, index * dimension);
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- if (dimension != buffer.getDimension()) {
- throw new IllegalArgumentException("TupleArray and Tuple must have the same number of dimensions");
- }
- buffer.set(array, index * dimension);
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- if (dimension != tuple.getDimension()) {
- throw new IllegalArgumentException("TupleArray and Tuple must have the same number of dimensions");
- }
- tuple.toArrayFloat(array, index * dimension);
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- float temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public float[] toArrayFloat() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) array[k];
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (int) array[k];
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final double[] result = new double[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = array[k];
- }
- return result;
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final float[] arr = array.toArrayFloat(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public Float resize(int newSize) {
- return new Float(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Float copy() {
- return new Float(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = (float) value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNf{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
- }
-
- static final class Double extends TupleArrayND {
-
- private SampleSystem type;
- private final int dimension;
- private final double[] array;
-
- Double(SampleSystem type, double[] array) {
- this.type = type;
- this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not compatible, expected n*" + dimension + " but size is " + array.length);
- }
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
- @Override
- public int getLength() {
- return array.length / dimension;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public Tuple get(int index) {
- final Vector buffer = Vectors.create(type, DataType.DOUBLE);
- return buffer.set(array, index * dimension);
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- if (dimension != buffer.getDimension()) {
- throw new IllegalArgumentException("TupleArray and Tuple must have the same number of dimensions");
- }
- buffer.set(array, index * dimension);
- }
-
- @Override
- public void set(int index, Tuple tuple) {
- if (dimension != tuple.getDimension()) {
- throw new IllegalArgumentException("TupleArray and Tuple must have the same number of dimensions");
- }
- tuple.toArrayDouble(array, index * dimension);
- }
-
- @Override
- public void swap(int i, int j) {
- int oi = i*dimension + dimension;
- int oj = j*dimension + dimension;
- double temp;
- switch(dimension) {
- default: for (int k=dimension; k > 5; k--) {
- oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- case 5 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 4 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 3 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 2 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- case 1 : oi--; oj--; temp = array[oi]; array[oi] = array[oj]; array[oj] = temp;
- }
- }
-
- @Override
- public double[] toArrayDouble() {
- return array.clone();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final byte[] result = new byte[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (byte) array[k];
- }
- return result;
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final short[] result = new short[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (short) array[k];
- }
- return result;
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final int[] result = new int[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (int) array[k];
- }
- return result;
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- final int length = nbTuple * dimension;
- final float[] result = new float[length];
- for (int i = 0, k = offset * dimension; i < length; i++, k++) {
- result[i] = (float) array[k];
- }
- return result;
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- return Arrays.copyOfRange(array, offset*dimension, (offset+nbTuple)*dimension);
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- ArgumentChecks.ensureCountBetween("dimension", true, dimension, dimension, array.getDimension());
- final double[] arr = array.toArrayDouble(offset, nb);
- System.arraycopy(arr, 0, this.array, index*dimension, nb*dimension);
- }
-
- @Override
- public Double resize(int newSize) {
- return new Double(type, Arrays.copyOf(array, newSize*dimension));
- }
-
- @Override
- public Double copy() {
- return new Double(type, array.clone());
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new AbstractCursor(this) {
- @Override
- public double get(int tupleIndex, int sampleIndex) {
- return array[tupleIndex*dimension + sampleIndex];
- }
-
- @Override
- public void set(int tupleIndex, int sampleIndex, double value) {
- array[tupleIndex*dimension + sampleIndex] = value;
- }
- };
- }
-
- @Override
- public String toString() {
- return "TupleArrayNd{" + "dimension=" + dimension + ", tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArraySpliterator.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArraySpliterator.java
deleted file mode 100644
index a6d3165..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArraySpliterator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Spliterator;
-import java.util.function.Consumer;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-final class TupleArraySpliterator implements Spliterator<Tuple>{
-
- private final TupleArray array;
- /**
- * Inclusive
- */
- private int rangeStart;
- /**
- * Exclusive
- */
- private int rangeEnd;
-
- private TupleArrayCursor cursor;
-
- public TupleArraySpliterator(TupleArray array) {
- this(array,0, array.getLength());
- }
-
- public TupleArraySpliterator(TupleArray array, int rangeStart, int rangeEnd) {
- if (rangeEnd <= rangeStart) {
- throw new IllegalArgumentException("Range end must be superior to range start");
- }
- this.array = array;
- this.rangeStart = rangeStart;
- this.rangeEnd = rangeEnd;
- }
-
- @Override
- public boolean tryAdvance(Consumer<? super Tuple> action) {
- if (rangeStart >= rangeEnd) return false;
- if (cursor == null) cursor = array.cursor();
- cursor.moveTo(rangeStart);
- rangeStart++;
- action.accept(cursor.samples());
- return true;
- }
-
- @Override
- public Spliterator<Tuple> trySplit() {
- int remaining = rangeEnd - rangeStart;
- if (remaining < 5) {
- //too few elements to split it
- return null;
- }
-
- final int half = rangeStart + remaining / 2;
- final TupleArraySpliterator split = new TupleArraySpliterator(array, half, rangeEnd);
- rangeEnd = half;
- return split;
- }
-
- @Override
- public long estimateSize() {
- return rangeEnd - rangeStart;
- }
-
- @Override
- public int characteristics() {
- return SIZED | NONNULL;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayUnmodifiable.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayUnmodifiable.java
deleted file mode 100644
index 1e26217..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrayUnmodifiable.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Unmodifiable tuple array.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class TupleArrayUnmodifiable extends AbstractTupleArray {
-
- private final TupleArray parent;
-
- public TupleArrayUnmodifiable(TupleArray parent) {
- ArgumentChecks.ensureNonNull("parent", parent);
- this.parent = parent;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return parent.getSampleSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public boolean isEmpty() {
- return parent.isEmpty();
- }
-
- @Override
- public int getLength() {
- return parent.getLength();
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return parent.getCoordinateReferenceSystem();
- }
-
- @Override
- public int getDimension() {
- return parent.getDimension();
- }
-
- @Override
- public long getSampleCount() {
- return parent.getSampleCount();
- }
-
- @Override
- public DataType getDataType() {
- return parent.getDataType();
- }
-
- @Override
- public Tuple get(int index) {
- return parent.get(index);
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- parent.get(index, buffer);
- }
-
- @Override
- public void set(int index, Tuple buffer) {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public void set(int index, TupleArray array, int offset, int nb) {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public byte[] toArrayByte() {
- return parent.toArrayByte();
- }
-
- @Override
- public short[] toArrayShort() {
- return parent.toArrayShort();
- }
-
- @Override
- public int[] toArrayInt() {
- return parent.toArrayInt();
- }
-
- @Override
- public float[] toArrayFloat() {
- return parent.toArrayFloat();
- }
-
- @Override
- public double[] toArrayDouble() {
- return parent.toArrayDouble();
- }
-
- @Override
- public byte[] toArrayByte(int offset, int nbTuple) {
- return parent.toArrayByte(offset, nbTuple);
- }
-
- @Override
- public short[] toArrayShort(int offset, int nbTuple) {
- return parent.toArrayShort(offset, nbTuple);
- }
-
- @Override
- public int[] toArrayInt(int offset, int nbTuple) {
- return parent.toArrayInt(offset, nbTuple);
- }
-
- @Override
- public float[] toArrayFloat(int offset, int nbTuple) {
- return parent.toArrayFloat(offset, nbTuple);
- }
-
- @Override
- public double[] toArrayDouble(int offset, int nbTuple) {
- return parent.toArrayDouble(offset, nbTuple);
- }
-
- @Override
- public void transform(MathTransform trs) throws TransformException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public void transform(CoordinateReferenceSystem crs) throws FactoryException, TransformException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public TupleArray resize(int newSize) {
- return parent.resize(newSize);
- }
-
- @Override
- public TupleArray copy() {
- return parent.copy();
- }
-
- @Override
- public TupleArrayCursor cursor() {
- return new TupleArrayCursorUnmodifiable(parent.cursor());
- }
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrays.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrays.java
deleted file mode 100644
index 2860da8..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleArrays.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.RecursiveAction;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.coverage.SampleDimension;
-import org.apache.sis.geometries.BBox;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometry.GeneralDirectPosition;
-import org.apache.sis.measure.NumberRange;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Static;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class TupleArrays extends Static {
-
- public static TupleArray of(List<? extends Tuple> vectors, int dimension, DataType dataType) {
- return of(vectors, SampleSystem.ofSize(dimension), dataType);
- }
-
- public static TupleArray of(List<? extends Tuple> vectors, SampleSystem type, DataType dataType) {
- final int dimension = type.getSize();
- final TupleArray array;
- switch (dataType) {
- case BYTE : array = new TupleArrayND.Byte(type, new byte[vectors.size() * dimension]); break;
- case UBYTE : array = new TupleArrayND.UByte(type, new byte[vectors.size() * dimension]); break;
- case SHORT : array = new TupleArrayND.Short(type, new short[vectors.size() * dimension]); break;
- case USHORT : array = new TupleArrayND.UShort(type, new short[vectors.size() * dimension]); break;
- case INT : array = new TupleArrayND.Int(type, new int[vectors.size() * dimension]); break;
- case UINT : array = new TupleArrayND.UInt(type, new int[vectors.size() * dimension]); break;
- case LONG : array = new TupleArrayND.Long(type, new long[vectors.size() * dimension]); break;
- case FLOAT : array = new TupleArrayND.Float(type, new float[vectors.size() * dimension]); break;
- case DOUBLE : array = new TupleArrayND.Double(type, new double[vectors.size() * dimension]); break;
- default : throw new IllegalArgumentException("Unexpected data type " + dataType);
- }
-
- for (int i = 0, n = vectors.size(); i < n; i++) {
- array.set(i, vectors.get(i));
- }
-
- return array;
- }
-
- public static TupleArray of(SampleSystem type, DataType dataType, int nbTuple) {
- final int dimension = type.getSize();
- final int size = nbTuple * dimension;
- final TupleArray array;
- switch (dataType) {
- case BYTE : array = new TupleArrayND.Byte(type, new byte[size]); break;
- case UBYTE : array = new TupleArrayND.UByte(type, new byte[size]); break;
- case SHORT : array = new TupleArrayND.Short(type, new short[size]); break;
- case USHORT : array = new TupleArrayND.UShort(type, new short[size]); break;
- case INT : array = new TupleArrayND.Int(type, new int[size]); break;
- case UINT : array = new TupleArrayND.UInt(type, new int[size]); break;
- case LONG : array = new TupleArrayND.Long(type, new long[size]); break;
- case FLOAT : array = new TupleArrayND.Float(type, new float[size]); break;
- case DOUBLE : array = new TupleArrayND.Double(type, new double[size]); break;
- default : throw new IllegalArgumentException("Unexpected data type " + dataType);
- }
- return array;
- }
-
- public static TupleArray of(int dimension, byte ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(int dimension, short ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(int dimension, int ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(int dimension, long ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(int dimension, float ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(int dimension, double ... values) {
- return of(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray ofUnsigned(int dimension, byte ... values) {
- return ofUnsigned(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray ofUnsigned(int dimension, short ... values) {
- return ofUnsigned(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray ofUnsigned(int dimension, int ... values) {
- return ofUnsigned(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray ofUnsigned(int dimension, List<Integer> values) {
- return ofUnsigned(SampleSystem.ofSize(dimension), values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, byte ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, byte ... values) {
- return new TupleArrayND.Byte(type, values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, int ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, int ... values) {
- return new TupleArrayND.Int(type, values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, short ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, short ... values) {
- return new TupleArrayND.Short(type, values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, long ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, long ... values) {
- return new TupleArrayND.Long(type, values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, float ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, float ... values) {
- return new TupleArrayND.Float(type, values);
- }
-
- public static TupleArray of(CoordinateReferenceSystem crs, double ... values) {
- return of(SampleSystem.of(crs), values);
- }
-
- public static TupleArray of(SampleSystem type, double ... values) {
- return new TupleArrayND.Double(type, values);
- }
-
- public static TupleArray ofUnsigned(SampleSystem type, byte ... values) {
- return new TupleArrayND.UByte(type, values);
- }
-
- public static TupleArray ofUnsigned(SampleSystem type, short ... values) {
- return new TupleArrayND.UShort(type, values);
- }
-
- public static TupleArray ofUnsigned(SampleSystem type, int ... values) {
- return new TupleArrayND.UInt(type, values);
- }
-
- public static TupleArray ofUnsigned(SampleSystem type, List<Integer> values) {
- return new TupleArrayND.UInt(type, values);
- }
-
- /**
- * Compute the range of the given array.
- *
- * @param array to compute bbox from
- * @return vectors with the same crs as the array, lower and upper bounds.
- */
- public static BBox computeRange(TupleArray array) {
- final CoordinateReferenceSystem crs = array.getCoordinateReferenceSystem();
- final BBox bbox = crs == null ? new BBox(array.getDimension()) : new BBox(crs);
- bbox.setToNaN();
- boolean first = true;
- final TupleArrayCursor cursor = array.cursor();
- while (cursor.next()) {
- final Tuple samples = cursor.samples();
- if (first) {
- bbox.getLower().set(samples);
- bbox.getUpper().set(samples);
- first = false;
- } else {
- bbox.add(samples);
- }
- }
- return bbox;
- }
-
- /**
- * Try to compress array to a smaller data type.
- * The algorithm works for long, int or short types only.
- * The minimum and maximum values are extracted and if a small data type exist
- * values will be repacked in a new array of this type.
- *
- * @param array, not null
- * @return same or repacked array
- */
- public static TupleArray packIntegerDataType(TupleArray array) {
- final DataType dataType = array.getDataType();
-
- if ( DataType.LONG.equals(dataType)
- || DataType.INT.equals(dataType)
- || DataType.UINT.equals(dataType)
- || DataType.SHORT.equals(dataType)
- || DataType.USHORT.equals(dataType)) {
- DataType dt;
- if (array.isEmpty()) {
- dt = DataType.UBYTE;
- } else {
- BBox range = computeRange(array);
- dt = bestIntegerDataType(range);
- }
- if (dataType != dt) {
- //copy to a more efficiant data type
- TupleArray cp = TupleArrays.of(array.getSampleSystem(), dt, array.getLength());
- cp.set(0, array, 0, array.getLength());
- array = cp;
- }
- }
- return array;
- }
-
- /**
- * Create an unmodifiable view of the given array.
- *
- * @param array not null
- * @return unmodifiable view of the array.
- */
- public static TupleArray unmodifiable(TupleArray array) {
- return new TupleArrayUnmodifiable(array);
- }
-
- /**
- * Create an unmodifiable view of the given cursor.
- *
- * @param cursor not null
- * @return unmodifiable view of the array cursor.
- */
- public static TupleArrayCursor unmodifiable(TupleArrayCursor cursor) {
- return new TupleArrayCursorUnmodifiable(cursor);
- }
-
- /**
- * Create an concatenated view of the given arrays.
- *
- * @param arrays not null
- * @return unmodifiable view of the array cursor.
- */
- public static TupleArray concatenate(TupleArray ... arrays) {
- return new TupleArrayConcatenated(arrays);
- }
-
- /**
- * Group each tuple in given arrays.
- * Returns an array of same length and sum of all dimensions.
- *
- * @param arrays not null or empty
- * @return never null, if arrays size is one, then a copy is returned
- */
- public static TupleArray group(TupleArray ... arrays) throws FactoryException {
- ArgumentChecks.ensureNonEmpty("arrays", arrays);
- final int length = arrays[0].getLength();
- if (length == 1) return arrays[0].copy();
- final DataType dataType = arrays[0].getDataType();
- final CoordinateReferenceSystem[] crs = new CoordinateReferenceSystem[arrays.length];
- final List<SampleDimension> allDims = new ArrayList<>();
- crs[0] = arrays[0].getCoordinateReferenceSystem();
- boolean undefined = (crs[0] == null || Geometries.isUndefined(crs[0]));
- allDims.addAll(arrays[0].getSampleSystem().getSampleDimensions());
- for (int i = 1; i <arrays.length; i++) {
- if (arrays[i].getLength() != length) {
- throw new IllegalArgumentException("All arrays must have the same length");
- }
- if (arrays[i].getDataType() != dataType) {
- throw new IllegalArgumentException("All arrays must have the same data type");
- }
- crs[i] = arrays[i].getCoordinateReferenceSystem();
- undefined |= (crs[i] == null || Geometries.isUndefined(crs[i]));
- allDims.addAll(arrays[i].getSampleSystem().getSampleDimensions());
- }
-
- final TupleArray result;
- if (undefined) {
- SampleSystem sampleSystem = new SampleSystem(dataType, allDims.toArray(new SampleDimension[0]));
- result = TupleArrays.of(sampleSystem, dataType, length);
- } else {
- result = TupleArrays.of(SampleSystem.of(CRS.compound(crs)), dataType, length);
- }
-
- if (length == 0) return result;
-
- final TupleArrayCursor resultCursor = result.cursor();
- int offset = 0;
- for (int a = 0; a < arrays.length; a++) {
- final int dim = arrays[a].getDimension();
- TupleArrayCursor cursor = arrays[a].cursor();
- cursor.moveTo(0);
- resultCursor.moveTo(0);
- for (int i = 0; i < length; i++, cursor.next(), resultCursor.next()) {
- Tuple source = cursor.samples();
- Tuple target = resultCursor.samples();
- for (int s = 0; s < dim; s++) {
- target.set(s+offset, source.get(s));
- }
- }
- offset += dim;
- }
- return result;
- }
-
- /**
- * Create a view of only the given selected index tuples in the array.
- */
- public static TupleArray subset(TupleArray array, int ... selection) {
- return new Subset(array, selection);
- }
-
- /**
- * View TupleArray as a list.
- */
- public static List<Tuple> asList(TupleArray array) {
- return new AbstractList<Tuple>() {
- @Override
- public Tuple get(int index) {
- return array.get(index);
- }
-
- @Override
- public int size() {
- return array.getLength();
- }
- };
- }
-
- /**
- * Shuffle tuples in the array
- *
- * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
- *
- * @param array to shuffle
- */
- public static void shuffle(TupleArray array) {
- final Random random = new Random();
- for (int i = array.getLength() - 1; i >= 1; i--) {
- array.swap(i, random.nextInt(i));
- }
- }
-
- /**
- * Sort tuple array, in place, using quick sort algorithm.
- * Inspired by : https://www.geeksforgeeks.org/quick-sort-algorithm/
- */
- public static void quickSort(TupleArray array, Comparator<Tuple> comparator) {
- quickSort(array, array.cursor(), array.cursor(), comparator, 0, array.getLength() - 1);
- }
-
- /**
- * Sort tuple array, in place, using quick sort algorithm.
- * Inspired by : https://www.geeksforgeeks.org/quick-sort-algorithm/
- *
- * @param array to sort
- * @param comparator not null, to compare tuples
- * @param low inclusive
- * @param high inclusive
- */
- public static void quickSort(TupleArray array, Comparator<Tuple> comparator, int low, int high) {
- quickSort(array, array.cursor(), array.cursor(), comparator, low, high);
- }
-
- private static int partition(TupleArray array, TupleArrayCursor cursor1, TupleArrayCursor cursor2, Comparator<Tuple> comparator, int low, int high) {
- //pick the middle point as pivot, in case of already sorted arrays
- //it speeds up the operation and prevents the quicksort to make a java.lang.StackOverflowError
- array.swap((low+high)/2, high);
- cursor1.moveTo(high);
- final Tuple pivot = cursor1.samples();
- int i = low - 1;
- for (int j = low; j <= high - 1; j++) {
- cursor2.moveTo(j);
- if (comparator.compare(cursor2.samples(),pivot) < 0) {
- i++;
- if (i != j) array.swap(i, j);
- }
- }
- array.swap(i + 1, high);
- return i + 1;
- }
-
- private static void quickSort(TupleArray array, TupleArrayCursor cursor1, TupleArrayCursor cursor2, Comparator<Tuple> comparator, int low, int high) {
-
- if (low < high) {
- final int pi = partition(array, cursor1, cursor2, comparator, low, high);
- quickSort(array, cursor1, cursor2, comparator, low, pi - 1);
- quickSort(array, cursor1, cursor2, comparator, pi + 1, high);
- }
- }
-
- /**
- * Create a ForkJoinTask to sort very large arrays using a custom a ForkJoinPool.
- * The user is responsible for submitting the task to a pool.
- *
- * @param array to sort
- * @param comparator not null, to compare tuples
- * @param low inclusive
- * @param high inclusive
- * @return RecursiveAction to sort the array.
- * This action returns quickly, but forked tasks continue to be submitted to the pool
- * Therefor awaiting pool completion is necessary to ensure the operation is finished.
- */
- public static RecursiveAction quickSortAction(TupleArray array, Comparator<Tuple> comparator, int low, int high) {
- return new QuickSortAction(array, array.cursor(), array.cursor(), comparator, low, high);
- }
-
- private static final class QuickSortAction extends RecursiveAction {
-
- private final TupleArray array;
- private final TupleArrayCursor cursor1;
- private final TupleArrayCursor cursor2;
- private final Comparator<Tuple> comparator;
- private final int low;
- private final int high;
-
- public QuickSortAction(TupleArray array, TupleArrayCursor cursor1, TupleArrayCursor cursor2, Comparator<Tuple> comparator, int low, int high) {
- this.array = array;
- this.cursor1 = cursor1;
- this.cursor2 = cursor2;
- this.comparator = comparator;
- this.low = low;
- this.high = high;
- }
-
- @Override
- protected void compute() {
- if (low < high) {
- final int pi = partition(array, cursor1, cursor2, comparator, low, high);
- QuickSortAction qsa1 = new QuickSortAction(array, cursor1, cursor2, comparator, low, pi - 1);
- qsa1.fork();
- QuickSortAction qsa2 = new QuickSortAction(array, array.cursor(), array.cursor(), comparator, pi + 1, high);
- qsa2.fork();
-
- //we do not use .join() because is causes stack over flow
- }
- }
-
- }
-
-
- private static DataType bestIntegerDataType(BBox box) {
- double min = box.getMinimum(0);
- double max = box.getMaximum(0);
- for (int i = 1, n = box.getDimension(); i < n; i++) {
- min = Math.min(min, box.getMinimum(i));
- max = Math.max(max, box.getMaximum(i));
- }
- final NumberRange range = NumberRange.create(min, true, max, true);
- return DataType.forRange(range, true);
- }
-
- private TupleArrays(){}
-
- private static class Subset extends AbstractTupleArray {
-
- private final TupleArray base;
- private final int[] index;
-
- public Subset(TupleArray base, int[] index) {
- this.base = base;
- this.index = index;
- }
-
- @Override
- public int getLength() {
- return index.length;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return base.getSampleSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- base.setSampleSystem(type);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return base.getCoordinateReferenceSystem();
- }
-
- @Override
- public int getDimension() {
- return base.getDimension();
- }
-
- @Override
- public DataType getDataType() {
- return base.getDataType();
- }
-
- @Override
- public void get(int index, Tuple buffer) {
- base.get(this.index[index], buffer);
- }
-
- @Override
- public void set(int index, Tuple buffer) {
- base.set(this.index[index], buffer);
- }
-
- @Override
- public TupleArrayCursor cursor() {
- final TupleArrayCursor bc = base.cursor();
- return new TupleArrayCursor() {
- private int coordinate = -1;
- @Override
- public Tuple<?> samples() {
- bc.moveTo(index[coordinate]);
- return bc.samples();
- }
-
- @Override
- public int coordinate() {
- return coordinate;
- }
-
- @Override
- public void moveTo(int coordinate) {
- this.coordinate = coordinate;
- }
-
- @Override
- public boolean next() {
- if (coordinate >= index.length-1) return false;
- coordinate++;
- return true;
- }
- };
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleUnmodifiable.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleUnmodifiable.java
deleted file mode 100644
index 299dc3b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/TupleUnmodifiable.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Unmodifiable tuple.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class TupleUnmodifiable extends AbstractTuple {
-
- private final Tuple parent;
-
- public TupleUnmodifiable(Tuple parent) {
- super(parent.getSampleSystem());
- ArgumentChecks.ensureNonNull("parent", parent);
- this.parent = parent;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return parent.getSampleSystem();
- }
-
- @Override
- public int getDimension() {
- return parent.getDimension();
- }
-
- @Override
- public DataType getDataType() {
- return parent.getDataType();
- }
-
- @Override
- public double get(int indice) throws IndexOutOfBoundsException {
- return parent.get(indice);
- }
-
- @Override
- public void set(int indice, double value) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(DirectPosition values) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(double[] values) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(double[] values, int offset) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(float[] values) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(float[] values, int offset) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple set(Tuple values) throws IndexOutOfBoundsException {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public Tuple setAll(double value) {
- throw new UnsupportedOperationException("This implementation is unmodifiable");
- }
-
- @Override
- public byte[] toArrayByte() {
- return parent.toArrayByte();
- }
-
- @Override
- public short[] toArrayShort() {
- return parent.toArrayShort();
- }
-
- @Override
- public int[] toArrayInt() {
- return parent.toArrayInt();
- }
-
- @Override
- public float[] toArrayFloat() {
- return parent.toArrayFloat();
- }
-
- @Override
- public double[] toArrayDouble() {
- return parent.toArrayDouble();
- }
-
- @Override
- public void toArrayByte(byte[] buffer, int offset) {
- parent.toArrayByte(buffer, offset);
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- parent.toArrayShort(buffer, offset);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- parent.toArrayInt(buffer, offset);
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- parent.toArrayFloat(buffer, offset);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- parent.toArrayDouble(buffer, offset);
- }
-
- @Override
- public Tuple copy() {
- return parent.copy();
- }
-
- @Override
- public boolean isFinite() {
- return parent.isFinite();
- }
-
- @Override
- public boolean isAll(double value) {
- return parent.isAll(value);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return parent.getCoordinateReferenceSystem();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector.java
deleted file mode 100644
index b096193..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- * A vector is a subclass of tuple with arithmetic operations defined.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Vector<T extends Vector<T>> extends Tuple<T> {
-
- /**
- * @return vector length
- */
- default double length() {
- return Vectors.length(toArrayDouble());
- }
-
- /**
- * @return vector squere length
- */
- default double lengthSquare() {
- return Vectors.lengthSquare(toArrayDouble());
- }
-
- /**
- * Normalize this vector.
- * @return this vector
- */
- default T normalize() {
- set(Vectors.normalize(toArrayDouble()));
- return (T) this;
- }
-
- /**
- * Normalize this vector.
- * @param result where to store the result
- * @return result of the operation, this vector is unchanged
- */
- default <R extends Tuple<?>> R normalize(R result) {
- if (result == null) result = (R) this.copy();
- result.set(this);
- Vectors.castOrWrap(result).normalize();
- return result;
- }
-
- /**
- * Add other vector values to this vector.
- * @param other
- * @return this vector
- */
- default T add(Tuple<?> other) {
- set( Vectors.add(toArrayDouble(), other.toArrayDouble()));
- return (T) this;
- }
-
- /**
- * Subtract other vector values to this vector.
- * @param other
- * @return this vector
- */
- default T subtract(Tuple<?> other) {
- set( Vectors.subtract(toArrayDouble(), other.toArrayDouble()));
- return (T) this;
- }
-
- /**
- * Scale vector by given value.
- *
- * @param scale scaling factor
- * @return this vector
- */
- default T scale(double scale) {
- set( Vectors.scale(toArrayDouble(), scale));
- return (T) this;
- }
-
- /**
- * Cross product.
- *
- * @param other
- * @return cross product result
- */
- default T cross(Tuple<?> other) {
- double[] v1 = toArrayDouble();
- double[] v2 = other.toArrayDouble();
- double[] buffer = new double[v1.length];
- Vectors.cross(v1, v2, buffer);
- Vector<?> res = Vectors.createDouble(buffer.length);
- res.set(buffer);
- return (T) res;
- }
-
- /**
- * Dot product.
- *
- * @param other
- * @return dot product result
- */
- default double dot(Tuple<?> other) {
- double dot = 0;
- for (int i=0,n=getDimension();i<n;i++){
- dot += get(i) * other.get(i);
- }
- return dot;
- }
-
- /**
- * Increase size of the tuple by one value.
- * Vector CRS will be lost.
- *
- * @param d last dimension value
- * @return Vector
- */
- default Vector<?> extend(double d) {
- final int dim = getDimension();
- final Vector v = Vectors.create(dim+1, getDataType());
- for (int i = 0; i < dim; i++) {
- v.set(i, get(i));
- }
- v.set(dim, d);
- return v;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector1D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector1D.java
deleted file mode 100644
index b6f049a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector1D.java
+++ /dev/null
@@ -1,1438 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Vector1D<T extends Vector1D<T>> extends AbstractTuple<T> implements Vector<T> {
-
- public Vector1D() {
- super(1);
- }
-
- protected Vector1D(SampleSystem type) {
- super(type);
- }
-
- @Override
- public final int getDimension() {
- return 1;
- }
-
- public static class Byte extends Vector1D<Byte> {
-
- public byte x;
-
- public Byte() {
- }
-
- public Byte(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Byte(SampleSystem type, byte x) {
- this(type);
- this.x = x;
- }
-
- public Byte(byte x) {
- this.x = x;
- }
-
- public Byte(byte[] array) {
- this.x = array[0];
- }
-
- public Byte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Byte(byte x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Byte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Byte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- return this;
- }
-
- @Override
- public Byte set(double[] values, int offset) {
- x = (byte) values[ offset];
- return this;
- }
-
- @Override
- public Byte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- return this;
- }
-
- @Override
- public Byte set(float[] values, int offset) {
- x = (byte) values[offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Byte copy() {
- return new Byte(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UByte extends Vector1D<UByte> {
-
- public byte x;
-
- public UByte() {
- }
-
- public UByte(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public UByte(SampleSystem type, byte x) {
- this(type);
- this.x = x;
- }
-
- public UByte(byte x) {
- this.x = x;
- }
-
- public UByte(byte[] array) {
- this.x = array[0];
- }
-
- public UByte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UByte(byte x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UByte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x & 0xFF;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UByte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- return this;
- }
-
- @Override
- public UByte set(double[] values, int offset) {
- x = (byte) values[ offset];
- return this;
- }
-
- @Override
- public UByte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- return this;
- }
-
- @Override
- public UByte set(float[] values, int offset) {
- x = (byte) values[offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x & 0xFF};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x & 0xFF};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x & 0xFF};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) (x & 0xFF);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = x & 0xFF;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x & 0xFF;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x & 0xFF;
- }
-
- @Override
- public UByte copy() {
- return new UByte(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Short extends Vector1D<Short> {
-
- public short x;
-
- public Short() {
- }
-
- public Short(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Short(SampleSystem type, short x) {
- this(type);
- this.x = x;
- }
-
- public Short(short x) {
- this.x = x;
- }
-
- public Short(short[] array) {
- this.x = array[0];
- }
-
- public Short(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Short(short x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Short(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Short set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- return this;
- }
-
- @Override
- public Short set(double[] values, int offset) {
- x = (short) values[ offset];
- return this;
- }
-
- @Override
- public Short set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- return this;
- }
-
- @Override
- public Short set(float[] values, int offset) {
- x = (short) values[ offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Short copy() {
- return new Short(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UShort extends Vector1D<UShort> {
-
- public short x;
-
- public UShort() {
- }
-
- public UShort(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public UShort(SampleSystem type, short x) {
- this(type);
- this.x = x;
- }
-
- public UShort(short x) {
- this.x = x;
- }
-
- public UShort(short[] array) {
- this.x = array[0];
- }
-
- public UShort(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UShort(short x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UShort(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return java.lang.Short.toUnsignedInt(x);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UShort set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- return this;
- }
-
- @Override
- public UShort set(double[] values, int offset) {
- x = (short) values[ offset];
- return this;
- }
-
- @Override
- public UShort set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- return this;
- }
-
- @Override
- public UShort set(float[] values, int offset) {
- x = (short) values[ offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{java.lang.Short.toUnsignedInt(x)};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{java.lang.Short.toUnsignedInt(x)};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{java.lang.Short.toUnsignedInt(x)};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = java.lang.Short.toUnsignedInt(x);
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = java.lang.Short.toUnsignedInt(x);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = java.lang.Short.toUnsignedInt(x);
- }
-
- @Override
- public UShort copy() {
- return new UShort(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Int extends Vector1D<Int> {
-
- public int x;
-
- public Int() {
- }
-
- public Int(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Int(SampleSystem type, int x) {
- this(type);
- this.x = x;
- }
-
- public Int(int x) {
- this.x = x;
- }
-
- public Int(int[] array) {
- this.x = array[0];
- }
-
- public Int(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Int(int x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Int(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Int set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- return this;
- }
-
- @Override
- public Int set(double[] values, int offset) {
- x = (int) values[ offset];
- return this;
- }
-
- @Override
- public Int set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- return this;
- }
-
- @Override
- public Int set(float[] values, int offset) {
- x = (int) values[ offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Int copy() {
- return new Int(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UInt extends Vector1D<UInt> {
-
- public int x;
-
- public UInt() {
- }
-
- public UInt(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public UInt(SampleSystem type, int x) {
- this(type);
- this.x = x;
- }
-
- public UInt(int x) {
- this.x = x;
- }
-
- public UInt(int[] array) {
- this.x = array[0];
- }
-
- public UInt(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UInt(int x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UInt(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return Integer.toUnsignedLong(x);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UInt set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- return this;
- }
-
- @Override
- public UInt set(double[] values, int offset) {
- x = (int) values[ offset];
- return this;
- }
-
- @Override
- public UInt set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- return this;
- }
-
- @Override
- public UInt set(float[] values, int offset) {
- x = (int) values[ offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{Integer.toUnsignedLong(x)};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{Integer.toUnsignedLong(x)};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) Integer.toUnsignedLong(x);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = Integer.toUnsignedLong(x);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = Integer.toUnsignedLong(x);
- }
-
- @Override
- public UInt copy() {
- return new UInt(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Long extends Vector1D<Long> {
-
- public long x;
-
- public Long() {
- }
-
- public Long(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Long(SampleSystem type, long x) {
- this(type);
- this.x = x;
- }
-
- public Long(long x) {
- this.x = x;
- }
-
- public Long(long[] array) {
- this.x = array[0];
- }
-
- public Long(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Long(long x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Long(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (long) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Long set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- return this;
- }
-
- @Override
- public Long set(double[] values, int offset) {
- x = (long) values[ offset];
- return this;
- }
-
- @Override
- public Long set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- return this;
- }
-
- @Override
- public Long set(float[] values, int offset) {
- x = (long) values[ offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int) x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = (int) x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Long copy() {
- return new Long(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Float extends Vector1D<Float> {
-
- public float x;
-
- public Float() {
- }
-
- public Float(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Float(SampleSystem type, float x) {
- this(type);
- this.x = x;
- }
-
- public Float(float x) {
- this.x = x;
- }
-
- public Float(float[] array) {
- this.x = array[0];
- }
-
- public Float(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Float(float x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Float(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (float) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Float set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (float) values[0];
- return this;
- }
-
- @Override
- public Float set(double[] values, int offset) {
- x = (float) values[ offset];
- return this;
- }
-
- @Override
- public Float set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- return this;
- }
-
- @Override
- public Float set(float[] values, int offset) {
- x = values[offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x);
- }
-
- @Override
- public double lengthSquare() {
- return x*x;
- }
-
- @Override
- public Float normalize() {
- final double s = 1.0 / length();
- x *= s;
- return this;
- }
-
- @Override
- public Float add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- return this;
- }
-
- @Override
- public Float subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- return this;
- }
-
- @Override
- public Float scale(double scale) {
- x *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = (int) x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Float copy() {
- return new Float(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Float.isFinite(x);
- }
-
- }
-
- public static class Double extends Vector1D<Double> {
-
- public double x;
-
- public Double() {
- }
-
- public Double(SampleSystem type) {
- super(type);
- ensureDimension(type, 1);
- }
-
- public Double(SampleSystem type, double x) {
- this(type);
- this.x = x;
- }
-
- public Double(double x) {
- this.x = x;
- }
-
- public Double(double[] array) {
- this.x = array[0];
- }
-
- public Double(float[] array) {
- this.x = array[0];
- }
-
- public Double(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 1);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Double(double x, SampleSystem type) {
- super(type);
- this.x = x;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Double(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Double set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- return this;
- }
-
- @Override
- public Double set(double[] values, int offset) {
- x = values[ offset];
- return this;
- }
-
- @Override
- public Double set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- return this;
- }
-
- @Override
- public Double set(float[] values, int offset) {
- x = values[offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x);
- }
-
- @Override
- public double lengthSquare() {
- return x*x;
- }
-
- @Override
- public Double normalize() {
- final double s = 1.0 / length();
- x *= s;
- return this;
- }
-
- @Override
- public Double add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- return this;
- }
-
- @Override
- public Double subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- return this;
- }
-
- @Override
- public Double scale(double scale) {
- x *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{(float)x};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset] = (short) x;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset] = (int) x;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset] = (float) x;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset] = x;
- }
-
- @Override
- public Double copy() {
- return new Double(x, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Double.isFinite(x);
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector2D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector2D.java
deleted file mode 100644
index 715cf90..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector2D.java
+++ /dev/null
@@ -1,1601 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Vector2D<T extends Vector2D<T>> extends AbstractTuple<T> implements Vector<T> {
-
- public Vector2D() {
- super(2);
- }
-
- protected Vector2D(SampleSystem type) {
- super(type);
- }
-
- /**
- * Rotate this vector around given reference point.
- *
- * @param ref reference point to rotate around
- * @param angleRad angle in radians
- * @return this vector
- */
- public T rotate(Vector2D<?> ref, double angleRad) {
- final double sin = Math.sin(angleRad);
- final double cos = Math.cos(angleRad);
-
- final double relx = get(0) - ref.get(0);
- final double rely = get(1) - ref.get(1);
-
- set(0, relx * cos - rely * sin + ref.get(0));
- set(1, relx * sin + rely * cos + ref.get(1));
- return (T) this;
- }
-
- @Override
- public final int getDimension() {
- return 2;
- }
-
- public static class Byte extends Vector2D<Byte> {
-
- public byte x;
- public byte y;
-
- public Byte() {
- }
-
- public Byte(SampleSystem type) {
- super(type);
- }
-
- public Byte(SampleSystem type, byte x, byte y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Byte(byte x, byte y) {
- this.x = x;
- this.y = y;
- }
-
- public Byte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Byte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Byte(byte x, byte y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Byte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Byte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- return this;
- }
-
- @Override
- public Byte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- return this;
- }
-
- @Override
- public Byte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- return this;
- }
-
- @Override
- public Byte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Byte copy() {
- return new Byte(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UByte extends Vector2D<UByte> {
-
- public byte x;
- public byte y;
-
- public UByte() {
- }
-
- public UByte(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public UByte(SampleSystem type, byte x, byte y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public UByte(byte x, byte y) {
- this.x = x;
- this.y = y;
- }
-
- public UByte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public UByte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UByte(byte x, byte y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UByte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x & 0xFF;
- case 1 : return y & 0xFF;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UByte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- return this;
- }
-
- @Override
- public UByte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- return this;
- }
-
- @Override
- public UByte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- return this;
- }
-
- @Override
- public UByte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x & 0xFF,y & 0xFF};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x & 0xFF,y & 0xFF};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x & 0xFF,y & 0xFF};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) (x & 0xFF);
- buffer[offset+1] = (short) (y & 0xFF);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- }
-
- @Override
- public UByte copy() {
- return new UByte(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Short extends Vector2D<Short> {
-
- public short x;
- public short y;
-
- public Short() {
- }
-
- public Short(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public Short(SampleSystem type, short x, short y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Short(short x, short y) {
- this.x = x;
- this.y = y;
- }
-
- public Short(short[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Short(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Short(short x, short y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Short(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Short set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- return this;
- }
-
- @Override
- public Short set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- return this;
- }
-
- @Override
- public Short set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- return this;
- }
-
- @Override
- public Short set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Short copy() {
- return new Short(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UShort extends Vector2D<UShort> {
-
- public short x;
- public short y;
-
- public UShort() {
- }
-
- public UShort(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public UShort(SampleSystem type, short x, short y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public UShort(short x, short y) {
- this.x = x;
- this.y = y;
- }
-
- public UShort(short[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public UShort(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UShort(short x, short y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UShort(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return java.lang.Short.toUnsignedInt(x);
- case 1 : return java.lang.Short.toUnsignedInt(y);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UShort set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- return this;
- }
-
- @Override
- public UShort set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- return this;
- }
-
- @Override
- public UShort set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- return this;
- }
-
- @Override
- public UShort set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{java.lang.Short.toUnsignedInt(x),java.lang.Short.toUnsignedInt(y)};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{java.lang.Short.toUnsignedInt(x),java.lang.Short.toUnsignedInt(y)};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{java.lang.Short.toUnsignedInt(x),java.lang.Short.toUnsignedInt(y)};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- }
-
- @Override
- public UShort copy() {
- return new UShort(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Int extends Vector2D<Int> {
-
- public int x;
- public int y;
-
- public Int() {
- }
-
- public Int(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public Int(SampleSystem type, int x, int y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Int(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public Int(int[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Int(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Int(int x, int y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Int(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Int set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- return this;
- }
-
- @Override
- public Int set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- return this;
- }
-
- @Override
- public Int set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- return this;
- }
-
- @Override
- public Int set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Int copy() {
- return new Int(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UInt extends Vector2D<UInt> {
-
- public int x;
- public int y;
-
- public UInt() {
- }
-
- public UInt(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public UInt(SampleSystem type, int x, int y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public UInt(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public UInt(int[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public UInt(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UInt(int x, int y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UInt(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return Integer.toUnsignedLong(x);
- case 1 : return Integer.toUnsignedLong(y);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UInt set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- return this;
- }
-
- @Override
- public UInt set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- return this;
- }
-
- @Override
- public UInt set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- return this;
- }
-
- @Override
- public UInt set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{Integer.toUnsignedLong(x),Integer.toUnsignedLong(y)};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{Integer.toUnsignedLong(x),Integer.toUnsignedLong(y)};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) Integer.toUnsignedLong(x);
- buffer[offset+1] = (short) Integer.toUnsignedLong(y);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- }
-
- @Override
- public UInt copy() {
- return new UInt(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Long extends Vector2D<Long> {
-
- public long x;
- public long y;
-
- public Long() {
- }
-
- public Long(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public Long(SampleSystem type, long x, long y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Long(long x, long y) {
- this.x = x;
- this.y = y;
- }
-
- public Long(long[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Long(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Long(long x, long y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Long(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (long) value; break;
- case 1 : y = (long) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Long set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- return this;
- }
-
- @Override
- public Long set(double[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- return this;
- }
-
- @Override
- public Long set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- return this;
- }
-
- @Override
- public Long set(float[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int) x, (int) y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Long copy() {
- return new Long(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Float extends Vector2D<Float> {
-
- public float x;
- public float y;
-
- public Float() {
- }
-
- public Float(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public Float(SampleSystem type, float x, float y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Float(float x, float y) {
- this.x = x;
- this.y = y;
- }
-
- public Float(float[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Float(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Float(float x, float y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Float(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (float) value; break;
- case 1 : y = (float) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Float set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (float) values[0];
- y = (float) values[1];
- return this;
- }
-
- @Override
- public Float set(double[] values, int offset) {
- x = (float) values[ offset];
- y = (float) values[1 + offset];
- return this;
- }
-
- @Override
- public Float set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- return this;
- }
-
- @Override
- public Float set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y;
- }
-
- @Override
- public Float normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- return this;
- }
-
- @Override
- public Float add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- return this;
- }
-
- @Override
- public Float subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- return this;
- }
-
- @Override
- public Float scale(double scale) {
- x *= scale;
- y *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Float copy() {
- return new Float(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Float.isFinite(x) && java.lang.Float.isFinite(y);
- }
-
- }
-
- public static class Double extends Vector2D<Double> {
-
- public double x;
- public double y;
-
- public Double() {
- }
-
- public Double(SampleSystem type) {
- super(type);
- ensureDimension(type, 2);
- }
-
- public Double(SampleSystem type, double x, double y) {
- this(type);
- this.x = x;
- this.y = y;
- }
-
- public Double(double x, double y) {
- this.x = x;
- this.y = y;
- }
-
- public Double(double[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Double(float[] array) {
- this.x = array[0];
- this.y = array[1];
- }
-
- public Double(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 2);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Double(double x, double y, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Double(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = value; break;
- case 1 : y = value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Double set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- return this;
- }
-
- @Override
- public Double set(double[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- return this;
- }
-
- @Override
- public Double set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- return this;
- }
-
- @Override
- public Double set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y;
- }
-
- @Override
- public Double normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- return this;
- }
-
- @Override
- public Double add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- return this;
- }
-
- @Override
- public Double subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- return this;
- }
-
- @Override
- public Double scale(double scale) {
- x *= scale;
- y *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{(float)x,(float)y};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = (float) x;
- buffer[offset+1] = (float) y;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- }
-
- @Override
- public Double copy() {
- return new Double(x, y, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Double.isFinite(x) && java.lang.Double.isFinite(y);
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector3D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector3D.java
deleted file mode 100644
index 405b778..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector3D.java
+++ /dev/null
@@ -1,1835 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Vector3D<T extends Vector3D<T>> extends AbstractTuple<T> implements Vector<T> {
-
- public Vector3D() {
- super(3);
- }
-
- protected Vector3D(SampleSystem type) {
- super(type);
- }
-
- /**
- * Rotate on X axis this vector around given reference point.
- *
- * @param ref reference point to rotate around
- * @param angleRad angle in radians
- * @return this vector
- */
- public T rotateX(Vector3D<?> ref, double angleRad) {
- final double sin = Math.sin(angleRad);
- final double cos = Math.cos(angleRad);
-
- final double relx = get(0) - ref.get(0);
- final double rely = get(1) - ref.get(1);
- final double relz = get(2) - ref.get(2);
-
- set(0, ref.get(0) + relx);
- set(1, ref.get(1) + rely * cos - relz * sin);
- set(2, ref.get(2) + rely * sin + relz * cos);
- return (T) this;
- }
-
- /**
- * Rotate on Y axis this vector around given reference point.
- *
- * @param ref reference point to rotate around
- * @param angleRad angle in radians
- * @return this vector
- */
- public T rotateY(Vector3D<?> ref, double angleRad) {
- final double sin = Math.sin(angleRad);
- final double cos = Math.cos(angleRad);
-
- final double relx = get(0) - ref.get(0);
- final double rely = get(1) - ref.get(1);
- final double relz = get(2) - ref.get(2);
-
- set(0, ref.get(0) + relz * sin + relx * cos);
- set(1, ref.get(1) + rely);
- set(2, ref.get(2) + relz * cos - relx * sin);
- return (T) this;
- }
-
- /**
- * Rotate on Z axis this vector around given reference point.
- *
- * @param ref reference point to rotate around
- * @param angleRad angle in radians
- * @return this vector
- */
- public T rotateZ(Vector3D<?> ref, double angleRad) {
- final double sin = Math.sin(angleRad);
- final double cos = Math.cos(angleRad);
-
- final double relx = get(0) - ref.get(0);
- final double rely = get(1) - ref.get(1);
- final double relz = get(2) - ref.get(2);
-
- set(0, ref.get(0) + relx * cos - rely * sin);
- set(1, ref.get(1) + relx * sin + rely * cos);
- set(2, ref.get(2) + relz);
- return (T) this;
- }
-
- @Override
- public final int getDimension() {
- return 3;
- }
-
- public static class Byte extends Vector3D<Byte> {
-
- public byte x;
- public byte y;
- public byte z;
-
- public Byte() {
- }
-
- public Byte(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Byte(SampleSystem type, byte x, byte y, byte z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Byte(byte x, byte y, byte z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Byte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Byte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Byte(byte x, byte y, byte z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Byte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- case 2 : z = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Byte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- return this;
- }
-
- @Override
- public Byte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- return this;
- }
-
- @Override
- public Byte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- return this;
- }
-
- @Override
- public Byte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y,z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y,z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Byte copy() {
- return new Byte(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UByte extends Vector3D<UByte> {
-
- public byte x;
- public byte y;
- public byte z;
-
- public UByte() {
- }
-
- public UByte(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public UByte(SampleSystem type, byte x, byte y, byte z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UByte(byte x, byte y, byte z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UByte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public UByte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UByte(byte x, byte y, byte z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UByte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x & 0xFF;
- case 1 : return y & 0xFF;
- case 2 : return z & 0xFF;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- case 2 : z = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UByte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- return this;
- }
-
- @Override
- public UByte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- return this;
- }
-
- @Override
- public UByte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- return this;
- }
-
- @Override
- public UByte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x & 0xFF,y & 0xFF,z & 0xFF};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x & 0xFF,y & 0xFF,z & 0xFF};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x & 0xFF,y & 0xFF,z & 0xFF};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) (x & 0xFF);
- buffer[offset+1] = (short) (y & 0xFF);
- buffer[offset+2] = (short) (z & 0xFF);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- }
-
- @Override
- public UByte copy() {
- return new UByte(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Short extends Vector3D<Short> {
-
- public short x;
- public short y;
- public short z;
-
- public Short() {
- }
-
- public Short(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Short(SampleSystem type, short x, short y, short z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Short(short x, short y, short z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Short(short[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Short(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Short(short x, short y, short z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Short(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- case 2 : z = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Short set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- return this;
- }
-
- @Override
- public Short set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- return this;
- }
-
- @Override
- public Short set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- return this;
- }
-
- @Override
- public Short set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y,z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y,z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Short copy() {
- return new Short(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UShort extends Vector3D<UShort> {
-
- public short x;
- public short y;
- public short z;
-
- public UShort() {
- }
-
- public UShort(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public UShort(SampleSystem type, short x, short y, short z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UShort(short x, short y, short z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UShort(short[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public UShort(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UShort(short x, short y, short z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UShort(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return java.lang.Short.toUnsignedInt(x);
- case 1 : return java.lang.Short.toUnsignedInt(y);
- case 2 : return java.lang.Short.toUnsignedInt(z);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- case 2 : z = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UShort set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- return this;
- }
-
- @Override
- public UShort set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- return this;
- }
-
- @Override
- public UShort set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- return this;
- }
-
- @Override
- public UShort set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z)
- };
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z)
- };
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z)
- };
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- }
-
- @Override
- public UShort copy() {
- return new UShort(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Int extends Vector3D<Int> {
-
- public int x;
- public int y;
- public int z;
-
- public Int() {
- }
-
- public Int(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Int(SampleSystem type, int x, int y, int z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Int(int x, int y, int z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Int(int[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Int(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Int(int x, int y, int z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Int(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- case 2 : z = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Int set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- return this;
- }
-
- @Override
- public Int set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- return this;
- }
-
- @Override
- public Int set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- return this;
- }
-
- @Override
- public Int set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y,z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y,z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Int copy() {
- return new Int(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UInt extends Vector3D<UInt> {
-
- public int x;
- public int y;
- public int z;
-
- public UInt() {
- }
-
- public UInt(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public UInt(SampleSystem type, int x, int y, int z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UInt(int x, int y, int z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public UInt(int[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public UInt(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UInt(int x, int y, int z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UInt(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return Integer.toUnsignedLong(x);
- case 1 : return Integer.toUnsignedLong(y);
- case 2 : return Integer.toUnsignedLong(z);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- case 2 : z = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UInt set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- return this;
- }
-
- @Override
- public UInt set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- return this;
- }
-
- @Override
- public UInt set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- return this;
- }
-
- @Override
- public UInt set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x,y,z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{
- Integer.toUnsignedLong(x),
- Integer.toUnsignedLong(y),
- Integer.toUnsignedLong(z)
- };
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{
- Integer.toUnsignedLong(x),
- Integer.toUnsignedLong(y),
- Integer.toUnsignedLong(z)
- };
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- buffer[offset+2] = Integer.toUnsignedLong(z);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- buffer[offset+2] = Integer.toUnsignedLong(z);
- }
-
- @Override
- public UInt copy() {
- return new UInt(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Long extends Vector3D<Long> {
-
- public long x;
- public long y;
- public long z;
-
- public Long() {
- }
-
- public Long(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Long(SampleSystem type, long x, long y, long z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Long(long x, long y, long z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Long(long[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Long(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Long(long x, long y, long z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Long(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (long) value; break;
- case 1 : y = (long) value; break;
- case 2 : z = (long) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Long set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- z = (long) values[2];
- return this;
- }
-
- @Override
- public Long set(double[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- z = (long) values[2 + offset];
- return this;
- }
-
- @Override
- public Long set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- z = (long) values[2];
- return this;
- }
-
- @Override
- public Long set(float[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- z = (long) values[2 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int) x, (int) y, (int) z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y,z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Long copy() {
- return new Long(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Float extends Vector3D<Float> {
-
- public float x;
- public float y;
- public float z;
-
- public Float() {
- }
-
- public Float(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Float(SampleSystem type, float x, float y, float z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Float(float x, float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Float(float[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Float(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Float(float x, float y, float z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Float(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (float) value; break;
- case 1 : y = (float) value; break;
- case 2 : z = (float) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Float set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (float) values[0];
- y = (float) values[1];
- z = (float) values[2];
- return this;
- }
-
- @Override
- public Float set(double[] values, int offset) {
- x = (float) values[ offset];
- y = (float) values[1 + offset];
- z = (float) values[2 + offset];
- return this;
- }
-
- @Override
- public Float set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- return this;
- }
-
- @Override
- public Float set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- return this;
- }
-
- public Float set(Tuple v) {
- if (getDimension() != v.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+v.getDimension());
- }
- x = (float) v.get(0);
- y = (float) v.get(1);
- z = (float) v.get(2);
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y + z*z);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y + z*z;
- }
-
- @Override
- public Float normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- return this;
- }
-
- @Override
- public Float add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- return this;
- }
-
- @Override
- public Float subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- return this;
- }
-
- @Override
- public Float scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y, (int)z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x,y,z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Float copy() {
- return new Float(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Float.isFinite(x) && java.lang.Float.isFinite(y) && java.lang.Float.isFinite(z);
- }
-
- }
-
- public static class Double extends Vector3D<Double> {
-
- public double x;
- public double y;
- public double z;
-
- public Double() {
- }
-
- public Double(SampleSystem type) {
- super(type);
- ensureDimension(type, 3);
- }
-
- public Double(SampleSystem type, double x, double y, double z) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Double(double x, double y, double z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Double(double[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Double(float[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- }
-
- public Double(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 3);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Double(double x, double y, double z, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Double(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = value; break;
- case 1 : y = value; break;
- case 2 : z = value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Double set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- return this;
- }
-
- @Override
- public Double set(double[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- return this;
- }
-
- @Override
- public Double set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- return this;
- }
-
- @Override
- public Double set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y + z*z);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y + z*z;
- }
-
- @Override
- public Double normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- return this;
- }
-
- @Override
- public Double add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- return this;
- }
-
- @Override
- public Double subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- return this;
- }
-
- @Override
- public Double scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- return this;
- }
-
- @Override
- public Double cross(Tuple<?> other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- double ox = other.get(0);
- double oy = other.get(1);
- double oz = other.get(2);
- return new Double(
- (y * oz) - (z * oy),
- (z * ox) - (x * oz),
- (x * oy) - (y * ox)
- );
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y, (int)z};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{(float)x,(float)y,(float)z};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = (float) x;
- buffer[offset+1] = (float) y;
- buffer[offset+2] = (float) z;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- }
-
- @Override
- public Double copy() {
- return new Double(x, y, z, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Double.isFinite(x) && java.lang.Double.isFinite(y) && java.lang.Double.isFinite(z);
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector4D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector4D.java
deleted file mode 100644
index d8dfe18..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vector4D.java
+++ /dev/null
@@ -1,2078 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Vector4D<T extends Vector4D<T>> extends AbstractTuple<T> implements Vector<T> {
-
- public Vector4D() {
- super(4);
- }
-
- protected Vector4D(SampleSystem type) {
- super(type);
- }
-
- @Override
- public final int getDimension() {
- return 4;
- }
-
- public static class Byte extends Vector4D<Byte> {
-
- public byte x;
- public byte y;
- public byte z;
- public byte w;
-
- public Byte() {
- }
-
- public Byte(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Byte(SampleSystem type, byte x, byte y, byte z, byte w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Byte(byte x, byte y, byte z, byte w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Byte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Byte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Byte(byte x, byte y, byte z, byte w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Byte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- case 2 : z = (byte) value; break;
- case 3 : w = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Byte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- w = (byte) values[3];
- return this;
- }
-
- @Override
- public Byte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- w = (byte) values[3 + offset];
- return this;
- }
-
- @Override
- public Byte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- w = (byte) values[3];
- return this;
- }
-
- @Override
- public Byte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- w = (byte) values[3 + offset];
- return this;
- }
-
- @Override
- public Byte normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public Byte add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public Byte subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public Byte scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x, y, z, w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x, y, z, w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Byte copy() {
- return new Byte(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UByte extends Vector4D<UByte> {
-
- public byte x;
- public byte y;
- public byte z;
- public byte w;
-
- public UByte() {
- }
-
- public UByte(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public UByte(SampleSystem type, byte x, byte y, byte z, byte w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UByte(byte x, byte y, byte z, byte w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UByte(byte[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public UByte(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UByte(byte x, byte y, byte z, byte w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UByte(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x & 0xFF;
- case 1 : return y & 0xFF;
- case 2 : return z & 0xFF;
- case 3 : return w & 0xFF;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (byte) value; break;
- case 1 : y = (byte) value; break;
- case 2 : z = (byte) value; break;
- case 3 : w = (byte) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UByte set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- w = (byte) values[3];
- return this;
- }
-
- @Override
- public UByte set(double[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- w = (byte) values[3 + offset];
- return this;
- }
-
- @Override
- public UByte set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (byte) values[0];
- y = (byte) values[1];
- z = (byte) values[2];
- w = (byte) values[3];
- return this;
- }
-
- @Override
- public UByte set(float[] values, int offset) {
- x = (byte) values[ offset];
- y = (byte) values[1 + offset];
- z = (byte) values[2 + offset];
- w = (byte) values[3 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x & 0xFF, y & 0xFF, z & 0xFF, w & 0xFF};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x & 0xFF, y & 0xFF, z & 0xFF, w & 0xFF};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x & 0xFF,y & 0xFF,z & 0xFF,w & 0xFF};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) (x & 0xFF);
- buffer[offset+1] = (short) (y & 0xFF);
- buffer[offset+2] = (short) (z & 0xFF);
- buffer[offset+3] = (short) (w & 0xFF);
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- buffer[offset+3] = w & 0xFF;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- buffer[offset+3] = w & 0xFF;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x & 0xFF;
- buffer[offset+1] = y & 0xFF;
- buffer[offset+2] = z & 0xFF;
- buffer[offset+3] = w & 0xFF;
- }
-
- @Override
- public UByte copy() {
- return new UByte(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Short extends Vector4D<Short> {
-
- public short x;
- public short y;
- public short z;
- public short w;
-
- public Short() {
- }
-
- public Short(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Short(SampleSystem type, short x, short y, short z, short w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Short(short x, short y, short z, short w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Short(short[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Short(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check crs.
- */
- private Short(short x, short y, short z, short w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Short(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- case 2 : z = (short) value; break;
- case 3 : w = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Short set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- w = (short) values[3];
- return this;
- }
-
- @Override
- public Short set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- w = (short) values[3 + offset];
- return this;
- }
-
- @Override
- public Short set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- w = (short) values[3];
- return this;
- }
-
- @Override
- public Short set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- w = (short) values[3 + offset];
- return this;
- }
-
- @Override
- public Short normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public Short add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public Short subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public Short scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x, y, z, w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x, y, z, w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Short copy() {
- return new Short(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UShort extends Vector4D<UShort> {
-
- public short x;
- public short y;
- public short z;
- public short w;
-
- public UShort() {
- }
-
- public UShort(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public UShort(SampleSystem type, short x, short y, short z, short w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UShort(short x, short y, short z, short w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UShort(short[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public UShort(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UShort(short x, short y, short z, short w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UShort(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return java.lang.Short.toUnsignedInt(x);
- case 1 : return java.lang.Short.toUnsignedInt(y);
- case 2 : return java.lang.Short.toUnsignedInt(z);
- case 3 : return java.lang.Short.toUnsignedInt(w);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (short) value; break;
- case 1 : y = (short) value; break;
- case 2 : z = (short) value; break;
- case 3 : w = (short) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UShort set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- w = (short) values[3];
- return this;
- }
-
- @Override
- public UShort set(double[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- w = (short) values[3 + offset];
- return this;
- }
-
- @Override
- public UShort set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (short) values[0];
- y = (short) values[1];
- z = (short) values[2];
- w = (short) values[3];
- return this;
- }
-
- @Override
- public UShort set(float[] values, int offset) {
- x = (short) values[ offset];
- y = (short) values[1 + offset];
- z = (short) values[2 + offset];
- w = (short) values[3 + offset];
- return this;
- }
-
- @Override
- public UShort normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public UShort add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public UShort subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public UShort scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z),
- java.lang.Short.toUnsignedInt(w)
- };
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z),
- java.lang.Short.toUnsignedInt(w)
- };
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{
- java.lang.Short.toUnsignedInt(x),
- java.lang.Short.toUnsignedInt(y),
- java.lang.Short.toUnsignedInt(z),
- java.lang.Short.toUnsignedInt(w)
- };
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- buffer[offset+3] = java.lang.Short.toUnsignedInt(w);
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- buffer[offset+3] = java.lang.Short.toUnsignedInt(w);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = java.lang.Short.toUnsignedInt(x);
- buffer[offset+1] = java.lang.Short.toUnsignedInt(y);
- buffer[offset+2] = java.lang.Short.toUnsignedInt(z);
- buffer[offset+3] = java.lang.Short.toUnsignedInt(w);
- }
-
- @Override
- public UShort copy() {
- return new UShort(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Int extends Vector4D<Int> {
-
- public int x;
- public int y;
- public int z;
- public int w;
-
- public Int() {
- }
-
- public Int(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Int(SampleSystem type, int x, int y, int z, int w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Int(int x, int y, int z, int w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Int(int[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Int(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Int(int x, int y, int z, int w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Int(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- case 2 : z = (int) value; break;
- case 3 : w = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Int set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- w = (int) values[3];
- return this;
- }
-
- @Override
- public Int set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- w = (int) values[3 + offset];
- return this;
- }
-
- @Override
- public Int set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- w = (int) values[3];
- return this;
- }
-
- @Override
- public Int set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- w = (int) values[3 + offset];
- return this;
- }
-
- @Override
- public Int normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public Int add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public Int subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public Int scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x, y, z, w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x, y, z, w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- buffer[offset+3] = (short) w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Int copy() {
- return new Int(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UInt extends Vector4D<UInt> {
-
- public int x;
- public int y;
- public int z;
- public int w;
-
- public UInt() {
- }
-
- public UInt(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public UInt(SampleSystem type, int x, int y, int z, int w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UInt(int x, int y, int z, int w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public UInt(int[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public UInt(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private UInt(int x, int y, int z, int w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- UInt(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return Integer.toUnsignedLong(x);
- case 1 : return Integer.toUnsignedLong(y);
- case 2 : return Integer.toUnsignedLong(z);
- case 3 : return Integer.toUnsignedLong(w);
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (int) value; break;
- case 1 : y = (int) value; break;
- case 2 : z = (int) value; break;
- case 3 : w = (int) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public UInt set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- w = (int) values[3];
- return this;
- }
-
- @Override
- public UInt set(double[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- w = (int) values[3 + offset];
- return this;
- }
-
- @Override
- public UInt set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (int) values[0];
- y = (int) values[1];
- z = (int) values[2];
- w = (int) values[3];
- return this;
- }
-
- @Override
- public UInt set(float[] values, int offset) {
- x = (int) values[ offset];
- y = (int) values[1 + offset];
- z = (int) values[2 + offset];
- w = (int) values[3 + offset];
- return this;
- }
-
- @Override
- public UInt normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{x, y, z, w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{
- Integer.toUnsignedLong(x),
- Integer.toUnsignedLong(y),
- Integer.toUnsignedLong(z),
- Integer.toUnsignedLong(w),
- };
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{
- Integer.toUnsignedLong(x),
- Integer.toUnsignedLong(y),
- Integer.toUnsignedLong(z),
- Integer.toUnsignedLong(w),
- };
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- buffer[offset+3] = (short) w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- buffer[offset+2] = Integer.toUnsignedLong(z);
- buffer[offset+3] = Integer.toUnsignedLong(w);
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = Integer.toUnsignedLong(x);
- buffer[offset+1] = Integer.toUnsignedLong(y);
- buffer[offset+2] = Integer.toUnsignedLong(z);
- buffer[offset+3] = Integer.toUnsignedLong(w);
- }
-
- @Override
- public UInt copy() {
- return new UInt(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Long extends Vector4D<Long> {
-
- public long x;
- public long y;
- public long z;
- public long w;
-
- public Long() {
- }
-
- public Long(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Long(SampleSystem type, long x, long y, long z, long w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Long(long x, long y, long z, long w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Long(long[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Long(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Long(long x, long y, long z, long w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Long(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (long) value; break;
- case 1 : y = (long) value; break;
- case 2 : z = (long) value; break;
- case 3 : w = (long) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Long set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- z = (long) values[2];
- w = (long) values[3];
- return this;
- }
-
- @Override
- public Long set(double[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- z = (long) values[2 + offset];
- w = (long) values[3 + offset];
- return this;
- }
-
- @Override
- public Long set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (long) values[0];
- y = (long) values[1];
- z = (long) values[2];
- w = (long) values[3];
- return this;
- }
-
- @Override
- public Long set(float[] values, int offset) {
- x = (long) values[ offset];
- y = (long) values[1 + offset];
- z = (long) values[2 + offset];
- w = (long) values[3 + offset];
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int) x, (int) y, (int) z, (int) w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x, y, z, w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- buffer[offset+3] = (short) w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- buffer[offset+3] = (int) w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Long copy() {
- return new Long(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Float extends Vector4D<Float> {
-
- public float x;
- public float y;
- public float z;
- public float w;
-
- public Float() {
- }
-
- public Float(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Float(SampleSystem type, float x, float y, float z, float w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Float(float x, float y, float z, float w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Float(float[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Float(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Float(float x, float y, float z, float w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Float(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = (float) value; break;
- case 1 : y = (float) value; break;
- case 2 : z = (float) value; break;
- case 3 : w = (float) value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Float set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = (float) values[0];
- y = (float) values[1];
- z = (float) values[2];
- w = (float) values[3];
- return this;
- }
-
- @Override
- public Float set(double[] values, int offset) {
- x = (float) values[ offset];
- y = (float) values[1 + offset];
- z = (float) values[2 + offset];
- w = (float) values[3 + offset];
- return this;
- }
-
- @Override
- public Float set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- w = values[3];
- return this;
- }
-
- @Override
- public Float set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- w = values[3 + offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y + z*z + w*w);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y + z*z + w*w;
- }
-
- @Override
- public Float normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public Float add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public Float subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public Float scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y, (int)z, (int)w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{x, y, z, w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- buffer[offset+3] = (short) w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- buffer[offset+3] = (int) w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Float copy() {
- return new Float(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Float.isFinite(x) && java.lang.Float.isFinite(y) && java.lang.Float.isFinite(z) && java.lang.Float.isFinite(w);
- }
-
- }
-
- public static class Double extends Vector4D<Double> {
-
- public double x;
- public double y;
- public double z;
- public double w;
-
- public Double() {
- }
-
- public Double(SampleSystem type) {
- super(type);
- ensureDimension(type, 4);
- }
-
- public Double(SampleSystem type, double x, double y, double z, double w) {
- this(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Double(double x, double y, double z, double w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- public Double(double[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Double(float[] array) {
- this.x = array[0];
- this.y = array[1];
- this.z = array[2];
- this.w = array[3];
- }
-
- public Double(Tuple tuple) {
- super(tuple.getSampleSystem());
- ensureDimension(type, 4);
- set(tuple);
- }
-
- /**
- * Copy constructor which does not check type.
- */
- private Double(double x, double y, double z, double w, SampleSystem type) {
- super(type);
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /**
- * Package private benchmarked performance constructor which does not check type.
- * @param type must be of the correct size, it is not verified
- * @param none not used, to differenciate with public constructor
- */
- Double(SampleSystem type, boolean none) {
- super(type);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) {
- switch (indice) {
- case 0 : return x;
- case 1 : return y;
- case 2 : return z;
- case 3 : return w;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public void set(int indice, double value) {
- switch (indice) {
- case 0 : x = value; break;
- case 1 : y = value; break;
- case 2 : z = value; break;
- case 3 : w = value; break;
- default : throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- }
-
- @Override
- public Double set(double[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- w = values[3];
- return this;
- }
-
- @Override
- public Double set(double[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- w = values[3 + offset];
- return this;
- }
-
- @Override
- public Double set(float[] values) {
- if (getDimension() != values.length) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+values.length);
- }
- x = values[0];
- y = values[1];
- z = values[2];
- w = values[3];
- return this;
- }
-
- @Override
- public Double set(float[] values, int offset) {
- x = values[ offset];
- y = values[1 + offset];
- z = values[2 + offset];
- w = values[3 + offset];
- return this;
- }
-
- @Override
- public double length() {
- return Math.sqrt(x*x + y*y + z*z + w*w);
- }
-
- @Override
- public double lengthSquare() {
- return x*x + y*y + z*z + w*w;
- }
-
- @Override
- public Double normalize() {
- final double s = 1.0 / length();
- x *= s;
- y *= s;
- z *= s;
- w *= s;
- return this;
- }
-
- @Override
- public Double add(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x += other.get(0);
- y += other.get(1);
- z += other.get(2);
- w += other.get(3);
- return this;
- }
-
- @Override
- public Double subtract(Tuple other) {
- if (getDimension() != other.getDimension()) {
- throw new IllegalArgumentException("Vectors size are different : "+getDimension()+" and "+other.getDimension());
- }
- x -= other.get(0);
- y -= other.get(1);
- z -= other.get(2);
- w -= other.get(3);
- return this;
- }
-
- @Override
- public Double scale(double scale) {
- x *= scale;
- y *= scale;
- z *= scale;
- w *= scale;
- return this;
- }
-
- @Override
- public int[] toArrayInt() {
- return new int[]{(int)x, (int)y, (int)z, (int)w};
- }
-
- @Override
- public float[] toArrayFloat() {
- return new float[]{(float)x, (float)y, (float)z, (float)w};
- }
-
- @Override
- public double[] toArrayDouble() {
- return new double[]{x,y,z,w};
- }
-
- @Override
- public void toArrayShort(short[] buffer, int offset) {
- buffer[offset ] = (short) x;
- buffer[offset+1] = (short) y;
- buffer[offset+2] = (short) z;
- buffer[offset+3] = (short) w;
- }
-
- @Override
- public void toArrayInt(int[] buffer, int offset) {
- buffer[offset ] = (int) x;
- buffer[offset+1] = (int) y;
- buffer[offset+2] = (int) z;
- buffer[offset+3] = (int) w;
- }
-
- @Override
- public void toArrayFloat(float[] buffer, int offset) {
- buffer[offset ] = (float) x;
- buffer[offset+1] = (float) y;
- buffer[offset+2] = (float) z;
- buffer[offset+3] = (float) w;
- }
-
- @Override
- public void toArrayDouble(double[] buffer, int offset) {
- buffer[offset ] = x;
- buffer[offset+1] = y;
- buffer[offset+2] = z;
- buffer[offset+3] = w;
- }
-
- @Override
- public Double copy() {
- return new Double(x, y, z, w, type);
- }
-
- @Override
- public boolean isFinite() {
- return java.lang.Double.isFinite(x) && java.lang.Double.isFinite(y) && java.lang.Double.isFinite(z) && java.lang.Double.isFinite(w);
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/VectorND.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/VectorND.java
deleted file mode 100644
index 5268a6f..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/VectorND.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class VectorND<T extends VectorND<T>> extends AbstractTuple<T> implements Vector<T> {
-
- public VectorND(int size) {
- super(size);
- }
-
- protected VectorND(SampleSystem type) {
- super(type);
- }
-
- public static class Byte extends VectorND<Byte> {
-
- public final byte[] values;
-
- public Byte(int size) {
- super(size);
- this.values = new byte[size];
- }
-
- public Byte(SampleSystem type) {
- super(type);
- this.values = new byte[type.getSize()];
- }
-
- public Byte(byte[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Byte(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new byte[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.BYTE;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (byte) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UByte extends VectorND<UByte> {
-
- public final byte[] values;
-
- public UByte(int size) {
- super(size);
- this.values = new byte[size];
- }
-
- public UByte(SampleSystem type) {
- super(type);
- this.values = new byte[type.getSize()];
- }
-
- public UByte(byte[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public UByte(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new byte[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UBYTE;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice] & 0xFF;
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (byte) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Short extends VectorND<Short> {
-
- public final short[] values;
-
- public Short(int size) {
- super(size);
- this.values = new short[size];
- }
-
- public Short(SampleSystem type) {
- super(type);
- this.values = new short[type.getSize()];
- }
-
- public Short(short[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Short(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new short[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.SHORT;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (short) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UShort extends VectorND<UShort> {
-
- public final short[] values;
-
- public UShort(int size) {
- super(size);
- this.values = new short[size];
- }
-
- public UShort(SampleSystem type) {
- super(type);
- this.values = new short[type.getSize()];
- }
-
- public UShort(short[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public UShort(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new short[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.USHORT;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return java.lang.Short.toUnsignedInt(values[indice]);
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (short) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Int extends VectorND<Int> {
-
- public final int[] values;
-
- public Int(int size) {
- super(size);
- this.values = new int[size];
- }
-
- public Int(SampleSystem type) {
- super(type);
- this.values = new int[type.getSize()];
- }
-
- public Int(int[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Int(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new int[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.INT;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (int) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class UInt extends VectorND<UInt> {
-
- public final int[] values;
-
- public UInt(int size) {
- super(size);
- this.values = new int[size];
- }
-
- public UInt(SampleSystem type) {
- super(type);
- this.values = new int[type.getSize()];
- }
-
- public UInt(int[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public UInt(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new int[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.UINT;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return Integer.toUnsignedLong(values[indice]);
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (int) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Long extends VectorND<Long> {
-
- public final long[] values;
-
- public Long(int size) {
- super(size);
- this.values = new long[size];
- }
-
- public Long(SampleSystem type) {
- super(type);
- this.values = new long[type.getSize()];
- }
-
- public Long(long[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Long(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new long[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.LONG;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (long) value;
- }
-
- @Override
- public boolean isFinite() {
- return true;
- }
-
- }
-
- public static class Float extends VectorND<Float> {
-
- public final float[] values;
-
- public Float(int size) {
- super(size);
- this.values = new float[size];
- }
-
- public Float(SampleSystem type) {
- super(type);
- this.values = new float[type.getSize()];
- }
-
- public Float(float[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Float(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new float[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.FLOAT;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = (float) value;
- }
-
- }
-
- public static class Double extends VectorND<Double> {
-
- public final double[] values;
-
- public Double(int size) {
- super(size);
- this.values = new double[size];
- }
-
- public Double(SampleSystem type) {
- super(type);
- this.values = new double[type.getSize()];
- }
-
- public Double(double[] array) {
- super(array.length);
- this.values = array.clone();
- }
-
- public Double(float[] array) {
- super(array.length);
- this.values = new double[array.length];
- set(array);
- }
-
- public Double(Tuple tuple) {
- super(tuple.getSampleSystem());
- this.values = new double[tuple.getDimension()];
- set(tuple);
- }
-
- @Override
- public DataType getDataType() {
- return DataType.DOUBLE;
- }
-
- @Override
- public int getDimension() {
- return values.length;
- }
-
- @Override
- public double get(int indice) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- return values[indice];
- }
-
- @Override
- public void set(int indice, double value) {
- if (indice < 0 || indice >= values.length) {
- throw new IndexOutOfBoundsException("Invalid index " + indice);
- }
- values[indice] = value;
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vectors.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vectors.java
deleted file mode 100644
index 7384c7c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Vectors.java
+++ /dev/null
@@ -1,1876 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.measure.NumberRange;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.transform.MathTransforms;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Static;
-
-
-/**
- * Origin : Adapted from Unlicense-Lib
- *
- * @author Johann Sorel
- * @author Bertrand COTE
- */
-public final class Vectors extends Static {
-
- public static Vector<?> create(CoordinateReferenceSystem crs, DataType dataType) {
- return create(SampleSystem.of(crs), dataType);
- }
-
- public static Vector<?> create(SampleSystem type, DataType dataType) {
- final int size = type.getSize();
- switch (dataType) {
- case BYTE :
- return switch (size) {
- case 1 -> new Vector1D.Byte(type, false);
- case 2 -> new Vector2D.Byte(type, false);
- case 3 -> new Vector3D.Byte(type, false);
- case 4 -> new Vector4D.Byte(type, false);
- default -> new VectorND.Byte(type);
- };
- case UBYTE :
- return switch (size) {
- case 1 -> new Vector1D.UByte(type, false);
- case 2 -> new Vector2D.UByte(type, false);
- case 3 -> new Vector3D.UByte(type, false);
- case 4 -> new Vector4D.UByte(type, false);
- default -> new VectorND.UByte(type);
- };
- case SHORT :
- return switch (size) {
- case 1 -> new Vector1D.Short(type, false);
- case 2 -> new Vector2D.Short(type, false);
- case 3 -> new Vector3D.Short(type, false);
- case 4 -> new Vector4D.Short(type, false);
- default -> new VectorND.Short(type);
- };
- case USHORT :
- return switch (size) {
- case 1 -> new Vector1D.UShort(type, false);
- case 2 -> new Vector2D.UShort(type, false);
- case 3 -> new Vector3D.UShort(type, false);
- case 4 -> new Vector4D.UShort(type, false);
- default -> new VectorND.UShort(type);
- };
- case INT :
- return switch (size) {
- case 1 -> new Vector1D.Int(type, false);
- case 2 -> new Vector2D.Int(type, false);
- case 3 -> new Vector3D.Int(type, false);
- case 4 -> new Vector4D.Int(type, false);
- default -> new VectorND.Int(type);
- };
- case UINT :
- return switch (size) {
- case 1 -> new Vector1D.UInt(type, false);
- case 2 -> new Vector2D.UInt(type, false);
- case 3 -> new Vector3D.UInt(type, false);
- case 4 -> new Vector4D.UInt(type, false);
- default -> new VectorND.UInt(type);
- };
- case LONG :
- return switch (size) {
- case 1 -> new Vector1D.Long(type, false);
- case 2 -> new Vector2D.Long(type, false);
- case 3 -> new Vector3D.Long(type, false);
- case 4 -> new Vector4D.Long(type, false);
- default -> new VectorND.Long(type);
- };
- case FLOAT :
- return switch (size) {
- case 1 -> new Vector1D.Float(type, false);
- case 2 -> new Vector2D.Float(type, false);
- case 3 -> new Vector3D.Float(type, false);
- case 4 -> new Vector4D.Float(type, false);
- default -> new VectorND.Float(type);
- };
- case DOUBLE :
- return switch (size) {
- case 1 -> new Vector1D.Double(type, false);
- case 2 -> new Vector2D.Double(type, false);
- case 3 -> new Vector3D.Double(type, false);
- case 4 -> new Vector4D.Double(type, false);
- default -> new VectorND.Double(type);
- };
- default :
- throw new UnsupportedOperationException("Unexpected data type");
- }
- }
-
- public static Vector<?> create(int dimension, DataType dataType) {
- return create(SampleSystem.ofSize(dimension), dataType);
- }
-
- public static Vector<?> createByte(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.BYTE);
- }
-
- public static Vector<?> createByte(CoordinateReferenceSystem crs) {
- return create(crs, DataType.BYTE);
- }
-
- public static Vector<?> createUByte(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.UBYTE);
- }
-
- public static Vector<?> createUByte(CoordinateReferenceSystem crs) {
- return create(crs, DataType.UBYTE);
- }
-
- public static Vector<?> createShort(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.SHORT);
- }
-
- public static Vector<?> createShort(CoordinateReferenceSystem crs) {
- return create(crs, DataType.SHORT);
- }
-
- public static Vector<?> createUShort(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.USHORT);
- }
-
- public static Vector<?> createUShort(CoordinateReferenceSystem crs) {
- return create(crs, DataType.USHORT);
- }
-
- public static Vector<?> createInt(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.INT);
- }
-
- public static Vector<?> createInt(CoordinateReferenceSystem crs) {
- return create(crs, DataType.INT);
- }
-
- public static Vector<?> createUInt(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.UINT);
- }
-
- public static Vector<?> createUInt(CoordinateReferenceSystem crs) {
- return create(crs, DataType.UINT);
- }
-
- public static Vector<?> createLong(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.LONG);
- }
-
- public static Vector<?> createLong(CoordinateReferenceSystem crs) {
- return create(crs, DataType.LONG);
- }
-
- public static Vector<?> createFloat(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.FLOAT);
- }
-
- public static Vector<?> createFloat(CoordinateReferenceSystem crs) {
- return create(crs, DataType.FLOAT);
- }
-
- public static Vector<?> createDouble(int dimension) {
- return create(SampleSystem.ofSize(dimension), DataType.DOUBLE);
- }
-
- public static Vector<?> createDouble(CoordinateReferenceSystem crs) {
- return create(crs, DataType.DOUBLE);
- }
-
- public static Vector<?> castOrCopy(DirectPosition pos) {
- if (pos instanceof Vector) {
- return (Vector) pos;
- } else {
- final SampleSystem type;
- final DataType dt;
- if (pos instanceof Tuple) {
- type = ((Tuple) pos).getSampleSystem();
- dt = ((Tuple) pos).getDataType();
- } else {
- CoordinateReferenceSystem crs = pos.getCoordinateReferenceSystem();
- type = crs != null ? SampleSystem.of(pos.getCoordinateReferenceSystem()) :
- SampleSystem.ofSize(pos.getDimension());
- dt = DataType.DOUBLE;
- }
- final Vector v = create(type, dt);
- v.set(pos);
- return v;
- }
- }
-
- public static Vector<?> castOrCopy(Tuple pos) {
- if (pos instanceof Vector) {
- return (Vector) pos;
- } else {
- final SampleSystem type = pos.getSampleSystem();
- final DataType dt = pos.getDataType();
- final Vector v = create(type, dt);
- v.set(pos);
- return v;
- }
- }
-
- public static Vector<?> castOrWrap(DirectPosition pos) {
- if (pos instanceof Vector) {
- return (Vector) pos;
- } else if (pos instanceof Tuple) {
- return new WrapTuple((Tuple) pos);
- } else {
- CoordinateReferenceSystem crs = pos.getCoordinateReferenceSystem();
- return crs == null ? new WrapDirectPostion(pos, pos.getDimension()) : new WrapDirectPostion(pos);
- }
- }
-
- public static Vector<?> castOrWrap(Tuple tuple) {
- if (tuple instanceof Vector) {
- return (Vector) tuple;
- } else {
- return new WrapTuple(tuple);
- }
- }
-
- public static DirectPosition asDirectPostion(Tuple tuple) {
- return new AsDirectPosition(tuple);
- }
- /**
- * Create an unmodifiable view of the given tuple.
- *
- * @param tuple not null
- * @return unmodifiable view of the tuple.
- */
- public static Tuple<?> unmodifiable(Tuple<?> tuple) {
- return new TupleUnmodifiable(tuple);
- }
-
- private static class WrapTuple extends AbstractTuple<WrapTuple> implements Vector<WrapTuple> {
-
- private final Tuple pos;
-
- public WrapTuple(Tuple pos, int size) {
- super(size);
- this.pos = pos;
- }
-
- public WrapTuple(Tuple pos) {
- super(pos.getSampleSystem());
- this.pos = pos;
- }
-
- @Override
- public DataType getDataType() {
- return pos.getDataType();
- }
-
- @Override
- public double get(int indice) {
- return pos.get(indice);
- }
-
- @Override
- public void set(int indice, double value) {
- pos.set(indice, value);
- }
-
- @Override
- public int getDimension() {
- return pos.getDimension();
- }
- }
-
- private static class WrapDirectPostion extends AbstractTuple<WrapDirectPostion> implements Vector<WrapDirectPostion> {
-
- private final DirectPosition pos;
-
- public WrapDirectPostion(DirectPosition pos, int size) {
- super(size);
- this.pos = pos;
- }
-
- public WrapDirectPostion(DirectPosition pos) {
- super(pos.getCoordinateReferenceSystem());
- this.pos = pos;
- }
-
- @Override
- public DataType getDataType() {
- return (pos instanceof Tuple) ? ((Tuple) pos).getDataType() : DataType.DOUBLE;
- }
-
- @Override
- public double get(int indice) {
- return pos.getCoordinate(indice);
- }
-
- @Override
- public void set(int indice, double value) {
- pos.setCoordinate(indice, value);
- }
-
- @Override
- public int getDimension() {
- return pos.getDimension();
- }
- }
-
- private static class AsDirectPosition implements DirectPosition {
-
- private final Tuple tuple;
-
- public AsDirectPosition(Tuple tuple) {
- this.tuple = tuple;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return tuple.getCoordinateReferenceSystem();
- }
-
- @Override
- public int getDimension() {
- return tuple.getDimension();
- }
-
- @Override
- public double[] getCoordinates() {
- return tuple.toArrayDouble();
- }
-
- @Override
- public double getCoordinate(int i) {
- return tuple.get(i);
- }
-
- @Override
- public void setCoordinate(int i, double d) {
- tuple.set(i,d);
- }
-
- }
-
- /**
- * Computes the vector's length.
- *
- * @param vector input vector
- * @return length
- */
- public static double length(final double[] vector){
- return Math.sqrt(lengthSquare(vector));
- }
-
- /**
- * Computes the vector's length.
- *
- * @param vector vector to process
- * @return vector length
- */
- public static float length(final float[] vector){
- return (float)Math.sqrt(lengthSquare(vector));
- }
-
- /**
- * Computes the vector's square length.
- *
- * @param vector input vector
- * @return vector square length
- */
- public static double lengthSquare(final double[] vector){
- double length = 0;
- for(int i=0;i<vector.length;i++){
- length += vector[i]*vector[i];
- }
- return length;
- }
-
- /**
- * Computes the vector's square length.
- *
- * @param vector input vector
- * @return vector square length
- */
- public static float lengthSquare(final float[] vector){
- float length = 0;
- for(int i=0;i<vector.length;i++){
- length += vector[i]*vector[i];
- }
- return length;
- }
-
- /**
- * Computes the shortest angle between given vectors.
- * formula : acos(dot(vector,other)/(length(vector)*length(other)))
- *
- * @param vector input vector
- * @param other second vector
- * @return shortest angle in radian
- */
- public static double shortestAngle(final double[] vector, final double[] other){
- return Math.acos(cos( vector, other ));
- }
-
- /**
- * Computes the shortest angle between given vectors.
- * formula : acos(dot(vector,other)/(length(vector)*length(other)))
- *
- * @param vector input vector
- * @param other second vector
- * @return shortest angle in radian
- */
- public static float shortestAngle(final float[] vector, final float[] other){
- return (float)Math.acos(cos( vector, other ));
- }
-
- /**
- * Cosine of the angle between the two vectors.
- * formula : dot(vector,other)
- *
- * @param vector input vector
- * @param other second vector
- * @return angle cosinus value
- */
- public static double cos( double[] vector, double[] other ) {
- return dot(vector, other)/(length(vector)*length(other));
- }
-
- /**
- * Cosine of the angle between the two vectors.
- * formula : dot(vector,other)
- *
- * @param vector input vector
- * @param other second vector
- * @return angle cosinus value
- */
- public static float cos( float[] vector, float[] other ) {
- return dot(vector, other)/(length(vector)*length(other));
- }
-
- /**
- * Sinus of the angle between the two vectors.
- * The returned value is signed for 2D vectors, and unsigned for 3D vectors.
- *
- * @param vector input vector
- * @param other second vector
- * @return angle sinus value
- */
- public static double sin( double[] vector, double[] other ) {
- if( vector.length == 2 ) {
- return (vector[0]*other[1]-vector[1]*other[0])/(length(vector)*length(other));
- } else if ( vector.length == 3 ) {
- return length(cross(vector, other))/(length(vector)*length(other));
- }
- throw new IllegalArgumentException(" Vector size must be 2 or 3");
- }
-
- /**
- * Sinus of the angle between the two vectors.
- * The returned value is signed for 2D vectors, and unsigned for 3D vectors.
- *
- * @param vector input vector
- * @param other second vector
- * @return angle sinus value
- */
- public static float sin( float[] vector, float[] other ) {
- if ( vector.length == 2 ) {
- return (vector[0]*other[1]-vector[1]*other[0])/(length(vector)*length(other));
- } else if ( vector.length == 3 ) {
- return length(cross(vector, other))/(length(vector)*length(other));
- }
- throw new IllegalArgumentException(" Vector size must be 2 or 3");
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // OPERATIONS WITHOuT BUFFER ///////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////
-
- /**
- * Copy vector into another one.
- * @param target
- * @param src
- */
- public static void copy(double[] target, double[] src) {
- if (src.length<target.length) {
- throw new IllegalArgumentException(" Source vector size must be equal or greater than target vector");
- }
- System.arraycopy(src, 0, target, 0, target.length);
- }
-
- /**
- * Add vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return addition of both vectors
- */
- public static double[] add(final double[] vector, final double[] other){
- return add(vector,other,null);
- }
-
- /**
- * Add vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return addition of both vectors
- */
- public static float[] add(final float[] vector, final float[] other){
- return add(vector,other,null);
- }
-
- /**
- * Subtract vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return subtraction of both vectors
- */
- public static double[] subtract(final double[] vector, final double[] other){
- return subtract(vector,other,null);
- }
-
- /**
- * Subtract vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return subtraction of both vectors
- */
- public static float[] subtract(final float[] vector, final float[] other){
- return subtract(vector,other,null);
- }
-
- /**
- * Multiply vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return multiplication of both vectors
- */
- public static double[] multiply(final double[] vector, final double[] other){
- return multiply(vector,other,null);
- }
-
- /**
- * Multiply vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return multiplication of both vectors
- */
- public static float[] multiply(final float[] vector, final float[] other){
- return multiply(vector,other,null);
- }
-
- /**
- * Divide vector and other.
- * Vectors must have the same size.
- *
- * @param vector numerators vector.
- * @param other denominators vector.
- * @return division of both vectors
- */
- public static double[] divide(final double[] vector, final double[] other){
- return divide(vector,other,null);
- }
-
- /**
- * Divide vector and other.
- * Vectors must have the same size.
- *
- * @param vector numerators vector.
- * @param other denominators vector.
- * @return division of both vectors
- */
- public static float[] divide(final float[] vector, final float[] other){
- return divide(vector,other,null);
- }
-
- /**
- * Scale vector by the given scale.
- *
- * @param vector the vector to scale.
- * @param scale the scale coefficient.
- * @return the scaled vector.
- */
- public static double[] scale(final double[] vector, final double scale){
- return scale(vector,scale,null);
- }
-
- /**
- * Scale vector by the given scale.
- *
- * @param vector the vector to scale.
- * @param scale the scale coefficient.
- * @return the scaled vector.
- */
- public static float[] scale(final float[] vector, final float scale){
- return scale(vector,scale,null);
- }
-
- /**
- * Cross product of v1 and v2.
- * Vectors must have size 3.
- *
- * @param vector first vector
- * @param other second vector
- * @return the cross product of vector by other.
- */
- public static double[] cross(final double[] vector, final double[] other){
- return cross(vector,other,null);
- }
-
- /**
- * Cross product of v1 and v2.
- * Vectors must have size 3.
- *
- * @param vector first vector
- * @param other second vector
- * @return the cross product of vector by other.
- */
- public static float[] cross(final float[] vector, final float[] other){
- return cross(vector,other,null);
- }
-
- /**
- * Dot product of vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return dot product
- */
- public static double dot(final double[] vector, final double[] other){
- double dot = 0;
- for(int i=0;i<vector.length;i++){
- dot += vector[i]*other[i];
- }
- return dot;
- }
-
- /**
- * Dot product of vector and other.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return dot product
- */
- public static float dot(final float[] vector, final float[] other){
- float dot = 0;
- for(int i=0;i<vector.length;i++){
- dot += vector[i]*other[i];
- }
- return dot;
- }
-
- /**
- * Normalizes vector.
- * Vectors must have the same size.
- *
- * @param vector the vector to normalize.
- * @return the normalized vector.
- */
- public static double[] normalize(final double[] vector){
- return normalize(vector, null);
- }
-
- /**
- * Normalizes vector.
- * Vectors must have the same size.
- *
- * @param vector the vector to normalize.
- * @return the normalized vector.
- */
- public static float[] normalize(final float[] vector){
- return normalize(vector, null);
- }
-
- /**
- * Negates the vector, equivalent to multiply all values by -1.
- *
- * @param vector the vector to negate.
- * @return the negated vector.
- */
- public static double[] negate(final double[] vector){
- return negate(vector, null);
- }
-
- /**
- * Negates the vector, equivalent to multiply all values by -1.
- *
- * @param vector the vector to negate.
- * @return the negated vector.
- */
- public static float[] negate(final float[] vector){
- return negate(vector, null);
- }
-
- /**
- * Interpolates between given vectors.
- *
- * @param start start vector (return value for ratio == 0.)
- * @param end end vector (return value for ratio == 1.)
- * @param ratio : 0 is close to start vector, 1 is on end vector
- * @return the interpolated vector.
- */
- public static float[] lerp(final float[] start, final float[] end, final float ratio) {
- return lerp(start, end, ratio, null);
- }
-
- /**
- * Interpolates between given vectors.
- *
- * @param start start vector (return value for ratio == 0.)
- * @param end end vector (return value for ratio == 1.)
- * @param ratio : 0 is close to start vector, 1 is on end vector
- * @return the interpolated vector.
- */
- public static double[] lerp(final double[] start, final double[] end, final double ratio) {
- return lerp(start, end, ratio, null);
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // OPERATIONS WITH BUFFER //////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////
-
- /**
- * Add vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector or be null.
- * @return addition of both vectors, buffer if not null
- */
- public static double[] add(final double[] vector, final double[] other, double[] buffer) {
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]+other[i];
- }
- return buffer;
- }
-
- /**
- * Add vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector or be null.
- * @return addition of both vectors, buffer if not null
- */
- public static float[] add(final float[] vector, final float[] other, float[] buffer) {
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]+other[i];
- }
- return buffer;
- }
-
- /**
- * Subtract vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @return subtraction of both vectors, buffer if not null
- */
- public static double[] subtract(final double[] vector, final double[] other, double[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]-other[i];
- }
- return buffer;
- }
-
- /**
- * Subtract vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector or be null.
- * @return subtraction of both vectors, buffer if not null
- */
- public static float[] subtract(final float[] vector, final float[] other, float[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]-other[i];
- }
- return buffer;
- }
-
- /**
- * Multiply vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector or be null.
- * @return multiplication of both vectors, buffer if not null
- */
- public static double[] multiply(final double[] vector, final double[] other, double[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]*other[i];
- }
- return buffer;
- }
-
- /**
- * Multiply vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector or be null.
- * @return multiplication of both vectors, buffer if not null
- */
- public static float[] multiply(final float[] vector, final float[] other, float[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]*other[i];
- }
- return buffer;
- }
-
- /**
- * Divide vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector numerators vector.
- * @param other denominators vector.
- * @param buffer must have same size as vector or be null.
- * @return division of both vectors, buffer if not null
- */
- public static double[] divide(final double[] vector, final double[] other, double[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]/other[i];
- }
- return buffer;
- }
-
- /**
- * Divide vector and other, result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have the same size.
- *
- * @param vector numerators vector.
- * @param other denominators vector.
- * @param buffer must have same size as vector or be null.
- * @return division of both vectors, buffer if not null
- */
- public static float[] divide(final float[] vector, final float[] other, float[] buffer){
- if( vector.length != other.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]/other[i];
- }
- return buffer;
- }
-
- /**
- * Scale vector by the given scale, result is stored in buffer.
- * If buffer is null, a new vector is created.
- *
- * @param vector the vector to scale.
- * @param scale the scale coefficient.
- * @param buffer must have same size as vector or be null.
- * @return the scaled vector.
- */
- public static double[] scale(final double[] vector, final double scale, double[] buffer){
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]*scale;
- }
- return buffer;
- }
-
- /**
- * Scale vector by the given scale, result is stored in buffer.
- * If buffer is null, a new vector is created.
- *
- * @param vector the vector to scale.
- * @param scale the scale coefficient.
- * @param buffer must have same size as vector or be null.
- * @return the scaled vector.
- */
- public static float[] scale(final float[] vector, final float scale, float[] buffer){
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for(int i=0;i<vector.length;i++){
- buffer[i] = vector[i]*scale;
- }
- return buffer;
- }
-
- /**
- * Cross product of v1 and v2. result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have size 3.
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector and other or be null.
- * @return the cross product of vector by other.
- */
- public static double[] cross(final double[] vector, final double[] other, double[] buffer){
- if( vector.length!=3 || other.length!=3 ) {
- throw new IllegalArgumentException("vector and v2 size must be 3.");
- }
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector and other.");
- }
-
- final double newX = (vector[1] * other[2]) - (vector[2] * other[1]);
- final double newY = (vector[2] * other[0]) - (vector[0] * other[2]);
- final double newZ = (vector[0] * other[1]) - (vector[1] * other[0]);
- buffer[0] = newX;
- buffer[1] = newY;
- buffer[2] = newZ;
- return buffer;
- }
-
- /**
- * Cross product of v1 and v2. result is stored in buffer.
- * If buffer is null, a new vector is created.
- * Vectors must have size 3.
- * @param vector first vector
- * @param other second vector
- * @param buffer must have same size as vector and other or be null.
- * @return the cross product of vector by other.
- */
- public static float[] cross(final float[] vector, final float[] other, float[] buffer){
- if( vector.length!=3 || other.length!=3 ) {
- throw new IllegalArgumentException("vector and other size must be 3.");
- }
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector and other.");
- }
-
- buffer[0] = (vector[1] * other[2]) - (vector[2] * other[1]); // new X
- buffer[1] = (vector[2] * other[0]) - (vector[0] * other[2]); // new Y
- buffer[2] = (vector[0] * other[1]) - (vector[1] * other[0]); // new Z
- return buffer;
- }
-
- /**
- * Normalizes vector, result is stored in buffer.
- *
- * If buffer is null, a new vector is created.
- * Vectors must have the same size
- * @param vector the vector to normalize.
- * @param buffer must have same size as vector or be null.
- * @return the normalized vector.
- */
- public static double[] normalize(final double[] vector, double[] buffer){
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- scale(vector, 1d/length(vector), buffer);
- return buffer;
- }
-
- /**
- * Normalizes vector, result is stored in buffer.
- *
- * If buffer is null, a new vector is created.
- * Vectors must have the same size
- * @param vector the vector to normalize.
- * @param buffer must have same size as vector or be null.
- * @return the normalized vector.
- */
- public static float[] normalize(final float[] vector, float[] buffer){
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- scale(vector, 1f/length(vector), buffer);
- return buffer;
- }
-
- /**
- * Negates the vector, equivalent to multiply all values by -1.
- *
- * @param vector the vector to negate.
- * @param buffer must have same size as vector or be null.
- * @return the negated vector.
- */
- public static double[] negate(final double[] vector, double[] buffer){
- if( buffer == null ){
- buffer = new double[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for( int i=0; i<vector.length; i++ ) {
- buffer[i] = - vector[i];
- }
- return buffer;
- }
-
- /**
- * Negates the vector, equivalent to multiply all values by -1.
- *
- * @param vector the vector to negate.
- * @param buffer must have same size as vector or be null.
- * @return the negated vector.
- */
- public static float[] negate(final float[] vector, float[] buffer){
- if( buffer == null ){
- buffer = new float[vector.length];
- } else if( vector.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as vector.");
- }
-
- for( int i=0; i<vector.length; i++ ) {
- buffer[i] = - vector[i];
- }
- return buffer;
- }
-
-
- /**
- * Interpolates between given vectors.
- *
- * @param start start vector (return value for ratio == 0.)
- * @param end end vector (return value for ratio == 1.)
- * @param ratio : 0 is close to start vector, 1 is on end vector
- * @param buffer must have same size as start and end or be null.
- * @return the interpolated vector.
- */
- public static float[] lerp(final float[] start, final float[] end, final float ratio, float[] buffer) {
- if( start.length != end.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new float[start.length];
- } else if( start.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as start and end vectors.");
- }
-
- for(int i=0;i<start.length;i++){
- buffer[i] = (1-ratio)*start[i] + ratio * end[i];
- }
- return buffer;
- }
-
- public static double[] lerp(final double[] start, final double[] end, final double ratio, double[] buffer) {
- if( start.length != end.length ) {
- throw new IllegalArgumentException("Both vectors must have same length.");
- }
- if( buffer == null ){
- buffer = new double[start.length];
- } else if( start.length != buffer.length ) {
- throw new IllegalArgumentException("Buffer must have same length as start and end vectors.");
- }
-
- for(int i=0;i<start.length;i++){
- buffer[i] = (1-ratio)*start[i] + ratio * end[i];
- }
- return buffer;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // OPERATIONS WITH MULTIPLE ELEMENTS AT THE SAME TIME //////////////////////
- // /////////////////////////////////////////////////////////////////////////
-
- /**
- * Add source1 and source2, result is stored in buffer.
- * @param source1 first vectors array
- * @param source2 second vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param source2Offset second array offset
- * @param bufferOffset output buffer offset
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] add(double[] source1, double[] source2, double[] buffer,
- int source1Offset, int source2Offset, int bufferOffset, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] + source2[source2Offset+i];
- }
- return buffer;
- }
-
- /**
- * Add source1 and source2, result is stored in buffer.
- * @param source1 first vectors array
- * @param source2 second vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param source2Offset second array offset
- * @param bufferOffset output buffer offset
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] add(float[] source1, float[] source2, float[] buffer,
- int source1Offset, int source2Offset, int bufferOffset, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] + source2[source2Offset+i];
- }
- return buffer;
- }
-
- /**
- * Add 'addition' to all source1 elements, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param addition vector to add
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] addRegular(double[] source1, double[] buffer,
- int source1Offset, int bufferOffset, double[] addition, int nbTuple){
- final int tupleSize = addition.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] + addition[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Add 'addition' to all source1 elements, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param addition vector to add
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] addRegular(float[] source1, float[] buffer,
- int source1Offset, int bufferOffset, float[] addition, int nbTuple){
- final int tupleSize = addition.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] + addition[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Substract source1 and source2, result is stored in buffer.
- * @param source1 first vectors array
- * @param source2 second vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param source2Offset second array offset
- * @param bufferOffset output buffer offset
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] subtract(double[] source1, double[] source2, double[] buffer,
- int source1Offset, int source2Offset, int bufferOffset, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] - source2[source2Offset+i];
- }
- return buffer;
- }
-
- /**
- * Substract source1 and source2, result is stored in buffer.
- * @param source1 first vectors array
- * @param source2 second vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param source2Offset second array offset
- * @param bufferOffset output buffer offset
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] subtract(float[] source1, float[] source2, float[] buffer,
- int source1Offset, int source2Offset, int bufferOffset, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] - source2[source2Offset+i];
- }
- return buffer;
- }
-
- /**
- * Substract 'subtraction' to all source1 elements, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param subtraction vector to subtract
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] subtractRegular(double[] source1, double[] buffer,
- int source1Offset, int bufferOffset, double[] subtraction, int nbTuple){
- final int tupleSize = subtraction.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] - subtraction[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Substract 'subtraction' to all source1 elements, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param subtraction vector to subtract
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] subtractRegular(float[] source1, float[] buffer,
- int source1Offset, int bufferOffset, float[] subtraction, int nbTuple){
- final int tupleSize = subtraction.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] - subtraction[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Scale source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale sclaing factor
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] scaleRegular(double[] source1, double[] buffer, int source1Offset,
- int bufferOffset, double scale, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] * scale;
- }
- return buffer;
- }
-
- /**
- * Scale source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale scaling factor
- * @param tupleSize tuples size
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] scaleRegular(float[] source1, float[] buffer, int source1Offset,
- int bufferOffset, float scale, int tupleSize, int nbTuple){
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] * scale;
- }
- return buffer;
- }
-
- /**
- * Scale source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale scaling factor
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] multiplyRegular(double[] source1, double[] buffer, int source1Offset,
- int bufferOffset, double[] scale, int nbTuple){
- final int tupleSize = scale.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] * scale[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Scale source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale scaling factor
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] multiplyRegular(float[] source1, float[] buffer, int source1Offset,
- int bufferOffset, float[] scale, int nbTuple){
- final int tupleSize = scale.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] * scale[i%tupleSize];
- }
- return buffer;
- }
-
-
- /**
- * Divide source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale scaling factor
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static double[] divideRegular(double[] source1, double[] buffer, int source1Offset,
- int bufferOffset, double[] scale, int nbTuple){
- final int tupleSize = scale.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] / scale[i%tupleSize];
- }
- return buffer;
- }
-
- /**
- * Divide source1, result is stored in buffer.
- * @param source1 first vectors array
- * @param buffer result buffer, not null
- * @param source1Offset first array offset
- * @param bufferOffset output buffer offset
- * @param scale scaling factor
- * @param nbTuple number of tuple to process
- * @return buffer result array, same as buffer parameter
- */
- public static float[] divideRegular(float[] source1, float[] buffer, int source1Offset,
- int bufferOffset, float[] scale, int nbTuple){
- final int tupleSize = scale.length;
- for(int i=0,n=nbTuple*tupleSize;i<n;i++){
- buffer[bufferOffset+i] = source1[source1Offset+i] / scale[i%tupleSize];
- }
- return buffer;
- }
-
-
- // =========================================================================
-
- /**
- * From cartesian to polar coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#To_polar_coordinates_from_Cartesian_coordinates
- * <ul>
- * <li>r: cartesian's norm.</li>
- * <li>theta: angle between x and cartesian = atan2(y , x)</li>
- * </ul>
- *
- * @param cartesian { x, y }
- * @return { r, theta }
- */
- public static double[] cartesianToPolar( double[] cartesian ) {
- if( cartesian.length != 2 ) throw new IllegalArgumentException("cartesian.length must be 2({ x, y }).");
- final double r = Vectors.length( cartesian );
- final double theta = Math.atan2(cartesian[1] , cartesian[0]);
- return new double[]{ r, theta };
- }
-
- /**
- * From cartesian to polar coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#To_polar_coordinates_from_Cartesian_coordinates
- * <ul>
- * <li>r: cartesian's norm.</li>
- * <li>theta: angle between x and cartesian = atan2(y , x)</li>
- * </ul>
- *
- * @param cartesian { x, y }
- * @return { r, theta }
- */
- public static float[] cartesianToPolar( float[] cartesian ) {
- if( cartesian.length != 2 ) throw new IllegalArgumentException("cartesian.length must be 2({ x, y }).");
- final float r = Vectors.length( cartesian );
- final float theta = (float)Math.atan2(cartesian[1] , cartesian[0]);
- return new float[]{ r, theta };
- }
-
- /**
- * From polar to cartesian coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#To_Cartesian_coordinates_from_polar_coordinates
- * <ul>
- * <li>x: r*cos(theta).</li>
- * <li>y: r*sin(theta).</li>
- * </ul>
- *
- * @param polar { r, theta }
- * @return { x, y }
- */
- public static double[] polarToCartesian( double[] polar ) {
- if( polar.length != 2 ) throw new IllegalArgumentException("polar.length must be 2({ r, theta }).");
- final double x = polar[0]*Math.cos(polar[1]);
- final double y = polar[0]*Math.sin(polar[1]);
- return new double[]{ x, y };
- }
-
- /**
- * From polar to cartesian coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#To_Cartesian_coordinates_from_polar_coordinates
- * <ul>
- * <li>x: r*cos(theta).</li>
- * <li>y: r*sin(theta).</li>
- * </ul>
- *
- * @param polar { r, theta }
- * @return { x, y }
- */
- public static float[] polarToCartesian( float[] polar ) {
- if( polar.length != 2 ) throw new IllegalArgumentException("polar.length must be 2({ r, theta }).");
- final float x = polar[0]*(float)Math.cos(polar[1]);
- final float y = polar[0]*(float)Math.sin(polar[1]);
- return new float[]{ x, y };
- }
-
- /**
- * From cartesian to cylindrical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_Coordinates_2
- * <ul>
- * <li>r: { x, y }'s norm.</li>
- * <li>theta: angle between x and { x, y, 0 }.</li>
- * <li>z: z (same as in cartesian).</li>
- * </ul>
- *
- * @param cartesian { x, y, z }
- * @return { r, theta, z }
- */
- public static double[] cartesianToCylindrical( double[] cartesian ) {
- if ( cartesian.length != 3 ) throw new IllegalArgumentException("cartesian.length must be 3({ x, y, z }).");
- final double[] polar = cartesianToPolar( new double[] {cartesian[0], cartesian[1]} );
- final double r = polar[0];
- final double theta = polar[1];
- final double h = cartesian[2];
- return new double[]{ r, theta, h };
- }
-
- /**
- * From cartesian to cylindrical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_Coordinates_2
- * <ul>
- * <li>r: { x, y }'s norm.</li>
- * <li>theta: angle between x and { x, y, 0 }.</li>
- * <li>z: z (same as in cartesian).</li>
- * </ul>
- *
- * @param cartesian { x, y, z }
- * @return { r, theta, z }
- */
- public static float[] cartesianToCylindrical( float[] cartesian ) {
- if ( cartesian.length != 3 ) throw new IllegalArgumentException("cartesian.length must be 3({ x, y, z }).");
- final float[] polar = cartesianToPolar( new float[] {cartesian[0], cartesian[1]} );
- final float r = polar[0];
- final float theta = polar[1];
- final float h = cartesian[2];
- return new float[]{ r, theta, h };
- }
-
- /**
- * From cartesian to cylindrical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_Coordinates_2
- * <ul>
- * <li>x: r*cos(theta).</li>
- * <li>y: r*sin(theta).</li>
- * <li>z: z (same as in cylindrical).</li>
- * </ul>
- *
- * @param cylindrical { r, theta, z }
- * @return { x, y, z }
- */
- public static double[] cylindricalToCartesian( double[] cylindrical ) {
- if ( cylindrical.length != 3 ) throw new IllegalArgumentException("cartesian.length must be 3({ r, theta, z }).");
- final double x = cylindrical[0]*Math.cos(cylindrical[1]);
- final double y = cylindrical[0]*Math.sin(cylindrical[1]);
- final double z = cylindrical[2];
- return new double[]{ x, y, z };
- }
-
- /**
- * From cartesian to cylindrical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_Coordinates_2
- * <ul>
- * <li>x: r*cos(theta).</li>
- * <li>y: r*sin(theta).</li>
- * <li>z: z (same as in cylindrical).</li>
- * </ul>
- *
- * @param cylindrical { r, theta, z }
- * @return { x, y, z }
- */
- public static float[] cylindricalToCartesian( float[] cylindrical ) {
- if ( cylindrical.length != 3 ) throw new IllegalArgumentException("cartesian.length must be 3({ r, theta, z }).");
- final float x = cylindrical[0]*(float)Math.cos(cylindrical[1]);
- final float y = cylindrical[0]*(float)Math.sin(cylindrical[1]);
- final float z = cylindrical[2];
- return new float[]{ x, y, z };
- }
-
- // =========================================================================
-
- /**
- * From cartesian to spherical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_coordinates
- * <ul>
- * <li>rho: cartesian's norm.</li>
- * <li>theta: angle between z and cartesian.</li>
- * <li>phi: angle between plan x.z and plan cartesian.z</li>
- * </ul>
- *
- * @param cartesian { x, y, z }
- * @return { rho, theta, phi }
- */
- public static double[] cartesianToSpherical( double[] cartesian ) {
- if( cartesian.length != 3 ) throw new IllegalArgumentException("cartesian.length must 3({ x, y, z }).");
- final double rho = Vectors.length(cartesian);
- final double theta = Math.atan2( cartesian[1], cartesian[0] );
- final double phi = Math.atan2( cartesian[2], Math.sqrt(cartesian[0]*cartesian[0] + cartesian[1]*cartesian[1]) );
- return new double[]{ rho, theta, phi };
- }
-
- /**
- * From cartesian to spherical coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_Cartesian_coordinates
- * <ul>
- * <li>rho: cartesian's norm.</li>
- * <li>theta: angle between z and cartesian.</li>
- * <li>phi: angle between plan x.z and plan cartesian.z</li>
- * </ul>
- *
- * @param cartesian { x, y, z }
- * @return { rho, theta, phi }
- */
- public static float[] cartesianToSpherical( float[] cartesian ) {
- if( cartesian.length != 3 ) throw new IllegalArgumentException("cartesian.length must 3({ x, y, z }).");
- final float rho = Vectors.length(cartesian);
- final float theta = (float)Math.atan2( cartesian[1], cartesian[0] );
- final float phi = (float)Math.atan2( cartesian[2], Math.sqrt(cartesian[0]*cartesian[0] + cartesian[1]*cartesian[1]) );
- return new float[]{ rho, theta, phi };
- }
-
- /**
- * From spherical to cartesian coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_spherical_coordinates
- * <ul>
- * <li>x: rho*cos(phi)*cos(theta).</li>
- * <li>y: rho*cos(phi)*sin(theta).</li>
- * <li>z: rho*sin(phi).</li>
- * </ul>
- *
- * @param spherical { rho, theta, phi }
- * @return { x, y, z }
- */
- public static double[] sphericalToCartesian( double[] spherical ) {
- if( spherical.length != 3 ) throw new IllegalArgumentException("cartesian.length must 3({ rho, theta, phi }).");
- final double rhoCosPhi = spherical[0]*Math.cos(spherical[2]);
- final double x = rhoCosPhi*Math.cos(spherical[1]);
- final double y = rhoCosPhi*Math.sin(spherical[1]);
- final double z = spherical[0]*Math.sin(spherical[2]);
- return new double[]{ x, y, z };
- }
-
- /**
- * From spherical to cartesian coordinate system transformation.
- * http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#From_spherical_coordinates
- * <ul>
- * <li>x: rho*cos(phi)*cos(theta).</li>
- * <li>y: rho*cos(phi)*sin(theta).</li>
- * <li>z: rho*sin(phi).</li>
- * </ul>
- *
- * @param spherical { rho, theta, phi }
- * @return { x, y, z }
- */
- public static float[] sphericalToCartesian( float[] spherical ) {
- if( spherical.length != 3 ) throw new IllegalArgumentException("cartesian.length must 3({ rho, theta, phi }).");
- final float rhoCosPhi = spherical[0]*(float)Math.cos(spherical[2]);
- final float x = rhoCosPhi*(float)Math.cos(spherical[1]);
- final float y = rhoCosPhi*(float)Math.sin(spherical[1]);
- final float z = spherical[0]*(float)Math.sin(spherical[2]);
- return new float[]{ x, y, z };
- }
-
- /**
- * Oct compression from : <a href="http://jcgt.org/published/0003/02/01/paper-lowres.pdf">http://jcgt.org/published/0003/02/01/paper-lowres.pdf</a>
- *
- * <pre>
- * {@code
- * vec2 float32x3_to_oct(vec3 v) {
- * vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
- * return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;
- * }
- * }
- * </pre>
- *
- * @param unitVector unencoded unit vector value of size 3
- * @return encoded value
- */
- public static Vector2D.Float toOctEncoding(Tuple<?> unitVector){
- ArgumentChecks.ensureCountBetween("dimension", true, 3, 3, unitVector.getDimension());
- final double x = unitVector.get(0);
- final double y = unitVector.get(1);
- final double z = unitVector.get(2);
- final float s = (float) (1f / (Math.abs(x) + Math.abs(y) + Math.abs(z)));
- final Vector2D.Float p = new Vector2D.Float((float) (s*x), (float) (s*y));
- if (z <= 0) {
- return new Vector2D.Float(
- (1f-Math.abs(p.y)) * ((p.x >= 0.0) ? +1f : -1f),
- (1f-Math.abs(p.x)) * ((p.y >= 0.0) ? +1f : -1f)
- );
- } else {
- return p;
- }
- }
-
- /**
- * Encode unit vector with Oct compression and store it as ushort values.
- *
- * @param unitVector unencoded unit vector value of size 3
- * @return encoded value
- */
- public static Vector2D.UShort toOctUShort(Tuple<?> unitVector){
- final Vector2D.Float oct = toOctEncoding(unitVector);
- return new Vector2D.UShort(
- (short) ( (oct.x + 1f) / 2f * 65535f),
- (short) ( (oct.y + 1f) / 2f * 65535f)
- );
- }
-
- /**
- * Encode unit vector with Oct compression and store it as byte values.
- *
- * @param unitVector unencoded unit vector value of size 3
- * @return encoded value
- */
- public static byte[] toOctByte(Tuple<?> unitVector){
- final Vector2D.Float oct = toOctEncoding(unitVector);
- final byte[] b = new byte[2];
- b[0] = (byte) ( (oct.x + 1f) / 2f * 255f);
- b[1] = (byte) ( (oct.y + 1f) / 2f * 255f);
- return b;
- }
-
- /**
- * Convert a value [0,255] to [-1,+1]
- *
- * @param b input value in range [0,255]
- * @return output value in range [-1,+1]
- */
- public static float fromSNorm(byte b){
- return ((float) (b & 0xFF)) / 255f * 2f - 1f;
- }
-
- /**
- * Convert a value [0,65535] to [-1,+1]
- *
- * @param b input value in range [0,255]
- * @return output value in range [-1,+1]
- */
- public static float fromSNorm(short b){
- return ((float)(b & 0xFFFF)) / 65535f * 2f - 1f;
- }
-
- private static float signNotZero(float v){
- return v>=0 ? +1:-1 ;
- }
-
- /**
- * Oct compression to unit vector.
- *
- * @param x compressed first value
- * @param y compressed second value
- * @return unit vector
- */
- public static Vector3D.Float octToNormal(byte x, byte y){
- Vector3D.Float normal = new Vector3D.Float();
- normal.x = fromSNorm(x);
- normal.y = fromSNorm(y);
- normal.z = 1f - (Math.abs(normal.x) + Math.abs(normal.y));
-
- if (normal.z < 0.0){
- float oldVX = normal.x;
- normal.x = (1f - Math.abs(normal.y)) * signNotZero(oldVX);
- normal.y = (1f - Math.abs(oldVX)) * signNotZero(normal.y);
- }
-
- normal.normalize();
- return normal;
- }
-
- /**
- * Oct compression to unit vector.
- *
- * @param x compressed first value
- * @param y compressed second value
- * @return unit vector
- */
- public static Vector3D.Float octToNormal(short x, short y){
- Vector3D.Float normal = new Vector3D.Float();
- normal.x = fromSNorm(x);
- normal.y = fromSNorm(y);
- normal.z = 1f - (Math.abs(normal.x) + Math.abs(normal.y));
-
- if (normal.z < 0.0){
- float oldVX = normal.x;
- normal.x = (1f - Math.abs(normal.y)) * signNotZero(oldVX);
- normal.y = (1f - Math.abs(oldVX)) * signNotZero(normal.y);
- }
-
- normal.normalize();
- return normal;
- }
-
- /**
- * Quantize a single tuple.
- *
- * @param tuple to quantize
- * @param quantizeBox expected bounding range of input tuple
- * @param quantizeRange resulting quantized values will range between 0 and this value inclusive.
- * @param buffer where quantized value is stored
- */
- public static <R extends Tuple<?>> R toQuantizedEncoding(Tuple<?> tuple, Envelope quantizeBox, int quantizeRange, R buffer) throws MismatchedDimensionException, TransformException {
- final MathTransform trs = quantizedTransform(quantizeBox, quantizeRange);
- if (buffer == null) {
- final DataType dt = DataType.forRange(NumberRange.create(0, true, quantizeRange, true), true);
- buffer = (R) Vectors.create(tuple.getDimension(), dt);
- }
- double[] array = buffer.toArrayDouble();
- trs.transform(tuple.toArrayDouble(), 0, array, 0, 1);
- buffer.set(array);
- return buffer;
- }
-
- /**
- * Create transform from coordinates in quantizeBox to quantizeRange.
- *
- * @param quantizeBox expected bounding range of input tuple
- * @param quantizeRange resulting quantized values will range between 0 and this value inclusive.
- * @return transform, not null
- */
- public static MathTransform quantizedTransform(Envelope quantizeBox, int quantizeRange){
- final int dim = quantizeBox.getDimension();
- final MatrixSIS matrix = org.apache.sis.referencing.operation.matrix.Matrices.createDiagonal(dim + 1, dim + 1);
- for (int i = 0; i < dim; i++) {
- final double minx = quantizeBox.getMinimum(i);
- double scale = quantizeRange / quantizeBox.getSpan(i);
- if (!Double.isFinite(scale)) {
- scale = 1.0;
- }
- matrix.setElement(i, i, scale);
- matrix.setElement(i, dim, -minx * scale);
- }
- return MathTransforms.linear(matrix);
- }
-
- private Vectors(){}
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/package-info.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/package-info.java
deleted file mode 100644
index 1a4dd64..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- * Most of the code in this package is copied or inspired by the Unlicense-Lib project.
- */
-package org.apache.sis.geometries.math;
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitive.java
deleted file mode 100644
index 9888771..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitive.java
+++ /dev/null
@@ -1,1289 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.BBox;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.MultiLineString;
-import org.apache.sis.geometries.MultiPoint;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.TIN;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.math.AbstractTupleArray;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vector1D;
-import org.apache.sis.geometries.math.Vector3D;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometry.GeneralDirectPosition;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.privy.UnmodifiableArrayList;
-
-
-/**
- * A mesh geometry is a structure which mimics the natural primitives used
- * by GPUs.
- *
- * Inspired by GLTF 2.0 :
- * https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
- *
- * Relation to OGC Simple Feature Access :
- * A primitive is a efficient batch of simple geometries, we view it as a GeometryCollection.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface MeshPrimitive extends Geometry {
-
- public static final Logger LOGGER = Logger.getLogger("org.apache.sis.geometries");
-
- /**
- * Enumeration of GPU supported primitive types.
- */
- public static enum Type {
- POINTS,
- LINES,
- LINE_LOOP,
- LINE_STRIP,
- TRIANGLES,
- TRIANGLE_FAN,
- TRIANGLE_STRIP;
- }
-
- public static MeshPrimitive create(Type type) {
- switch (type) {
- case POINTS: return new Points();
- case LINES: return new Lines();
- case LINE_LOOP: return new LineLoop();
- case LINE_STRIP: return new LineStrip();
- case TRIANGLES: return new Triangles();
- case TRIANGLE_FAN: return new TriangleFan();
- case TRIANGLE_STRIP: return new TriangleStrip();
- default: throw new IllegalArgumentException("Unknown type " + type);
- }
- }
-
- public static MeshPrimitive createEmpty(Type type, AttributesType attDef) {
- Abs p = (Abs) create(type);
- for (String name : attDef.getAttributeNames()) {
- p.attributes.put(name, TupleArrays.of(attDef.getAttributeSystem(name), attDef.getAttributeType(name), 0));
- }
- p.positions = p.attributes.get(AttributesType.ATT_POSITION);
- ArgumentChecks.ensureNonNull(AttributesType.ATT_POSITION, p.positions);
- return p;
- }
-
-
- /**
- * @return primitive (and positions) CRS.
- */
- @Override
- CoordinateReferenceSystem getCoordinateReferenceSystem();
-
- /**
- * Change primitive CRS, this will modify the position Record type.
- */
- @Override
- void setCoordinateReferenceSystem(CoordinateReferenceSystem crs);
-
- /**
- * Calculate envelope of this primitive.
- *
- * @return Envelope of the mesh
- */
- @Override
- Envelope getEnvelope();
-
- /**
- * @return OpenGL primtive type
- */
- Type getType();
-
- /**
- * Primitive is empty if :
- * - index is null and position array is empty
- * - index is not null and is empty
- */
- @Override
- boolean isEmpty();
-
- /**
- * Returns tuple array for given name.
- *
- * @param name seached attribute name
- * @return attribute array or null.
- */
- TupleArray getAttribute(String name);
-
- /**
- * @param name attribute name
- * @param array if null, will remove the attribute
- */
- void setAttribute(String name, TupleArray array);
-
- /**
- * Get geometry index.
- * The index combined with the index range define the different primitives.
- * If index is null all points in the geometry are used.
- *
- * @return vertex indices, may be null
- */
- TupleArray getIndex();
-
- /**
- * Set geometry index.
- * If index is null all points in the geometry are used.
- *
- * @param index can be null.
- */
- void setIndex(TupleArray index);
-
- /**
- * @return standard positions attribute
- */
- TupleArray getPositions();
-
- /**
- * Change positions.
- * Caution : changing the positions will change the primitive CRS,
- * the positions crs is used as primitive CRS.
- * @param array not null
- */
- void setPositions(TupleArray array);
-
- /**
- * @return standard normals attribute
- */
- TupleArray getNormals();
-
- void setNormals(TupleArray array);
-
- /**
- * @return standard tangents attribute
- */
- TupleArray getTangents();
-
- void setTangents(TupleArray array);
-
- /**
- * @return standard indexed color attribute
- */
- TupleArray getColors(int index);
-
- void setColors(int index, TupleArray array);
-
- /**
- * @return standard indexed texture coordinate attribute
- */
- TupleArray getTexCoords(int index);
-
- void setTexCoords(int index, TupleArray array);
-
- /**
- * @return standard indexed joints attribute
- */
- TupleArray getJoints(int index);
-
- void setJoints(int index, TupleArray array);
-
- /**
- * @return standard indexed weights attribute
- */
- TupleArray getWeights(int index);
-
- void setWeights(int index, TupleArray array);
-
- /**
- * Check geometry definition.
- */
- void validate();
-
- /**
- * Get vertex at index.
- *
- * @param index vertex index.
- * @return Vertex
- */
- Vertex getVertex(int index);
-
- /**
- * Create a deep copy of this primitive.
- *
- * Note : this method will clone all attributes.
- *
- * @return copied primitive
- */
- MeshPrimitive deepCopy();
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- * This method should not be used if vertices are shared by multiple
- * triangles or it will cause visual glitches.
- */
- void computeFaceNormals();
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- */
- void computeSmoothNormals();
-
-
- /**
- * Removes any duplicated vertice.
- * Compare operation is based on vertice position.
- *
- * Only the first duplicated vertex attributes are preserved.
- */
- void removeDuplicatesByPosition();
-
- public static abstract class Abs implements MeshPrimitive, AttributesType {
-
- /**
- * Checks tuplearray change for position is in the same crs as the geometry.
- */
- protected final LinkedHashMap<String,TupleArray> attributes = new LinkedHashMap<>();
- protected TupleArray index;
- protected final Type type;
- //keep it as variable for fast access, used a lot
- protected TupleArray positions;
-
- private Map<String, Object> userProperties;
-
- protected Abs(Type type) {
- positions = TupleArrays.of(SampleSystem.of(Geometries.RIGHT_HAND_3D), new double[0]);
- attributes.put(AttributesType.ATT_POSITION, positions);
- this.type = type;
- }
-
- /**
- * @return primitive (and positions) CRS.
- */
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return getPositions().getCoordinateReferenceSystem();
- }
-
- /**
- * Change primitive CRS, this will modify the position Record type.
- */
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
- getPositions().setSampleSystem(SampleSystem.of(crs));
- }
-
- @Override
- public AttributesType getAttributesType() {
- return this;
- }
-
- @Override
- public List<String> getAttributeNames() {
- return UnmodifiableArrayList.wrap(attributes.keySet().toArray(new String[0]));
- }
-
- @Override
- public SampleSystem getAttributeSystem(String name) {
- final TupleArray ta = attributes.get(name);
- if (ta == null) return null;
- return ta.getSampleSystem();
- }
-
- @Override
- public DataType getAttributeType(String name) {
- final TupleArray ta = attributes.get(name);
- if (ta == null) return null;
- return ta.getDataType();
- }
-
- /**
- * Calculate envelope of this primitive.
- *
- * @return Envelope of the mesh
- */
- @Override
- public Envelope getEnvelope() {
- final TupleArray positions = getAttribute(ATT_POSITION);
- if (positions.isEmpty()) {
- final GeneralEnvelope env = new GeneralEnvelope(getCoordinateReferenceSystem());
- env.setToNaN();
- return env;
- }
- return TupleArrays.computeRange(positions);
- }
-
- public List<Geometry> getComponents() {
- final List<Geometry> elements = new ArrayList<>();
- MeshPrimitiveVisitor visitor = new MeshPrimitiveVisitor(this) {
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- }
-
- @Override
- protected void visit(LineString candidate) {
- elements.add(candidate);
- }
-
- @Override
- protected void visit(Point candidate) {
- elements.add(candidate);
- }
-
- @Override
- protected void visit(Triangle candidate) {
- elements.add(candidate);
- }
- };
- visitor.visit();
- return elements;
- }
-
- /**
- * @return OpenGL primtive type
- */
- @Override
- public Type getType() {
- return type;
- }
-
- /**
- * Primitive is empty if :
- * - index is null and position array is empty
- * - index is not null and is empty
- */
- @Override
- public boolean isEmpty() {
- if (index != null) {
- return index.isEmpty();
- }
-
- final TupleArray positions = getPositions();
- return positions == null || positions.isEmpty();
- }
-
- /**
- * Returns tuple array for given name.
- *
- * @param name seached attribute name
- * @return attribute array or null.
- */
- @Override
- public TupleArray getAttribute(String name) {
- return attributes.get(name);
- }
-
- /**
- * @param name attribute name
- * @param array if null, will remove the attribute
- */
- @Override
- public void setAttribute(String name, TupleArray array) {
- if (ATT_POSITION.equals(name)) {
- //makes extract verifications
- setPositions(array);
- } else if (array == null) {
- attributes.remove(name);
- } else {
- attributes.put(name, array);
- }
- }
-
- /**
- * Get geometry index.
- * The index combined with the index range define the different primitives.
- *
- * @return vertex indices, may be null
- */
- @Override
- public TupleArray getIndex() {
- return index;
- }
-
- /**
- * Set geometry index.
- *
- * @param index can be null.
- */
- @Override
- public void setIndex(TupleArray index) {
- if (index != null) {
- //verify type
- DataType dataType = index.getDataType();
- switch (dataType) {
- case BYTE :
- case SHORT :
- case INT :
- case LONG :
- case FLOAT :
- case DOUBLE :
- throw new IllegalArgumentException("Index must be of positive integer types.");
- }
- if (index.getDimension() != 1) {
- throw new IllegalArgumentException("Index dimensions must be 1.");
- }
- if (index.getCoordinateReferenceSystem() != null) {
- throw new IllegalArgumentException("Index array must no have a CRS");
- }
- }
- this.index = index;
- }
-
- /**
- * @return standard positions attribute
- */
- @Override
- public TupleArray getPositions() {
- return positions;
- }
-
- /**
- * Change positions.
- * Caution : changing the positions will change the primitive CRS,
- * the positions crs is used as primitive CRS.
- * @param array not null
- */
- @Override
- public void setPositions(TupleArray array) {
- ArgumentChecks.ensureNonNull(ATT_POSITION, array);
- ArgumentChecks.ensureNonNull("positions crs", array.getCoordinateReferenceSystem());
- this.positions = array;
- attributes.put(ATT_POSITION, array);
- }
-
- /**
- * @return standard normals attribute
- */
- @Override
- public TupleArray getNormals() {
- return getAttribute(ATT_NORMAL);
- }
-
- @Override
- public void setNormals(TupleArray array) {
- attributes.put(ATT_NORMAL, array);
- }
-
- /**
- * @return standard tangents attribute
- */
- @Override
- public TupleArray getTangents() {
- return getAttribute(ATT_TANGENT);
- }
-
- @Override
- public void setTangents(TupleArray array) {
- attributes.put(ATT_TANGENT, array);
- }
-
- /**
- * @return standard indexed color attribute
- */
- @Override
- public TupleArray getColors(int index) {
- return getAttribute(ATT_COLOR + "_" + index);
- }
-
- @Override
- public void setColors(int index, TupleArray array) {
- attributes.put(ATT_COLOR + "_" + index, array);
- }
-
- /**
- * @return standard indexed texture coordinate attribute
- */
- @Override
- public TupleArray getTexCoords(int index) {
- return getAttribute(ATT_TEXCOORD + "_" + index);
- }
-
- @Override
- public void setTexCoords(int index, TupleArray array) {
- attributes.put(ATT_TEXCOORD + "_" + index, array);
- }
-
- /**
- * @return standard indexed joints attribute
- */
- @Override
- public TupleArray getJoints(int index) {
- return getAttribute(ATT_JOINTS + "_" + index);
- }
-
- @Override
- public void setJoints(int index, TupleArray array) {
- attributes.put(ATT_JOINTS + "_" + index, array);
- }
-
- /**
- * @return standard indexed weights attribute
- */
- @Override
- public TupleArray getWeights(int index) {
- return getAttribute(ATT_WEIGHTS + "_" + index);
- }
-
- @Override
- public void setWeights(int index, TupleArray array) {
- attributes.put(ATT_WEIGHTS + "_" + index, array);
- }
-
- /**
- * Check geometry definition.
- */
- @Override
- public void validate() {
- TupleArray positions = getPositions();
- if (positions == null) {
- throw new IllegalArgumentException("Positions attribute is undefined");
- }
-
- int size = -1;
- for (Map.Entry<String,TupleArray> entry : attributes.entrySet()) {
- validate(entry.getKey(), entry.getValue());
- if (size == -1) {
- size = entry.getValue().getLength();
- } else if (size != entry.getValue().getLength()) {
- throw new IllegalArgumentException("Attributes have different tuple array lengths.");
- }
- }
- if (index != null) {
- validate("index", index);
-
- //check no index value is greater the array size
- final Set<Integer> usedIndexes = new HashSet<>();
- final TupleArrayCursor cursor = index.cursor();
- while (cursor.next()) {
- int i = (int) cursor.samples().get(0);
- if (i < 0 || i >= size) throw new IllegalArgumentException("Index " + i + " is not in range 0:"+size);
- usedIndexes.add(i);
- }
-
- final List<Integer> unusedIndex = new ArrayList<>();
- for (int i = 0, n = positions.getLength(); i < n; i++) {
- if (!usedIndexes.contains(i)) {
- unusedIndex.add(i);
- }
- }
- if (!unusedIndex.isEmpty()) {
- //may not be a bug, tuple arrays may be shared by multiple primitives
- LOGGER.log(Level.INFO, "Unused indexes {0}", Arrays.toString(unusedIndex.toArray()));
- }
- }
-
- //check index size type
- final int nbEntries;
- if (index != null) {
- nbEntries = index.getLength();
- } else {
- nbEntries = positions.getLength();
- }
- switch (type) {
- case POINTS :
- if (nbEntries < 1) throw new IllegalArgumentException("Points index range should have a length of at least one");
- break;
- case LINES :
- if (nbEntries < 2) throw new IllegalArgumentException("Lines index range should have a length of at least two");
- if ((nbEntries % 2) != 0) throw new IllegalArgumentException("Lines index range must be a factor of 2");
- break;
- case LINE_STRIP :
- if (nbEntries < 2) throw new IllegalArgumentException("Line strip index range should have a length of at least two");
- break;
- case TRIANGLES :
- if (nbEntries < 3) throw new IllegalArgumentException("Triangles index range should have a length of at least three");
- if ((nbEntries % 3) != 0) throw new IllegalArgumentException("Triangles index range must be a factor of 3");
- break;
- case TRIANGLE_FAN :
- if (nbEntries < 3) throw new IllegalArgumentException("Triangle fan index range should have a length of at least three");
- break;
- case TRIANGLE_STRIP :
- if (nbEntries < 3) throw new IllegalArgumentException("Triangle strip index range should have a length of at least three");
- break;
- default : //do nothing
- break;
- }
-
- //check normals
- final TupleArray normals = getNormals();
- if (normals != null) {
- for (int i = 0, n = normals.getLength(); i < n; i++) {
- Tuple normal = normals.get(i);
- if (!normal.isFinite()) {
- throw new IllegalArgumentException("Normal " + i + " is not finite. " + normal);
- } else if ( Math.abs(Vectors.castOrWrap(normal).length() - 1.0) > 1e-6) {
- throw new IllegalArgumentException("Normal " + i + " is not unitary. " + normal);
- }
- }
- }
-
- }
-
- private void validate(String name, TupleArray ta) {
-
- final int dimension = ta.getDimension();
- final int length = ta.getLength();
- final Tuple tuple = Vectors.createDouble(dimension);
-
- for (int i = 0; i <length; i++) {
- ta.get(i, tuple);
- if (!tuple.isFinite()) {
- throw new IllegalArgumentException("Found a NaN on attribute " + name +" at index "+ i);
- }
- }
- }
-
- /**
- * Get vertex at index.
- *
- * @param index vertex index.
- * @return Vertex
- */
- @Override
- public Vertex getVertex(int index) {
- return new Vertex(this, index);
- }
-
- /**
- * Create a deep copy of this primitive.
- *
- * Note : this method will clone all attributes.
- *
- * @return copied primitive
- */
- @Override
- public MeshPrimitive deepCopy() {
- final Abs copy = (Abs) create(type);
-
- for (Map.Entry<String,TupleArray> entry : attributes.entrySet()) {
- copy.attributes.put(entry.getKey(), entry.getValue().copy());
- }
-
- //copy index and ranges
- if (index != null) {
- copy.setIndex(index.copy());
- }
- copy.positions = copy.attributes.get(AttributesType.ATT_POSITION);
- return copy;
- }
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- * This method should not be used if vertices are shared by multiple
- * triangles or it will cause visual glitches.
- */
- @Override
- public void computeFaceNormals() {
- if (Type.TRIANGLES.equals(type)) {
- final TupleArrayCursor icursor = getIndex().cursor();
- final TupleArray vertices = getPositions();
- final TupleArrayCursor vcursor = vertices.cursor();
-
- final long size = vertices.getLength();
- final TupleArray normals = TupleArrays.of(positions.getSampleSystem(), new float[(int)size * 3]);
- final TupleArrayCursor ncursor = normals.cursor();
- final Vector nv = Vectors.castOrWrap(ncursor.samples());
- final Tuple v0 = Vectors.createFloat(3);
- final Tuple v1 = Vectors.createFloat(3);
- final Tuple v2 = Vectors.createFloat(3);
- Tuple normal = null;
-
- // accumulate normal vectors
- final int offset = 0;
- for (int i=0,n=index.getLength();i<n;i+=3) {
- icursor.moveTo(i+offset);
- final int idx0 = (int) icursor.samples().get(0);
- icursor.next();
- final int idx1 = (int) icursor.samples().get(0);
- icursor.next();
- final int idx2 = (int) icursor.samples().get(0);
- vcursor.moveTo(idx0); v0.set(vcursor.samples());
- vcursor.moveTo(idx1); v1.set(vcursor.samples());
- vcursor.moveTo(idx2); v2.set(vcursor.samples());
- normal = Maths.calculateNormal(v0, v1, v2);
-
- //a normal may already be set at given index, we accumulate
- //values and we will normalize them in a second loop
- ncursor.moveTo(idx0); nv.add(normal);
- ncursor.moveTo(idx1); nv.add(normal);
- ncursor.moveTo(idx2); nv.add(normal);
- }
-
- //normalize normals
- for (int i=0,n=index.getLength();i<n;i+=3) {
- icursor.moveTo(i+offset);
- final int idx0 = (int) icursor.samples().get(0);
- icursor.next();
- final int idx1 = (int) icursor.samples().get(0);
- icursor.next();
- final int idx2 = (int) icursor.samples().get(0);
- ncursor.moveTo(idx0); nv.normalize();
- if (!nv.isFinite()) nv.set(new double[]{1,0,0});
- ncursor.moveTo(idx1); nv.normalize();
- if (!nv.isFinite()) nv.set(new double[]{1,0,0});
- ncursor.moveTo(idx2); nv.normalize();
- if (!nv.isFinite()) nv.set(new double[]{1,0,0});
- }
-
- setNormals(normals);
- }
- }
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- */
- @Override
- public void computeSmoothNormals() {
-
- final TupleArray positions = getAttribute(ATT_POSITION);
- final TupleArray normals = TupleArrays.of(positions.getSampleSystem(), new float[positions.getLength()*3]);
-
- //compute smooth normals
- final Vector pos0 = Vectors.createDouble(3);
- final Vector pos1 = Vectors.createDouble(3);
- final Vector pos2 = Vectors.createDouble(3);
- final Vector nor0 = Vectors.createDouble(3);
- final Vector nor1 = Vectors.createDouble(3);
- final Vector nor2 = Vectors.createDouble(3);
-
- new MeshPrimitiveVisitor(this) {
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- }
-
- @Override
- protected void visit(Triangle candidate) {
- final PointSequence points = candidate.getExteriorRing().getPoints();
- int idx0 = ((MeshPrimitive.Vertex)points.getPoint(0)).getIndex();
- int idx1 = ((MeshPrimitive.Vertex)points.getPoint(1)).getIndex();
- int idx2 = ((MeshPrimitive.Vertex)points.getPoint(2)).getIndex();
- if (idx0 == idx1 || idx0 == idx2 || idx1 == idx2) {
- //flat triangle ignore it
- return;
- }
- positions.get(idx0, pos0);
- positions.get(idx1, pos1);
- positions.get(idx2, pos2);
-
- if (fastEquals(pos0, pos1) || fastEquals(pos0, pos2) || fastEquals(pos1, pos2)) {
- //flat triangle ignore it
- return;
- }
-
- final Vector normal = Maths.calculateNormal(pos0, pos1, pos2);
- if (normal.isFinite()) {
- //we do this check to ignore bad or degenerated triangles
- normals.get(idx0, nor0);
- normals.get(idx1, nor1);
- normals.get(idx2, nor2);
- nor0.add(normal);
- nor1.add(normal);
- nor2.add(normal);
- normals.set(idx0, nor0);
- normals.set(idx1, nor1);
- normals.set(idx2, nor2);
- }
- }
-
- @Override
- protected void visit(LineString candidate) {
- final PointSequence points = candidate.getPoints();
- int idx0 = ((MeshPrimitive.Vertex)points.getPoint(0)).getIndex();
- int idx1 = ((MeshPrimitive.Vertex)points.getPoint(1)).getIndex();
- positions.get(idx0, pos0);
- positions.get(idx1, pos1);
- final Vector normal = new Vector3D.Float(0,0,1);
-
- normals.get(idx0, nor0);
- normals.get(idx1, nor1);
- nor0.add(normal);
- nor1.add(normal);
- normals.set(idx0, nor0);
- normals.set(idx1, nor1);
- }
-
- @Override
- protected void visit(Point candidate) {
- int idx0 = ((Vertex)candidate).getIndex();
- final Vector normal = new Vector3D.Float(0,0,1);
- normals.set(idx0, normal);
- }
-
- }.visit();
-
- //normalize
- for (int i = 0, n = normals.getLength(); i < n; i++) {
- normals.get(i, nor0);
- nor0.normalize();
- if (nor0.isFinite()) {
- //we do this check to ignore bad or degenerated triangles
- normals.set(i, nor0);
- }
- }
-
- setNormals(normals);
- }
-
- private static boolean fastEquals(Tuple t1, Tuple t2) {
- return t1.get(0) == t2.get(0) && t1.get(1) == t2.get(1) && t1.get(2) == t2.get(2);
- }
-
- /**
- * Removes any duplicated vertice.
- * Compare operation is based on vertice position.
- *
- * Only the first duplicated vertex attributes are preserved.
- */
- @Override
- public void removeDuplicatesByPosition() {
-
- final Set<String> attNames = attributes.keySet();
- final Map<String,List<Tuple>> atts = new HashMap();
- final List<Entry<List<Tuple>,TupleArray>> mapping = new ArrayList<>();
- for (String attName : attNames) {
- final List<Tuple> lst = new ArrayList<>();
- atts.put(attName, lst);
- mapping.add(new AbstractMap.SimpleImmutableEntry<>(lst, attributes.get(attName)));
- }
- final List<Tuple> aNewAttribute = mapping.get(0).getKey();
-
- final Map<Tuple, Integer> reindex = new HashMap<>();
- final TupleArrayCursor cursorIdx = index.cursor();
- final TupleArrayCursor cursorPos = getPositions().cursor();
- final List<Vector1D.Int> newIndex = new ArrayList<>();
-
- while (cursorIdx.next()) {
- int idx = (int) cursorIdx.samples().get(0);
- cursorPos.moveTo(idx);
- final Tuple position = cursorPos.samples().copy();
-
- int newIdx = aNewAttribute.size();
- Integer previous = reindex.putIfAbsent(position, newIdx);
- if (previous == null) {
- //copy attributes
- for (Entry<List<Tuple>,TupleArray> entry : mapping) {
- entry.getKey().add(entry.getValue().get(idx).copy());
- }
- newIndex.add(new Vector1D.Int(newIdx));
- } else {
- newIndex.add(new Vector1D.Int(previous));
- }
- }
-
- setIndex(TupleArrays.of(newIndex, 1, index.getDataType()));
-
- final Map<String, TupleArray> newAttributes = new HashMap();
- for (String attName : attNames) {
- final TupleArray model = attributes.get(attName);
- final TupleArray array = TupleArrays.of(atts.get(attName), model.getSampleSystem(), model.getDataType());
- newAttributes.put(attName, array);
- }
- attributes.clear();
- attributes.putAll(newAttributes);
- positions = attributes.get(AttributesType.ATT_POSITION);
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 23 * hash + Objects.hashCode(this.attributes);
- hash = 23 * hash + Objects.hashCode(this.index);
- hash = 23 * hash + Objects.hashCode(this.type);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Abs other = (Abs) obj;
- if (!Objects.equals(this.attributes, other.attributes)) {
- return false;
- }
- if (!Objects.equals(this.index, other.index)) {
- return false;
- }
- if (this.type != other.type) {
- return false;
- }
- return true;
- }
-
- @Override
- public synchronized Map<String, Object> userProperties() {
- if (userProperties == null) {
- userProperties = new HashMap<>();
- }
- return userProperties;
- }
- }
-
-
- /**
- * A vertex is a indexed point in a geometry.
- */
- public static class Vertex implements Point {
-
- private final Abs parent;
- private int index;
-
- public Vertex(MeshPrimitive geometry, int index) {
- this.parent = (Abs) geometry;
- this.index = index;
- }
-
- @Override
- public Tuple getPosition() {
- final TupleArrayCursor cursor = parent.getPositions().cursor();
- cursor.moveTo(index);
- return cursor.samples();
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- /**
- * @return index in the parent mesh.
- */
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- @Override
- public Tuple getAttribute(String key) {
- final TupleArray tupleGrid = parent.attributes.get(key);
- if (tupleGrid == null) return null;
- final TupleArrayCursor cursor = tupleGrid.cursor();
- cursor.moveTo(index);
- return cursor.samples();
- }
-
- @Override
- public void setAttribute(String name, Tuple tuple) {
- final TupleArray tupleGrid = parent.attributes.get(name);
- if (tupleGrid == null) throw new IllegalArgumentException("Attribute " + name + " do not exist");
- final TupleArrayCursor cursor = tupleGrid.cursor();
- cursor.moveTo(index);
- cursor.samples().set(tuple);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return parent.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public AttributesType getAttributesType() {
- return parent.getAttributesType();
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("V:");
- sb.append(getIndex());
- final TreeSet<String> properties = new TreeSet<>(getAttributesType().getAttributeNames());
- for (String name : properties) {
- sb.append(" ");
- sb.append(name);
- final Tuple tuple = getAttribute(name);
- sb.append(Arrays.toString(tuple.toArrayDouble()));
- }
- return sb.toString();
- }
- }
-
- public static final class Sequence implements PointSequence {
-
- private final Abs primitive;
- public final int[] index;
-
- public Sequence(MeshPrimitive primitive, int[] index) {
- this.primitive = (Abs) primitive;
- this.index = index;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return primitive.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public int size() {
- return index.length;
- }
-
- @Override
- public Point getPoint(int index) {
- return new Vertex(primitive, this.index[index]);
- }
-
- @Override
- public Tuple getPosition(int index) {
- return primitive.getPositions().get(this.index[index]);
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- return primitive.getAttribute(name).get(this.index[index]);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return primitive.getAttributesType();
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- primitive.getPositions().set(this.index[index], value);
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- primitive.getAttribute(name).set(this.index[index], value);
- }
-
- @Override
- public BBox getAttributeRange(String name) {
- return TupleArrays.computeRange(TupleArrays.subset(primitive.getAttribute(name),index));
- }
- }
-
- public static class Points extends Abs implements MultiPoint<Point>{
- public Points() {
- super(Type.POINTS);
- }
-
- @Override
- public String getGeometryType() {
- return "MULTIPOINT";
- }
-
- @Override
- public int getNumGeometries() {
- if (index == null) return getPositions().getLength();
- return this.index.getLength();
- }
-
- @Override
- public Point getGeometryN(int n) {
- final int[] indices = (index == null) ? new int[]{n} : index.toArrayInt(n, 1);
- return new Sequence(this, indices).getPoint(0);
- }
- }
-
- public static class Lines extends Abs implements MultiLineString {
- public Lines() {
- super(Type.LINES);
- }
-
- @Override
- public int getNumGeometries() {
- if (index == null) return getPositions().getLength() / 2;
- return index.getLength() / 2;
- }
-
- @Override
- public LineString getGeometryN(int n) {
- final int[] indices = (index == null) ? new int[]{n*2, n*2+1} : index.toArrayInt(n*2, 2);
- return GeometryFactory.createLineString(new Sequence(this, indices));
- }
- }
-
- public static class LineLoop extends Abs implements LineString {
- public LineLoop() {
- super(Type.LINE_LOOP);
- }
-
- @Override
- public PointSequence getPoints() {
- //select all points, duplicate first point as last
- int[] indices;
- if (index == null) {
- indices = new int[getPositions().getLength() + 1];
- for (int i = 0; i < indices.length; i++) indices[i] = i;
- indices[indices.length - 1] = 0;
- } else {
- indices = index.toArrayInt();
- indices = Arrays.copyOf(indices, indices.length + 1);
- indices[indices.length - 1] = indices[0];
- }
- return new Sequence(this, indices);
- }
- }
-
- public static class LineStrip extends Abs implements LineString {
- public LineStrip() {
- super(Type.LINE_STRIP);
- }
-
- @Override
- public PointSequence getPoints() {
- final int[] indices;
- if (index == null) {
- indices = new int[getPositions().getLength()];
- for (int i = 0; i < indices.length; i++) indices[i] = i;
- } else {
- indices = index.toArrayInt();
- }
- return new Sequence(this, indices);
- }
- }
-
- public static class Triangles extends Abs implements TIN {
- public Triangles() {
- super(Type.TRIANGLES);
- }
-
- @Override
- public int getNumPatches() {
- if (index == null) return getPositions().getLength() / 3;
- return index.getLength() / 3;
- }
-
- @Override
- public Triangle getPatchN(int n) {
- int[] indices;
- if (index == null) {
- int o = n*3;
- indices = new int[]{o, o+1, o+2, o};
- } else {
- indices = index.toArrayInt(n*3, 3);
- indices = Arrays.copyOf(indices, 4);
- indices[3] = indices[0];
- }
- return GeometryFactory.createTriangle(GeometryFactory.createLinearRing(new Sequence(this, indices)));
- }
- }
-
- public static class TriangleFan extends Abs implements TIN {
- public TriangleFan() {
- super(Type.TRIANGLE_FAN);
- }
-
- @Override
- public int getNumPatches() {
- if (index == null) return getPositions().getLength() - 2;
- return index.getLength() - 2;
- }
-
- @Override
- public Triangle getPatchN(int n) {
- final int[] indices = new int[4];
- if (index == null) {
- indices[0] = 0;
- indices[1] = 1 + n;
- indices[2] = 2 + n;
- } else {
- indices[0] = (int) index.get(0 ).get(0);
- indices[1] = (int) index.get(1 + n).get(0);
- indices[2] = (int) index.get(2 + n).get(0);
- }
- indices[3] = indices[0];
- return GeometryFactory.createTriangle(GeometryFactory.createLinearRing(new Sequence(this, indices)));
- }
- }
-
- public static class TriangleStrip extends Abs implements TIN {
- public TriangleStrip() {
- super(Type.TRIANGLE_STRIP);
- }
-
- @Override
- public int getNumPatches() {
- if (index == null) return getPositions().getLength() - 2;
- return index.getLength() - 2;
- }
-
- @Override
- public Triangle getPatchN(int n) {
- final int[] indices = new int[4];
- if (index == null) {
- indices[0] = n ;
- indices[1] = n + 1;
- indices[2] = n + 2;
- } else {
- indices[0] = (int) index.get(n ).get(0);
- indices[1] = (int) index.get(n + 1).get(0);
- indices[2] = (int) index.get(n + 2).get(0);
- }
-
- //in triangle strip we must take care to reverse index
- //at every new point, otherwise we would have reverse winding
- //for each triangle
- if (n % 2 != 0) {
- int t = indices[0];
- indices[0] = indices[1];
- indices[1] = t;
- }
- indices[3] = indices[0];
-
- return GeometryFactory.createTriangle(GeometryFactory.createLinearRing(new Sequence(this, indices)));
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java
deleted file mode 100644
index 677b2bd..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.util.Utilities;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class MeshPrimitiveComparator {
-
- private boolean compareCrs = true;
- private boolean compareByElement = false;
- private boolean skipDegenerated = false;
- private List<String> comparedAttributes = new ArrayList<>();
-
- /**
- * Set to false to ignore CRS.
- */
- public MeshPrimitiveComparator compareCrs(boolean compareCrs) {
- this.compareCrs = compareCrs;
- return this;
- }
-
- /**
- * Set to true to compare point,line,triangles as unique element
- * and ignore variable indexing.
- */
- public MeshPrimitiveComparator compareByElement(boolean compareByElement) {
- this.compareByElement = compareByElement;
- return this;
- }
-
- /**
- * Set to true to skip degenerated lines and triangles.
- * This parameter only works when comparison by elements is true.
- */
- public MeshPrimitiveComparator skipDegenerated(boolean skipDegenerated) {
- this.skipDegenerated = skipDegenerated;
- return this;
- }
-
- /**
- * Finite list of attributes to compare.
- * This parameter only works when comparison by elements is true.
- */
- public MeshPrimitiveComparator comparedAttributes(String ... names) {
- comparedAttributes = Arrays.asList(names);
- return this;
- }
-
- /**
- * Compare two primitive.
- * @throws IllegalArgumentException if they are not equal
- */
- public void compare(MeshPrimitive expected, MeshPrimitive candidate) throws IllegalArgumentException {
-
- if (compareCrs) {
- if (!Utilities.equalsIgnoreMetadata(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
- throw new IllegalArgumentException("CRS are different");
- }
- }
-
- if (!compareByElement) {
- if (!expected.getType().equals(candidate.getType())) {
- throw new IllegalArgumentException("Primitive type differ, expected " + expected.getType() + " but was " + candidate.getType());
- }
-
- final List<String> expectedAtts = expected.getAttributesType().getAttributeNames();
- final List<String> candidateAtts = candidate.getAttributesType().getAttributeNames();
- final TupleArray expectedIdx = expected.getIndex();
- final TupleArray candidateIdx = candidate.getIndex();
-
- if (!Objects.equals(expectedAtts, candidateAtts)) {
- throw new IllegalArgumentException("Primitive attributes differ");
- }
- for (String attName : expectedAtts) {
- if (!Objects.equals(expected.getAttribute(attName), candidate.getAttribute(attName))) {
- throw new IllegalArgumentException("Primitive attributes " + attName + "differ");
- }
- }
-
- if (!Objects.equals(expectedIdx, candidateIdx)) {
- throw new IllegalArgumentException("Primitive index differ");
- }
- } else {
- final List<Geometry> expectedElements = elements(expected);
- final List<Geometry> candidateElements = elements(candidate);
-
- if (skipDegenerated) {
- //remove all degenerated elements
- for (int i = expectedElements.size() - 1; i >= 0; i--) {
- if (isDegenerated(expectedElements.get(i))) {
- expectedElements.remove(i);
- }
- }
- for (int i = candidateElements.size() - 1; i >= 0; i--) {
- if (isDegenerated(candidateElements.get(i))) {
- candidateElements.remove(i);
- }
- }
- }
-
- if (expectedElements.size() != candidateElements.size()) {
- throw new IllegalArgumentException("Number of elements do not match. expected " + expectedElements.size() + " but was " + candidateElements.size());
- }
-
- search:
- for (int t=0,n=expectedElements.size();t<n;t++) {
- Object exp = expectedElements.get(t);
- if (skipDegenerated && isDegenerated(exp)) {
- continue;
- }
-
- for (Object cdt : candidateElements) {
- if (equals(exp, cdt)) {
- //found equivalent
- candidateElements.remove(cdt);
- continue search;
- }
- }
- throw new IllegalArgumentException("Primitive element " + t + " not found " + exp);
- }
-
- }
-
- }
-
- /**
- * Compare two multi-primitive.
- * @throws IllegalArgumentException if they are not equal
- */
- public void compare(MultiMeshPrimitive expected, MultiMeshPrimitive candidate) throws IllegalArgumentException {
-
- if (compareCrs) {
- if (!Utilities.equalsIgnoreMetadata(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
- throw new IllegalArgumentException("CRS are different");
- }
- }
-
- final List<? extends MeshPrimitive> expectedPrimitives = expected.getComponents();
- final List<? extends MeshPrimitive> candidatePrimitives = candidate.getComponents();
-
- int size = expectedPrimitives.size();
- if (expectedPrimitives.size() != candidatePrimitives.size()) {
- throw new IllegalArgumentException("Number of primitives differ, expected " + expectedPrimitives.size() + " but was " + candidatePrimitives.size());
- }
-
- for (int i = 0; i < size; i++) {
- final MeshPrimitive pe = expectedPrimitives.get(i);
- final MeshPrimitive pc = candidatePrimitives.get(i);
- compare(pe, pc);
- }
- }
-
- /**
- * Compare two mesh element.
- * @return true if elements are equal.
- */
- private boolean equals(Object expected, Object candidate) {
- if (expected instanceof Point && candidate instanceof Point) {
- final Point e1 = (Point) expected;
- final Point e2 = (Point) candidate;
- return compareVertex((MeshPrimitive.Vertex) e1, (MeshPrimitive.Vertex) e2);
-
- } else if (expected instanceof LineString && candidate instanceof LineString) {
- final LineString e1 = (LineString) expected;
- final LineString e2 = (LineString) candidate;
-
- final Vertex e1v0 = (Vertex) e1.getPoints().getPoint(0);
- final Vertex e1v1 = (Vertex) e1.getPoints().getPoint(1);
- final Vertex e2v0 = (Vertex) e2.getPoints().getPoint(0);
- final Vertex e2v1 = (Vertex) e2.getPoints().getPoint(1);
- return (compareVertex(e1v0, e2v0) && compareVertex(e1v1, e2v1))
- || (compareVertex(e1v0, e2v1) && compareVertex(e1v1, e2v0));
-
-
- } else if (expected instanceof Triangle && candidate instanceof Triangle) {
- final LineString e1 = ((Triangle) expected).getExteriorRing();
- final LineString e2 = ((Triangle) candidate).getExteriorRing();
-
- final Vertex e1v0 = (Vertex) e1.getPoints().getPoint(0);
- final Vertex e1v1 = (Vertex) e1.getPoints().getPoint(1);
- final Vertex e1v2 = (Vertex) e1.getPoints().getPoint(2);
- final Vertex e2v0 = (Vertex) e2.getPoints().getPoint(0);
- final Vertex e2v1 = (Vertex) e2.getPoints().getPoint(1);
- final Vertex e2v2 = (Vertex) e2.getPoints().getPoint(2);
- return (compareVertex(e1v0, e2v0) && compareVertex(e1v1, e2v1) && compareVertex(e1v2, e2v2))
- || (compareVertex(e1v0, e2v1) && compareVertex(e1v1, e2v2) && compareVertex(e1v2, e2v0))
- || (compareVertex(e1v0, e2v2) && compareVertex(e1v1, e2v0) && compareVertex(e1v2, e2v1));
- }
- return false;
- }
-
- /**
- * Compare two mesh vertex attributes.
- * @return true if vertex are equal.
- */
- private boolean compareVertex(MeshPrimitive.Vertex expected, MeshPrimitive.Vertex candidate) {
-
- Collection<String> toTest = comparedAttributes;
- if (toTest.isEmpty()) {
- toTest = expected.getAttributesType().getAttributeNames();
- if (toTest.size() != candidate.getAttributesType().getAttributeNames().size()) {
- throw new IllegalArgumentException("Attributes do not match, expected "
- + Arrays.toString(toTest.toArray()) + " but was "
- + Arrays.toString(candidate.getAttributesType().getAttributeNames().toArray()));
- }
- }
-
- for (String attName : toTest) {
- final Object att1 = expected.getAttribute(attName);
- final Object att2 = candidate.getAttribute(attName);
- if (!Objects.equals(att1, att2)) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Test if given element is a degenerated line or triangle.
- */
- private static boolean isDegenerated(Object candidate) {
- if (candidate instanceof LineString) {
- final LineString cdt = (LineString) candidate;
- final PointSequence points = cdt.getPoints();
- return points.getPosition(0).equals(points.getPosition(1));
-
- } else if (candidate instanceof Triangle) {
- final Triangle cdt = (Triangle) candidate;
- final PointSequence points = cdt.getExteriorRing().getPoints();
- final Tuple c0 = points.getPosition(0);
- final Tuple c1 = points.getPosition(1);
- final Tuple c2 = points.getPosition(2);
- return c0.equals(c1)
- || c0.equals(c2)
- || c1.equals(c2);
-
- }
- return false;
- }
-
- /**
- * List all elements in given primitive.
- */
- private static List<Geometry> elements(MeshPrimitive p) {
-
- final List<Geometry> elements = new ArrayList<>();
- final MeshPrimitiveVisitor visitor = new MeshPrimitiveVisitor(p) {
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- }
-
- @Override
- protected void visit(LineString candidate) {
- elements.add(candidate);
- }
-
- @Override
- protected void visit(Point candidate) {
- elements.add(candidate);
- }
-
- @Override
- protected void visit(Triangle candidate) {
- elements.add(candidate);
- }
- };
- visitor.visit();
- return elements;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveIndexes.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveIndexes.java
deleted file mode 100644
index ed2ac47..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveIndexes.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector1D;
-
-
-/**
- * Various algorithms to transform primitive indexes.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class MeshPrimitiveIndexes {
-
- private MeshPrimitiveIndexes(){
- //for futur parameters
- }
-
- /**
- * Create an opposite winding triangle strip index.
- *
- * Current algorithm build a triangle index which are converted to a strip again.
- * TODO : we should search for a more efficient solution.
- * A solution is to add a degenerated triangle, but this might not create the best solution.
- *
- * @param index triangle strip index
- * @param type index type, only triangle type index supported
- * @return reverse winding triangle index, returned type is the same as input
- */
- public static TupleArray reverseTriangles(TupleArray index, MeshPrimitive.Type type) {
- switch (type) {
- case TRIANGLE_FAN :
- throw new UnsupportedOperationException("Triangle fan type not supported yet");
- case TRIANGLE_STRIP :
- return toTriangleStrip(
- reverseTriangles(
- toTrianglesNoPack(index),
- MeshPrimitive.Type.TRIANGLES),
- MeshPrimitive.Type.TRIANGLES);
- case TRIANGLES :
- break;
- default :
- throw new IllegalArgumentException("Only triangle index type supported, but was " + type.name());
- }
-
- int[] array = index.toArrayInt();
- for(int i = 0, t = 0; i < array.length; i+=3) {
- t = array[i+1];
- array[i+1] = array[i+2];
- array[i+2] = t;
- }
- return TupleArrays.packIntegerDataType(TupleArrays.of(index.getSampleSystem(), array));
- }
-
- /**
- * Build triangles from primitive triangles.
- * This method generate a new index of type TRIANGLES.
- *
- * @param index triangle strip index.
- * @param type index type, only triangle type index supported
- * @return triangles index, can be the original index if it is already triangle.
- */
- public static TupleArray toTriangles(TupleArray index, MeshPrimitive.Type type) {
- switch (type) {
- case TRIANGLE_FAN :
- throw new UnsupportedOperationException("Triangle fan type not supported yet");
- case TRIANGLE_STRIP :
- //continues below
- break;
- case TRIANGLES :
- //return unchanged
- return index;
- default :
- throw new IllegalArgumentException("Only triangle index type supported, but was " + type.name());
- }
- final TupleArray tidx = toTrianglesNoPack(index);
- return TupleArrays.packIntegerDataType(tidx);
- }
-
- /**
- * Build triangles from primitive triangle strip.
- * This method generate a new index of type TRIANGLES.
- * Empty triangles are removed (two identical index in the same triangle).
- *
- * @param triangleStripIndex triangle strip index.
- * @return triangles index.
- */
- private static TupleArray toTrianglesNoPack(TupleArray triangleStripIndex) {
-
- final TupleArrayCursor cursor = triangleStripIndex.cursor();
-
- int[] triangles = new int[(triangleStripIndex.getLength()-2)*3];
- cursor.moveTo(0);
- int idx0 = (int) cursor.samples().get(0);
- cursor.moveTo(1);
- int idx1 = (int) cursor.samples().get(0);
-
- int realsize = 0;
- int maxIdx = Math.max(idx0, idx1);
- for (int i = 2, n = triangleStripIndex.getLength(), k = 0; i < n; i++) {
- cursor.moveTo(i);
- int idx2 = (int) cursor.samples().get(0);
- maxIdx = Math.max(maxIdx, idx2);
-
- //check for empty triangle and remove them
- if (idx0 == idx1 || idx0 == idx2 || idx1 == idx2) {
- //ignore it, empty
- } else {
- //in triangle strip we must take care to reverse index
- //at every new point, otherwise we would have reverse winding
- //for each triangle winding is reversed
- if (i % 2 == 0) {
- triangles[k ] = idx0;
- triangles[k+1] = idx1;
- triangles[k+2] = idx2;
- } else {
- triangles[k ] = idx0;
- triangles[k+1] = idx2;
- triangles[k+2] = idx1;
- }
-
- k += 3;
- realsize += 3;
- }
- idx0 = idx1;
- idx1 = idx2;
- }
-
- if (triangles.length != realsize) {
- triangles = Arrays.copyOf(triangles, realsize);
- }
-
- return TupleArrays.of(1, triangles);
- }
-
- /**
- * Build a triangle strip index from triangles index.
- * This method generate a new index of type TRIANGLE_STRIP.
- *
- * @param index triangles index.
- * @param type index type, only triangle type index supported
- * @return triangle strip index, can be the original index if it is already a strip
- */
- public static TupleArray toTriangleStrip(TupleArray index, MeshPrimitive.Type type) {
-
- switch (type) {
- case TRIANGLE_FAN :
- throw new UnsupportedOperationException("Triangle fan type not supported yet");
- case TRIANGLE_STRIP :
- //return unchanged
- return index;
- case TRIANGLES :
- //continues below
- break;
- default :
- throw new IllegalArgumentException("Only triangle index type supported, but was " + type.name());
- }
-
- final Map<Long,Edge> map = new HashMap<>();
- final Set<Edge> edges = new HashSet<>();
-
- //build edges map
- final TupleArrayCursor cursor = index.cursor();
- while (cursor.next()) {
- final int i0 = (int) cursor.samples().get(0);
- cursor.next();
- final int i1 = (int) cursor.samples().get(0);
- cursor.next();
- final int i2 = (int) cursor.samples().get(0);
- final Triangle t = new Triangle(i0,i1,i2);
- t.buildEdges(map);
- edges.add(t.edge0);
- edges.add(t.edge1);
- edges.add(t.edge2);
- }
-
- //pick the first edge which is a mesh border
- //if none left pick the first edge if any remaining
- final List<LinkedList<Vector1D.Int>> strips = new ArrayList<>();
- while (!edges.isEmpty()) {
-
- //find a good starting edge
- Edge edge = null;
- int priority = -100;
- for (Edge e : edges) {
- final int p = e.priority();
- if (p == 20) {
- //best case
- edge = e;
- break;
- } else if (p > priority) {
- priority = p;
- edge = e;
- }
- }
-
- //build strip starting with this edge
- strips.add(buildStrip(edge, edges));
- }
-
- //connect each strip with a degenerated triangle
- final List<Vector1D.Int> stripIndex = connect(strips);
-
- TupleArray idx = TupleArrays.of(stripIndex, 1, DataType.UINT);
- return TupleArrays.packIntegerDataType(idx);
- }
-
- /**
- * Connect each strip with a degenerated triangle.
- */
- private static List<Vector1D.Int> connect(List<? extends List<Vector1D.Int>> strips) {
- final List<Vector1D.Int> index = new ArrayList<>();
- for (List<Vector1D.Int> strip : strips) {
- if (!index.isEmpty()) {
- //we must have even size trips otherwise next concatenated strip will have reversed winding
- if (index.size() % 2 != 0) {
- //repeat the last index to reset winding
- index.add(new Vector1D.Int(index.get(index.size()-1)));
- }
- //add a degenerated triangle as link between strips
- index.add(new Vector1D.Int(index.get(index.size()-1)));
- index.add(new Vector1D.Int(strip.get(0)));
- }
- index.addAll(strip);
- }
- return index;
- }
-
- private static LinkedList<Vector1D.Int> buildStrip(final Edge root, Collection<Edge> edges) {
-
- //Build list of edges we will use in the strip
- final LinkedList<Vector1D.Int> index = new LinkedList<>();
-
- Triangle triangle;
- {//loop one way
- Edge edge = root;
- triangle = edge.triangle;
- //add the 3 first indices
- index.add(new Vector1D.Int(edge.start));
- index.add(new Vector1D.Int(edge.end));
- index.add(new Vector1D.Int(edge.next.end));
-
- //add each next triangle new vertex
- edge = edge.next;
- edge = edge.neighbor;
-
- //remove from list triangle edges
- triangle.unregister(edges);
-
- for (boolean odd = false; edge != null; odd = !odd) {
- index.add(new Vector1D.Int(edge.next.end));
- edge = odd ? edge.next : edge.next.next;
- triangle = edge.triangle;
- edge = edge.neighbor;
- triangle.unregister(edges);
- }
- }
- {//loop the other way
- //we need at least 2 triangles to preserve winding order
- Edge edge = root;
- boolean odd = true;
- while (edge.neighbor != null && edge.neighbor.opposite(odd) != null) {
- edge = edge.neighbor;
- index.add(new Vector1D.Int(edge.next.end));
- triangle = edge.triangle;
- edge = edge.opposite(odd).neighbor;
- triangle.unregister(edges);
- }
- }
- return index;
- }
-
- private static long edgeId(int start, int end) {
- return (((long) start) << 32) | ((long) end);
- }
-
- private static final class Triangle {
- final int i0;
- final int i1;
- final int i2;
- final Edge edge0;
- final Edge edge1;
- final Edge edge2;
-
- public Triangle(int i0, int i1, int i2) {
- this.i0 = i0;
- this.i1 = i1;
- this.i2 = i2;
- this.edge0 = new Edge(i0, i1, this);
- this.edge1 = new Edge(i1, i2, this);
- this.edge2 = new Edge(i2, i0, this);
- this.edge0.next = this.edge1;
- this.edge1.next = this.edge2;
- this.edge2.next = this.edge0;
- }
-
- private void buildEdges(Map<Long,Edge> edges) {
- edges.put(edgeId(i0, i1), edge0);
- edges.put(edgeId(i1, i2), edge1);
- edges.put(edgeId(i2, i0), edge2);
- edge0.updateNeighbor(edges.get(edgeId(i1, i0)));
- edge1.updateNeighbor(edges.get(edgeId(i2, i1)));
- edge2.updateNeighbor(edges.get(edgeId(i0, i2)));
- }
-
- private void unregister(Collection<Edge> edges) {
- edges.remove(edge0);
- edges.remove(edge1);
- edges.remove(edge2);
- edge0.updateNeighbor(null);
- edge1.updateNeighbor(null);
- edge2.updateNeighbor(null);
- }
- }
-
- private static final class Edge {
- private final int start;
- private final int end;
- private final Triangle triangle;
- private Edge next;
- private Edge neighbor;
-
- public Edge(int start, int end, Triangle triangle) {
- this.start = start;
- this.end = end;
- this.triangle = triangle;
- }
-
- /**
- * Get the edge where the strip exist if it started by this edge.
- */
- private Edge opposite(boolean odd) {
- return odd ? next : next.next;
- }
-
- private void updateNeighbor(Edge edge) {
- if (neighbor != null) {
- //remove revious neighbor relation both ways
- neighbor.neighbor = null;
- }
- neighbor = edge;
- if (neighbor != null) {
- neighbor.neighbor = this;
- }
- }
-
- private int priority() {
- final boolean border = this.neighbor != null;
- final boolean nextborder = this.next.neighbor != null;
- final boolean previousborder = this.next.next.neighbor != null;
-
- // NO NEIGHBOR TRIANGLES EDGES /////////////////////////////////////
- if (!border && !nextborder && !previousborder) {
- /*
- single triangle edge, highest priority
- +
- |\
- | \
- +==+
- */
- return 20;
- }
- // SINGLE NEIGHBOR TRIANGLES EDGES /////////////////////////////////
- else if (!border && nextborder && !previousborder) {
- /*
- Strip starting edge.
- corner triangle starting edge,
- highest priority
- +--+
- |\ |
- | \|
- +==+
- */
- return 20;
- } else if ( border && !nextborder && !previousborder) {
- /*
- not possible strip starting edge.
- A better edge in the triangle exist !
- never start with such edge.
- +
- |\
- | \
- +==+
- \ |
- \|
- +
- */
- return -10;
- } else if (!border && !nextborder && previousborder) {
- /*
- not possible strip starting edge.
- A better edge in the triangle exist !
- never start with such edge.
- +--+
- \ |\
- \| \
- +==+
- */
- return -10;
- }
-
- // TWO NEIGHBOR TRIANGLES EDGES ////////////////////////////////////
- else if ( border && nextborder && !previousborder) {
- /*
- possible strip starting edge.
- low priority
- +--+
- |\ |
- | \|
- +==+
- \ |
- \|
- +
- */
- return 4;
- } else if ( border && !nextborder && previousborder) {
- /*
- not possible strip starting edge.
- edge in a strip,
- lower priority
- +--+
- \ |\
- \| \
- +==+
- \ |
- \|
- +
- */
- return 3;
- } else if (!border && nextborder && previousborder) {
- /*
- possible strip starting edge.
- edge in a strip,
- low priority
- +--+--+
- \ |\ |
- \| \|
- +==+
- */
- return 4;
- }
-
- // THREE NEIGHBOR TRIANGLES EDGES //////////////////////////////////
- else if ( border && nextborder && previousborder) {
- /*
- possible strip starting edge.
- edge in the middle of multiple triangles.
- lowest priority
- +--+--+
- \ |\ |
- \| \|
- +==+
- \ |
- \|
- +
- */
- return 0;
- } else {
- throw new IllegalArgumentException("Should never happen");
- }
- }
-
- @Override
- public String toString() {
- return "E " + start + " " + end + " P" + priority();
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveVisitor.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveVisitor.java
deleted file mode 100644
index e138f8c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveVisitor.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.HashSet;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Loop on all geometry primitive and vertex informations.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class MeshPrimitiveVisitor {
-
- private final HashSet visited = new HashSet();
- private MultiMeshPrimitive<?> geometry;
- private MeshPrimitive primitive;
-
-
- public MeshPrimitiveVisitor() {}
-
- /**
- *
- * @param geometry to visit, not null.
- */
- public MeshPrimitiveVisitor(Geometry geometry) {
- if (geometry instanceof MeshPrimitive p) {
- reset(new MultiMeshPrimitive(p));
- } else if (geometry instanceof MultiMeshPrimitive mp) {
- reset(mp);
- } else {
- throw new IllegalArgumentException("Geometry is not a primitive");
- }
- }
-
- /**
- * Change visited geometry and reset visit states.
- *
- * @param geometry not null
- */
- public void reset(MultiMeshPrimitive geometry) {
- ArgumentChecks.ensureNonNull("geometry", geometry);
- this.geometry = geometry;
- visited.clear();
- }
-
- /**
- * Loop on all primitives in the geometry.
- */
- public void visit() {
- for (MeshPrimitive p : geometry.getComponents()) {
- visit(p);
- }
- }
-
- protected void visit(MeshPrimitive primitive) {
- visited.clear();
- this.primitive = primitive;
-
- TupleArray index = primitive.getIndex();
- if (index == null) {
- //create a virtual index with all points
- int[] indices = new int[primitive.getPositions().getLength()];
- for (int i = 0; i < indices.length; i++) indices[i] = i;
- index = TupleArrays.ofUnsigned(1, indices);
- }
- if (index.isEmpty()) return;
-
- final TupleArrayCursor cursor = index.cursor();
-
- int idx0;
- int idx1;
- int idx2;
- int cnt = index.getLength();
- MeshPrimitive.Type mode = primitive.getType();
- int offset = 0;
- int i;
- int n;
-
- switch (mode) {
- case POINTS:
- for (i = 0; i < cnt; i++) {
- cursor.moveTo(i + offset + 0);
- idx0 = (int) cursor.samples().get(0);
- visit(readPoint(idx0));
- visited.add(idx0);
- } break;
- case LINES:
- for (i = 0; i < cnt; i+=2) {
- cursor.moveTo(i + offset + 0);
- idx0 = (int) cursor.samples().get(0);
- cursor.moveTo(i + offset + 1);
- idx1 = (int) cursor.samples().get(0);
- visit(readLine(idx0, idx1));
- visited.add(idx0);
- visited.add(idx1);
- } break;
- case LINE_STRIP:
- for (i = 1; i < cnt; i++) {
- cursor.moveTo(i-1);
- idx0 = (int) cursor.samples().get(0);
- cursor.moveTo(i);
- idx1 = (int) cursor.samples().get(0);
- visit(readLine(idx0, idx1));
- visited.add(idx0);
- visited.add(idx1);
- } break;
- case TRIANGLES:
- for (n = offset + cnt; offset < n;) {
- cursor.moveTo(offset);
- idx0 = (int) cursor.samples().get(0);
- offset++;
- cursor.moveTo(offset);
- idx1 = (int) cursor.samples().get(0);
- offset++;
- cursor.moveTo(offset);
- idx2 = (int) cursor.samples().get(0);
- offset++;
- visit(readTriangle(idx0, idx1, idx2));
- visited.add(idx0);
- visited.add(idx1);
- visited.add(idx2);
- } break;
- case TRIANGLE_FAN:
- cursor.moveTo(offset+0);
- idx0 = (int) cursor.samples().get(0);
- for (i = 1, n = cnt-1; i < n; i++) {
- cursor.moveTo(offset + i);
- idx1 = (int) cursor.samples().get(0);
- cursor.moveTo(offset + i + 1);
- idx2 = (int) cursor.samples().get(0);
- visit(readTriangle(idx0, idx1, idx2));
- visited.add(idx0);
- visited.add(idx1);
- visited.add(idx2);
- } break;
- case TRIANGLE_STRIP:
- cursor.moveTo(0);
- idx0 = (int) cursor.samples().get(0);
- cursor.moveTo(1);
- idx1 = (int) cursor.samples().get(0);
- for (i = 2, n = cnt; i < n; i++) {
- cursor.moveTo(i);
- idx2 = (int) cursor.samples().get(0);
- //in triangle strip we must take care to reverse index
- //at every new point, otherwise we would have reverse winding
- //for each triangle
- Triangle t;
- if (i % 2 == 0) {
- t = readTriangle(idx0, idx1, idx2);
- } else {
- t = readTriangle(idx1, idx0, idx2);
- }
- visit(t);
- visited.add(idx0);
- visited.add(idx1);
- visited.add(idx2);
- idx0 = idx1;
- idx1 = idx2;
- } break;
- default:
- throw new UnsupportedOperationException("TODO");
- }
-
- }
-
- private Point readPoint(int idx0) {
- return new MeshPrimitive.Vertex(primitive, idx0);
- }
-
- private Triangle readTriangle(int idx0, int idx1, int idx2) {
- return GeometryFactory.createTriangle(GeometryFactory.createLinearRing(new MeshPrimitive.Sequence(primitive, new int[]{idx0, idx1, idx2, idx0})));
- }
-
- private LineString readLine(int idx0, int idx1) {
- return GeometryFactory.createLineString(new MeshPrimitive.Sequence(primitive, new int[]{idx0, idx1}));
- }
-
- /**
- * Override this method to process a triangle.
- */
- protected void visit(Triangle candidate) {
- final PointSequence points = candidate.getExteriorRing().getPoints();
- visit((MeshPrimitive.Vertex) points.getPoint(0));
- visit((MeshPrimitive.Vertex) points.getPoint(1));
- visit((MeshPrimitive.Vertex) points.getPoint(2));
- }
-
- /**
- * Override this method to process a line.
- */
- protected void visit(LineString candidate) {
- final PointSequence points = candidate.getPoints();
- visit((MeshPrimitive.Vertex) points.getPoint(0));
- visit((MeshPrimitive.Vertex) points.getPoint(1));
- }
-
- /**
- * Override this method to process a point.
- */
- protected void visit(Point candidate) {
- visit((MeshPrimitive.Vertex) candidate);
- }
-
- /**
- * Called when visiting a mesh vertex.
- * @param vertex visited vertex.
- */
- protected abstract void visit(MeshPrimitive.Vertex vertex);
-
- public boolean isVisited(MeshPrimitive.Vertex vertex) {
- return visited.contains(vertex.getIndex());
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java
deleted file mode 100644
index 4a91844..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.GeometryCollection;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
-
-
-/**
- * MultiPrimitive is a group of primitive defining a more complex geometry.
- * A primitive mimics the natural structures used by GPUs.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class MultiMeshPrimitive<T extends MeshPrimitive> extends AbstractGeometry implements GeometryCollection<T> {
-
- protected final List<T> primitives = new ArrayList<>();
-
- private CoordinateReferenceSystem crs;
- private Map<String, Object> userProperties;
-
- /**
- * Create a geometry with right hand 3D CRS.
- */
- public MultiMeshPrimitive() {
- this(Geometries.RIGHT_HAND_3D);
- }
-
- public MultiMeshPrimitive(CoordinateReferenceSystem crs) {
- ArgumentChecks.ensureNonNull("crs", crs);
- this.crs = crs;
- }
-
- public MultiMeshPrimitive(MeshPrimitive ... primitives) {
- this(primitives[0].getCoordinateReferenceSystem());
- append(Arrays.asList(primitives));
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- for (MeshPrimitive p : primitives) {
- return p.getCoordinateReferenceSystem();
- }
- return crs;
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
- for (MeshPrimitive p : primitives) {
- p.setCoordinateReferenceSystem(crs);
- }
- this.crs = crs;
- }
-
- public boolean isEmpty() {
- for (MeshPrimitive p : primitives) {
- if (!p.isEmpty()) {
- return false;
- }
- }
- return true;
- }
-
- public List<T> getComponents() {
- return Collections.unmodifiableList(primitives);
- }
-
- @Override
- public int getNumGeometries() {
- return primitives.size();
- }
-
- @Override
- public T getGeometryN(int n) {
- return primitives.get(n);
- }
-
- /**
- * Check geometry definition.
- */
- public void validate() {
- for (MeshPrimitive p : primitives) {
- p.validate();
- }
- }
-
- /**
- * Add primitives.
- *
- * @param other Primitives to merge in.
- */
- public void append(Collection<? extends MeshPrimitive> other) {
- for (MeshPrimitive p : other) {
- if (!Utilities.equalsIgnoreMetadata(crs, p.getCoordinateReferenceSystem())) {
- throw new IllegalArgumentException("Primitives must have the same CRS as the MultiPrimitive.");
- }
- }
- primitives.addAll((Collection<? extends T>) other);
- }
-
- /**
- * Make a deep copy of this multi-primitive.
- *
- * Note : this method will clone all attributes.
- *
- * @return copied MultiPrimitive
- */
- public MultiMeshPrimitive deepCopy() throws TransformException {
- final MultiMeshPrimitive copy = new MultiMeshPrimitive(getCoordinateReferenceSystem());
- for (MeshPrimitive p : primitives) {
- copy.primitives.add(p.deepCopy());
- }
- return copy;
- }
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- * This method should not be used if vertices are shared by multiple
- * triangles or it will cause visual glitches.
- */
- public void computeFaceNormals() {
- for (MeshPrimitive p : primitives) {
- p.computeFaceNormals();
- }
- }
-
- /**
- * Set each vertex normal by computing the normal of the triangle
- * where it is used.
- */
- public void computeSmoothNormals() {
- for (MeshPrimitive p : primitives) {
- p.computeSmoothNormals();
- }
- }
-
- @Override
- public synchronized Map<String, Object> userProperties() {
- if (userProperties == null) {
- userProperties = new HashMap<>();
- }
- return userProperties;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 23 * hash + Objects.hashCode(this.primitives);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final MultiMeshPrimitive other = (MultiMeshPrimitive) obj;
- if (!Objects.equals(this.primitives, other.primitives)) {
- return false;
- }
- return Objects.equals(this.getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem());
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/GeometryOperations.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/GeometryOperations.java
deleted file mode 100644
index 0a47545..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/GeometryOperations.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * 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.geometries.operation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.ServiceLoader;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import javax.measure.quantity.Length;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Buffer;
-import org.apache.sis.geometries.operation.spatialanalysis2d.ConvexHull;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Difference;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Distance;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Intersection;
-import org.apache.sis.geometries.operation.spatialanalysis2d.SymDifference;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Union;
-import org.apache.sis.geometries.operation.spatialedition.ComputeAttribute;
-import org.apache.sis.geometries.operation.spatialedition.To3D;
-import org.apache.sis.geometries.operation.spatialedition.ToPrimitive;
-import org.apache.sis.geometries.operation.spatialedition.Transform;
-import org.apache.sis.geometries.operation.spatialrelations2d.Contains;
-import org.apache.sis.geometries.operation.spatialrelations2d.Crosses;
-import org.apache.sis.geometries.operation.spatialrelations2d.Disjoint;
-import org.apache.sis.geometries.operation.spatialrelations2d.Equals;
-import org.apache.sis.geometries.operation.spatialrelations2d.Intersects;
-import org.apache.sis.geometries.operation.spatialrelations2d.LocateAlong;
-import org.apache.sis.geometries.operation.spatialrelations2d.LocateBetween;
-import org.apache.sis.geometries.operation.spatialrelations2d.Overlaps;
-import org.apache.sis.geometries.operation.spatialrelations2d.Relate;
-import org.apache.sis.geometries.operation.spatialrelations2d.Touches;
-import org.apache.sis.geometries.operation.spatialrelations2d.Within;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.util.Static;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class GeometryOperations extends Static {
-
- private static final Processor NONE = new Processor() {
- @Override
- public Class<Operation> getOperationClass() {
- return Operation.class;
- }
-
- @Override
- public Class<Geometry> getGeometryClass() {
- return Geometry.class;
- }
-
- @Override
- public void process(Operation operand) throws OperationException {
- throw new OperationException("Not supported.");
- }
- };
-
- private static final Map<UnaryKey,Processor> UNARY_PROCESSORS = new HashMap<>();
- private static final Map<BinaryKey,Processor> BINARY_PROCESSORS = new HashMap<>();
- static {
- final ServiceLoader<Processor> serviceLoader = ServiceLoader.load(Processor.class, Processor.class.getClassLoader());
- final Iterator<Processor> iterator = serviceLoader.iterator();
- while (iterator.hasNext()) {
- final Processor p = iterator.next();
- if (Operation.Binary.class.isAssignableFrom(p.getOperationClass())) {
- final Processor.Binary bp = (Processor.Binary) p;
- final BinaryKey key = new BinaryKey(p.getOperationClass(), p.getGeometryClass(), bp.getRelatedClass(), true);
- BINARY_PROCESSORS.put(key, p);
- if (Operation.ReversableBinary.class.isAssignableFrom(p.getOperationClass())) {
- final BinaryKey key2 = new BinaryKey(p.getOperationClass(), bp.getRelatedClass(), p.getGeometryClass(), true);
- BINARY_PROCESSORS.put(key2, p);
- }
- } else {
- final UnaryKey key = new UnaryKey(p.getOperationClass(), p.getGeometryClass(), true);
- UNARY_PROCESSORS.put(key, p);
- }
- }
- }
-
- private GeometryOperations() {}
-
- /**
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- */
- @UML(identifier="Query2D", specification=ISO_19107) // section 6.4.8
- public static final class SpatialAnalysis2D extends Static {
-
- private SpatialAnalysis2D(){}
-
- /**
- * Returns a geometric object that represents all Points whose distance from this geometric object is less than
- * or equal to distance. Calculations are in the spatial reference system of this geometric object. Because of the
- * limitations of linear interpolation, there will often be some relatively small error in this distance,
- * but it should be near the resolution of the coordinates used.
- */
- public static Geometry buffer(Geometry geom, double distance) {
- return evaluate(new Buffer(geom, distance)).result;
- }
-
- @UML(identifier="buffer", specification=ISO_19107) // section 6.4.4.24 and 6.4.8.3
- public static Geometry buffer(Geometry geom, Length radius){
- throw new OperationException("Not supported yet");
- }
-
- /**
- * Returns a geometric object that represents the convex hull of this geometric object.
- * Convex hulls, being dependent on straight lines, can be accurately represented in linear interpolations
- * for any geometry restricted to linear interpolations.
- */
- public static Geometry convexHull(Geometry geom) {
- return evaluate(new ConvexHull(geom)).result;
- }
-
- /**
- * Returns a geometric object that represents the Point set difference of this geometric object with anotherGeometry.
- */
- @UML(identifier="difference", specification=ISO_19107) // section 6.4.4.30 and 6.4.8.5
- public static Geometry difference(Geometry geom1, Geometry geom2) {
- return evaluate(new Difference(geom1, geom2)).result;
- }
-
- /**
- * Returns the shortest distance between any two Points in the two geometric objects as calculated in the
- * spatial reference system of this geometric object.
- * Because the geometries are closed, it is possible to find a point on each geometric object involved, such that
- * the distance between these 2 points is the returned distance between their geometric objects.
- */
- public static double distance(Geometry geom1, Geometry geom2) {
- return evaluate(new Distance(geom1, geom2)).result;
- }
-
- @UML(identifier="distance", specification=ISO_19107) // section 6.4.4.26 and 6.4.8.2
- public static Length distance2(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
-
- /**
- * Returns a geometric object that represents the Point set intersection of this geometric object with anotherGeometry.
- */
- @UML(identifier="intersection", specification=ISO_19107) // section 6.4.4.30 and 6.4.8.4
- public static Geometry intersection(Geometry geom1, Geometry geom2) {
- return evaluate(new Intersection(geom1, geom2)).result;
- }
-
- /**
- * Returns a geometric object that represents the Point set symmetric difference of this geometric
- * object with anotherGeometry.
- */
- @UML(identifier="symDifference", specification=ISO_19107) // section 6.4.4.30 and 6.4.8.6
- public static Geometry symDifference(Geometry geom1, Geometry geom2) {
- return evaluate(new SymDifference(geom1, geom2)).result;
- }
-
- /**
- * Returns a geometric object that represents the Point set union of this geometric object with anotherGeometry.
- */
- @UML(identifier="union", specification=ISO_19107) // section 6.4.4.30 and 6.4.8.7
- public static Geometry union(Geometry geom1, Geometry geom2) {
- return evaluate(new Union(geom1, geom2)).result;
- }
- }
-
- @UML(identifier="Query3D", specification=ISO_19107) // section 6.4.9
- public static final class SpatialAnalysis3D extends Static {
-
- private SpatialAnalysis3D(){}
-
- @UML(identifier="3Dintersection", specification=ISO_19107) // section 6.4.9
- public static Geometry intersection(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Ddifference", specification=ISO_19107) // section 6.4.9
- public static Geometry difference(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3DsymDifference", specification=ISO_19107) // section 6.4.9
- public static Geometry symDifference(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dunion", specification=ISO_19107) // section 6.4.9
- public static Geometry union(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dbuffer", specification=ISO_19107) // section 6.4.9
- public static Geometry buffer(Length radius) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3DconvexHull", specification=ISO_19107) // section 6.4.9
- public static Geometry getConvexHull() {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Ddistance", specification=ISO_19107) // section 6.4.9
- public static Length distance(Geometry geometry) {
- throw new OperationException("Not supported yet");
- }
- }
-
- /**
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- */
- @UML(identifier="Query2D", specification=ISO_19107) // section 6.4.8
- public static final class SpatialRelations2D extends Static {
-
- private SpatialRelations2D(){}
-
- @UML(identifier="contains", specification=ISO_19107) // section 6.4.4.30 ?
- public static boolean contains(Geometry geom1, DirectPosition element) {
- throw new OperationException("Not supported yet");
- }
-
- /**
- * Returns TRUE if this geometric object “spatially contains” anotherGeometry.
- */
- @UML(identifier="contains", specification=ISO_19107) // section 6.4.8.8, 6.4.4.2
- public static boolean contains(Geometry geom1, Geometry geom2) {
- return evaluate(new Contains(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially crosses” anotherGeometry.
- */
- @UML(identifier="crosses", specification=ISO_19107) // section 6.4.8.8
- public static boolean crosses(Geometry geom1, Geometry geom2) {
- return evaluate(new Crosses(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially disjoint” anotherGeometry.
- */
- @UML(identifier="disjoint", specification=ISO_19107) // section 6.4.8.8
- public static boolean disjoint(Geometry geom1, Geometry geom2) {
- return evaluate(new Disjoint(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially equal” anotherGeometry.
- */
- @UML(identifier="equals", specification=ISO_19107) // section 6.4.8.8, 6.4.4.30
- public static boolean Equals(Geometry geom1, Geometry geom2) {
- return evaluate(new Equals(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially intersects” anotherGeometry.
- */
- @UML(identifier="intersects", specification=ISO_19107) // section 6.4.8.8, 6.4.4.30
- public static boolean intersects(Geometry geom1, Geometry geom2) {
- return evaluate(new Intersects(geom1, geom2)).result;
- }
-
- /**
- * Returns a derived geometry collection value that matches the specified m coordinate value.
- * See Subclause 6.1.2.6 “Measures on Geometry” for more details.
- */
- public static Geometry locateAlong(Geometry geom1, double mValue) {
- return evaluate(new LocateAlong(geom1, mValue)).result;
- }
-
- /**
- * Returns a derived geometry collection value that matches the specified range of m coordinate values inclusively.
- * See Subclause 6.1.2.6 “Measures on Geometry” for more details.
- */
- public static Geometry contains(Geometry geom1, double mStart, double mEnd) {
- return evaluate(new LocateBetween(geom1, mStart, mEnd)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially overlaps” anotherGeometry.
- */
- @UML(identifier="overlaps", specification=ISO_19107) // section 6.4.8.8
- public static boolean overlaps(Geometry geom1, Geometry geom2) {
- return evaluate(new Overlaps(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object is spatially related to anotherGeometry by testing for intersections between
- * the interior, boundary and exterior of the two geometric objects as specified by the values in the
- * intersectionPatternMatrix.
- * This returns FALSE if all the tested intersections are empty except exterior (this) intersect exterior (another).
- */
- public static boolean Relate(Geometry geom1, Geometry geom2, int matrix) {
- return evaluate(new Relate(geom1, geom2, matrix)).result;
- }
-
- @UML(identifier="relate", specification=ISO_19107) // section 6.4.8.8
- public static boolean relate(Geometry another, String matrix) {
- throw new OperationException("Not supported yet");
- }
-
- /**
- * Returns TRUE if this geometric object “spatially touches” anotherGeometry.
- */
- @UML(identifier="touches", specification=ISO_19107) // section 6.4.8.8
- public static boolean touches(Geometry geom1, Geometry geom2) {
- return evaluate(new Touches(geom1, geom2)).result;
- }
-
- /**
- * Returns TRUE if this geometric object “spatially within” anotherGeometry.
- */
- @UML(identifier="within", specification=ISO_19107) // section 6.4.8.8
- public static boolean within(Geometry geom1, Geometry geom2) {
- return evaluate(new Within(geom1, geom2)).result;
- }
-
- @UML(identifier="withinDistance", specification=ISO_19107) // section 6.4.8.8
- public static boolean withinDistance(Geometry another, Length distance) {
- throw new OperationException("Not supported yet");
- }
-
- }
-
- @UML(identifier="Query3D", specification=ISO_19107) // section 6.4.9
- public static final class SpatialRelations3D extends Static {
-
- private SpatialRelations3D(){}
-
- @UML(identifier="3Dcontains", specification=ISO_19107) // section 6.4.9
- public static boolean contains(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dcrosses", specification=ISO_19107) // section 6.4.9
- public static boolean crosses(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Ddisjoint", specification=ISO_19107) // section 6.4.9
- public static boolean disjoint(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dequals", specification=ISO_19107) // section 6.4.9
- public static boolean equals(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dintersects", specification=ISO_19107) // section 6.4.9
- public static boolean intersects(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Doverlaps", specification=ISO_19107) // section 6.4.9
- public static boolean overlaps(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dtouches", specification=ISO_19107) // section 6.4.9
- public static boolean touches(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Dwithin", specification=ISO_19107) // section 6.4.9
- public static boolean within(Geometry another) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3DwithinDistance", specification=ISO_19107) // section 6.4.9
- public static boolean withinDistance3D(Geometry another, Length distance) {
- throw new OperationException("Not supported yet");
- }
-
- @UML(identifier="3Drelate", specification=ISO_19107) // section 6.4.9
- public static boolean relate3D(Geometry another, String matrix) {
- throw new OperationException("Not supported yet");
- }
- }
-
- public static final class SpatialEdition extends Static {
-
- private SpatialEdition(){}
-
- /**
- * Returns a geometric object that represents a transformed version of the geometry.
- *
- * @param geom geometry to transform
- * @param crs target CRS, if null geometry crs is unchanged but transform will still be applied
- * @param transform transform to apply, if null, geometry crs to target crs will be used
- * @return geometry of same type when possible
- */
- @UML(identifier="transform", specification=ISO_19107) // section 6.4.4.28
- public static Geometry transform(Geometry geom, CoordinateReferenceSystem crs, MathTransform transform) {
- return evaluate(new Transform(geom, crs, transform)).result;
- }
-
- /**
- * Convert this geometry to a Primitive geometry type.
- * This method is provided as a conversion to GPU geometric model.
- *
- * @return equivalent primitive, all attributes are copied.
- * can be a Primitive or MultiPrimitive
- */
- public static Geometry toPrimitive(Geometry geom) {
- return evaluate(new ToPrimitive(geom)).result;
- }
-
- /**
- * Add a Z axis on the geometry and configure it's ordinates.
- *
- * @param geom geometry to transform, if it already has a 3D crs and given crs is null, geometry crs will be preserved.
- * @param crs3d the result crs in 3d, if null an ellipsoid height is assumed
- * @param zEdit called to configure the Z value on each position, if null, value 0.0 will be used
- */
- public static Geometry to3D(Geometry geom, CoordinateReferenceSystem crs3d, Consumer<Tuple> zEdit) {
- return evaluate(new To3D(geom, crs3d, zEdit)).result;
- }
-
- /**
- * Create a new attribute or update an existing one.
- * @param geom geometry to modify
- * @param attributeName new attribute name
- * @param attributeSystem new attribute system
- * @param attributeType new attribute type
- * @param valueGenerator function to generate attribute value
- * @return new or modified geometry
- */
- public static Geometry computeAttribute(Geometry geom, String attributeName, SampleSystem attributeSystem, DataType attributeType, Function<Point,Tuple> valueGenerator) {
- return evaluate(new ComputeAttribute(geom, attributeName, attributeSystem, attributeType, valueGenerator)).result;
- }
-
- /**
- * Separate the points/lines/triangles in the given primitive.
- * This ensure each point is used only once.
- *
- * @return equivalent primitive, all attributes are copied.
- * can be a Primitive or MultiPrimitive
- */
- public static Geometry separateFaces(Geometry geom) {
- final MeshPrimitive p = (MeshPrimitive) geom;
-
- final AttributesType attributesType = p.getAttributesType();
- final Map<String,List<Tuple>> atts = new HashMap<>();
-
- for (String name : attributesType.getAttributeNames()) {
- atts.put(name, new ArrayList<>());
- }
-
- MeshPrimitiveVisitor pv = new MeshPrimitiveVisitor(geom) {
- @Override
- protected void visit(Point candidate) {
- for (Entry<String,List<Tuple>> entry : atts.entrySet()) {
- entry.getValue().add(candidate.getAttribute(entry.getKey()));
- }
- }
-
- @Override
- protected void visit(LineString candidate) {
- final Point p0 = candidate.getPointN(0);
- final Point p1 = candidate.getPointN(1);
- for (Entry<String,List<Tuple>> entry : atts.entrySet()) {
- entry.getValue().add(p0.getAttribute(entry.getKey()));
- entry.getValue().add(p1.getAttribute(entry.getKey()));
- }
- }
-
- @Override
- protected void visit(Triangle candidate) {
- final LinearRing ring = candidate.getExteriorRing();
- final Point p0 = ring.getPointN(0);
- final Point p1 = ring.getPointN(1);
- final Point p2 = ring.getPointN(2);
- for (Entry<String,List<Tuple>> entry : atts.entrySet()) {
- entry.getValue().add(p0.getAttribute(entry.getKey()));
- entry.getValue().add(p1.getAttribute(entry.getKey()));
- entry.getValue().add(p2.getAttribute(entry.getKey()));
- }
- }
-
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {}
- };
- pv.visit();
-
- //do not create an index, result elements
- final MeshPrimitive.Type type;
- switch (p.getType()) {
- case POINTS : type = MeshPrimitive.Type.POINTS; break;
- case LINES :
- case LINE_LOOP :
- case LINE_STRIP : type = MeshPrimitive.Type.LINES; break;
- case TRIANGLES :
- case TRIANGLE_FAN :
- case TRIANGLE_STRIP :
- default : type = MeshPrimitive.Type.TRIANGLES; break;
- }
- final MeshPrimitive sep = MeshPrimitive.create(type);
- for (Entry<String,List<Tuple>> entry : atts.entrySet()) {
- final String name = entry.getKey();
- final TupleArray array = TupleArrays.of(entry.getValue(), attributesType.getAttributeSystem(name), attributesType.getAttributeType(name));
- sep.setAttribute(name, array);
- }
- return sep;
- }
- }
-
- /**
- * Find a processor capable to execute the operand.
- *
- * @param <T>
- * @param op searched operand, not null
- * @return processor or empty optional
- */
- public static <T extends Operation> Optional<Processor<T, ?>> findProcessor(T op) {
- if (op instanceof Operation.Binary cdt) {
- final BinaryKey key = new BinaryKey(op.getClass(), cdt.getGeometry().getClass(), cdt.getOtherGeometry().getClass(), false);
- Processor p;
- synchronized (BINARY_PROCESSORS) {
- p = BINARY_PROCESSORS.get(key);
- if (p == null) {
- p = deepSearch(key);
- BINARY_PROCESSORS.put(key, p);
- }
- }
- if (p == NONE) return Optional.empty();
- return Optional.of(p);
-
- } else {
- final UnaryKey key = new UnaryKey(op.getClass(), op.getGeometry().getClass(), false);
- Processor p;
- synchronized (UNARY_PROCESSORS) {
- p = UNARY_PROCESSORS.get(key);
- if (p == null) {
- p = deepSearch(key);
- UNARY_PROCESSORS.put(key, p);
- }
- }
- if (p == NONE) return Optional.empty();
- return Optional.of(p);
- }
- }
-
- /**
- * Find a processor and execute the operand.
- *
- * @param <T>
- * @param op operand to compute
- * @return input operand with filled results
- * @throws OperationException if no processor could be found or computing failed
- */
- public static <T extends Operation> T evaluate(T op) throws OperationException {
- final Optional<Processor<T, ?>> proc = findProcessor(op);
- if (proc.isEmpty()) throw new OperationException("No processor can handle requested operation.");
- proc.get().process(op);
- return op;
- }
-
- /**
- * Make a deep search for another processor with wider scope that can handle the operand.
- * @param key searched key
- * @return
- */
- private static Processor deepSearch(UnaryKey key) {
-
- //find keys that can support the combine parameters
- List<UnaryKey> candidates = UNARY_PROCESSORS.keySet().stream()
- .filter(Key::mainKey)
- .filter((t) -> t.canSupport(key))
- .collect(Collectors.toCollection(ArrayList::new));
-
- //try to reduce list
- reduce:
- while (candidates.size() > 1) {
- final UnaryKey cdt1 = candidates.get(0);
- for (int i = candidates.size() - 1; i > 0; i--) {
- final UnaryKey cdt2 = candidates.get(i);
- if (cdt2.canSupport(cdt1)) {
- //means cdt2 has a larger scope, it is less specialized so less efficient
- candidates.remove(i);
- continue reduce;
- } else if (cdt1.canSupport(cdt2)) {
- //means cdt2 has a larger scope, it is less specialized so less efficient
- candidates.remove(0);
- continue reduce;
- }
- }
- //no more simplification possible, or we encounter a case were we can not identify the most efficient one
- break;
- }
-
- if (candidates.size() > 1) {
- throw new OperationException("Could not identify a single processor, several matches");
- } else if (candidates.size() == 1) {
- return UNARY_PROCESSORS.get(candidates.get(0));
- } else {
- return NONE;
- }
- }
-
- /**
- * Make a deep search for another processor with wider scope that can handle the operand.
- * @param key searched key
- * @return
- */
- private static Processor deepSearch(BinaryKey key) {
-
- //find keys that can support the combine parameters
- List<BinaryKey> candidates = BINARY_PROCESSORS.keySet().stream()
- .filter(Key::mainKey)
- .filter((t) -> t.canSupport(key))
- .collect(Collectors.toCollection(ArrayList::new));
-
- //try to reduce list
- reduce:
- while (candidates.size() > 1) {
- final BinaryKey cdt1 = candidates.get(0);
- for (int i = candidates.size() - 1; i > 0; i--) {
- final BinaryKey cdt2 = candidates.get(i);
- if (cdt2.canSupport(cdt1)) {
- //means cdt2 has a larger scope, it is less specialized so less efficient
- candidates.remove(i);
- continue reduce;
- } else if (cdt1.canSupport(cdt2)) {
- //means cdt2 has a larger scope, it is less specialized so less efficient
- candidates.remove(0);
- continue reduce;
- }
- }
- //no more simplification possible, or we encounter a case were we can not identify the most efficient one
- break;
- }
-
- if (candidates.size() > 1) {
- throw new OperationException("Could not identify a single processor, several matches");
- } else if (candidates.size() == 1) {
- return BINARY_PROCESSORS.get(candidates.get(0));
- } else {
- return NONE;
- }
- }
-
- private static abstract class Key<T extends Operation> {
-
- protected final Class opClass;
- protected final boolean mainKey;
-
- public Key(Class opClass, boolean mainKey) {
- this.opClass = opClass;
- this.mainKey = mainKey;
- }
-
- public boolean mainKey() {
- return mainKey;
- }
- }
-
- private static final class UnaryKey extends Key {
- private final Class geomClass;
-
- public UnaryKey(Class opClass, Class geomClass, boolean mainKey) {
- super(opClass, mainKey);
- this.geomClass = geomClass;
- }
-
- @Override
- public int hashCode() {
- return opClass.hashCode() + geomClass.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- final UnaryKey other = (UnaryKey) obj;
- return this.opClass.equals(other.opClass)
- && this.geomClass.equals(other.geomClass);
- }
-
- boolean canSupport(UnaryKey other) {
- return this.opClass == other.opClass
- && this.geomClass.isAssignableFrom(other.geomClass);
- }
- }
-
- private static final class BinaryKey extends Key {
- private final Class geom1Class;
- private final Class geom2Class;
-
- public BinaryKey(Class opClass, Class geom1Class, Class geom2Class, boolean mainKey) {
- super(opClass, mainKey);
- this.geom1Class = geom1Class;
- this.geom2Class = geom2Class;
- }
-
- @Override
- public int hashCode() {
- return opClass.hashCode() + geom1Class.hashCode() + geom2Class.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- final BinaryKey other = (BinaryKey) obj;
- return this.opClass.equals(other.opClass)
- && this.geom1Class.equals(other.geom1Class)
- && this.geom2Class.equals(other.geom2Class);
- }
-
- boolean canSupport(BinaryKey other) {
- return this.opClass == other.opClass
- && this.geom1Class.isAssignableFrom(other.geom1Class)
- && this.geom2Class.isAssignableFrom(other.geom2Class);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/Operation.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/Operation.java
deleted file mode 100644
index 2e63093..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/Operation.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.geometries.operation;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * A geometric operation which involve one or two geometries and produces one or many results.
- *
- * An operation class contains both the input and ouput results of the process.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Operation<T extends Operation> {
-
- public final Geometry geometry;
-
- public Operation(Geometry geometry) {
- ArgumentChecks.ensureNonNull("geometry", geometry);
- this.geometry = geometry;
- }
-
- public Geometry getGeometry() {
- return geometry;
- }
-
- /**
- * Evaluate operand using default geometry processors.
- * @return this
- */
- public T eval() {
- GeometryOperations.evaluate(this);
- return (T) this;
- }
-
- /**
- * An operand which involves two geometries.
- * @param <T>
- */
- public static abstract class Binary<T extends Operation.Binary> extends Operation<T> {
-
- public final Geometry other;
-
- public Binary(Geometry geometry, Geometry other) {
- super(geometry);
- this.other = other;
- }
-
- public Geometry getOtherGeometry() {
- return other;
- }
- }
-
- /**
- * An operand which involves two geometries and geometries order do not matter in the process.
- * @param <T>
- */
- public static abstract class ReversableBinary<T extends Operation.Binary> extends Binary<T> {
-
- public ReversableBinary(Geometry geometry, Geometry other) {
- super(geometry, other);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/OperationException.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/OperationException.java
deleted file mode 100644
index 7d22d29..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/OperationException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.geometries.operation;
-
-
-/**
- * Raised if an geometry operation fails.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class OperationException extends RuntimeException {
-
- public OperationException() {
- }
-
- public OperationException(String message) {
- super(message);
- }
-
- public OperationException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/SutherlandHodgman.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/SutherlandHodgman.java
deleted file mode 100644
index 026f4eb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/SutherlandHodgman.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.geometries.operation;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.sis.geometries.processor.spatialanalysis2d.Distance;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vectors;
-
-
-/**
- * The Sutherland–Hodgman algorithm is an algorithm used for clipping polygons.
- *
- * reference :
- * https://en.wikipedia.org/wiki/Sutherland–Hodgman_algorithm
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SutherlandHodgman {
-
- private SutherlandHodgman(){}
-
- /**
- *
- * @param subject : sequence of Tuples
- * @param clip : sequence of Segment, must be counter-clockwise direction, first point must equals last
- * @return Sequence of tuple for the result polygon
- */
- public static List<Tuple> clip(List<Tuple> subject, List<Tuple> clip){
- final List<Tuple> outputList = new ArrayList(subject);
-
- for (int i = 0, n = clip.size() - 1; i < n; i++){
- final Tuple clipEdgeStart = clip.get(i);
- final Tuple clipEdgeEnd = clip.get(i + 1);
-
- final List<Tuple> inputList = new ArrayList<>(outputList);
- if (inputList.isEmpty()) break;
- outputList.clear();
-
- Tuple start = inputList.get(inputList.size() - 1);
- for (int k = 0, kn = inputList.size(); k < kn; k++){
- final Tuple end = (Tuple) inputList.get(k);
-
- if (isInside(clipEdgeStart, clipEdgeEnd, end)){
- if (!isInside(clipEdgeStart, clipEdgeEnd, start)){
- outputList.add(computeIntersection(clipEdgeStart, clipEdgeEnd, start, end));
- }
- outputList.add(end.copy());
- } else if (isInside(clipEdgeStart, clipEdgeEnd, start)){
- outputList.add(computeIntersection(clipEdgeStart, clipEdgeEnd, start, end));
- }
- start = end;
- }
- }
-
- return outputList;
- }
-
- private static boolean isInside(Tuple edgeStart, Tuple edgeEnd, Tuple point){
- return Maths.lineSide(edgeStart, edgeEnd, point) > 0;
- }
-
- private static Tuple computeIntersection(Tuple start1, Tuple end1, Tuple start2, Tuple end2){
- final double[] buffer1 = new double[start2.getDimension()];
- final double[] buffer2 = new double[start2.getDimension()];
- final double[] ratio = new double[2];
- Distance.distanceSquare(
- start1.toArrayDouble(),
- end1.toArrayDouble(),
- buffer1,
- start2.toArrayDouble(),
- end2.toArrayDouble(),
- buffer2,
- ratio,
- 0.000000000000001);
- final Vector v = Vectors.createDouble(start1.getDimension());
- v.set(buffer1);
- return v;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Buffer.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Buffer.java
deleted file mode 100644
index a7cec47..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Buffer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents all Points whose distance from this geometric object is less than
- * or equal to distance. Calculations are in the spatial reference system of this geometric object. Because of the
- * limitations of linear interpolation, there will often be some relatively small error in this distance,
- * but it should be near the resolution of the coordinates used.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class Buffer extends Operation<Buffer> {
-
- public double distance;
- public Geometry result;
-
- public Buffer(Geometry geom, double distance) {
- super(geom);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ConvexHull.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ConvexHull.java
deleted file mode 100644
index 24dab9c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ConvexHull.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents the convex hull of this geometric object.
- * Convex hulls, being dependent on straight lines, can be accurately represented in linear interpolations
- * for any geometry restricted to linear interpolations.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class ConvexHull extends Operation<ConvexHull> {
-
- public Geometry result;
-
- public ConvexHull(Geometry geom) {
- super(geom);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Difference.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Difference.java
deleted file mode 100644
index 9330d69..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Difference.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents the Point set difference of this geometric object with anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class Difference extends Operation.Binary<Difference> {
-
- public Geometry result;
-
- public Difference(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Distance.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Distance.java
deleted file mode 100644
index 71bf1ff..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Distance.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns the shortest distance between any two Points in the two geometric objects as calculated in the
- * spatial reference system of this geometric object.
- * Because the geometries are closed, it is possible to find a point on each geometric object involved, such that
- * the distance between these 2 points is the returned distance between their geometric objects.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class Distance extends Operation.ReversableBinary<Distance> {
-
- public double result;
-
- public Distance(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOBand.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOBand.java
deleted file mode 100644
index b1403d9..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOBand.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryCollection;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.Polygon;
-import org.locationtech.jts.geom.TopologyException;
-import org.locationtech.jts.geom.impl.PackedCoordinateSequence;
-import org.locationtech.jts.geom.impl.PackedCoordinateSequenceFactory;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import static org.apache.sis.geometries.operation.spatialanalysis2d.ISOLine.interpolateToArray;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.measure.NumberRange;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- * @author Matthieu Bastianelli (Geomatys)
- */
-public final class ISOBand {
-
- //force packed coordinates, use less memory space
- private static final GeometryFactory GF = new GeometryFactory(new PackedCoordinateSequenceFactory());
- private static final int Z = 2;
-
- private ISOBand(){}
-
- /**
- * <a href="https://en.wikipedia.org/wiki/Marching_squares#Contouring_triangle_meshes">...</a>
- */
- public static Map<NumberRange<Double>,List<Polygon>> create(MeshPrimitive.Triangles triangles, double[] steps) throws FactoryException {
- return create(triangles, steps, IsoInclusion.MIN);
- }
- public static Map<NumberRange<Double>,List<Polygon>> create(MeshPrimitive.Triangles triangles, double[] steps, final IsoInclusion isoInclusion) throws FactoryException {
- ArgumentChecks.ensureNonNull("Triangles", triangles);
- ArgumentChecks.ensureNonNull("Band steps", steps);
- ArgumentChecks.ensureNonNull("ISOBand Strategy", isoInclusion);
-
- final Map<NumberRange<Double>, List<Polygon>> levels = new HashMap<>();
-
- for (int i = 0, n = steps.length-1; i < n; i++) {
- double s0 = steps[i];
- double s1 = steps[i+1];
- if (s0 > s1) {
- s0 = steps[i+1];
- s1 = steps[i];
- } else if(s0 == s1) {
- throw new IllegalArgumentException("Values at index " + i +" and " + (i+1) + " are identical = " + s0);
- }
- levels.put(NumberRange.create(s0, true, s1, true), new ArrayList<>());
- }
-
- final MeshPrimitiveVisitor visitor = new MeshPrimitiveVisitor(triangles) {
- @Override
- protected void visit(Triangle candidate) {
- final PointSequence points = candidate.getExteriorRing().getPoints();
- Tuple t0 = points.getPosition(0);
- Tuple t1 = points.getPosition(1);
- Tuple t2 = points.getPosition(2);
- //sort points by Z, the point ordering to not matter for the algo
- if (t0.get(Z) < t1.get(Z)) {
- Tuple t = t0;
- t0 = t1;
- t1 = t;
- }
- if (t1.get(Z) < t2.get(Z)) {
- Tuple t = t1;
- t1 = t2;
- t2 = t;
- if (t0.get(Z) < t1.get(Z)) {
- t = t0;
- t0 = t1;
- t1 = t;
- }
- }
-
- final double[] p0 = t0.toArrayDouble();
- final double[] p1 = t1.toArrayDouble();
- final double[] p2 = t2.toArrayDouble();
-
- for (NumberRange range : levels.keySet()) {
- final double min = range.getMinDouble(true);
- final double max = range.getMaxDouble(true);
- final List<Polygon> polys = levels.get(range);
- computeStepBand(min, max, p0, p1, p2, polys, isoInclusion);
-
- }
- }
-
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- }
- };
- visitor.visit();
-
- //merge polygons of same range
- for (Map.Entry<NumberRange<Double>,List<Polygon>> entry : levels.entrySet()) {
- List<Polygon> polys = entry.getValue();
- Geometry mp = GF.createMultiPolygon(polys.toArray(Polygon[]::new));
- mp = cleanAndUnion(mp);
- if (mp.isEmpty()) {
- polys.clear();
- } else if (mp instanceof GeometryCollection gc) {
- polys.clear();
- for (int i = 0; i < gc.getNumGeometries(); i++) {
- polys.add((Polygon) gc.getGeometryN(i));
- }
- } else if (mp instanceof Polygon p) {
- polys.clear();
- polys.add(p);
- }
-
- if (mp.isEmpty()) {
- polys.clear();
- }
- }
-
- return levels;
- }
-
- /**
- * same as {@link #computeStepBand(double, double, double[], double[], double[], List, IsoInclusion)} with default
- * {@link IsoInclusion#MIN}
- */
- static void computeStepBand(double min, double max, double[] p0, double[] p1, double[] p2, List<Polygon> toFill) {
- computeStepBand(min, max, p0, p1, p2, toFill, IsoInclusion.MIN);
- }
-
- /**
- * Compute intersecting polygon for a step of {@link #Z} between min (inclusive) and max (inclusive)
- * @param min : assessed step's min value (inclusive)
- * @param max : assessed step's max value (inclusive)
- * @param p0, p1, p2 : not null double array of length 3 representing coordinates of an assessed triangle; It is expected
- * those vertices to be ordered by the {@link #Z} axis such as p2[Z] <= p1[Z] <= p0[Z]
- * @param toFill : not null list of polygon to fill with the intersecting polygon.
- */
- static void computeStepBand(double min, double max, double[] p0, double[] p1, double[] p2, final List<Polygon> toFill, final IsoInclusion isoInclusion) {
- final double z0 = p0[Z];
- final double z1 = p1[Z];
- final double z2 = p2[Z];
-
- switch (isoInclusion) {
- case MAX: {
- if ((z0 == min) && (z2 == min)) return;
- break;
- }
- case MIN: {
- if ((z0 == max) && (z2 == max)) return;
- break;
- }
- }
-
- final boolean p0a = z0 >= max;
- final boolean p1a = z1 >= max;
- final boolean strictP2a = z2 > max;
- final boolean strictP0u = z0 < min;
- if (strictP2a || strictP0u) { // lower point (or highest) point is strictly above (or under) than the of band
- return;
- }
- final boolean p1u = z1 <= min;
- final boolean p2u = z2 <= min;
- final boolean p0i = z0 >= min && z0 <= max;
- final boolean p1i = z1 >= min && z1 <= max;
- final boolean p2i = z2 >= min && z2 <= max;
-
-
- //cas avec 3 points dedans
- if (p0i && p2i) {
- final double[] coords = new double[]{
- p0[0], p0[1], p0[2],
- p1[0], p1[1], p1[2],
- p2[0], p2[1], p2[2],
- p0[0], p0[1], p0[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
-
- //cas avec 1 point dedans et 2 points en dessous
- else if (p0i && p1u && p2u) {
- //if p0[Z] == min the result is a point, skip it
- if (z0 != min) {
- final double[] i1 = interpolateToArray(p1, p0, min);
- final double[] i2 = interpolateToArray(p2, p0, min);
- final double[] coords = new double[]{
- p0[0], p0[1], p0[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- p0[0], p0[1], p0[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- }
- //cas avec 1 point dedans et 2 points au dessus
- else if (p0a && p1a && p2i) {
- //if p2[Z] == max the result is a point, skip it
- if (z2 != max) {
- final double[] i1 = interpolateToArray(p2, p1, max);
- final double[] i2 = interpolateToArray(p2, p0, max);
- final double[] coords = new double[]{
- p2[0], p2[1], p2[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- p2[0], p2[1], p2[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- }
-
- //cas avec 2 points dedans et 1 point en dessous
- else if (p0i && p1i && p2u) {
- final double[] i1 = interpolateToArray(p2, p1, min);
- final double[] i2 = interpolateToArray(p2, p0, min);
- final double[] coords = new double[]{
- p0[0], p0[1], p0[2],
- p1[0], p1[1], p1[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- p0[0], p0[1], p0[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- //cas avec 2 points dedans et 1 point au dessus
- else if (p0a && p1i && p2i) {
- final double[] i1 = interpolateToArray(p2, p0, max);
- final double[] i2 = interpolateToArray(p1, p0, max);
- final double[] coords = new double[]{
- p1[0], p1[1], p1[2],
- p2[0], p2[1], p2[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- p1[0], p1[1], p1[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
-
- //cas avec 1 point au dessus et 2 points en dessous
- else if (p0a && p1u && p2u) {
- final double[] se = interpolateToArray(p1, p0, max);
- final double[] i1 = interpolateToArray(p1, p0, min);
- final double[] i2 = interpolateToArray(p2, p0, min);
- final double[] i3 = interpolateToArray(p2, p0, max);
- final double[] coords = new double[]{
- se[0], se[1], se[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- i3[0], i3[1], i3[2],
- se[0], se[1], se[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- //cas avec 2 points au dessus et 1 point en dessous
- else if (p0a && p1a && p2u) {
- final double[] se = interpolateToArray(p2, p0, min);
- final double[] i1 = interpolateToArray(p2, p0, max);
- final double[] i2 = interpolateToArray(p2, p1, max);
- final double[] i3 = interpolateToArray(p2, p1, min);
- final double[] coords = new double[]{
- se[0], se[1], se[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- i3[0], i3[1], i3[2],
- se[0], se[1], se[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- //cas avec 1 point au dessus, 1 point dedans et 1 point en dessous
- else if (p0a && p1i && p2u) {
- final double[] se = interpolateToArray(p1, p0, max);
- final double[] i1 = interpolateToArray(p2, p1, min);
- final double[] i2 = interpolateToArray(p2, p0, min);
- final double[] i3 = interpolateToArray(p2, p0, max);
- final double[] coords = new double[]{
- se[0], se[1], se[2],
- p1[0], p1[1], p1[2],
- i1[0], i1[1], i1[2],
- i2[0], i2[1], i2[2],
- i3[0], i3[1], i3[2],
- se[0], se[1], se[2]
- };
- toFill.add(GF.createPolygon(GF.createLinearRing(new PackedCoordinateSequence.Double(coords, 3, 0))));
- }
- }
-
- private static Geometry cleanAndUnion(Geometry geom) {
- try {
- geom = geom.union();
- } catch (TopologyException ex) {
- try {
- geom = geom.buffer(0);
- geom = geom.union();
- } catch (TopologyException e) {
- //we have try
- }
- }
-
- return geom;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOLine.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOLine.java
deleted file mode 100644
index 5419b2d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/ISOLine.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.locationtech.jts.geom.Coordinate;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector3D;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ISOLine {
-
- private static final int Z = 2;
-
- private ISOLine(){}
-
- /**
- * https://en.wikipedia.org/wiki/Marching_squares#Contouring_triangle_meshes
- */
- public static MeshPrimitive.Lines createMesh(MeshPrimitive.Triangles triangles, double[] steps) throws FactoryException {
-
- final List<Vector3D.Double> segments = new ArrayList<>();
- final MeshPrimitiveVisitor visitor = new MeshPrimitiveVisitor(triangles) {
- @Override
- protected void visit(Triangle candidate) {
- final PointSequence points = candidate.getExteriorRing().getPoints();
- final double[] p0 = points.getPosition(0).toArrayDouble();
- final double[] p1 = points.getPosition(1).toArrayDouble();
- final double[] p2 = points.getPosition(2).toArrayDouble();
-
- for (double step : steps) {
- final boolean p0a = p0[Z] >= step;
- final boolean p1a = p1[Z] >= step;
- final boolean p2a = p2[Z] >= step;
- final boolean p0e = p0[Z] == step;
- final boolean p1e = p1[Z] == step;
- final boolean p2e = p2[Z] == step;
-
- if (p1a && !p1e && !p2a && !p0a) {
- // under : P0 P2 above : P1
- segments.add(new Vector3D.Double(interpolateToArray(p0, p1, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p2, p1, step)));
- } else if (p0a && !p0e && !p1a && !p2a) {
- // under : P1 P2 above : P0
- segments.add(new Vector3D.Double(interpolateToArray(p1, p0, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p2, p0, step)));
- } else if (p2a && !p2e && !p0a && !p1a) {
- // under : P0 P1 above : P2
- segments.add(new Vector3D.Double(interpolateToArray(p0, p2, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p1, p2, step)));
- } else if (p0a && !p1a && p2a) {
- // under : P1 above : P0 P2
- segments.add(new Vector3D.Double(interpolateToArray(p1, p0, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p1, p2, step)));
- } else if (!p0a && p1a && p2a) {
- // under : P0 above : P1 P2
- segments.add(new Vector3D.Double(interpolateToArray(p0, p1, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p0, p2, step)));
- } else if (p0a && p1a && !p2a) {
- // under : P2 above : P0 P1
- segments.add(new Vector3D.Double(interpolateToArray(p2, p0, step)));
- segments.add(new Vector3D.Double(interpolateToArray(p2, p1, step)));
- }
- }
- }
-
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- }
- };
- visitor.visit();
-
- final CoordinateReferenceSystem crs = CRS.compound(CommonCRS.WGS84.normalizedGeographic(), CommonCRS.Vertical.ELLIPSOIDAL.crs());
-
- final MeshPrimitive.Lines lines = new MeshPrimitive.Lines();
- TupleArray position = TupleArrays.of(SampleSystem.of(crs), DataType.DOUBLE, segments.size());
- Iterator<Vector3D.Double> iterator = segments.iterator();
- int i = 0;
- while (iterator.hasNext()) {
- Vector3D.Double v3d = iterator.next();
- position.set(i, v3d);
- i++;
- }
- lines.setCoordinateReferenceSystem(crs);
- lines.setPositions(position);
-
- return lines;
- }
-
- static double[] interpolateToArray(double[] start, double[] end, double z) {
- final double startZ = start[Z];
- double ratio = end[Z] - startZ;
- if (ratio == 0) {
- if (z != startZ) throw new IllegalStateException("Start and end coordinates have the same value of "+Z+" interpolation to target value ("+startZ+") can't be performed.");
- return new double[]{start[0], start[1], z}; //flat line
- }
- ratio = (z - start[Z]) / ratio;
- if (ratio > 1 || ratio < 0) throw new IllegalStateException("Expected point of isoline out of the current triangulation segment");
- double[] res = Vectors.lerp(start, end, ratio);
- return new double[]{res[0], res[1], z};
- }
-
- static Coordinate interpolateToCoord2D(double[] start, double[] end, double z) {
- final double startZ = start[Z];
- double ratio = end[Z] - startZ;
- if (ratio == 0) {
- if (z != startZ) throw new IllegalStateException("Start and end coordinates have the same value of "+Z+" interpolation to target value ("+startZ+") can't be performed.");
- return new Coordinate(start[0], start[1], z); //flat line
- }
- ratio = (z - start[Z]) / ratio;
- if (ratio > 1 || ratio < 0) throw new IllegalStateException("Expected point of isoline out of the current triangulation segment");
- double[] res = Vectors.lerp(start, end, ratio);
- return new Coordinate(res[0], res[1], z);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Intersection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Intersection.java
deleted file mode 100644
index 41a625b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Intersection.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents the Point set intersection of this geometric object with anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class Intersection extends Operation.Binary<Intersection> {
-
- public Geometry result;
-
- public Intersection(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/IsoInclusion.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/IsoInclusion.java
deleted file mode 100644
index 0473ab8..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/IsoInclusion.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-
-
-/**
- * Enum used in {@linkplain ISOBand isoband computation} to manage the integration of
- * {@linkplain MeshPrimitive.Triangles triangles} whose vertices are all located at the intersection altitude of
- * isobands.
- *
- * @author Matthieu Bastianelli (Geomatys)
- */
-public enum IsoInclusion {
- /**
- * On {@link ISOBand} computation, triangles with ALL points on upper isoline are included
- */
- MAX,
- /**
- * On {@link ISOBand} computation, triangles with ALL points on lower isoline are included.
- */
- MIN,
-
- /**
- * On {@link ISOBand} computation, keep triangles on both upper and lower isoline of the band.
- */
- BOTH
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/SymDifference.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/SymDifference.java
deleted file mode 100644
index 50969eb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/SymDifference.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents the Point set symmetric difference of this geometric
- * object with anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class SymDifference extends Operation.Binary<SymDifference> {
-
- public Geometry result;
-
- public SymDifference(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Union.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Union.java
deleted file mode 100644
index 0361dca..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialanalysis2d/Union.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a geometric object that represents the Point set union of this geometric object with anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.4 Methods that support spatial analysis
- * @author Johann Sorel (Geomatys)
- */
-public final class Union extends Operation.ReversableBinary<Union> {
-
- public Geometry result;
-
- public Union(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ComputeAttribute.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ComputeAttribute.java
deleted file mode 100644
index 9f9e4cd..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ComputeAttribute.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.geometries.operation.spatialedition;
-
-import java.util.function.Function;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Create a new attribute or update an existing one.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ComputeAttribute extends Operation<ComputeAttribute> {
-
- /**
- * Function to generate attribute value
- */
- public final Function<Point,Tuple> valueGenerator;
- /**
- * New attribute name
- */
- public final String attributeName;
- /**
- * New attribute system
- */
- public final SampleSystem attributeSystem;
- /**
- * New attribute type
- */
- public final DataType attributeType;
- /**
- * Result geometry, this is often the same geometry as input
- * but may be a new one if adding or modifying the input was not possible.
- */
- public Geometry result;
-
- /**
- *
- * @param geom geometry to modify
- * @param attributeName new attribute name
- * @param attributeSystem new attribute system
- * @param attributeType new attribute type
- * @param valueGenerator function to generate attribute value
- */
- public ComputeAttribute(Geometry geom, String attributeName, SampleSystem attributeSystem, DataType attributeType, Function<Point,Tuple> valueGenerator) {
- super(geom);
- this.attributeName = attributeName;
- this.attributeSystem = attributeSystem;
- this.attributeType = attributeType;
- this.valueGenerator = valueGenerator;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/To3D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/To3D.java
deleted file mode 100644
index b47ff2c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/To3D.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.geometries.operation.spatialedition;
-
-import java.util.function.Consumer;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * Add a Z axis on the geometry and configure it's ordinates.
- * @author Johann Sorel (Geomatys)
- */
-public final class To3D extends Operation<To3D> {
-
- public final CoordinateReferenceSystem crs3d;
- public final Consumer<Tuple> Zeditor;
- public Geometry result;
-
- /**
- *
- * @param geom geometry to transform, if it already has a 3D crs and given crs is null, geometry crs will be preserved.
- * @param crs3d the result crs in 3d, if null an ellipsoid height is assumed
- * @param zEdit called to configure the Z value on each position, if null, value 0.0 will be used
- */
- public To3D(Geometry geom, CoordinateReferenceSystem crs3d, Consumer<Tuple> zEdit) {
- super(geom);
- this.crs3d = crs3d;
- this.Zeditor = zEdit;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ToPrimitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ToPrimitive.java
deleted file mode 100644
index ffe6f48..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/ToPrimitive.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.geometries.operation.spatialedition;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Transform geometry to a Primitive or MultiPrimitive.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class ToPrimitive extends Operation<ToPrimitive> {
-
- public Geometry result;
-
- /**
- *
- * @param geom geometry to transform
- */
- public ToPrimitive(Geometry geom) {
- super(geom);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/Transform.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/Transform.java
deleted file mode 100644
index cde06a3..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialedition/Transform.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.geometries.operation.spatialedition;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.referencing.CRS;
-
-
-/**
- * Returns a geometric object that represents a transformed version of the geometry.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Transform extends Operation<Transform> {
-
- public final CoordinateReferenceSystem crs;
- public final MathTransform transform;
- public Geometry result;
-
- /**
- *
- * @param geom geometry to transform
- * @param crs target CRS, if null geometry crs is unchanged but transform will still be applied
- * @param transform transform to apply, if null, geometry crs to target crs will be used
- */
- public Transform(Geometry geom, CoordinateReferenceSystem crs, MathTransform transform) {
- super(geom);
- if (crs == null) {
- this.crs = geom.getCoordinateReferenceSystem();
- this.transform = transform;
- } else if (transform == null) {
- this.crs = crs;
- try {
- this.transform = CRS.findOperation(geom.getCoordinateReferenceSystem(), crs, null).getMathTransform();
- } catch (FactoryException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- } else {
- this.crs = crs;
- this.transform = transform;
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Contains.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Contains.java
deleted file mode 100644
index 60bf112..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Contains.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially contains” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class Contains extends Operation.Binary<Contains> {
-
- public boolean result;
-
- public Contains(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Crosses.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Crosses.java
deleted file mode 100644
index 8e8f25c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Crosses.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially crosses” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class Crosses extends Operation.Binary<Crosses> {
-
- public boolean result;
-
- public Crosses(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Disjoint.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Disjoint.java
deleted file mode 100644
index d4c9cf5..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Disjoint.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially disjoint” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public class Disjoint extends Operation.ReversableBinary<Disjoint> {
-
- public boolean result;
-
- public Disjoint(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Equals.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Equals.java
deleted file mode 100644
index df2bdb2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Equals.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially equal” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public class Equals extends Operation.ReversableBinary<Equals> {
-
- public boolean result;
-
- public Equals(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Intersects.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Intersects.java
deleted file mode 100644
index 9e56220..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Intersects.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially intersects” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public class Intersects extends Operation.ReversableBinary<Intersects> {
-
- public boolean result;
-
- public Intersects(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateAlong.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateAlong.java
deleted file mode 100644
index 5f358a4..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateAlong.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a derived geometry collection value that matches the specified m coordinate value.
- * See Subclause 6.1.2.6 “Measures on Geometry” for more details.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class LocateAlong extends Operation<LocateAlong> {
-
- public final double mValue;
- public Geometry result;
-
- public LocateAlong(Geometry geom, double mValue) {
- super(geom);
- this.mValue = mValue;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateBetween.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateBetween.java
deleted file mode 100644
index 8cf2552..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/LocateBetween.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns a derived geometry collection value that matches the specified range of m coordinate values inclusively.
- * See Subclause 6.1.2.6 “Measures on Geometry” for more details.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class LocateBetween extends Operation<LocateBetween> {
-
- public final double mStart;
- public final double mEnd;
- public Geometry result;
-
- public LocateBetween(Geometry geom, double mStart, double mEnd) {
- super(geom);
- this.mStart = mStart;
- this.mEnd = mEnd;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Overlaps.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Overlaps.java
deleted file mode 100644
index 4d5c483..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Overlaps.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially overlaps” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class Overlaps extends Operation.Binary<Overlaps> {
-
- public boolean result;
-
- public Overlaps(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Relate.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Relate.java
deleted file mode 100644
index a4c9b06..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Relate.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object is spatially related to anotherGeometry by testing for intersections between
- * the interior, boundary and exterior of the two geometric objects as specified by the values in the
- * intersectionPatternMatrix.
- * This returns FALSE if all the tested intersections are empty except exterior (this) intersect exterior (another).
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class Relate extends Operation.Binary<Relate> {
-
- public final int intersectionPatternMatrix;
- public boolean result;
-
- public Relate(Geometry geom1, Geometry geom2, int intersectionPatternMatrix) {
- super(geom1, geom2);
- this.intersectionPatternMatrix = intersectionPatternMatrix;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Touches.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Touches.java
deleted file mode 100644
index c443ed6..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Touches.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially touches” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public class Touches extends Operation.ReversableBinary<Touches> {
-
- public boolean result;
-
- public Touches(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Within.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Within.java
deleted file mode 100644
index d86d5f0..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/operation/spatialrelations2d/Within.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.operation.spatialrelations2d;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-
-
-/**
- * Returns TRUE if this geometric object “spatially within” anotherGeometry.
- *
- * @see OGC Simple Feature Access 1.2.1 - 6.1.2.3 Methods for testing spatial relations between geometric objects
- * @author Johann Sorel (Geomatys)
- */
-public final class Within extends Operation.Binary<Within> {
-
- public boolean result;
-
- public Within(Geometry geom1, Geometry geom2) {
- super(geom1, geom2);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/package-info.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/package-info.java
deleted file mode 100644
index c1030b4..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/package-info.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.
- */
-
-/**
- *
- * Based on specifications :
- * <ul>
- * <li>ISO 19107 version 2019</li>
- * <li>OGC Simple Feature Access https://www.ogc.org/standards/sfa</li>
- * <li>OGC Features and Geometries JSON - Part 1: Core https://docs.ogc.org/DRAFTS/21-045r1.html</li>
- * <li>Khronos GLTF-2 https://github.com/KhronosGroup/glTF/tree/main/specification/2.0</li>
- * <li>Khronos ANARI https://github.com/KhronosGroup/ANARI-SDK</li>
- * </ul>
- *
- * This API being a merge of different geometry standard some elements differ from the original specifications.
- * OGC SFA is a simplified version on ISO 19107.
- * Khronos GLTF-2 is a set of highly specialized implementations.
- *
- * <h2>API Differences</h2>
- *
- * <h3>Key differences with OGC SFA</h3>
- * <ul>
- * <li>SRID : replaced by getCoordinateReferenceSystem</li>
- * <li>is3D : look at geometry CoordinateReferenceSystem instead</li>
- * <li>isMeasured() : replaced by Attributive interface which holds more informations.</li>
- * <li>Relation and query function have been moved to {@link org.apache.sis.geometries.operation.GeometryOperations GeometryOperations}</li>
- * <li>Query3D interface is moved to {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialAnalysis3D SpatialAnalysis3D}
- * and {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialRelations3D SpatialRelations3D}</li>
- * </ul>
- *
- * <h3>Key differences with ISO 19107</h3>
- * <ul>
- * <li>Encoding interface is fused in Geometry interface</li>
- * <li>Query2D interface is moved to {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialAnalysis2D SpatialAnalysis2D}
- * and {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialRelations2D SpatialRelations2D}</li>
- * <li>Query3D interface is moved to {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialAnalysis3D SpatialAnalysis3D}
- * and {@link org.apache.sis.geometries.operation.GeometryOperations#SpatialRelations3D SpatialRelations3D}</li>
- * <li>Encoding.asGML has been removed since it is a large task to implement and multiple versions
- * exists. GML support should be located in a different module</li>
- * </ul>
- *
- *
- * <h2>Remaining work to be done</h2>
- *
- * <h3>TODO : ISO 19107 CRS</h3>
- * No interface or implementation yet, check SIS CRS have everything needed.
- *
- * <h3>TODO : ISO 19107 Geometry has an mbResult ?</h3>
- * This attribute is only on the UML but not in the document, recheck this.
- *
- * <h3>TODO : ISO 19107 Complex (Section 6.4.34)</h3>
- * No interface or implementation yet.
- * This is special sub class of Collection with advance analysis capabilities.
- * Add methode getMaximalComplex on Geometry, see section 6.4.4.17
- *
- * <h3>TODO : ISO 19107 Topology (Section 10)</h3>
- * No interface or implementation yet.
- * This work would be interesting to formalize delaunay classes.
- *
- * <h3>TODO : ISO 19107 Simplex (Section 11.1)</h3>
- * No interface or implementation yet.
- *
- * <h3>TODO : ISO 19107 PointCloud (Section 11.2.2)</h3>
- * No interface or implementation yet.
- *
- * <h3>TODO : ISO 19107 PointCloud (Section 6.4.4.27)</h3>
- * Geometry has an equal method with a surface parameter.
- *
- *
- */
-package org.apache.sis.geometries;
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/BilinearGrid.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/BilinearGrid.java
deleted file mode 100644
index 65c779a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/BilinearGrid.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.parametriccurvesurfaces;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="BilinearGrid", specification=ISO_19107) // section 8.3.4
-public interface BilinearGrid extends ParametricCurveSurface{
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cone.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cone.java
deleted file mode 100644
index bd96033..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cone.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.parametriccurvesurfaces;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Cone", specification=ISO_19107) // section 8.5.3
-public interface Cone extends ParametricCurveSurface{
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cylinder.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cylinder.java
deleted file mode 100644
index 77b9cf2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Cylinder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.parametriccurvesurfaces;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Cylinder", specification=ISO_19107) // section 8.5.4
-public interface Cylinder extends Cone {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/ParametricCurveSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/ParametricCurveSurface.java
deleted file mode 100644
index f4e2c5b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/ParametricCurveSurface.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.geometries.parametriccurvesurfaces;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.ReferenceSystem;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.GeometryType;
-import org.apache.sis.geometries.Knot;
-import org.apache.sis.geometries.Surface;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="ParametricCurveSurface", specification=ISO_19107) // section 8.3.2
-public interface ParametricCurveSurface extends Surface, ReferenceSystem {
-
- @UML(identifier="rows", specification=ISO_19107) // section 8.3.2.3
- int getRows();
-
- @UML(identifier="columns", specification=ISO_19107) // section 8.3.2.4
- int getColumns();
-
- @UML(identifier="controlPoints", specification=ISO_19107) // section 8.3.2.6
- @Override
- List<DirectPosition> getControlPoints();
-
- @UML(identifier="dataPoints", specification=ISO_19107) // section 8.3.2.5
- @Override
- List<DirectPosition> getDataPoints();
-
- @UML(identifier="horizontalCurveType", specification=ISO_19107) // section 8.3.2.2, 8.3.2.7
- GeometryType getHorizontalCurveType();
-
- @UML(identifier="verticalCurveType", specification=ISO_19107) // section 8.3.2.2, 8.3.2.8
- GeometryType getVerticalCurveType();
-
- @Override
- List<Knot> getKnots();
-
- @UML(identifier="horizontalCurve", specification=ISO_19107) // section 8.3.2.9
- Curve getHorizontalCurve(double v);
-
- @UML(identifier="verticalCurve", specification=ISO_19107) // section 8.3.2.10
- Curve getVerticalCurve(double u);
-
- @UML(identifier="surface", specification=ISO_19107) // section 8.3.2.11
- DirectPosition getSurface(double u, double v);
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Sphere.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Sphere.java
deleted file mode 100644
index f56e24e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/parametriccurvesurfaces/Sphere.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.parametriccurvesurfaces;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Sphere", specification=ISO_19107) // section 8.5.2
-public interface Sphere extends ParametricCurveSurface{
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionArc.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionArc.java
deleted file mode 100644
index 50d1def..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionArc.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.measure.Range;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="FunctionArc", specification=ISO_19107) // section 7.7.3
-public interface FunctionArc {
-
- @UML(identifier="domain", specification=ISO_19107) // section 7.7.3.2
- Range getDomain();
-
- @UML(identifier="function", specification=ISO_19107) // section 7.7.4
- RealFunction function(FunctionArc arc, Vector coordinateOffset);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionCurve.java
deleted file mode 100644
index fca71cb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/FunctionCurve.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.Curve;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="FunctionCurve", specification=ISO_19107) // section 7.7.5
-public interface FunctionCurve<T extends FunctionArc> extends Curve{
-
- @UML(identifier="numArc", specification=ISO_19107) // section 7.7.5.2
- Integer getNumArc();
-
- @UML(identifier="segment", specification=ISO_19107) // section 7.7.5.4
- T getSegment(int idx);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialArc.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialArc.java
deleted file mode 100644
index 25a6c7a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialArc.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="PolynomialArc", specification=ISO_19107) // section 7.7.7
-public interface PolynomialArc extends FunctionArc{
-
- @UML(identifier="degree", specification=ISO_19107) // section 7.7.7.1
- int getDegree();
-
- @UML(identifier="function", specification=ISO_19107) // section 7.7.7.3
- RealPolynomial function(int coordinateOffset);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialCurve.java
deleted file mode 100644
index fb27e94..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/PolynomialCurve.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="PolynomialCurve", specification=ISO_19107) // section 7.7.9
-public interface PolynomialCurve<PolynomialArc> extends FunctionCurve {
-
- @UML(identifier="degree", specification=ISO_19107) // section 7.7.9.2
- int getDegree();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealFunction.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealFunction.java
deleted file mode 100644
index c280e14..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealFunction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import java.net.URI;
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.util.GenericName;
-import org.apache.sis.measure.Range;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="RealFunction", specification=ISO_19107) // section 7.7.2
-public interface RealFunction {
-
- @UML(identifier="name", specification=ISO_19107) // section 7.7.2.2
- GenericName getName();
-
- @UML(identifier="domain", specification=ISO_19107) // section 7.7.2.3
- Range getDomain();
-
- @UML(identifier="metadata", specification=ISO_19107) // section 7.7.2.4
- List<URI> getMetadata();
-
- @UML(identifier="value", specification=ISO_19107) // section 7.7.2.5
- double value(double r);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealPolynomial.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealPolynomial.java
deleted file mode 100644
index 4afea45..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/polynomials/RealPolynomial.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.geometries.polynomials;
-
-import java.net.URI;
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.util.GenericName;
-import org.apache.sis.measure.Range;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="RealPolynomial", specification=ISO_19107) // section 7.7.6
-public interface RealPolynomial {
-
- @UML(identifier="name", specification=ISO_19107) // section 7.7.6.2
- GenericName getName();
-
- @UML(identifier="domain", specification=ISO_19107) // section 7.7.6.2
- Range getDomain();
-
- @UML(identifier="metadata", specification=ISO_19107) // section 7.7.6.2
- List<URI> getMetadata();
-
- @UML(identifier="degree", specification=ISO_19107) // section 7.7.6.3
- int getDegree();
-
- @UML(identifier="c", specification=ISO_19107) // section 7.7.6.4
- double[] getC();
-
- @UML(identifier="value", specification=ISO_19107) // section 7.7.6.5
- double value(double r);
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/AbstractGeometry.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/AbstractGeometry.java
deleted file mode 100644
index 3d99d57..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/AbstractGeometry.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-
-
-/**
- * Abstract geometry, manages crs only.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class AbstractGeometry implements Geometry {
-
- private Map<String,Object> properties;
-
- @Override
- public synchronized Map<String, Object> userProperties() {
- if (properties == null) {
- properties = new HashMap<>();
- }
- return properties;
- }
-
- @Override
- public String toString() {
- return asText();
- }
-
- public static void toText(StringBuilder sb, Tuple tuple) {
- sb.append(tuple.get(0));
- for (int i = 1, n = tuple.getDimension(); i < n; i++) {
- sb.append(' ');
- sb.append(tuple.get(i));
- }
- }
-
- public static void toText(StringBuilder sb, TupleArray array) {
- final TupleArrayCursor cursor = array.cursor();
- boolean first = true;
- while (cursor.next()) {
- if (!first) {
- sb.append(", ");
- }
- toText(sb, cursor.samples());
- first = false;
- }
- }
-
- public static void toText(StringBuilder sb, PointSequence array) {
- final int size = array.size();
- if (size == 0) return;
-
- for (int i = 0; i < size; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- toText(sb, array.getPosition(i));
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/ArraySequence.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/ArraySequence.java
deleted file mode 100644
index 7ab287b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/ArraySequence.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.BBox;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ArraySequence implements PointSequence, AttributesType {
-
- private TupleArray positions;
- private final Map<String,TupleArray> attributes = new HashMap<>(1);
-
- public ArraySequence(TupleArray positions) {
- this(Collections.singletonMap(AttributesType.ATT_POSITION, positions));
- }
-
- public ArraySequence(Map<String, TupleArray> attributes) {
- this.attributes.putAll(attributes);
- this.positions = attributes.get(AttributesType.ATT_POSITION);
- ArgumentChecks.ensureNonNull("positions", this.positions);
- ArgumentChecks.ensureNonNull("positions crs", this.positions.getCoordinateReferenceSystem());
- final int size = this.positions.getLength();
- for (TupleArray ta : this.attributes.values()) {
- if (ta.getLength() != size) {
- throw new IllegalArgumentException("All arrays must have the same length");
- }
- }
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return positions.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- positions.setSampleSystem(SampleSystem.of(cs));
- }
-
- @Override
- public int getDimension() {
- return positions.getDimension();
- }
-
- @Override
- public boolean isEmpty() {
- return positions.isEmpty();
- }
-
- @Override
- public int size() {
- return positions.getLength();
- }
-
- @Override
- public Point getPoint(int index) {
- return new Indexed(this, index);
- }
-
- @Override
- public Tuple getPosition(int index) {
- return positions.get(index);
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- positions.set(index, value);
- }
-
- public TupleArray getAttribute(String name) {
- return attributes.get(name);
- }
-
- public void setAttribute(String name, TupleArray array) {
- if (array == null) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- throw new IllegalArgumentException("Positions attribute can not be removed");
- }
- attributes.remove(name);
- } else if (array.getLength() != size()) {
- throw new IllegalArgumentException("Array must have the same length");
- } else if (AttributesType.ATT_POSITION.equals(name)) {
- this.positions = array;
- attributes.put(name, array);
- } else {
- attributes.put(name, array);
- }
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- return attributes.get(name).get(index);
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- attributes.get(name).set(index, value);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return this;
- }
-
- @Override
- public SampleSystem getAttributeSystem(String name) {
- return attributes.get(name).getSampleSystem();
- }
-
- @Override
- public DataType getAttributeType(String name) {
- return attributes.get(name).getDataType();
- }
-
- @Override
- public List<String> getAttributeNames() {
- return new ArrayList<>(attributes.keySet());
- }
-
- @Override
- public TupleArray getAttributeArray(String name) {
- return attributes.get(name).copy();
- }
-
- @Override
- public BBox getAttributeRange(String name) {
- return TupleArrays.computeRange(attributes.get(name));
- }
-
- /**
- * An indexed point in the point sequence
- */
- public static class Indexed implements Point {
-
- private final ArraySequence parent;
- private final int index;
-
- public Indexed(ArraySequence geometry, int index) {
- this.parent = geometry;
- this.index = index;
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public Tuple getPosition() {
- final TupleArrayCursor cursor = parent.positions.cursor();
- cursor.moveTo(index);
- return cursor.samples();
- }
-
- /**
- * @return index in the parent mesh.
- */
- public int getIndex() {
- return index;
- }
-
- @Override
- public Tuple getAttribute(String key) {
- final TupleArray tupleGrid = parent.attributes.get(key);
- if (tupleGrid == null) return null;
- final TupleArrayCursor cursor = tupleGrid.cursor();
- cursor.moveTo(index);
- return cursor.samples();
- }
-
- @Override
- public void setAttribute(String name, Tuple tuple) {
- final TupleArray tupleGrid = parent.attributes.get(name);
- if (tupleGrid == null) throw new IllegalArgumentException("Attribute " + name + " do not exist");
- final TupleArrayCursor cursor = tupleGrid.cursor();
- cursor.moveTo(index);
- cursor.samples().set(tuple);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return parent.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public AttributesType getAttributesType() {
- return parent.getAttributesType();
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultGeometryCollection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultGeometryCollection.java
deleted file mode 100644
index cb48c82..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultGeometryCollection.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.GeometryCollection;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultGeometryCollection<T extends Geometry> extends AbstractGeometry implements GeometryCollection<T> {
-
- private final T[] geometries;
-
- public DefaultGeometryCollection(T[] geometries) {
- this.geometries = geometries;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return geometries[0].getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- for (T c : geometries) {
- c.setCoordinateReferenceSystem(cs);
- }
- }
-
- @Override
- public int getNumGeometries() {
- return geometries.length;
- }
-
- @Override
- public T getGeometryN(int n) {
- return geometries[n];
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLineString.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLineString.java
deleted file mode 100644
index 213d2ee..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLineString.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.PointSequence;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultLineString extends AbstractGeometry implements LineString {
-
- private final PointSequence points;
-
- public DefaultLineString(PointSequence points) {
- this.points = points;
- }
-
- @Override
- public boolean isEmpty() {
- return points.isEmpty();
- }
-
- @Override
- public PointSequence getPoints() {
- return points;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLinearRing.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLinearRing.java
deleted file mode 100644
index 58ecdeb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultLinearRing.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.PointSequence;
-
-
-/**
- * TODO : add linear ring constraints.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultLinearRing extends DefaultLineString implements LinearRing{
-
- public DefaultLinearRing(PointSequence points) {
- super(points);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiCurve.java
deleted file mode 100644
index 626d71b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiCurve.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.MultiCurve;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultMultiCurve<T extends Curve> extends AbstractGeometry implements MultiCurve<T> {
-
- private final T[] curves;
-
- public DefaultMultiCurve(T[] geometries) {
- this.curves = geometries;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return curves[0].getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- for (Curve c : curves) {
- c.setCoordinateReferenceSystem(cs);
- }
- }
-
- @Override
- public int getNumGeometries() {
- return curves.length;
- }
-
- @Override
- public T getGeometryN(int n) {
- return curves[n];
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiLineString.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiLineString.java
deleted file mode 100644
index 6c42795..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiLineString.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.MultiLineString;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultMultiLineString extends DefaultMultiCurve<LineString> implements MultiLineString {
-
- public DefaultMultiLineString(LineString... geometries) {
- super(geometries);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPoint.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPoint.java
deleted file mode 100644
index 3eb8740..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPoint.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.MultiPoint;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultMultiPoint extends AbstractGeometry implements MultiPoint<Point> {
-
- private final PointSequence points;
-
- public DefaultMultiPoint(PointSequence points) {
- this.points = points;
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return points.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- points.setCoordinateReferenceSystem(cs);
- }
-
- @Override
- public Envelope getEnvelope() {
- return points.getEnvelope();
- }
-
- @Override
- public int getNumGeometries() {
- return points.size();
- }
-
- @Override
- public Point getGeometryN(int n) {
- return points.getPoint(n);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return points.getAttributesType();
- }
-
- @Override
- public PointSequence asPointSequence() {
- return points;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPolygon.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPolygon.java
deleted file mode 100644
index a9c0373..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiPolygon.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.apache.sis.geometries.MultiPolygon;
-import org.apache.sis.geometries.Polygon;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultMultiPolygon extends DefaultMultiSurface<Polygon> implements MultiPolygon {
-
- public DefaultMultiPolygon(Polygon[] geometries) {
- super(geometries);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiSurface.java
deleted file mode 100644
index c23499d..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultMultiSurface.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.MultiSurface;
-import org.apache.sis.geometries.Surface;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultMultiSurface<T extends Surface> extends AbstractGeometry implements MultiSurface<T> {
-
- private final T[] surfaces;
-
- public DefaultMultiSurface(T[] geometries) {
- this.surfaces = geometries;
- }
-
- @Override
- public String getGeometryType() {
- return "MULTISURFACE";
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return surfaces[0].getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- for (T c : surfaces) {
- c.setCoordinateReferenceSystem(cs);
- }
- }
-
- @Override
- public int getNumGeometries() {
- return surfaces.length;
- }
-
- @Override
- public T getGeometryN(int n) {
- return surfaces[n];
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPoint.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPoint.java
deleted file mode 100644
index e87944e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPoint.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.Objects;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.DataType;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArrays;
-
-
-/**
- * Default line implementation.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultPoint extends AbstractGeometry implements Point {
-
- private final PointSequence points;
-
- /**
- * @param crs geometry coordinate system, not null.
- */
- public DefaultPoint(CoordinateReferenceSystem crs) {
- points = new ArraySequence(TupleArrays.of(SampleSystem.of(crs), DataType.DOUBLE, 1));
- }
-
- public DefaultPoint(Tuple position) {
- points = new ArraySequence(TupleArrays.of(position.getSampleSystem(), position.getDataType(), 1));
- points.setPosition(0, position);
- }
-
- public DefaultPoint(CoordinateReferenceSystem crs, double... position) {
- points = new ArraySequence(TupleArrays.of(crs, position));
- }
-
- public DefaultPoint(SampleSystem ss, double... position) {
- points = new ArraySequence(TupleArrays.of(ss, position));
- }
-
- public DefaultPoint(PointSequence ps) {
- if (ps.size() != 1) {
- throw new IllegalArgumentException("Point sequence must contain one point");
- }
- points = ps;
- }
-
- @Override
- public PointSequence asPointSequence() {
- return points;
- }
-
- @Override
- public boolean isEmpty() {
- return points.isEmpty();
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return points.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- points.setCoordinateReferenceSystem(cs);
- }
-
- @Override
- public AttributesType getAttributesType() {
- return points.getAttributesType();
- }
-
- @Override
- public Tuple getAttribute(String name) {
- return points.getAttribute(0, name);
- }
-
- @Override
- public void setAttribute(String name, Tuple tuple) {
- points.setAttribute(0, name, tuple);
- }
-
- @Override
- public Tuple getPosition() {
- return points.getPosition(0);
- }
-
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 19 * hash + Objects.hashCode(this.points);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final DefaultPoint other = (DefaultPoint) obj;
- if (!Objects.equals(this.points, other.points)) {
- return false;
- }
- return true;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPointSequence.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPointSequence.java
deleted file mode 100644
index 776b30a..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPointSequence.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.Arrays;
-import java.util.List;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Point sequence backed by a list of Point.
- * @author Johann Sorel (Geomatys)
- */
-public final class DefaultPointSequence implements PointSequence {
-
- private final List<Point> points;
-
- /**
- * @param points list will be used directly.
- */
- public DefaultPointSequence(List<Point> points) {
- ArgumentChecks.ensureNonEmpty("points", points);
- this.points = points;
- }
-
- public DefaultPointSequence(Point... points) {
- this(Arrays.asList(points));
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return points.get(0).getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public AttributesType getAttributesType() {
- return points.get(0).getAttributesType();
- }
-
- @Override
- public int size() {
- return points.size();
- }
-
- @Override
- public Point getPoint(int index) {
- return points.get(index);
- }
-
- @Override
- public Tuple getPosition(int index) {
- return points.get(index).getPosition();
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- points.get(index).getPosition().set(value);
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- return points.get(index).getAttribute(name);
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- points.get(index).setAttribute(name, value);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPolygon.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPolygon.java
deleted file mode 100644
index b16e83e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultPolygon.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.Collections;
-import java.util.List;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.Polygon;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.privy.UnmodifiableArrayList;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultPolygon extends AbstractGeometry implements Polygon {
-
- protected final LinearRing exterior;
- protected final List<LinearRing> interiors;
-
- public DefaultPolygon(LinearRing exterior) {
- this(exterior, null);
- }
-
- public DefaultPolygon(LinearRing exterior, List<LinearRing> interiors) {
- ArgumentChecks.ensureNonNull("exterior", exterior);
- this.exterior = exterior;
- this.interiors = interiors == null ? Collections.EMPTY_LIST : UnmodifiableArrayList.wrap(interiors.toArray(new LinearRing[0]));
-
- if (!this.interiors.isEmpty()) {
- for (Curve interior : this.interiors) {
- Geometries.ensureSameAttributes(exterior.getAttributesType(), interior.getAttributesType());
- }
- }
- }
-
- @Override
- public boolean isEmpty() {
- return exterior.isEmpty();
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return exterior.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- exterior.setCoordinateReferenceSystem(cs);
- for (Curve interior : interiors) {
- interior.setCoordinateReferenceSystem(cs);
- }
- }
-
- @Override
- public LinearRing getExteriorRing() {
- return exterior;
- }
-
- @Override
- public List<LinearRing> getInteriorRings() {
- return interiors;
- }
-
- @Override
- public Envelope getEnvelope() {
- return getExteriorRing().getEnvelope();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultTriangle.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultTriangle.java
deleted file mode 100644
index d49e682..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/privy/DefaultTriangle.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.Objects;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-
-
-/**
- * Default triangle implementation.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DefaultTriangle extends DefaultPolygon implements Triangle {
-
- /**
- * @param exterior exterior triangle ring
- */
- public DefaultTriangle(LinearRing exterior) {
- super(exterior);
- final PointSequence points = exterior.getPoints();
- final int size = points.size();
- switch (size) {
- case 0: //empty triangle
- break;
- case 4:
- if (!points.getPosition(0).equals(points.getPosition(3))) {
- throw new IllegalArgumentException("Triangle first and last point positions must be identical");
- } break;
- default:
- throw new IllegalArgumentException("Triangle exterior ring must be composed of 0 or 4 points");
- }
- }
-
- @Override
- public LinearRing getExteriorRing() {
- return (LinearRing) exterior;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final DefaultTriangle other = (DefaultTriangle) obj;
- return Objects.equals(this.exterior, other.exterior);
- }
-
- @Override
- public int hashCode() {
- return 7 * exterior.hashCode();
- }
-
- @Override
- public String asText() {
- return Triangle.super.asText();
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/Processor.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/Processor.java
deleted file mode 100644
index b99097b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/Processor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.geometries.processor;
-
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.Operation;
-import org.apache.sis.geometries.operation.OperationException;
-
-
-/**
- * A processor is able to process a single operation type.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface Processor<T extends Operation, G extends Geometry> {
-
- Class<T> getOperationClass();
-
- Class<G> getGeometryClass();
-
- /**
- *
- * @param operation not null
- * @throws OperationException
- */
- void process(T operation) throws OperationException;
-
- public interface Binary<T extends Operation.Binary, G extends Geometry, O extends Geometry> extends Processor<T,G> {
-
- Class<O> getRelatedClass();
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java
deleted file mode 100644
index 9f9f71f..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.geometries.processor;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.opengis.referencing.crs.CompoundCRS;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.util.Static;
-import org.apache.sis.util.Utilities;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ProcessorUtils extends Static {
-
- /**
- * Ensure given geometries have the same CRS.
- * @param geom1 not null
- * @param geom2 not null
- */
- public static void ensureSameCRS(Geometry geom1, Geometry geom2) {
- final CoordinateReferenceSystem crs1 = geom1.getCoordinateReferenceSystem();
- final CoordinateReferenceSystem crs2 = geom2.getCoordinateReferenceSystem();
- if (!Utilities.equalsIgnoreMetadata(crs1, crs2)) {
- throw new OperationException("Geometries do not have the same CRS");
- }
- }
-
- /**
- * Ensure given geometries have the same CRS 2D.
- * @param geom1 not null
- * @param geom2 not null
- */
- public static void ensureSameCRS2D(Geometry geom1, Geometry geom2) {
- CoordinateReferenceSystem crs1 = geom1.getCoordinateReferenceSystem();
- CoordinateReferenceSystem crs2 = geom2.getCoordinateReferenceSystem();
- final int dim1 = crs1.getCoordinateSystem().getDimension();
- final int dim2 = crs2.getCoordinateSystem().getDimension();
- if (dim1 < 2 || dim2 < 2) {
- throw new OperationException("Geometries CRS must be at least 2D");
- }
-
- if (!Utilities.equalsIgnoreMetadata(crs1, crs2)) {
- if (dim1 != 2 || dim2 != 2) {
- CoordinateReferenceSystem subcrs1 = getCrs2d(crs1);
- CoordinateReferenceSystem subcrs2 = getCrs2d(crs2);
- if (subcrs1 == null || !Utilities.equalsIgnoreMetadata(subcrs1, subcrs2)) {
- throw new OperationException("Geometries do not have the same CRS 2D");
- }
- }
- }
- }
-
- private static CoordinateReferenceSystem getCrs2d(CoordinateReferenceSystem crs) {
- CoordinateReferenceSystem subcrs = org.apache.sis.referencing.CRS.getComponentAt(crs, 0, 2);
- if (subcrs == null) subcrs = getOrCreateSubCRS(crs, 0, 2);
- if (subcrs == null) {
- //in some cases may be the only solution, TODO, how to ensure the horizontal part is on index [0,2] ?
- subcrs = org.apache.sis.referencing.CRS.getHorizontalComponent(crs);
- }
- return subcrs;
- }
-
-
- /**
- * @todo Duplicate of {@link org.apache.sis.referencing.privy.ReferencingFactoryContainer}?
- *
- * @see <a href="https://issues.apache.org/jira/browse/SIS-162">SIS-162</a>
- */
- private static CoordinateReferenceSystem getOrCreateSubCRS(CoordinateReferenceSystem crs, int lower, int upper) {
- if (crs == null) return crs;
-
- int dimension = crs.getCoordinateSystem().getDimension();
- if (lower < 0 || lower > upper || upper > dimension) {
- throw new IndexOutOfBoundsException("["+lower+".."+upper+"] range is not possible with crs dimension "+ dimension);
- }
-
- // Dimension exactly matches, no need to decompse the CRS
- if (lower == 0 && dimension == upper) return crs;
-
- // CRS can not be decomposed
- if (!(crs instanceof CompoundCRS)) return null;
-
- final List<CoordinateReferenceSystem> parts = new ArrayList<>(1);
- final int res = decomposeCRS(crs, lower, upper, parts);
- if (res == -1) {
- // CRS could not be divided
- return null;
- }
-
- final int size = parts.size();
- if (size == 1) {
- return parts.get(0);
- } else try {
- return org.apache.sis.referencing.CRS.compound(parts.toArray(new CoordinateReferenceSystem[size]));
- } catch (FactoryException e) {
- throw new IllegalArgumentException("Illegal CRS.", e);
- }
- }
-
- /**
- * Internal use only.
- * Fill a list of CoordinateReferenceSystem with CRS parts in the given lower/upper range.
- *
- * @param crs CoordinateReferenceSystem to decompose
- * @param lower dimension start range
- * @param upper dimension start range
- * @param parts used to stack CoordinateReferenceSystem when decomposing CRS.
- * @return number of dimensions used, -1 if the current crs could not be decomposed to match lower/upper bounds
- */
- private static int decomposeCRS(CoordinateReferenceSystem crs, int lower, int upper, final List<CoordinateReferenceSystem> parts) {
- final int dimension = crs.getCoordinateSystem().getDimension();
-
- if (lower == 0 && dimension <= upper) {
- // Dimension is smaller or exactly match, no need to decompse the crs
- parts.add(crs);
- return dimension;
- } else if (lower >= dimension){
- // Skip this CRS
- return dimension;
- }
-
- // CRS can not be decomposed
- if (!(crs instanceof CompoundCRS)) return -1;
-
- int nbDimRead = 0;
- final List<CoordinateReferenceSystem> components = ((CompoundCRS) crs).getComponents();
- for (CoordinateReferenceSystem component : components) {
- int res = decomposeCRS(component, lower, upper, parts);
- if (res == -1) {
- // Sub element could not be decomposed
- return -1;
- }
- nbDimRead += res;
- lower = Math.max(0, lower-res);
- upper = Math.max(0, upper-res);
- if (upper == 0) break;
- }
-
- return nbDimRead;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Distance.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Distance.java
deleted file mode 100644
index 2db333c..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Distance.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.geometries.processor.spatialanalysis2d;
-
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.geometries.processor.ProcessorUtils;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vectors;
-
-
-/**
- * Distance 2D processors.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Distance {
-
- private Distance(){}
-
- /**
- * Calculate distance between two points.
- *
- * @param p1 first point
- * @param p2 second point
- * @return double, distance
- */
- public static double distance(Tuple p1, Tuple p2){
- return Math.sqrt(distanceSquare(p1, p2));
- }
-
- /**
- * Calculate square distance between two points.
- *
- * @param p1 first point
- * @param p2 second point
- * @return double, distance
- */
- public static double distanceSquare(Tuple p1, Tuple p2){
- final double t0 = p1.get(0) - p2.get(0);
- final double t1 = p1.get(1) - p2.get(1);
- return t0*t0 + t1*t1;
- }
-
- /**
- * Calculate square distance between two line segments.
- *
- * Adapted from book : Real-TimeCollision Detection by Christer Ericson
- * (ClosestPtSegmentSegment p.149)
- *
- * @param line1Start line 1 start point
- * @param line1End line 1 start point
- * @param buffer1 closest point on line 1
- * @param line2Start line 1 start point
- * @param line2End line 1 start point
- * @param buffer2 closest point on line 2
- * @param ratio size 2 , for each line,
- * ratio [0..1] of the closest point position between start and end points.
- * @param epsilon tolerance
- * @return distance
- */
- public static double distanceSquare(double[] line1Start, double[] line1End, double[] buffer1,
- double[] line2Start, double[] line2End, double[] buffer2,
- double[] ratio, double epsilon) {
- final double[] d1 = Vectors.subtract(line1End,line1Start); // Direction vector of segment S1
- final double[] d2 = Vectors.subtract(line2End,line2Start); // Direction vector of segment S2
- final double[] r = Vectors.subtract(line1Start, line2Start);
- final double a = Vectors.dot(d1, d1); // Squared length of segment S1, always nonnegative
- final double e = Vectors.dot(d2, d2); // Squared length of segment S2, always nonnegative
- final double f = Vectors.dot(d2, r);
- // Check if either or both segments degenerate into points
- if (a <= epsilon && e <= epsilon) {
- // Both segments degenerate into points
- ratio[0] = 0;
- ratio[1] = 0;
- System.arraycopy(line1Start, 0, buffer1, 0, line1Start.length);
- System.arraycopy(line2Start, 0, buffer2, 0, line2Start.length);
- final double[] t = Vectors.subtract(buffer1,buffer2);
- return Vectors.dot(t,t);
- }
- if (a <= epsilon) {
- // First segment degenerates into a point
- ratio[0] = 0;
- ratio[1] = Maths.clamp( f/e, 0, 1);
- } else {
- final double c = Vectors.dot(d1, r);
- if (e <= epsilon) {
- // Second segment degenerates into a point
- ratio[0] = Maths.clamp( -c/a, 0, 1);
- ratio[1] = 0;
- } else {
- // The general nondegenerate case starts here
- final double b = Vectors.dot(d1, d2);
- final double denom = a*e-b*b; // Always nonnegative
- // If segments not parallel, compute closest point on L1 to L2 and
- // clamp to segment S1. Else pick arbitrary s (here 0)
- if (denom != 0d) {
- ratio[0] = Maths.clamp((b*f - c*e) / denom, 0.0f, 1.0f);
- } else {
- ratio[0] = 0;
- }
- // Compute point on L2 closest to S1(s) using
- // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
- ratio[1] = (b*ratio[0] + f) / e;
-
- //If t in [0,1] done. Else clamp t, recompute s for the new value
- //of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
- //and clamp s to [0, 1]
- if (ratio[1] < 0){
- ratio[1] = 0;
- ratio[0] = Maths.clamp(-c / a, 0.0f, 1.0f);
- } else if (ratio[1] > 1){
- ratio[1] = 1;
- ratio[0] = Maths.clamp((b - c) / a, 0.0f, 1.0f);
- }
-
- }
- }
-
- Vectors.add(line1Start, Vectors.scale(d1, ratio[0]), buffer1);
- Vectors.add(line2Start, Vectors.scale(d2, ratio[1]), buffer2);
- final double[] t = Vectors.subtract(buffer1,buffer2);
- return Vectors.dot(t,t);
- }
-
- /**
- * Point to point distance.
- */
- public static class PointPoint implements Processor.Binary<org.apache.sis.geometries.operation.spatialanalysis2d.Distance, Point, Point>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialanalysis2d.Distance> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialanalysis2d.Distance.class;
- }
-
- @Override
- public Class<Point> getRelatedClass() {
- return Point.class;
- }
-
- @Override
- public Class<Point> getGeometryClass() {
- return Point.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialanalysis2d.Distance operation) throws OperationException {
- ProcessorUtils.ensureSameCRS(operation.geometry, operation.other);
- final Point p1 = (Point) operation.geometry;
- final Point p2 = (Point) operation.other;
- operation.result = distance(p1.getPosition(), p2.getPosition());
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Intersection.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Intersection.java
deleted file mode 100644
index e68028b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialanalysis2d/Intersection.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.geometries.processor.spatialanalysis2d;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Stream;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.MultiLineString;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PreparedTIN;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.privy.DefaultPointSequence;
-import org.apache.sis.geometries.mesh.MultiMeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.operation.SutherlandHodgman;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.geometries.processor.ProcessorUtils;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Intersection {
-
- private Intersection(){}
-
-
- /**
- * Inherit attributes from TIN.
- * The POSITION attribute is ignored.
- */
- private static void copyAttributes(PreparedTIN tin, MultiMeshPrimitive<?> primitives) {
- for (MeshPrimitive primitive : primitives.getComponents()) {
- copyAttributes(tin, primitive);
- }
- }
-
- /**
- * Inherit attributes from TIN.
- * The POSITION attribute is ignored.
- */
- private static void copyAttributes(PreparedTIN tin, MeshPrimitive primitive) {
-
- final AttributesType attributesType = tin.getAttributesType();
- final int nbVertex = primitive.getPositions().getLength();
-
- final List<String> attributeNames = new ArrayList<>(attributesType.getAttributeNames());
- if (attributeNames.size() == 1) {
- //no attributes to copy
- return;
- }
- attributeNames.remove(AttributesType.ATT_POSITION);
- final String[] templateNames = new String[attributeNames.size()];
- final TupleArray[] attributes = new TupleArray[attributeNames.size()];
- for (int i = 0; i < templateNames.length; i++) {
- templateNames[i] = attributeNames.get(i);
- final TupleArray ta = TupleArrays.of(
- attributesType.getAttributeSystem(templateNames[i]),
- attributesType.getAttributeType(templateNames[i]),
- nbVertex);
- attributes[i] = ta;
- primitive.setAttribute(templateNames[i], ta);
- }
-
- //interpolate attributes from TIN
- final PreparedTIN.Evaluator evaluator = tin.evaluator();
- new MeshPrimitiveVisitor(primitive) {
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- if (isVisited(vertex)) return;
- final Optional<Point> opt = evaluator.evaluate(vertex.getPosition());
- if (opt.isEmpty()) return;
- final Point point = opt.get();
- final int index = vertex.getIndex();
- for (int i = 0; i < templateNames.length; i++) {
- attributes[i].set(index, point.getAttribute(templateNames[i]));
- }
- }
- }.visit();
- }
-
- /**
- * Triangles with points.
- */
- public static class PrimitiveTrianglesPrimitivePoints implements Processor.Binary<org.apache.sis.geometries.operation.spatialanalysis2d.Intersection, MeshPrimitive.Triangles, MeshPrimitive.Points>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialanalysis2d.Intersection> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialanalysis2d.Intersection.class;
- }
-
- @Override
- public Class<MeshPrimitive.Points> getRelatedClass() {
- return MeshPrimitive.Points.class;
- }
-
- @Override
- public Class<MeshPrimitive.Triangles> getGeometryClass() {
- return MeshPrimitive.Triangles.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialanalysis2d.Intersection operation) throws OperationException {
- ProcessorUtils.ensureSameCRS(operation.geometry, operation.other);
- final MeshPrimitive.Triangles p1 = (MeshPrimitive.Triangles) operation.geometry;
- final MeshPrimitive.Points p2 = (MeshPrimitive.Points) operation.other;
-
- final PreparedTIN pt = PreparedTIN.create(p1);
-
- final TupleArray positions = p2.getPositions().copy();
-
- final MeshPrimitive.Points intersection = new MeshPrimitive.Points();
- operation.result = intersection;
-
- //create a copy of the points positions
- intersection.setPositions(positions);
-
- //create an index only for points which intersect
- final PreparedTIN.Evaluator evaluator = pt.evaluator();
- final TupleArrayCursor cursor = positions.cursor();
- final List<Integer> values = new ArrayList<>();
- while (cursor.next()) {
- Tuple position = cursor.samples();
- if (evaluator.evaluate(position).isPresent()) {
- values.add(cursor.coordinate());
- }
- }
- if (!values.isEmpty()) {
- final TupleArray index = TupleArrays.ofUnsigned(1, values);
- intersection.setIndex(index);
- }
-
- //remove unused indices
- Geometries.compact(intersection);
-
- //copy attributes
- copyAttributes(pt, intersection);
- }
- }
-
- /**
- * Triangles with lines.
- */
- public static class PrimitiveTrianglesPrimitiveLines implements Processor.Binary<org.apache.sis.geometries.operation.spatialanalysis2d.Intersection, MeshPrimitive.Triangles, MeshPrimitive.Lines>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialanalysis2d.Intersection> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialanalysis2d.Intersection.class;
- }
-
- @Override
- public Class<MeshPrimitive.Lines> getRelatedClass() {
- return MeshPrimitive.Lines.class;
- }
-
- @Override
- public Class<MeshPrimitive.Triangles> getGeometryClass() {
- return MeshPrimitive.Triangles.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialanalysis2d.Intersection operation) throws OperationException {
- ProcessorUtils.ensureSameCRS(operation.geometry, operation.other);
- final MeshPrimitive.Triangles triangles = (MeshPrimitive.Triangles) operation.geometry;
- final MeshPrimitive.Lines lines = (MeshPrimitive.Lines) operation.other;
-
- final PreparedTIN tin = PreparedTIN.create(triangles);
-
- final List<LineString> segments = new ArrayList<>();
- for (int i = 0, n = lines.getNumGeometries(); i < n; i++) {
- final LineString line = lines.getGeometryN(i);
- final TupleArray segment = line.getPoints().getAttributeArray(AttributesType.ATT_POSITION);
- final Tuple s1 = segment.get(0);
- final Tuple s2 = segment.get(1);
-
- try (Stream<Triangle> stream = tin.getPatches(line.getEnvelope())) {
- final Iterator<Triangle> iterator = stream.iterator();
-
- while (iterator.hasNext()) {
- final Triangle triangle = iterator.next();
- final TupleArray corners = triangle.getExteriorRing().getPoints().getAttributeArray(AttributesType.ATT_POSITION);
- final Tuple c0 = corners.get(0);
- final Tuple c1 = corners.get(1);
- final Tuple c2 = corners.get(2);
- final List<Tuple> clip = SutherlandHodgman.clip(Arrays.asList(s1,s2,s1), Arrays.asList(c0,c1,c2,c0));
- if (clip.size() >= 2) {
- //inherit attributes
- final double x1 = c0.get(0);
- final double y1 = c0.get(1);
- final double x2 = c1.get(0);
- final double y2 = c1.get(1);
- final double x3 = c2.get(0);
- final double y3 = c2.get(1);
- final Tuple p1 = clip.get(0);
- final Tuple p2 = clip.get(1);
- final double[] bary1 = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, p1.get(0), p1.get(1), 0.0, false);
- final double[] bary2 = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, p2.get(0), p2.get(1), 0.0, false);
- final Point point1 = triangle.interpolate(bary1);
- final Point point2 = triangle.interpolate(bary2);
- segments.add(GeometryFactory.createLineString(new DefaultPointSequence(point1, point2)));
- }
- }
- } catch (TransformException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- }
-
- final MultiLineString mline = GeometryFactory.createMultiLineString(segments.toArray(LineString[]::new));
- final MeshPrimitive intersection = (MeshPrimitive) GeometryOperations.SpatialEdition.toPrimitive(mline);
- operation.result = intersection;
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ComputeAttribute.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ComputeAttribute.java
deleted file mode 100644
index fbb53e5..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ComputeAttribute.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ComputeAttribute {
-
- private ComputeAttribute(){}
-
-
- /**
- * Compute attribute on Primitive.
- * Also works for ModelPrimitive.
- */
- public static class Primitive implements Processor<org.apache.sis.geometries.operation.spatialedition.ComputeAttribute, org.apache.sis.geometries.mesh.MeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ComputeAttribute> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ComputeAttribute.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ComputeAttribute operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MeshPrimitive base = (org.apache.sis.geometries.mesh.MeshPrimitive) operation.geometry;
- final org.apache.sis.geometries.mesh.MeshPrimitive copy3d = base.deepCopy();
- operation.result = copy3d;
-
- TupleArray ta = copy3d.getAttribute(operation.attributeName);
- if (ta == null) {
- ta = TupleArrays.of(operation.attributeSystem, operation.attributeType, copy3d.getPositions().getLength());
- copy3d.setAttribute(operation.attributeName, ta);
- }
-
- if (operation.valueGenerator != null) {
- new MeshPrimitiveVisitor(copy3d) {
- @Override
- protected void visit(org.apache.sis.geometries.mesh.MeshPrimitive.Vertex vertex) {
- vertex.setAttribute(operation.attributeName, operation.valueGenerator.apply(vertex));
- }
- }.visit();
- }
- }
- }
-
-
- /**
- * Compute attribute on MultiPrimitive.
- * Also works for ModelPrimitive.
- */
- public static class MultiPrimitive implements Processor<org.apache.sis.geometries.operation.spatialedition.ComputeAttribute, org.apache.sis.geometries.mesh.MultiMeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ComputeAttribute> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ComputeAttribute.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MultiMeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MultiMeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ComputeAttribute operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive base = (org.apache.sis.geometries.mesh.MultiMeshPrimitive) operation.geometry;
-
- final List<org.apache.sis.geometries.mesh.MeshPrimitive> news = new ArrayList<>();
- for (int i = 0, n = base.getNumGeometries(); i < n; i++) {
- Geometry p = base.getGeometryN(i);
- p = GeometryOperations.SpatialEdition.computeAttribute(p, operation.attributeName, operation.attributeSystem, operation.attributeType, operation.valueGenerator);
- news.add((org.apache.sis.geometries.mesh.MeshPrimitive) p);
- }
-
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive copy3d = new org.apache.sis.geometries.mesh.MultiMeshPrimitive(base.getCoordinateReferenceSystem());
- copy3d.append(news);
- operation.result = copy3d;
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/To3D.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/To3D.java
deleted file mode 100644
index 754b537..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/To3D.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Consumer;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class To3D {
-
- private To3D(){}
-
- private static void zedit(TupleArray array, Consumer<Tuple> Zeditor) {
- final TupleArrayCursor cursor = array.cursor();
- while (cursor.next()) {
- Zeditor.accept(cursor.samples());
- }
- }
-
- private static ArraySequence copy(PointSequence ps) {
- final Map<String,TupleArray> attributes = new HashMap<>();
- for (String name : ps.getAttributesType().getAttributeNames()) {
- attributes.put(name, ps.getAttributeArray(name).copy());
- }
- return new ArraySequence(attributes);
- }
-
- private static ArraySequence to3d(PointSequence base, CoordinateReferenceSystem crs3d, Consumer<Tuple> Zeditor) {
-
- final ArraySequence ps = copy(base);
-
- if (Zeditor == null) {
- Zeditor = (Tuple t) -> t.set(2, 0.0);
- }
-
- TupleArray positions = ps.getAttributeArray(AttributesType.ATT_POSITION);
- positions = to3d(positions, crs3d, Zeditor);
- ps.setAttribute(AttributesType.ATT_POSITION, positions);
- return ps;
- }
-
- private static TupleArray to3d(TupleArray positions, CoordinateReferenceSystem crs3d, Consumer<Tuple> Zeditor) {
-
- if (Zeditor == null) {
- Zeditor = (Tuple t) -> t.set(2, 0.0);
- }
-
- final CoordinateReferenceSystem geomCrs = positions.getCoordinateReferenceSystem();
- final int geomCrsDim = geomCrs.getCoordinateSystem().getDimension();
- if (geomCrsDim < 2) throw new OperationException("Geometry crs must have at least two dimensions");
-
- if (crs3d == null && geomCrsDim > 2) {
- //just edit the Z values
- zedit(positions, Zeditor);
- } else if (crs3d != null && geomCrsDim == 3) {
- //change the crs and edit values
- positions.setSampleSystem(SampleSystem.of(crs3d));
- zedit(positions, Zeditor);
- } else {
- if (crs3d == null) {
- try {
- crs3d = CRS.compound(geomCrs, CommonCRS.Vertical.ELLIPSOIDAL.crs());
- } catch (FactoryException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- }
- //create a new one
- final TupleArray array = TupleArrays.of(SampleSystem.of(crs3d), positions.getDataType(), positions.getLength());
- final TupleArrayCursor target = array.cursor();
- final TupleArrayCursor source = positions.cursor();
- while (source.next() && target.next()) {
- Tuple t = target.samples();
- Tuple s = source.samples();
- t.set(0, s.get(0));
- t.set(1, s.get(1));
- Zeditor.accept(t);
- }
- positions = array;
- }
- return positions;
- }
-
- /**
- * Add Z axis to Point.
- */
- public static class Point implements Processor<org.apache.sis.geometries.operation.spatialedition.To3D, org.apache.sis.geometries.Point>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.To3D> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.To3D.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.Point> getGeometryClass() {
- return org.apache.sis.geometries.Point.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.To3D operation) throws OperationException {
- final org.apache.sis.geometries.Point base = (org.apache.sis.geometries.Point) operation.geometry;
- final PointSequence copy3d = to3d(base.asPointSequence(), operation.crs3d, operation.Zeditor);
- operation.result = GeometryFactory.createPoint(copy3d);
- }
- }
-
- /**
- * Add Z axis to LineString.
- */
- public static class LineString implements Processor<org.apache.sis.geometries.operation.spatialedition.To3D, org.apache.sis.geometries.LineString>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.To3D> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.To3D.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.LineString> getGeometryClass() {
- return org.apache.sis.geometries.LineString.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.To3D operation) throws OperationException {
- final org.apache.sis.geometries.LineString base = (org.apache.sis.geometries.LineString) operation.geometry;
- final PointSequence copy3d = to3d(base.getPoints(), operation.crs3d, operation.Zeditor);
- operation.result = GeometryFactory.createLineString(copy3d);
- }
- }
-
- /**
- * Add Z axis to Primitive.
- * Also works for ModelPrimitive.
- */
- public static class Primitive implements Processor<org.apache.sis.geometries.operation.spatialedition.To3D, org.apache.sis.geometries.mesh.MeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.To3D> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.To3D.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.To3D operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MeshPrimitive base = (org.apache.sis.geometries.mesh.MeshPrimitive) operation.geometry;
- final org.apache.sis.geometries.mesh.MeshPrimitive copy3d = base.deepCopy();
- operation.result = copy3d;
-
- TupleArray positions = copy3d.getPositions();
- positions = to3d(positions, operation.crs3d, operation.Zeditor);
- copy3d.setPositions(positions);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ToPrimitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ToPrimitive.java
deleted file mode 100644
index 6c42d59..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/ToPrimitive.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.geometries.triangulate.EarClipping;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class ToPrimitive {
-
- private ToPrimitive(){}
-
- private static ArraySequence toArraySequence(PointSequence points) {
- final Map<String,TupleArray> attributes = new HashMap<>();
- for (String name : points.getAttributesType().getAttributeNames()) {
- attributes.put(name, points.getAttributeArray(name));
- }
- return new ArraySequence(attributes);
- }
-
- /**
- * Transform Point to Primitive.
- */
- public static class Point implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.Point>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.Point> getGeometryClass() {
- return org.apache.sis.geometries.Point.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MeshPrimitive primitive = new org.apache.sis.geometries.mesh.MeshPrimitive.Points();
- final AttributesType attributesType = operation.geometry.getAttributesType();
- for (String name : attributesType.getAttributeNames()) {
- final TupleArray array = TupleArrays.of(attributesType.getAttributeSystem(name), attributesType.getAttributeType(name), 1);
- array.set(0, ((org.apache.sis.geometries.Point) operation.geometry).getAttribute(name));
- primitive.setAttribute(name, array);
- }
- operation.result = primitive;
- }
- }
-
- /**
- * Transform LineString to Primitive.
- */
- public static class LineString implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.LineString>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.LineString> getGeometryClass() {
- return org.apache.sis.geometries.LineString.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MeshPrimitive primitive = new org.apache.sis.geometries.mesh.MeshPrimitive.LineStrip();
- final ArraySequence array = toArraySequence(((org.apache.sis.geometries.LineString) operation.geometry).getPoints());
- for (String name : array.getAttributeNames()) {
- primitive.setAttribute(name, array.getAttribute(name));
- }
- operation.result = primitive;
- }
- }
-
- /**
- * Transform Polygon to Primitive.
- */
- public static class Polygon implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.Polygon>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.Polygon> getGeometryClass() {
- return org.apache.sis.geometries.Polygon.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- //we must triangulate it
- operation.result = new EarClipping().toMesh((org.apache.sis.geometries.Polygon) operation.geometry);
- }
- }
-
- /**
- * Transform MultiPoint to Primitive.
- */
- public static class MultiPoint implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.MultiPoint>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.MultiPoint> getGeometryClass() {
- return org.apache.sis.geometries.MultiPoint.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- final org.apache.sis.geometries.MultiPoint cdt = (org.apache.sis.geometries.MultiPoint) operation.geometry;
- final ArraySequence array = toArraySequence(cdt.asPointSequence());
- final org.apache.sis.geometries.mesh.MeshPrimitive primitive = new org.apache.sis.geometries.mesh.MeshPrimitive.Points();
- for (String name : array.getAttributeNames()) {
- primitive.setAttribute(name, array.getAttribute(name));
- }
- operation.result = primitive;
- }
- }
-
- /**
- * Transform MultiLineString to Primitive.
- * If all LineString are Lines, the return a single Primitive.lines otherwise return a MultiPrimitive.
- */
- public static class MultiLineString implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.MultiLineString>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.MultiLineString> getGeometryClass() {
- return org.apache.sis.geometries.MultiLineString.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- final org.apache.sis.geometries.MultiLineString cdt = (org.apache.sis.geometries.MultiLineString) operation.geometry;
- boolean allLines = true;
- final int numGeometries = cdt.getNumGeometries();
- for (int i = 0; i < numGeometries && allLines; i++) {
- allLines &= cdt.getGeometryN(i).isLine();
- }
-
- if (allLines) {
- final org.apache.sis.geometries.mesh.MeshPrimitive.Lines primitive = new org.apache.sis.geometries.mesh.MeshPrimitive.Lines();
- final AttributesType attributesType = cdt.getAttributesType();
- for (String name : attributesType.getAttributeNames()) {
- primitive.setAttribute(name, TupleArrays.of(attributesType.getAttributeSystem(name), attributesType.getAttributeType(name), numGeometries*2));
- }
-
- for (int i = 0, k = 0; i < numGeometries; i++, k += 2) {
- final org.apache.sis.geometries.LineString line = cdt.getGeometryN(i);
- final PointSequence points = line.getPoints();
- for (String name : attributesType.getAttributeNames()) {
- TupleArray att = primitive.getAttribute(name);
- att.set(k, points.getAttribute(0, name));
- att.set(k+1, points.getAttribute(1, name));
- }
- }
- operation.result = primitive;
- } else {
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive<org.apache.sis.geometries.mesh.MeshPrimitive> mp =
- new org.apache.sis.geometries.mesh.MultiMeshPrimitive(operation.geometry.getCoordinateReferenceSystem());
- for (int i = 0; i < numGeometries; i++) {
- final Geometry p = GeometryOperations.SpatialEdition.toPrimitive(cdt.getGeometryN(i));
- if (p instanceof org.apache.sis.geometries.mesh.MultiMeshPrimitive<?> subm) {
- mp.append(subm.getComponents());
- } else if (p instanceof org.apache.sis.geometries.mesh.MeshPrimitive cd){
- mp.append(Collections.singletonList(cd));
- }
- }
- operation.result = mp;
- }
- }
- }
-
- /**
- * Transform GeometryCollection to Primitive.
- */
- public static class GeometryCollection implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.GeometryCollection>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.GeometryCollection> getGeometryClass() {
- return org.apache.sis.geometries.GeometryCollection.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive<org.apache.sis.geometries.mesh.MeshPrimitive> mp = new org.apache.sis.geometries.mesh.MultiMeshPrimitive(operation.geometry.getCoordinateReferenceSystem());
- final org.apache.sis.geometries.GeometryCollection cdt = (org.apache.sis.geometries.GeometryCollection) operation.geometry;
- for (int i = 0, n = cdt.getNumGeometries(); i < n; i++) {
- final Geometry p = GeometryOperations.SpatialEdition.toPrimitive(cdt.getGeometryN(i));
- if (p instanceof org.apache.sis.geometries.mesh.MultiMeshPrimitive<?> subm) {
- mp.append(subm.getComponents());
- } else if (p instanceof org.apache.sis.geometries.mesh.MeshPrimitive cd){
- mp.append(Collections.singletonList(cd));
- }
- }
- operation.result = mp;
- }
- }
-
- /**
- * Does nothing, geometry is already a Primitive.
- */
- public static class Primitive implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.mesh.MeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- operation.result = (org.apache.sis.geometries.mesh.MeshPrimitive) operation.geometry;
- }
- }
-
- /**
- * Does nothing, geometry is already a MultiPrimitive.
- */
- public static class MultiPrimitive implements Processor<org.apache.sis.geometries.operation.spatialedition.ToPrimitive, org.apache.sis.geometries.mesh.MultiMeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.ToPrimitive> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.ToPrimitive.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MultiMeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MultiMeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.ToPrimitive operation) throws OperationException {
- operation.result = (org.apache.sis.geometries.mesh.MultiMeshPrimitive) operation.geometry;
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/Transform.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/Transform.java
deleted file mode 100644
index 521e92f..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialedition/Transform.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.privy.ArraySequence;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Transform {
-
- private Transform(){}
-
- private static TupleArray transform(TupleArray reference, org.apache.sis.geometries.operation.spatialedition.Transform operation) {
-
- final int sourceDimension = reference.getDimension();
- final int targetDimension = operation.crs.getCoordinateSystem().getDimension();
- final SampleSystem ss = SampleSystem.of(operation.crs);
-
- if (sourceDimension == targetDimension) {
- //use in place transform
- final TupleArray positions = reference.copy();
- try {
- positions.transform(operation.transform);
- } catch (TransformException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- positions.setSampleSystem(ss);
- return positions;
- } else {
- final int nb = reference.getLength();
- final double[] values = reference.toArrayDouble();
- final double[] result = new double[targetDimension * nb];
- try {
- operation.transform.transform(values, 0, result, 0, nb);
- } catch (TransformException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- return TupleArrays.of(ss, result);
- }
- }
-
- public static class LinearRing implements Processor<org.apache.sis.geometries.operation.spatialedition.Transform, org.apache.sis.geometries.LinearRing> {
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.Transform> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.Transform.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.LinearRing> getGeometryClass() {
- return org.apache.sis.geometries.LinearRing.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.Transform operation) throws OperationException {
- final org.apache.sis.geometries.LinearRing r = (org.apache.sis.geometries.LinearRing) operation.geometry;
-
- PointSequence ps = r.getPoints();
- final TupleArray reference = ps.getAttributeArray(AttributesType.ATT_POSITION);
- final TupleArray positions = transform(reference, operation);
- final ArraySequence cp = new ArraySequence(positions);
- for (String name : ps.getAttributesType().getAttributeNames()) {
- if (!AttributesType.ATT_POSITION.equals(name)) {
- cp.setAttribute(name, ps.getAttributeArray(name).copy());
- }
- }
- operation.result = GeometryFactory.createLinearRing(cp);
- }
- }
-
- public static class Polygon implements Processor<org.apache.sis.geometries.operation.spatialedition.Transform, org.apache.sis.geometries.Polygon> {
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.Transform> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.Transform.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.Polygon> getGeometryClass() {
- return org.apache.sis.geometries.Polygon.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.Transform operation) throws OperationException {
- final org.apache.sis.geometries.Polygon p = (org.apache.sis.geometries.Polygon) operation.geometry;
-
- org.apache.sis.geometries.LinearRing exterior = (org.apache.sis.geometries.LinearRing) GeometryOperations.SpatialEdition.transform(p.getExteriorRing(), operation.crs, operation.transform);
-
- final List<org.apache.sis.geometries.LinearRing> interiors = new ArrayList<>(p.getInteriorRings());
- for (int i = 0, n = interiors.size(); i < n; i++) {
- interiors.set(i, (org.apache.sis.geometries.LinearRing) GeometryOperations.SpatialEdition.transform(interiors.get(i), operation.crs, operation.transform));
- }
-
- operation.result = GeometryFactory.createPolygon(exterior, interiors);
- }
- }
-
- public static class MultiPrimitive implements Processor<org.apache.sis.geometries.operation.spatialedition.Transform, org.apache.sis.geometries.mesh.MultiMeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.Transform> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.Transform.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MultiMeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MultiMeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.Transform operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive<?> mp = (org.apache.sis.geometries.mesh.MultiMeshPrimitive) operation.geometry;
- final org.apache.sis.geometries.mesh.MultiMeshPrimitive<?> copy = new org.apache.sis.geometries.mesh.MultiMeshPrimitive(operation.crs);
- final List<org.apache.sis.geometries.mesh.MeshPrimitive> primitives = new ArrayList<>();
- for (org.apache.sis.geometries.mesh.MeshPrimitive p : mp.getComponents()) {
- primitives.add((org.apache.sis.geometries.mesh.MeshPrimitive) GeometryOperations.SpatialEdition.transform(p, operation.crs, operation.transform));
- }
- copy.append(primitives);
- operation.result = copy;
- }
- }
-
- /**
- * Transform primitive to a new CoordinateReferenceSystem.
- * Note : this method will clone all other attributes untransformed.
- */
- public static class Primitive implements Processor<org.apache.sis.geometries.operation.spatialedition.Transform, org.apache.sis.geometries.mesh.MeshPrimitive>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.Transform> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.Transform.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.mesh.MeshPrimitive> getGeometryClass() {
- return org.apache.sis.geometries.mesh.MeshPrimitive.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.Transform operation) throws OperationException {
- final org.apache.sis.geometries.mesh.MeshPrimitive p = (org.apache.sis.geometries.mesh.MeshPrimitive) operation.geometry;
- final org.apache.sis.geometries.mesh.MeshPrimitive copy = org.apache.sis.geometries.mesh.MeshPrimitive.create(p.getType());
-
- final Set<String> toSkip = new HashSet<>();
- final TupleArray positions = p.getAttribute(AttributesType.ATT_POSITION);
- final TupleArray normals = p.getAttribute(AttributesType.ATT_NORMAL);
- final TupleArray tangents = p.getAttribute(AttributesType.ATT_TANGENT);
- if (positions != null) {
- toSkip.add(AttributesType.ATT_POSITION);
- toSkip.add(AttributesType.ATT_NORMAL);
- toSkip.add(AttributesType.ATT_TANGENT);
-
- try {
- //transform positions
- final TupleArray cpp = positions.copy();
- cpp.setSampleSystem(SampleSystem.of(operation.crs));
- cpp.transform(operation.transform);
- copy.setAttribute(AttributesType.ATT_POSITION, cpp);
-
- final TupleArray cpn = (normals == null) ? null : normals.copy();
- final TupleArray cpt = (tangents == null) ? null : tangents.copy();
-
- //transform normal and tangent with local matrix at each point
- if (normals != null || tangents != null) {
- final Vector pos = Vectors.create(positions.getSampleSystem(), positions.getDataType());
-
- final Vector nor = (normals == null) ? null : Vectors.create(normals.getSampleSystem(), normals.getDataType());
- final Vector tag = (tangents == null) ? null : Vectors.create(tangents.getSampleSystem(), tangents.getDataType());
- for (int i = 0, n = positions.getLength(); i < n; i++) {
- positions.get(i, pos);
- final MatrixSIS matrix = MatrixSIS.castOrCopy(operation.transform.derivative(Vectors.asDirectPostion(pos)));
- if (nor != null) {
- cpn.get(i, nor);
- nor.set(matrix.multiply(nor.toArrayDouble()));
- nor.normalize();
- cpn.set(i, nor);
- }
- if (tag != null) {
- cpt.get(i, tag);
- tag.set(matrix.multiply(tag.toArrayDouble()));
- tag.normalize();
- cpt.set(i, tag);
- }
- }
- if (cpn != null) copy.setAttribute(AttributesType.ATT_NORMAL, cpn);
- if (cpt != null) copy.setAttribute(AttributesType.ATT_TANGENT, cpt);
- }
- } catch (TransformException ex) {
- throw new OperationException(ex.getMessage(), ex);
- }
- }
-
- //copy all other attributes
- for (String name : p.getAttributesType().getAttributeNames()) {
- if (!toSkip.contains(name)) {
- copy.setAttribute(name, p.getAttribute(name).copy());
- }
- }
-
- //copy index and ranges
- final TupleArray index = p.getIndex();
- if (index != null) {
- copy.setIndex(index.copy());
- }
-
- operation.result = copy;
- }
- }
-
- public static class Triangle implements Processor<org.apache.sis.geometries.operation.spatialedition.Transform, org.apache.sis.geometries.Triangle> {
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialedition.Transform> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialedition.Transform.class;
- }
-
- @Override
- public Class<org.apache.sis.geometries.Triangle> getGeometryClass() {
- return org.apache.sis.geometries.Triangle.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialedition.Transform operation) throws OperationException {
- final org.apache.sis.geometries.Triangle p = (org.apache.sis.geometries.Triangle) operation.geometry;
- final PointSequence ps = p.getExteriorRing().getPoints();
-
- final TupleArray reference = ps.getAttributeArray(AttributesType.ATT_POSITION);
- final TupleArray positions = transform(reference, operation);
- final ArraySequence cp = new ArraySequence(positions);
- for (String name : ps.getAttributesType().getAttributeNames()) {
- if (!AttributesType.ATT_POSITION.equals(name)) {
- cp.setAttribute(name, ps.getAttributeArray(name).copy());
- }
- }
- operation.result = GeometryFactory.createTriangle(GeometryFactory.createLinearRing(cp));
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialrelations2d/Contains.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialrelations2d/Contains.java
deleted file mode 100644
index b0cac29..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/spatialrelations2d/Contains.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.geometries.processor.spatialrelations2d;
-
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.Polygon;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.processor.Processor;
-import org.apache.sis.geometries.processor.ProcessorUtils;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrayCursor;
-import org.apache.sis.geometries.math.Vectors;
-
-
-/**
- * Constains 2D processors.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Contains {
-
- private Contains(){}
-
- /**
- * Test if point is within polygon using Winding Number algorithm.
- * http://geomalgorithms.com/a03-_inclusion.html
- * http://en.wikipedia.org/wiki/Point_in_polygon
- *
- * @param ring not null
- * @param point not null
- */
- private static boolean contains(TupleArray ring, Tuple point) {
- final TupleArrayCursor cursor = ring.cursor();
-
- int windingNumber = 0;
- Tuple current;
- Tuple previous;
- cursor.moveTo(0);
- current = cursor.samples();
- previous = Vectors.create(current.getSampleSystem(), current.getDataType());
- final double pointY = point.get(1);
- for (int i = 1, n = ring.getLength(); i < n; i++){
- previous.set(current);
- cursor.moveTo(i);
- current = cursor.samples();
-
- if (previous.get(1) <= pointY){
- if (current.get(1) > pointY){
- if (Maths.lineSide(previous, current, point) > 0){
- windingNumber++;
- }
- }
- } else {
- if (current.get(1) <= pointY){
- if (Maths.lineSide(previous, current, point) < 0){
- windingNumber--;
- }
- }
- }
- }
-
- //if 0 point is outside
- return windingNumber != 0;
- }
-
- /**
- * Polygon contains Point test.
- */
- public static class PolygonPoint implements Processor.Binary<org.apache.sis.geometries.operation.spatialrelations2d.Contains, Polygon, Point>{
-
- @Override
- public Class<org.apache.sis.geometries.operation.spatialrelations2d.Contains> getOperationClass() {
- return org.apache.sis.geometries.operation.spatialrelations2d.Contains.class;
- }
-
- @Override
- public Class<Polygon> getGeometryClass() {
- return Polygon.class;
- }
-
- @Override
- public Class<Point> getRelatedClass() {
- return Point.class;
- }
-
- @Override
- public void process(org.apache.sis.geometries.operation.spatialrelations2d.Contains operation) throws OperationException {
- ProcessorUtils.ensureSameCRS2D(operation.geometry, operation.other);
- final Polygon polygon = (Polygon) operation.geometry;
- final Point candidate = (Point) operation.other;
-
-
- { //check exterior
- final TupleArray coords = polygon.getExteriorRing().getPoints().getAttributeArray(AttributesType.ATT_POSITION);
- if (!contains(coords, candidate.getPosition())) {
- //point is outside the exterior ring
- operation.result = false;
- return;
- }
- }
-
- { //check holes
- for (int i = 0, n = polygon.getNumInteriorRing(); i < n; i++) {
- final LineString hole = polygon.getInteriorRingN(i);
- final TupleArray coords = hole.getPoints().getAttributeArray(AttributesType.ATT_POSITION);
- if (contains(coords, candidate.getPosition())) {
- //point is within a hole
- operation.result = false;
- return;
- }
- }
- }
-
- //point is inside polygon
- operation.result = true;
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/rhumb/Rhumb.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/rhumb/Rhumb.java
deleted file mode 100644
index 1feb865..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/rhumb/Rhumb.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.geometries.rhumb;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.CurveInterpolation;
-import org.apache.sis.geometries.Bearing;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Rhumb", specification=ISO_19107) // section 7.5.1
-public interface Rhumb extends Curve {
-
- @UML(identifier="interpolation", specification=ISO_19107) // section 7.5.2.1
- @Override
- public default CurveInterpolation getInterpolation() {
- return CurveInterpolation.RHUMB;
- }
-
- //TODO in the UML but not in the spec
- Bearing getBearing();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/TextureAtlas.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/TextureAtlas.java
deleted file mode 100644
index 72210f8..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/TextureAtlas.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * 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.geometries.simplify;
-
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.sis.coverage.grid.GridExtent;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- *
- * Creation algorithm from :
- * http://www.blackpawn.com/texts/lightmaps/
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class TextureAtlas {
-
- private final int pageWidth;
- private final int pageHeight;
- private final int padding;
- private final List<Page> pages = new ArrayList<>();
-
- public TextureAtlas(int pageWidth, int pageHeight, int padding) {
- this.pageWidth = pageWidth;
- this.pageHeight = pageHeight;
- this.padding = padding;
- }
-
- /**
- * @return Pages in the atlas.
- */
- public List<Page> getPages() {
- return Collections.unmodifiableList(pages);
- }
-
- /**
- * Get page where image is stored.
- * @param name searched image name, not null
- * @return Page or null if not found
- */
- public Page getPage(String name) throws IllegalArgumentException{
- return pages.get(getPageIndex(name));
- }
-
- /**
- * Get page where image is stored.
- * @param name searched image name, not null
- * @return Page or null if not found
- */
- public int getPageIndex(String name) throws IllegalArgumentException{
- for (int i = 0, n = pages.size(); i < n; i++) {
- if (pages.get(i).index.containsKey(name)) {
- return i;
- }
- }
- throw new IllegalArgumentException("Image " + name + " is not stored in this atlas.");
- }
-
- /**
- * Insert image in the atlas.
- * If the image is larger then atlas pages,
- * a new page with the image size will be created.
- *
- * @param name user defined name or null, if null a new one will be created
- * @param image not null
- * @return image name
- */
- public String add(String name, RenderedImage image) {
- ArgumentChecks.ensureNonNull("image", image);
- if (name == null) name = UUID.randomUUID().toString();
-
- //ensure name is not used
- for (Page p : pages) {
- if (p.index.containsKey(name)) {
- throw new IllegalArgumentException("Name " + name + " is already used in the atlas");
- }
- }
-
- if (image.getWidth() > pageWidth || image.getHeight() > pageHeight) {
- //big image are added to their own page
- final Page page = new Page(name, image);
- pages.add(page);
- return name;
- } else {
- //search a page where to store the image
- for (Page page : pages) {
- if (page.tryInsert(name, image)) {
- return name;
- }
- }
-
- //create a new page
- final Page page = new Page();
- page.tryInsert(name, image);
- pages.add(page);
- return name;
- }
- }
-
- /**
- * Atlas page.
- */
- public final class Page {
- private final RenderedImage image;
- private final Node tree;
- private final Map<String,GridExtent> index = new HashMap<>();
-
- Page() {
- this.image = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_ARGB);
- this.tree = new Node(0, 0, pageWidth, pageHeight);
- }
-
- /**
- * Single image page.
- * @param name
- * @param image
- */
- Page(String name, RenderedImage image) {
- this.image = image;
- this.tree = new Node(name, image);
- this.index.put(name, tree.extent);
- }
-
- public Map<String,GridExtent> index() {
- return Collections.unmodifiableMap(index);
- }
-
- public RenderedImage image() {
- return image;
- }
-
- private boolean tryInsert(String name, RenderedImage image) {
- final Node node = tree.tryInsert(name, image);
-
- if (node == null) {
- return false;
- }
-
- final Graphics2D graphics = ((BufferedImage) this.image).createGraphics();
- graphics.drawRenderedImage(image, new AffineTransform(1, 0, 0, 1, node.extent.getLow(0), node.extent.getLow(1)));
- graphics.dispose();
- index.put(name, node.extent);
- return true;
- }
- }
-
- private final class Node {
-
- public final GridExtent extent;
- public Node child0;
- public Node child1;
- public String name;
-
- public Node(long x, long y, long width, long height) {
- extent = new GridExtent(null, new long[]{x,y}, new long[]{x+width, y+height}, false);
- }
-
- /**
- * Single image node.
- */
- public Node(String name, RenderedImage image) {
- this.extent = new GridExtent(image.getWidth(), image.getHeight());
- this.name = name;
- }
-
- public Node tryInsert(String name, RenderedImage image) {
- if (child0 != null || child1 != null) {
- // try inserting into first child
- Node newNode = child0.tryInsert(name, image);
- if (newNode != null) {
- return newNode;
- }
- // no room, insert into second
- return child1.tryInsert(name, image);
- } else {
- final int imgWidth = image.getWidth();
- final int imgHeight = image.getHeight();
- final long x = extent.getLow(0);
- final long y = extent.getLow(1);
- final long width = extent.getSize(0);
- final long height = extent.getSize(1);
- if (this.name != null) {
- // if there's already a image here, return
- return null;
- } else if (imgWidth > width || imgHeight > height) {
- // if we're too small, return
- return null;
- } else if (imgWidth == width && imgHeight == height) {
- // if we're just right, accept
- this.name = name;
- return this;
- } else {
- // otherwise, gotta split this node and create some kids
- // decide which way to split
- long dw = width - imgWidth;
- long dh = height - imgHeight;
-
- if (dw > dh) {
- //vertical split
- child0 = new Node(
- x,
- y,
- imgWidth,
- height);
- child1 = new Node(
- x + imgWidth + padding,
- y,
- width - imgWidth - padding,
- height);
- } else {
- //horizontal split
- child0 = new Node(
- x,
- y,
- width,
- imgHeight);
- child1 = new Node(
- x,
- y + imgHeight + padding,
- width,
- height - imgHeight - padding);
- }
- // insert into first child we created
- return child0.tryInsert(name, image);
- }
- }
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/Edge.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/Edge.java
deleted file mode 100644
index 3b0b530..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/Edge.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.geometries.simplify.greedyinsert;
-
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Edge {
-
- private boolean obsolete = false;
- public final Tuple p0;
- public final Tuple p1;
- public WTriangle t0;
- public WTriangle t1;
- /**
- * Set to true if this edge is a constraint.
- * If true this edge should not be removed in the TIN creation process.
- * Still this edge can be split, each resulting edge will inherit the constraint.
- */
- private boolean constraint = false;
-
- public Edge(Tuple p0, Tuple p1) {
- if (p0.get(0) == p1.get(0) && p0.get(1) == p1.get(1)) {
- throw new IllegalArgumentException("Edge points XY are identical");
- }
- this.p0 = p0;
- this.p1 = p1;
- }
-
- void makeObsolete(){
- this.obsolete = true;
- }
-
- boolean isObsolete() {
- return obsolete;
- }
-
- /**
- * @return true if point in on the edge
- */
- public boolean isOnEdge(Tuple pt) {
- assert (!obsolete);
- return Maths.isOnLine(p0, p1, pt);
- }
-
- void change(WTriangle before, WTriangle after) {
- assert (!obsolete);
- if (t0 == before) {
- t0 = after;
- } else if (t1 == before) {
- t1 = after;
- } else{
- throw new IllegalStateException("Triangle is not defined for this edge");
- }
- }
-
- /**
- * @return true if one of the two edge point is the same as given point.
- */
- public boolean hasPoint(Tuple pt) {
- assert (!obsolete);
- return p0 == pt || p1 == pt;
- }
-
- /**
- * Set to true if this edge is a constraint.
- * If true this edge should not be removed in the TIN creation process.
- * Still this edge can be split, each resulting edge will inherit the constraint.
- *
- * @param constraint true for a constraint edge
- */
- public void setConstraint(boolean constraint) {
- this.constraint = constraint;
- }
-
- /**
- * @return true if edge is a constraint
- */
- public boolean isConstraint() {
- return constraint;
- }
-
- @Override
- public String toString() {
- return "E "+p0+" "+p1;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java
deleted file mode 100644
index 351d8d2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * 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.geometries.simplify.greedyinsert;
-
-import java.awt.geom.Point2D;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
-
-
-/**
- * Variant of progressive TIN creation until an error threshold is met.
- * This approach is called 'greedy insertion'.
- *
- * Multiple papers and algorithms variants exist.
- * http://mgarland.org/files/papers/scape.pdf
- * https://pdfs.semanticscholar.org/5f25/071f17d3a6bd730463984644767d206d0def.pdf
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class TINBuilder {
-
- private static final Logger LOGGER = Logger.getLogger("org.apache.sis.geometries");
-
- private final CoordinateReferenceSystem crs;
- private final ArrayDeque<WTriangle> workStackTriangles = new ArrayDeque<>();
- private final ArrayDeque<Edge> workStackEdges = new ArrayDeque<>();
- private final List<WTriangle> finished = new ArrayList<>();
- private final List<Tuple> vertices = new ArrayList<>();
- private final double delta;
- private final BiFunction<Tuple,Triangle,Double> errorCalculator;
- private boolean decimateInsert = true;
-
- /**
- *
- * p0 +---+ p1
- * | / |
- * p2 +---+ p3
- *
- * @param p0 first dem corner
- * @param p1 second dem corner
- * @param p2 third dem corner
- * @param p3 fourth dem corner
- * @param delta minimum distance to dem to include point
- * @throws OperationException if an invalid geometry state occurs
- */
- public TINBuilder(Tuple p0, Tuple p1, Tuple p2, Tuple p3, double delta, BiFunction<Tuple,Triangle,Double> errorCalculator) throws OperationException {
- this.crs = p0.getCoordinateReferenceSystem();
- ArgumentChecks.ensureNonNull("crs", crs);
- if ( !crs.equals(p1.getCoordinateReferenceSystem())
- || !crs.equals(p2.getCoordinateReferenceSystem())
- || !crs.equals(p3.getCoordinateReferenceSystem())
- ) {
- throw new IllegalArgumentException("All corner points must have the same crs");
- }
-
- this.delta = delta;
- this.errorCalculator = errorCalculator;
-
- final Edge e01 = new Edge(p0, p1);
- final Edge e02 = new Edge(p0, p2);
- final Edge e12 = new Edge(p1, p2);
- final Edge e31 = new Edge(p3, p1);
- final Edge e32 = new Edge(p3, p2);
-
- final WTriangle t0 = new WTriangle(e01,e12,e02, errorCalculator);
- final WTriangle t1 = new WTriangle(e12,e31,e32, errorCalculator);
-
- e01.t1 = t0;
- e02.t0 = t0;
- e12.t1 = t0;
- e12.t0 = t1;
- e31.t0 = t1;
- e32.t1 = t1;
-
- vertices.add(p0);
- vertices.add(p1);
- vertices.add(p2);
- vertices.add(p3);
-
- finished.add(t0);
- finished.add(t1);
-
- assert t0.validate();
- assert t1.validate();
- }
-
- public List<Triangle> getTriangles(){
- final List<Triangle> triangles = new ArrayList<>(finished.size());
- for (int i = 0, n = finished.size(); i < n; i++) {
- final WTriangle t = finished.get(i);
- final TupleArray positions = TupleArrays.of(Arrays.asList(t.p0, t.p1, t.p2, t.p0), t.p0.getSampleSystem(), t.p0.getDataType());
- final PointSequence points = GeometryFactory.createSequence(positions);
- final LinearRing exterior = GeometryFactory.createLinearRing(points);
- triangles.add(GeometryFactory.createTriangle(exterior));
- }
- return triangles;
- }
-
- /**
- * Loop on all edges.
- * Caution : use with care, may break the building process.
- * @param consumer to be called on each edge.
- */
- public void forEachEdge(Consumer<Edge> consumer) {
- for (WTriangle triangle : finished) {
- consumer.accept(triangle.e0);
- consumer.accept(triangle.e1);
- consumer.accept(triangle.e2);
- }
- }
-
- /**
- * Insert new points in the TIN.
- *
- * @param pts points to insert
- * @param decimate true to apply decimation based on error calculator, false to force insertion.
- * @throws ProcessException
- */
- public void add(List<Tuple> pts, boolean decimate) throws OperationException {
- decimateInsert = decimate;
-
- //remove any duplicated points
- final Set<Point2D.Double> set = new HashSet<>(pts.size());
- final List<Tuple> uniques = new ArrayList<>();
- for (Tuple t : pts) {
- if (!Utilities.equalsIgnoreMetadata(crs, t.getCoordinateReferenceSystem())) {
- throw new OperationException("Points must have the same crs avec corner points");
- }
- if (set.add(new Point2D.Double(t.get(0), t.get(1)))) {
- uniques.add(t);
- } else {
- LOGGER.log(Level.FINE, "Point {0} already defined in add list, point will be ignored", t);
- }
- }
-
- //assign points into each triangle
- assign(uniques, finished);
-
- workStackTriangles.addAll(finished);
- finished.clear();
-
- //solve triangles
- Edge edge;
- WTriangle triangle;
- while (!workStackEdges.isEmpty() || !workStackTriangles.isEmpty()) {
- //solve delaunay edges
- for (edge = workStackEdges.poll(); edge != null; edge = workStackEdges.poll()) {
- //delaunay simplification test
- if (!edge.isObsolete()) {
- testDelaunay(edge);
- }
- }
-
- triangle = workStackTriangles.poll();
- if (triangle != null && !triangle.isObsolete()) {
- solve(triangle);
- }
- }
-
- finished.addAll(workStackTriangles);
- workStackTriangles.clear();
- workStackEdges.clear();
- //remove all points we didn't use
- for (WTriangle t : finished) {
- t.clearCandidates();
- }
-
- }
-
- private void assign(List<Tuple> pts, Collection<WTriangle> triangles) throws OperationException {
- ptLoop:
- for (int i = pts.size() - 1; i >= 0; i--) {
- final Tuple pt = pts.get(i);
- if (pt == null) continue;
-
- double ptx = pt.get(0);
- double pty = pt.get(1);
-
- for (WTriangle t : triangles) {
-
- if ( (t.p0.get(0) == ptx && t.p0.get(1) == pty)
- || (t.p1.get(0) == ptx && t.p1.get(1) == pty)
- || (t.p2.get(0) == ptx && t.p2.get(1) == pty)
- ){
- LOGGER.log(Level.FINE, "Point {0} already exist in TIN, point will be ignored", pt);
- pts.set(i, null);
- continue ptLoop;
- }
-
- if (t.contains(pt)) {
- t.addCandidate(pt);
- pts.set(i, null);
- continue ptLoop;
- }
- }
-
- LOGGER.log(Level.INFO, "Point {0} not in any triangle", pt);
- }
- }
-
- private void solve(WTriangle triangle) throws OperationException {
-
- final Tuple maxPt = triangle.findMaxDistancePoint();
- if (maxPt == null) {
- finished.add(triangle);
- return;
- }
-
- if (decimateInsert) {
- final double error = errorCalculator.apply(maxPt, triangle);
- if (error < delta) {
- finished.add(triangle);
- return;
- }
- }
-
- //remove point from list
- triangle.removeCandidate(maxPt);
- vertices.add(maxPt);
-
- if (triangle.e0.isOnEdge(maxPt)) {
- splitOnEdge(triangle.e0, maxPt);
- } else if (triangle.e1.isOnEdge(maxPt)) {
- splitOnEdge(triangle.e1, maxPt);
- } else if (triangle.e2.isOnEdge(maxPt)) {
- splitOnEdge(triangle.e2, maxPt);
- } else {
- splitCenter(triangle, maxPt);
- }
- }
-
- private void splitCenter(WTriangle t, Tuple c) throws OperationException {
-
- /*
- p0
- +__
- |\ \__ a0
- |e0 \__
- | \ \
- a2 | c+-e1--+ p1
- | / __/
- |e2 __/
- |/_/ a1
- +
- p2
- */
-
- final Tuple p0 = t.p0;
- final Tuple p1 = t.p1;
- final Tuple p2 = t.p2;
- final Edge a0 = t.getEdge(p0, p1);
- final Edge a1 = t.getEdge(p1, p2);
- final Edge a2 = t.getEdge(p2, p0);
- //create the 3 new edges
- final Edge e0 = new Edge(p0, c);
- final Edge e1 = new Edge(p1, c);
- final Edge e2 = new Edge(p2, c);
- //create the 3 new triangles
- final WTriangle t0 = new WTriangle(a0, e1, e0, errorCalculator);
- final WTriangle t1 = new WTriangle(a1, e2, e1, errorCalculator);
- final WTriangle t2 = new WTriangle(a2, e0, e2, errorCalculator);
- //assign edge triangles
- a0.change(t, t0);
- a1.change(t, t1);
- a2.change(t, t2);
- e0.t0 = t0; e0.t1 = t2;
- e1.t0 = t1; e1.t1 = t0;
- e2.t0 = t2; e2.t1 = t1;
-
- //reassign points in new triangles
- t.reassign(t0, t1, t2);
- workStackTriangles.add(t0);
- workStackTriangles.add(t1);
- workStackTriangles.add(t2);
- assert t0.validate();
- assert t1.validate();
- assert t2.validate();
-
- //ensure we have delaunay triangles
- workStackEdges.addFirst(a0);
- workStackEdges.addFirst(a1);
- workStackEdges.addFirst(a2);
- }
-
- private void splitOnEdge(Edge edge, Tuple pt) throws OperationException {
- WTriangle t0 = edge.t0;
- WTriangle t1 = edge.t1;
- if (t0 == null) {
- t0 = t1;
- t1 = null;
- finished.remove(t0);
- workStackTriangles.remove(t0);
- } else {
- finished.remove(t0);
- finished.remove(t1);
- workStackTriangles.remove(t0);
- workStackTriangles.remove(t1);
- }
-
- /*
- +
- /|\
- a0 / | \ a1
- / e2 \
- / | \
- p0 +----+----+ p1
- e0 e1
-
- */
-
- //split edge in two
- Edge e0 = new Edge(edge.p0, pt);
- Edge e1 = new Edge(edge.p1, pt);
- //inherit constraint if parent is.
- e0.setConstraint(edge.isConstraint());
- e1.setConstraint(edge.isConstraint());
- Edge e2 = new Edge(t0.oppositePoint(edge), pt);
- t0.obsolete();
- //find opposite edges
- Edge a0 = null;
- Edge a1 = null;
- if (t0.e0 != edge) {
- if (t0.e0.hasPoint(edge.p0)) a0 = t0.e0;
- if (t0.e0.hasPoint(edge.p1)) a1 = t0.e0;
- }
- if (t0.e1 != edge) {
- if (t0.e1.hasPoint(edge.p0)) a0 = t0.e1;
- if (t0.e1.hasPoint(edge.p1)) a1 = t0.e1;
- }
- if (t0.e2 != edge) {
- if (t0.e2.hasPoint(edge.p0)) a0 = t0.e2;
- if (t0.e2.hasPoint(edge.p1)) a1 = t0.e2;
- }
- final WTriangle t0_0 = new WTriangle(e0, a0, e2, errorCalculator);
- final WTriangle t0_1 = new WTriangle(e1, a1, e2, errorCalculator);
- //affect triangles to edges
- e0.t0 = t0_0; e0.t1 = t1;
- e1.t0 = t0_1; e1.t1 = t1;
- e2.t0 = t0_0; e2.t1 = t0_1;
- a0.change(t0, t0_0);
- a1.change(t0, t0_1);
-
- //reassign points
- workStackTriangles.add(t0_0);
- workStackTriangles.add(t0_1);
- t0.reassign(t0_0, t0_1);
- assert t0_0.validate();
- assert t0_1.validate();
- workStackEdges.addFirst(a0);
- workStackEdges.addFirst(a1);
-
- if (t1 != null) {
-
- e2 = new Edge(t1.oppositePoint(edge), pt);
- t1.obsolete();
- //find opposite edges
- a0 = null;
- a1 = null;
- if (t1.e0 != edge) {
- if (t1.e0.hasPoint(edge.p0)) a0 = t1.e0;
- if (t1.e0.hasPoint(edge.p1)) a1 = t1.e0;
- }
- if (t1.e1 != edge) {
- if (t1.e1.hasPoint(edge.p0)) a0 = t1.e1;
- if (t1.e1.hasPoint(edge.p1)) a1 = t1.e1;
- }
- if (t1.e2 != edge) {
- if (t1.e2.hasPoint(edge.p0)) a0 = t1.e2;
- if (t1.e2.hasPoint(edge.p1)) a1 = t1.e2;
- }
-
- final WTriangle t1_0 = new WTriangle(e0, a0, e2, errorCalculator);
- final WTriangle t1_1 = new WTriangle(e1, a1, e2, errorCalculator);
- //affect triangles to edges
- e0.change(t1, t1_0);
- e1.change(t1, t1_1);
- e2.t0 = t1_0; e2.t1 = t1_1;
- a0.change(t1, t1_0);
- a1.change(t1, t1_1);
-
- //reassign points
- workStackTriangles.add(t1_0);
- workStackTriangles.add(t1_1);
- t1.reassign(t1_0, t1_1);
- assert t1_0.validate();
- assert t1_1.validate();
- workStackEdges.addFirst(a0);
- workStackEdges.addFirst(a1);
- }
- //ensure edge wont be used anymore
- edge.makeObsolete();
- }
-
- /**
- * Ensure the 2 triangles on each side of the edge are delaunay triangles.
- * if it's not the case the edge will be swapped.
- *
- * @param e0
- * @param pt
- */
- private void testDelaunay(Edge e0) throws OperationException {
- if (e0.isConstraint()) {
- //edge is a constraint, it can not be removed
- return;
- }
- WTriangle t0 = e0.t0;
- WTriangle t1 = e0.t1;
- if (t0 == null || t1 == null) return;
-
- /*
- p1
- +
- /|\
- t0 / | \ t1
- / | \
- p0 + e0 + p2
- \ | /
- \ | /
- \|/
- +
- p3
- */
- final Tuple p0 = t0.oppositePoint(e0);
- final Tuple p1 = e0.p0;
- final Tuple p2 = t1.oppositePoint(e0);
- final Tuple p3 = e0.p1;
-
- if (Maths.inCircle(t0.p0, t0.p1, t0.p2, p2)) {
- /* swap edge
-
- p1
- +
- / \
- t2 a0 a1
- / \
- p0 +---e1--+ p2
- \ /
- t3 a3 a2
- \ /
- +
- p3
- */
-
- //create new triangles
- final Edge a0 = t0.getEdge(p0, p1);
- final Edge a1 = t1.getEdge(p1, p2);
- final Edge a2 = t1.getEdge(p2, p3);
- final Edge a3 = t0.getEdge(p3, p0);
- e0.makeObsolete();
- t0.obsolete();
- t1.obsolete();
- final Edge e1 = new Edge(p0, p2);
- final WTriangle t2 = new WTriangle(e1, a0, a1, errorCalculator);
- final WTriangle t3 = new WTriangle(e1, a2, a3, errorCalculator);
- e1.t0 = t2;
- e1.t1 = t3;
- a0.change(t0, t2);
- a1.change(t1, t2);
- a2.change(t1, t3);
- a3.change(t0, t3);
- //reassign points
- t0.reassign(t2, t3);
- t1.reassign(t2, t3);
-
- //remove old and add new triangles in the stack
- workStackTriangles.remove(t0);
- workStackTriangles.remove(t1);
- finished.remove(t0);
- finished.remove(t1);
- workStackTriangles.add(t2);
- workStackTriangles.add(t3);
-
- assert t2.validate();
- assert t3.validate();
-
- workStackEdges.addFirst(a0);
- workStackEdges.addFirst(a1);
- workStackEdges.addFirst(a2);
- workStackEdges.addFirst(a3);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TinDistance.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TinDistance.java
deleted file mode 100644
index 3626dfb..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TinDistance.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.geometries.simplify.greedyinsert;
-
-import java.util.function.BiFunction;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-final class TinDistance implements BiFunction<Tuple,Triangle,Double> {
-
- @Override
- public Double apply(Tuple pt, Triangle triangle) {
- final PointSequence points = triangle.getExteriorRing().getPoints();
- final Tuple p0 = points.getPosition(0);
- final Tuple p1 = points.getPosition(1);
- final Tuple p2 = points.getPosition(2);
- Vector normal = Maths.calculateNormal(p0, p1, p2);
- double planD = normal.dot(p0);
-
- return Math.abs(Maths.distance(pt, normal, planD));
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/WTriangle.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/WTriangle.java
deleted file mode 100644
index 8950325..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/WTriangle.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * 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.geometries.simplify.greedyinsert;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.BiFunction;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.operation.OperationException;
-
-
-/**
- * Triangle.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class WTriangle extends AbstractGeometry implements Triangle {
-
- private final LinearRing ring = GeometryFactory.createLinearRing(new PointSequence() {
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return p0.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
- @Override
- public int size() {
- return 4;
- }
-
- @Override
- public Point getPoint(final int index) {
- final PointSequence ps = this;
- switch (index) {
- case 0 :
- case 1 :
- case 2 :
- case 3 :
- return new Point() {
- @Override
- public Tuple getPosition() {
- return ps.getPosition(index);
- }
-
- @Override
- public Tuple getAttribute(String name) {
- return ps.getAttribute(index, name);
- }
-
- @Override
- public void setAttribute(String name, Tuple tuple) {
- ps.setAttribute(index, name, tuple);
- }
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return p0.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public AttributesType getAttributesType() {
- return ps.getAttributesType();
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- };
- default : throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- @Override
- public Tuple getPosition(int index) {
- switch (index) {
- case 0 : return p0.copy();
- case 1 : return p1.copy();
- case 2 : return p2.copy();
- case 3 : return p0.copy();
- default : throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- return getPosition(index);
- }
- return null;
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- setPosition(index, value);
- return;
- }
- throw new UnsupportedOperationException("Not supported.");
- }
- });
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public LinearRing getExteriorRing() {
- return ring;
- }
-
- private static class Candidate implements Comparable<Candidate>{
-
- private final Tuple tuple;
- private final double error;
-
- public Candidate(Tuple tuple, double error) {
- this.tuple = tuple;
- this.error = error;
- }
-
- @Override
- public int compareTo(Candidate other) {
- return Double.compare(other.error, error);
- }
- }
-
- private boolean obsolete = false;
- public final Edge e0;
- public final Edge e1;
- public final Edge e2;
- /**
- * triangle points in counter clockwise order
- */
- public final Tuple p0;
- public final Tuple p1;
- public final Tuple p2;
-
- private final List<Candidate> candidates;
- private Candidate max;
- private final BiFunction<Tuple,Triangle,Double> errorCalculator;
-
- public WTriangle(Edge e0, Edge e1, Edge e2, BiFunction<Tuple,Triangle,Double> errorCalculator) {
- this.errorCalculator = errorCalculator;
-
- candidates = new ArrayList<>();
-
- this.e0 = e0;
- this.e1 = e1;
- this.e2 = e2;
- this.p0 = e0.p0;
-
- Tuple p1 = e0.p1;
- Tuple p2;
-
- if (e1.p0.equals(e0.p0) || e1.p0.equals(e0.p1)) {
- p2 = e1.p1;
- } else {
- p2 = e1.p0;
- }
- if (!Maths.isCounterClockwise(p0, p1, p2)) {
- Tuple temp = p1;
- p1 = p2;
- p2 = temp;
- }
- this.p1 = p1;
- this.p2 = p2;
- }
-
- public void addCandidate(Tuple t) {
- final double error = errorCalculator.apply(t, this);
- final Candidate cdt = new Candidate(t, error);
-
- if (max == null || error > max.error) {
- max = cdt;
- }
- candidates.add(cdt);
- }
-
- public void removeCandidate(Tuple t) {
- if (max.tuple == t) {
- max = null;
- }
-
- for (Candidate cdt : candidates) {
- if (cdt.tuple == t) {
- candidates.remove(cdt);
- return;
- }
- }
- }
-
- public void clearCandidates() {
- candidates.clear();
- max = null;
- }
-
- public void reassign(WTriangle triangle1, WTriangle triangle2) throws OperationException{
- for (Candidate cdt : candidates) {
- if (triangle1.contains(cdt.tuple)) {
- triangle1.addCandidate(cdt.tuple);
- } else {
- triangle2.addCandidate(cdt.tuple);
- }
- }
- }
-
- public void reassign(WTriangle triangle1, WTriangle triangle2, WTriangle triangle3) throws OperationException{
- for (Candidate cdt : candidates) {
- if (triangle1.contains(cdt.tuple)) {
- triangle1.addCandidate(cdt.tuple);
- } else if (triangle2.contains(cdt.tuple)) {
- triangle2.addCandidate(cdt.tuple);
- } else {
- triangle3.addCandidate(cdt.tuple);
- }
- }
- }
-
- public Tuple getFirstCoord() {
- return p0;
- }
-
- public Tuple getSecondCoord() {
- return p1;
- }
-
- public Tuple getThirdCoord() {
- return p2;
- }
-
- public boolean isObsolete() {
- return obsolete;
- }
-
- public void obsolete(){
- this.obsolete = true;
- }
-
- public boolean contains(Tuple pt) {
- assert (!obsolete);
- return Maths.isPointInTriangle_BaryAlgo(p0, p1, p2, pt)
- || e0.isOnEdge(pt)
- || e1.isOnEdge(pt)
- || e2.isOnEdge(pt);
- }
-
- public Tuple oppositePoint(Edge edge) throws OperationException {
- assert (!obsolete);
- if (!edge.hasPoint(p0)) {
- return p0;
- }
- if (!edge.hasPoint(p1)) {
- return p1;
- }
- if (!edge.hasPoint(p2)) {
- return p2;
- } else {
- throw new OperationException("Should not happen, TIN simplification algorithm flow.");
- }
- }
-
- public Edge getEdge(Tuple p0, Tuple p1) throws OperationException {
- assert (!obsolete);
- if ((e0.p0 == p0 && e0.p1 == p1) || (e0.p1 == p0 && e0.p0 == p1)) {
- return e0;
- }
- if ((e1.p0 == p0 && e1.p1 == p1) || (e1.p1 == p0 && e1.p0 == p1)) {
- return e1;
- }
- if ((e2.p0 == p0 && e2.p1 == p1) || (e2.p1 == p0 && e2.p0 == p1)) {
- return e2;
- } else {
- throw new OperationException("Should not happen, TIN simplification algorithm flow.");
- }
- }
-
- public Tuple findMaxDistancePoint(){
- if (max == null && !candidates.isEmpty()) {
- max = candidates.get(0);
- for (int i=1,n=candidates.size();i<n;i++) {
- Candidate c = candidates.get(i);
- if(c.error > max.error) {
- max = c;
- }
- }
- }
-
- if (max != null) {
- return max.tuple;
- } else {
- return null;
- }
- }
-
- public boolean validate() throws OperationException{
- assert (!obsolete);
-
- if(e0.p0 == e0.p1 || e1.p0 == e1.p1 || e2.p0 == e2.p1) throw new OperationException("Unvalid edges");
-
- if(e0.p0 != p0 && e0.p0 != p1 && e0.p0 != p2) throw new OperationException("Unvalid edge "+e0);
- if(e0.p1 != p0 && e0.p1 != p1 && e0.p1 != p2) throw new OperationException("Unvalid edge "+e0);
-
- if(e1.p0 != p0 && e1.p0 != p1 && e1.p0 != p2) throw new OperationException("Unvalid edge "+e1);
- if(e1.p1 != p0 && e1.p1 != p1 && e1.p1 != p2) throw new OperationException("Unvalid edge "+e1);
-
- if(e2.p0 != p0 && e2.p0 != p1 && e2.p0 != p2) throw new OperationException("Unvalid edge "+e2);
- if(e2.p1 != p0 && e2.p1 != p1 && e2.p1 != p2) throw new OperationException("Unvalid edge "+e2);
-
- if(e0.t0 != this && e0.t1 != this) throw new OperationException("Unvalid edge "+e0);
- if(e1.t0 != this && e1.t1 != this) throw new OperationException("Unvalid edge "+e1);
- if(e2.t0 != this && e2.t1 != this) throw new OperationException("Unvalid edge "+e2);
-
- if(e0.isObsolete()) throw new OperationException("Obsolete edge "+e0);
- if(e1.isObsolete()) throw new OperationException("Obsolete edge "+e1);
- if(e2.isObsolete()) throw new OperationException("Obsolete edge "+e2);
- return true;
- }
-
- @Override
- public String toString() {
- return "T "+p0+" "+p1+" "+p2;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Clothoid.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Clothoid.java
deleted file mode 100644
index ecaeeb7..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Clothoid.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.spirals;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Clothoid", specification=ISO_19107) // section 7.11.3
-public interface Clothoid extends Spiral {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Spiral.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Spiral.java
deleted file mode 100644
index 2b3565f..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/spirals/Spiral.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.spirals;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.polynomials.RealFunction;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="Spiral", specification=ISO_19107) // section 7.11.2
-public interface Spiral extends Curve {
-
- @UML(identifier="Spiral", specification=ISO_19107) // section 7.11.2.2
- RealFunction getCurvature();
-
- @UML(identifier="torsion", specification=ISO_19107) // section 7.11.2.3
- RealFunction getTorsion();
-
- @UML(identifier="startFrame", specification=ISO_19107) // section 7.11.2.4
- List<Vector> getStartFrame();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/BSplineCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/BSplineCurve.java
deleted file mode 100644
index 05fd5e8..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/BSplineCurve.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="BSplineCurve", specification=ISO_19107) // section 7.13.8
-public interface BSplineCurve extends SplineCurve{
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/CubicSpline.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/CubicSpline.java
deleted file mode 100644
index f636477..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/CubicSpline.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="CubicSpline", specification=ISO_19107) // section 7.13.6
-public interface CubicSpline extends PolynomialSpline {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/KnotType.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/KnotType.java
deleted file mode 100644
index 78104be..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/KnotType.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="KnotType", specification=ISO_19107) // section 7.13.2
-public enum KnotType {
- UNIFORM,
- NON_UNIFORM,
- QUASI_UNIFORM,
- PIECEWISE_BEZIER
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/NURB.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/NURB.java
deleted file mode 100644
index b11f976..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/NURB.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="NURB", specification=ISO_19107) // section 7.13.8
-public interface NURB extends BSplineCurve {
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/PolynomialSpline.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/PolynomialSpline.java
deleted file mode 100644
index bb9f362..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/PolynomialSpline.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.math.Vector;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="PolynomialSpline", specification=ISO_19107) // section 7.13.5
-public interface PolynomialSpline extends SplineCurve {
-
- @UML(identifier="derivativeAtStart", specification=ISO_19107) // section 7.13.5.2
- Vector getDerivativeAtStart();
-
- @UML(identifier="derivativeInterior", specification=ISO_19107) // section 7.13.5.2
- int getDerivativeInterior();
-
- @UML(identifier="derivativeAtEnd", specification=ISO_19107) // section 7.13.5.2
- Vector getDerivativeAtEnd();
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurve.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurve.java
deleted file mode 100644
index 0415802..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurve.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.apache.sis.geometries.Knot;
-import org.apache.sis.geometries.polynomials.PolynomialCurve;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="SplineCurve", specification=ISO_19107) // section 7.13.4
-public interface SplineCurve extends PolynomialCurve {
-
- @UML(identifier="curveForm", specification=ISO_19107) // section 7.13.4.2
- SplineCurveForm getCurveForm();
-
- @UML(identifier="knot", specification=ISO_19107) // section 7.13.4.3
- @Override
- List<Knot> getKnots();
-
- @UML(identifier="degree", specification=ISO_19107) // section 7.13.4.4
- @Override
- int getDegree();
-
- @UML(identifier="knotSpec", specification=ISO_19107) // section 7.13.4.5
- KnotType getKnotSpec();
-
- @UML(identifier="isRational", specification=ISO_19107) // section 7.13.4.6
- boolean isRational();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurveForm.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurveForm.java
deleted file mode 100644
index 0a5ec2e..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splines/SplineCurveForm.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.geometries.splines;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="SplineCurveForm", specification=ISO_19107) // section 7.13.3
-public enum SplineCurveForm {
- POLYLINE_FORM,
- CIRCULAR_ARC,
- ELLIPTICAL_ARC,
- PARABOLIC_ARC,
- HYPERBOLIC_ARC
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurface.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurface.java
deleted file mode 100644
index 3e1dcaa..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurface.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.geometries.splinesurfaces;
-
-import java.util.List;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-import org.opengis.geometry.coordinate.BSplineSurfaceForm;
-import org.apache.sis.geometries.Knot;
-import org.apache.sis.geometries.GeometryType;
-import org.apache.sis.geometries.parametriccurvesurfaces.ParametricCurveSurface;
-import org.apache.sis.geometries.splines.KnotType;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="BSplineSurface", specification=ISO_19107) // section 8.7.2
-public interface BSplineSurface extends ParametricCurveSurface {
-
- @UML(identifier="degree", specification=ISO_19107) // section 8.7.2.2
- int getDegree();
-
- @UML(identifier="knot", specification=ISO_19107) // section 8.7.2.3
- @Override
- public List<Knot> getKnots();
-
- @UML(identifier="knotSpec", specification=ISO_19107) // section 8.7.2.5
- KnotType getKnotSpec();
-
- @UML(identifier="surfaceForm", specification=ISO_19107) // section 8.7.2.4
- BSplineSurfaceForm getSurfaceForm();
-
- @UML(identifier="isPolynomial", specification=ISO_19107) // section 8.7.2.6
- boolean isPolynomial();
-
- @Override
- GeometryType getHorizontalCurveType();
-
- @Override
- GeometryType getVerticalCurveType();
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurfaceForm.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurfaceForm.java
deleted file mode 100644
index 80e06a2..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/splinesurfaces/BSplineSurfaceForm.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.geometries.splinesurfaces;
-
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@UML(identifier="BSplineSurfaceForm", specification=ISO_19107) // section 8.7.3
-public enum BSplineSurfaceForm {
- PLANAR,
- CYLINDRICAL,
- CONICAL,
- SPHERICAL,
- TOROIDAL,
- UNSPECIFIED
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/EarClipping.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/EarClipping.java
deleted file mode 100644
index 01a6138..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/EarClipping.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * 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.geometries.triangulate;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.Polygon;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector2D;
-import static org.apache.sis.geometries.math.Vectors.*;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.util.ArraysExt;
-
-
-/**
- * Origin : Adapted from Unlicense-Lib
- *
- * Triangulation using ear clipping algorithm.
- * http://en.wikipedia.org/wiki/Polygon_triangulation
- *
- * @author Johann Sorel
- */
-public class EarClipping {
-
- private static final Comparator<Geometry> X_SORTER = new Comparator<Geometry>() {
- public int compare(Geometry first, Geometry second) {
- final double m1 = first.getEnvelope().getMinimum(0);
- final double m2 = second.getEnvelope().getMinimum(0);
- double d = m2-m1;
- return (d<0) ? -1 : (d>0) ? +1 : 0;
- }
- };
- private static final class SimplePolygon{
- private LineString outter;
- private final List<LineString> inners = new ArrayList();
- /**
- * direction of the outter loop
- */
- private boolean outterIsClockwise;
- }
-
- private final List<Tuple[]> triangles = new ArrayList<>();
-
- /**
- * A path can be composed of multiple parts.
- * Each part is a closed polyline with inner holes.
- */
- private final List parts = new ArrayList();
-
- /** number of coordinates, may be inferior to coords length. */
- private int nbCoords;
- /** current coordinates to triangulate. */
- private Tuple[] coords;
- /**
- * store the type of angle made by the coordinate
- * avoid recalculate it each time.
- * 0 : not calculated
- * 1 : convex
- * 2 : concave
- */
- private int[] coordType;
-
- //current segment analyzed
- private int indexPrevious;
- private int index;
- private int indexNext;
- private Tuple t1; //previous point
- private Tuple t2; //point at index
- private Tuple t3; //next point
-
- private void reset(){
- //reset values
- triangles.clear();
- nbCoords = 0;
- coords = null;
- coordType = null;
- parts.clear();
- }
-
- /**
- *
- * @param geometry geometry to triangulate
- * @return List of Coordinate[] for each triangle.
- */
- public List<Tuple[]> triangulate(Polygon geometry) {
-
- reset();
-
- final SimplePolygon part = new SimplePolygon();
- //copy collection to avoid modifications
- part.outter = geometry.getExteriorRing();
-
- final int nbHole = geometry.getNumInteriorRing();
-
- for(int i=0;i<nbHole;i++){
- final LineString inner = geometry.getInteriorRingN(i);
- part.inners.add(inner);
- }
-
- run(part);
-
- return triangles;
- }
-
- /**
- * TODO not efficient, improve performances.
- */
- public MeshPrimitive.Triangles toMesh(Polygon polygon) {
- final List<Tuple[]> list = triangulate(polygon);
-
- final TupleArray positions = TupleArrays.of(polygon.getCoordinateReferenceSystem(), new double[list.size()*3*2]);
- for (int i = 0, k = 0, n = list.size(); i < n; i++, k+=3) {
- final Tuple[] t = list.get(i);
- positions.set(k+0, t[0]);
- positions.set(k+1, t[1]);
- positions.set(k+2, t[2]);
- }
-
- final MeshPrimitive.Triangles triangles = new MeshPrimitive.Triangles();
- triangles.setPositions(positions);
-
- return triangles;
- }
-
- private void run(SimplePolygon part){
-
- //build a single geometry linking inner holes.
- final List<Tuple> borderCoords = new ArrayList<>();
- part.outter.getPoints().getAttributeArray(AttributesType.ATT_POSITION).stream(false).forEach(borderCoords::add);
- //sort inner holes by minimum x value
- orderHoles(part);
-
- //attach holes to the main geometry
- for(int i=0,n=part.inners.size();i<n;i++){
- //we must find the minimum x coordinate in the inner loop
- final List<Tuple> loop = part.inners.get(i).getPoints().getAttributeArray(AttributesType.ATT_POSITION).stream(false).toList();
- int index = 0;
- Tuple min = loop.get(index);
- for(int k=1,p=loop.size();k<p;k++){
- Tuple candidate = (Tuple) loop.get(1);
- if (candidate.get(0) < min.get(0)) {
- min = candidate;
- index = k;
- }
- }
-
- //now find the closest point on the outter loop
- final List line2 = new ArrayList();
- line2.add(min);line2.add(min);
- final double[] buffer1 = new double[2];
- final double[] buffer2 = new double[2];
- final double[] ratio = new double[2];
- final int[] offset = new int[2];
- nearest(borderCoords, buffer1, line2, buffer2, ratio, offset, 0.000000001);
-
- //make a cut from outter loop to inner loop
- int insertIndex = offset[0]+1;
- borderCoords.add(insertIndex, new Vector2D.Double(buffer1[0],buffer1[1]));
- insertIndex++;
- //remove the duplicateion inner loop end point
- loop.remove(loop.size()-1);
- for(int k=index,p=loop.size();k<p;k++,insertIndex++){
- borderCoords.add(insertIndex,loop.get(k));
- }
- for(int k=0;k<=index;k++,insertIndex++){
- borderCoords.add(insertIndex,loop.get(k));
- }
- borderCoords.add(insertIndex, new Vector2D.Double(buffer1[0],buffer1[1]));
-
- }
-
- //remove any neighor points overlaping
- Tuple t = borderCoords.get(0);
- for(int i=1,n=borderCoords.size();i<n;i++){
- Tuple candidate = borderCoords.get(i);
- if(candidate.equals(t)){
- borderCoords.remove(i);
- i--;
- n--;
- }else{
- t = candidate;
- }
- }
-
-
-
- final boolean clockwise = Maths.isClockWise(borderCoords);
-
- nbCoords = borderCoords.size();
- coordType = new int[nbCoords];
- coords = borderCoords.toArray(Tuple[]::new);
-
- //flip coordinates if not clockwise
- if(!clockwise){
- ArraysExt.reverse(coords);
- }
-
- //now cut ears progressively
- int nbcut = 0;
- while(nbCoords > 3){
- nbcut = 0;
- for(index=0;index<nbCoords-2 && nbCoords>3;){
- indexPrevious = (index==0) ? nbCoords-2 : index-1 ;
- indexNext = index+1;
-
- t1 = coords[indexPrevious];
- t2 = coords[index];
- t3 = coords[indexNext];
-
- if(isConvex() && isEar()){
- //reset angle type, we remove a point so it might change
- coordType[indexPrevious]=0;
- coordType[indexNext]=0;
-
- triangles.add(new Tuple[]{t1,t2,t3});
- removeWithin(coords, index);
- removeWithin(coordType, index);
- nbCoords--;
- nbcut++;
- //we do not increment since we have remove the point
- }else{
- index++;
- }
- }
-
- if(nbcut == 0){
- //this should not happen if the geometry is correct
- //System.out.println("Triangulation failed. no ear to cut.");
- return;
- }
- }
- }
-
- /**
- * Sort inner holes by minimum x value.
- */
- private void orderHoles(SimplePolygon part){
- Collections.sort(part.inners, X_SORTER);
- }
-
-
- /**
- * @return true if currentsegment is convex
- */
- private boolean isConvex(){
- if(coordType[index]==0){
- //calculate angle type
- final double side = Maths.lineSide(t1, t3, t2);
- coordType[index] = side>0 ? 1 : 2;
- }
- return coordType[index] == 1;
- }
-
- /**
- * @return true if segment is convex
- */
- private boolean isConvex(int idx){
- if(coordType[idx]==0){
- //calculate angle type
- final Tuple s1 = coords[(idx==0) ? (nbCoords-2) : (idx-1)];
- final Tuple s2 = coords[idx];
- final Tuple s3 = coords[idx+1];
- final double side = Maths.lineSide(s1, s3, s2);
- coordType[idx] = side>0 ? 1 : 2;
- }
- return coordType[idx] == 1;
- }
-
- /**
- * Check this segment triangle is an ear.
- * Does not contain any other point.
- * @return
- * @throws OperationException
- */
- private boolean isEar() throws IllegalArgumentException {
- final double[] a = new double[]{t1.get(0), t1.get(1)};
- final double[] b = new double[]{t2.get(0), t2.get(1)};
- final double[] c = new double[]{t3.get(0), t3.get(1)};
-
- for(int i=0; i<nbCoords-1; i++){
- //test only concave points
- if (!isConvex(i)){
- //check it's not one of the current segment
- if(i!=index && i!=indexNext && i!=indexPrevious){
- //check if it's in the segment triangle
- if(Maths.inTriangle(a, b, c, new double[]{coords[i].get(0),coords[i].get(1)})){
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
-
- /**
- * Remove element at index.
- * Move elements after index by -1.
- * Last element is set to null
- *
- * @param values original array
- * @param index removed element index
- * @return removed object
- */
- public static Object removeWithin(Object[] values, int index) {
- final Object removedValue = values[index];
- if(index+1 < values.length){
- copy(values, index+1, values.length-index-1, values, index);
- }
- values[values.length-1] = null; //remove reference
- return removedValue;
- }
-
- /**
- * Remove element at index.
- * Move elements after index by -1.
- * Last element is set to zero
- *
- * @param values original array
- * @param index removed element index
- * @return removed value
- */
- public static int removeWithin(int[] values, int index) {
- final int removedValue = values[index];
- if(index+1 < values.length){
- copy(values, index+1, values.length-index-1, values, index);
- }
- values[values.length-1] = 0;
- return removedValue;
- }
-
- /**
- * Copy a portion of given source array of length elements from soffset index, to
- * the target array beginning to toffset index.
- * If needed, the returned array is padded with zeros to obtain the required
- * length.
- *
- * @param source not null
- * @param soffset offset to start copying
- * @param length number of elemnts to copy
- * @param target array where to insert new elements
- * @param toffset start insert index
- * @return the target array with copied values.
- */
- public static Object[] copy(Object[] source, int soffset, int length, Object[] target, int toffset){
- for(int i=soffset;i<soffset+length;i++,toffset++){
- target[toffset] = source[i];
- }
- return target;
- }
-
- /**
- * Copy a portion of given source array of length elements from soffset index, to
- * the target array beginning to toffset index.
- * If needed, the returned array is padded with zeros to obtain the required
- * length.
- *
- * @param source not null
- * @param soffset offset to start copying
- * @param length number of elemnts to copy
- * @param target array where to insert new elements
- * @param toffset start insert index
- * @return the target array with copied values.
- */
- public static int[] copy(int[] source, int soffset, int length, int[] target, int toffset){
- for(int i=soffset;i<soffset+length;i++,toffset++){
- target[toffset] = source[i];
- }
- return target;
- }
-
- /**
- * Copy a portion of given source array of length elements from soffset index, to
- * the target array beginning to toffset index.
- * If needed, the returned array is padded with zeros to obtain the required
- * length.
- *
- * @param source not null
- * @param soffset offset to start copying
- * @param length number of elemnts to copy
- * @param target array where to insert new elements
- * @param toffset start insert index
- * @return the target array with copied values.
- */
- public static double[] copy(double[] source, int soffset, int length, double[] target, int toffset){
- for(int i=soffset;i<soffset+length;i++,toffset++){
- target[toffset] = source[i];
- }
- return target;
- }
-
- /**
- * Find nearest points between two lines.
- * <br>
- * See Distance.
- *
- * @param line1Coords line 1 coordinates
- * @param buffer1 buffer to store nearest point on line 1
- * @param line2Coords line 2 coordinates
- * @param buffer2 buffer to store nearest point on line 2
- * @param ratio neareast points ratio between line start and end
- * @param offset : will store the segment offset of the nearest points
- * @param epsilon tolerance factor
- */
- public static void nearest(List<Tuple> line1Coords, double[] buffer1,
- List<Tuple> line2Coords, double[] buffer2,
- double[] ratio, int[] offset, double epsilon){
-
- double distance = Double.MAX_VALUE;
-
- final double[] tempRatio = new double[2];
- final double[] tempC1 = new double[buffer1.length];
- final double[] tempC2 = new double[buffer1.length];
-
- final int nb1 = line1Coords.size()-1;
- final int nb2 = line2Coords.size()-1;
-
- for(int i=0;i<nb1;i++){
- final Tuple s1 = line1Coords.get(i);
- final Tuple e1 = line1Coords.get(i+1);
- for(int k=0;k<nb2;k++){
- final Tuple s2 = line2Coords.get(k);
- final Tuple e2 = line2Coords.get(k+1);
-
- final double dist = Math.sqrt(distanceSquare(
- new double[]{s1.get(0),s1.get(1)}, new double[]{e1.get(0),e1.get(1)}, tempC1,
- new double[]{s2.get(0),s2.get(1)}, new double[]{e2.get(0),e2.get(1)}, tempC2,
- tempRatio,epsilon));
- if(dist<distance){
- //keep informations
- distance = dist;
- offset[0] = i;
- offset[1] = k;
- copy(tempC1, 0, tempC1.length, buffer1, 0);
- copy(tempC2, 0, tempC2.length, buffer2, 0);
- }
- }
- }
-
- }
-
- /**
- * Calculate square distance between two line segments.
- *
- * Adapted from book : Real-TimeCollision Detection by Christer Ericson
- * (ClosestPtSegmentSegment p.149)
- *
- * @param line1Start line 1 start point
- * @param line1End line 1 start point
- * @param buffer1 closest point on line 1
- * @param line2Start line 1 start point
- * @param line2End line 1 start point
- * @param buffer2 closest point on line 2
- * @param ratio size 2 , for each line,
- * ratio [0..1] of the closest point position between start and end points.
- * @param epsilon tolerance
- * @return distance
- */
- public static double distanceSquare(double[] line1Start, double[] line1End, double[] buffer1,
- double[] line2Start, double[] line2End, double[] buffer2,
- double[] ratio, double epsilon) {
- final double[] d1 = subtract(line1End,line1Start); // Direction vector of segment S1
- final double[] d2 = subtract(line2End,line2Start); // Direction vector of segment S2
- final double[] r = subtract(line1Start, line2Start);
- final double a = dot(d1, d1); // Squared length of segment S1, always nonnegative
- final double e = dot(d2, d2); // Squared length of segment S2, always nonnegative
- final double f = dot(d2, r);
- // Check if either or both segments degenerate into points
- if (a <= epsilon && e <= epsilon) {
- // Both segments degenerate into points
- ratio[0] = 0;
- ratio[1] = 0;
- copy(line1Start,0,line1Start.length,buffer1,0);
- copy(line2Start,0,line2Start.length,buffer2,0);
- final double[] t = subtract(buffer1,buffer2);
- return dot(t,t);
- }
- if (a <= epsilon) {
- // First segment degenerates into a point
- ratio[0] = 0;
- ratio[1] = clip( f/e, 0, 1);
- } else {
- final double c = dot(d1, r);
- if (e <= epsilon) {
- // Second segment degenerates into a point
- ratio[0] = clip( -c/a, 0, 1);
- ratio[1] = 0;
- } else {
- // The general nondegenerate case starts here
- final double b = dot(d1, d2);
- final double denom = a*e-b*b; // Always nonnegative
- // If segments not parallel, compute closest point on L1 to L2 and
- // clamp to segment S1. Else pick arbitrary s (here 0)
- if (denom != 0d) {
- ratio[0] = clip((b*f - c*e) / denom, 0.0f, 1.0f);
- } else {
- ratio[0] = 0;
- }
- // Compute point on L2 closest to S1(s) using
- // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
- ratio[1] = (b*ratio[0] + f) / e;
-
- //If t in [0,1] done. Else clamp t, recompute s for the new value
- //of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
- //and clamp s to [0, 1]
- if(ratio[1] < 0){
- ratio[1] = 0;
- ratio[0] = clip(-c / a, 0.0f, 1.0f);
- }else if(ratio[1] > 1){
- ratio[1] = 1;
- ratio[0] = clip((b - c) / a, 0.0f, 1.0f);
- }
-
- }
- }
-
- add(line1Start, scale(d1, ratio[0]), buffer1);
- add(line2Start, scale(d2, ratio[1]), buffer2);
- final double[] t = subtract(buffer1,buffer2);
- return dot(t,t);
- }
-
- /**
- * Clip returns:
- * <ul>
- * <li>min if the value is lower than min</li>
- * <li>value if the value is between min and max</li>
- * <li>max if the value is higher than max</li>
- * </ul>
- * @param val the value
- * @param min minimum value
- * @param max maximum value
- * @return clipped value
- */
- public static double clip(double val, double min, double max){
- if(val<min) return min;
- if(val>max) return max;
- return val;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/Delaunay.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/Delaunay.java
deleted file mode 100644
index 905c436..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/Delaunay.java
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
- * 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.geometries.triangulate.delaunay;
-
-import java.util.ArrayDeque;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.opengis.geometry.Envelope;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
-import org.apache.sis.geometries.index.KdTree;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector;
-import org.apache.sis.geometries.math.Vectors;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.util.ArgumentChecks;
-
-
-/**
- * Delaunay triangulation algorithm.
- *
- * https://en.wikipedia.org/wiki/Delaunay_triangulation
- * https://en.wikipedia.org/wiki/Constrained_Delaunay_triangulation
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Delaunay {
-
- private static final Logger LOGGER = Logger.getLogger("org.apache.sis.geometries");
-
- private MeshPrimitive.Points points;
-
- private MeshPrimitive pointsPlusRoot;
- private int rootOffset;
-
- /**
- * Contains edges which must be tested with delaunay circle.
- */
- private final ArrayDeque<OrientedEdge> triangulationStackEdges = new ArrayDeque<>();
-
- private final AtomicInteger crossingConstraints = new AtomicInteger();
- /*
- In some incorrect dataset we may have two constraints crossing each other.
- This would result in an infinite loop, to avoid it we do not allow a constraint
- edge to be processed more then once.
- */
- private final ArrayDeque<OrientedEdge> constraintStackEdges = new ArrayDeque<>() {
- private final HashSet<Long> unique = new HashSet<>();
- @Override
- public OrientedEdge poll() {
- OrientedEdge e = super.poll();
- //do not remove the edge from the set until the end of the constraint operation
- return e;
- }
-
- @Override
- public void addFirst(OrientedEdge e) {
- //create a key not affected by edge orientation
- int idx0 = e.getStart().getIndex();
- int idx1 = e.getEnd().getIndex();
- if (idx0 > idx1) {
- int i = idx0;
- idx0 = idx1;
- idx1 = i;
- }
- final long key = idx0 + ((long) idx1) << 32l;
- if (unique.add(key)) {
- super.addFirst(e);
- } else {
- crossingConstraints.incrementAndGet();
- }
- }
-
- @Override
- public void clear() {
- super.clear();
- unique.clear();
- }
- };
-
- /*
- Index the vertex to find closest point faster.
- */
- private final KdTree<Integer> tree = new KdTree();
- private OrientedEdge[] indexToEdge;
-
- private final Set<OrientedTriangle> triangles = new HashSet<>() {
- @Override
- public boolean add(OrientedTriangle triangle) {
- if (Maths.lineSide(triangle.a.getPosition(), triangle.b.getPosition(), triangle.c.getPosition()) == 0) {
- //flat triangle
- LOGGER.log(Level.FINE, "Delaunay triangulation generated a flat triangle, this may be normal on edges but may still cause issues later on.");
- }
- final boolean v = super.add(triangle);
- if (v) {
- indexToEdge[triangle.a.getIndex()] = triangle.ab;
- indexToEdge[triangle.b.getIndex()] = triangle.bc;
- indexToEdge[triangle.c.getIndex()] = triangle.ca;
- }
- return v;
- }
- };
-
- /**
- * Prepare a delaunay triangulation.
- */
- public Delaunay() {
- }
-
- /**
- * Create delaunay triangulation.
- * This method should be called only once.
- * @param points not null
- * @throws IllegalArgumentException if an index is incorrect
- * @throws OperationException if an algorithm exception occurs
- */
- public void build(MeshPrimitive.Points points) throws IllegalArgumentException, OperationException {
- ArgumentChecks.ensureNonNull("points", points);
- this.points = points;
- delaunayTriangulation();
- }
-
- /**
- * Insert a new constraint.
- *
- * @param startIndex start edge vertex index
- * @param endIndex end edge vertex index
- * @param hard true to create edge which should never be cut or changed again.
- * false for soft constraint which may be removed later.
- * @throws IllegalArgumentException if an index is incorrect
- * @throws OperationException if an algorithm exception occurs
- */
- public void pushConstraint(int startIndex, int endIndex, boolean hard) throws IllegalArgumentException, OperationException {
- insertEdge(startIndex, endIndex, hard);
- }
-
- /**
- * Insert new constraints.
- *
- * @param constraints lines index, not null.
- * @param hard true to create edge which should never be cut or changed again.
- * false for soft constraint which may be removed later.
- * @throws IllegalArgumentException if an index is incorrect
- * @throws OperationException if an algorithm exception occurs
- */
- public void pushConstraint(TupleArray constraints, boolean hard) throws IllegalArgumentException, OperationException {
- ArgumentChecks.ensureNonNull("constraints", constraints);
-
- final int[] index = constraints.toArrayInt();
- for (int i = 0; i < index.length; i += 2) {
- try {
- insertEdge(index[i], index[i+1], hard);
- } catch (StackOverflowError ex) {
- //TODO : fix it, hard to solve, catch it for now
- LOGGER.log(Level.FINE, "stack overflow {0} {1}", new Object[]{index[i], index[i+1]});
- } catch (IllegalStateException ex) {
- //TODO : fix it, hard to solve, catch it for now
- LOGGER.log(Level.FINE, "flat triangle {0} {1}", new Object[]{index[i], index[i+1]});
- }
-
- //solve any constraint edge we had to break
- for (OrientedEdge edge = constraintStackEdges.poll(); edge != null; edge = constraintStackEdges.poll()) {
- insertEdge(edge.getStart().getIndex(), edge.getEnd().getIndex(), true);
- }
- }
- }
-
- /**
- * @return index of the triangles.
- * @throws IllegalStateException if used before build method is called
- */
- public TupleArray getTrianglesIndex() throws IllegalStateException {
- if (triangles.isEmpty()) throw new IllegalStateException("Triangles list is empty, build method must be called first");
-
- int[] index = new int[(triangles.size()-3) * 3];
- int i = 0;
- for (OrientedTriangle t : triangles) {
- final int i0 = t.a.getIndex();
- final int i1 = t.b.getIndex();
- final int i2 = t.c.getIndex();
- if (!(isRootVertex(i0) || isRootVertex(i1) || isRootVertex(i2))) {
- index[i++] = i0;
- index[i++] = i1;
- index[i++] = i2;
- }
- }
-
- index = Arrays.copyOf(index, i);
- return TupleArrays.ofUnsigned(1, index);
- }
-
- /**
- * @return triangles as a primitive.
- * @throws IllegalStateException if used before build method is called
- */
- public MeshPrimitive.Triangles getTriangles() throws IllegalStateException {
- final MeshPrimitive.Triangles primitive = new MeshPrimitive.Triangles();
- primitive.setPositions(points.getPositions());
- primitive.setIndex(getTrianglesIndex());
- return primitive;
- }
-
- /**
- * Create the delaunay triangulation without constraints.
- * @throws IllegalArgumentException if an index is incorrect
- * @throws OperationException if an algorithm exception occurs
- */
- private void delaunayTriangulation() throws OperationException, IllegalArgumentException {
- triangles.clear();
-
- // INITIALIZE //////////////////////////////////////////////////////////
- /*
- Build the root triangle, contains all points
- Any triangle using one of the root triangle points will not be returned.
-
- C
- ■
- | ⟍
- | ⟍
- | ■----■
- | | | ⟍
- | ■----■ ⟍
- ■-------------■
- A B
-
- Add an extra margin to the bounding box to reduce mathematical errors.
- */
- final TupleArray positions = this.points.getPositions();
- final Envelope envelope = buffer(points.getEnvelope(), 10.0);
- final double envelopeMinX = envelope.getMinimum(0);
- final double envelopeMinY = envelope.getMinimum(1);
- final Vector<?> A = Vectors.create(positions.getSampleSystem(), positions.getDataType());
- A.set(0, envelopeMinX);
- A.set(1, envelopeMinY);
- final Vector<?> B = A.copy();
- B.set(0, envelopeMinX + envelope.getSpan(0) * 2);
- B.set(1, envelopeMinY);
- final Vector<?> C = A.copy();
- C.set(0, envelopeMinX);
- C.set(1, envelopeMinY + envelope.getSpan(1) * 2);
- rootOffset = positions.getLength();
- final TupleArray extraPositions = positions.resize(3);
- extraPositions.set(0, A);
- extraPositions.set(1, B);
- extraPositions.set(2, C);
- final TupleArray positionsPlusRoot = TupleArrays.concatenate(positions, extraPositions);
-
- pointsPlusRoot = new MeshPrimitive.Points();
- pointsPlusRoot.setPositions(positionsPlusRoot);
-
- //prepare index
- indexToEdge = new OrientedEdge[positionsPlusRoot.getLength()];
-
- //base triangle
- final Vertex v0 = new Vertex(pointsPlusRoot, rootOffset);
- final Vertex v1 = new Vertex(pointsPlusRoot, rootOffset+1);
- final Vertex v2 = new Vertex(pointsPlusRoot, rootOffset+2);
- final OrientedTriangle triangle = new OrientedTriangle(v0, v1, v2);
- triangles.add(triangle);
-
- tree.insert(v0.getPosition(),v0.getIndex());
- tree.insert(v1.getPosition(),v1.getIndex());
- tree.insert(v2.getPosition(),v2.getIndex());
-
-
- // TRIANGULATE /////////////////////////////////////////////////////////
- final TupleArray index = points.getIndex();
- if (index == null) {
- //use all points
- for (int idx = 0, n = positions.getLength(); idx < n; idx++) {
- insertPoint(idx);
- }
- } else {
- //user defined points
- for (int idx : index.toArrayInt()) {
- insertPoint(idx);
- }
- }
- }
-
- /**
- * Insert one point in the TIN.
- * @param index vertex index.
- * @throws IllegalArgumentException if index is incorrect
- * @throws OperationException if an algorithm exception occurs
- */
- private void insertPoint(int index) throws OperationException, IllegalArgumentException {
- if (index < 0 || index >= rootOffset) throw new IllegalArgumentException("Index do not exist : " + index);
- final Vertex vertex = new Vertex(pointsPlusRoot, index);
- final Tuple position = vertex.getPosition();
-
- //find nearest vertex and tst all triangles using this vertex
- final int nearestVertex = tree.nearest(position).getValue();
- solve(nearestVertex, vertex);
-
- tree.insertNoCopy(vertex.getPosition(),vertex.getIndex());
- //solve delaunay edges
- for (OrientedEdge edge = triangulationStackEdges.poll(); edge != null; edge = triangulationStackEdges.poll()) {
- //delaunay simplification test
- if (!edge.isObsolete()) {
- testDelaunay(edge);
- }
- }
- }
-
- private void solve(int nearestVertex, Vertex vertex) {
- OrientedEdge edge = indexToEdge[nearestVertex];
-
- for (;;) {
- OrientedTriangle triangle = edge.getTriangle();
- if (solve(triangle, vertex)) return;
-
- //search edge where point is on it's right side
- if (edge.getSide(vertex) < 0) {
- edge = edge.reverse();
- continue;
- }
- //NOTE : we must try the adjacent edge first, otherwise we may end in an infinite loop
- //try adjacent edge
- final OrientedEdge adjacent = triangle.adjacentEdge(edge);
- if (adjacent.getSide(vertex) < 0) {
- edge = adjacent.reverse();
- continue;
- }
- //must be the opposite edge
- OrientedEdge opposite = triangle.getEdge(edge.getEnd());
- if (opposite.getSide(vertex) < 0) {
- edge = opposite.reverse();
- continue;
- }
-
- throw new OperationException("Algorithm flow, no triangle found for a vertex");
- }
- }
-
- /**
- *
- * @throws OperationException if an algorithm exception occurs
- */
- private boolean solve(OrientedTriangle t, Vertex v) throws OperationException {
- if (t.ab.isOnEdge(v)) {
- splitOnEdge(t.ab, v);
- return true;
- } else if (t.bc.isOnEdge(v)) {
- splitOnEdge(t.bc, v);
- return true;
- } else if (t.ca.isOnEdge(v)) {
- splitOnEdge(t.ca, v);
- return true;
- } else if (Maths.isPointInTriangle_SideAlgo(t.a.getPosition(), t.b.getPosition(), t.c.getPosition(), v.getPosition())) {
- splitCenter(t, v);
- return true;
- }
- return false;
- }
-
- /**
- * Enforce a constraint segment
- * @param startIndex segment start vertex index.
- * @param endIndex segment end vertex index.
- * @param isContraint true is created or existing edge should be marked as constraint.
- * @return The created or existing constraint edge.
- * The edge end if guarantee to be the vertex with given end index.
- * The edge start may be the starting vertex or the closest point
- * to the end vertex which is on the edge line.
- * @throws OperationException if an algorithm exception occurs
- * @throws IllegalArgumentException if edge indexes are incorrect
- */
- private OrientedEdge insertEdge(int startIndex, int endIndex, boolean isContraint) throws OperationException, IllegalArgumentException {
- if (startIndex < 0 || startIndex >= rootOffset) throw new IllegalArgumentException("Constraint segment index do not exist : " + startIndex);
- if (endIndex < 0 || endIndex >= rootOffset) throw new IllegalArgumentException("Constraint segment index do not exist : " + endIndex);
-// System.out.println("e " + startIndex +" " + endIndex);
-
- final Vertex E = new Vertex(pointsPlusRoot, endIndex);
-
- //find the starting triangle
- /*
- A
- ■
- / \
- / \
- / \
- B ■⎻⎻⎻⎻⎻⎻⎻■ C
- \ /
- \ /
- \ /
- ■
- D
-
- */
- final OrientedEdge A_B = searchTriangle(startIndex, endIndex);
- final OrientedEdge X_E = insertEdge(A_B, E, isContraint);
- return X_E;
- }
-
- /**
- * Enforce a constraint segment
- *
- * @param startIndex segment start vertex index.
- * @param Z segment end vertex index.
- * @return The created or existing constraint edge.
- * The edge end if guarantee to be the vertex with given end index.
- * The edge start may be the starting vertex or the closest point
- * to the end vertex which is on the edge line.
- * @throws OperationException if an algorithm exception occurs
- */
- private OrientedEdge insertEdge(OrientedEdge A_B, Vertex Z, boolean isContraint) throws OperationException {
-// System.out.println("ee " + A_B.getTriangle().asTextPolygon() +" LINESTRING(" + A_B.getStart().getPosition().get(0) +" "+ A_B.getStart().getPosition().get(1) + ", " + Z.getPosition().get(0) +" "+ Z.getPosition().get(1) + ")");
-
- //find the starting triangle
- /*
- A
- ■
- _/ \_
- 🡷 _/ \_ 🡴
- / 🡲 \
- B ■⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻■ C
- \_ 🡰 _/
- 🡶 \_ _/ 🡵
- \ /
- ■
- D
- */
-
- { //special case : if this is a perfect match
- if (A_B.getEnd().getIndex() == Z.getIndex()) {
- //mark it as a constraint
- if (isContraint) A_B.setConstraint(true);
- return A_B;
- }
- }
-
- { //special case : if edge is colinear to constraint segment
- final Tuple endPosition = Z.getPosition();
- final double leftSide = Maths.lineSide(A_B.getStart().getPosition(), A_B.getEnd().getPosition(), endPosition);
- if (leftSide == 0) {
- //on the edge, mark the edge as a constraint and start a new constraint from edge end
- if (isContraint) A_B.setConstraint(true);
- return insertEdge(A_B.getEnd().getIndex(), Z.getIndex(), isContraint);
- } else if (leftSide < 0) {
- throw new OperationException("constraint end must be on the left side at this point, algorithm flaw");
- }
- }
-
- //intersects the triangle
- //use the flipscan algorithm to process this case
- //see https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- final Vertex A = A_B.getStart();
- final Vertex B = A_B.getEnd();
- final Vertex C = A_B.getTriangle().oppositePoint(A_B);
- final OrientedEdge B_C = A_B.getTriangle().getEdge(B);
- final OrientedEdge C_B = B_C.reverse();
- final OrientedTriangle triangle = C_B.getTriangle();
- final Vertex D = triangle.oppositePoint(C_B);
-
- if (D.getIndex() == Z.getIndex()) {
- /*
- Case if neigbhor triangle is the last one.
- Last flip operation
- A
- ■
- _/|\_
- 🡷 _/ | \_ 🡴
- / | \
- B ■ 🡱|🡳 ■ C
- \_ | _/
- 🡶 \_ | _/ 🡵
- \|/
- ■
- D = Z
- */
- final OrientedEdge A_D = swapTriangles(B_C, false, true);
- if (isContraint) A_D.setConstraint(true);
- return A_D;
- }
-
- //check if opposite triangle point is in the valid angle
- if (inScanArea(A, B, C, D)) {
- //flip triangles and continue to next one
- final OrientedEdge A_D = swapTriangles(B_C, false, true);
- if (Maths.lineSide(A.getPosition(), D.getPosition(), Z.getPosition()) >= 0) {
- /* continue with ADC triangle
- A A
- ■ ■
- _/|\_ _/|\_
- _/ | \\_ _/ | \_
- / | \ \ / | \
- B ■ | \ ■ C OR B ■ | ■ C
- \_ | _\ \_ | _/
- \_ | _/ \ \_ | _/
- \|/ \ \|/
- ■ \ ■ D
- D ■ |
- Z ■ Z
- */
- return insertEdge(A_D, Z, isContraint);
- } else {
- /* continue with ABD triangle
- A
- ■
- _/|\_
- _// | \_
- / / | \
- B ■ / | ■ C
- /_ | _/
- / \_ | _/
- / \|/
- / ■
- ■ D
- E
- */
- return insertEdge(A_B, Z, isContraint);
- }
- } else {
- /*
- Scan for next point in area
-
- A
- ■
- _/ \_
- _/ \_
- / \
- B ■⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻■ C
- __/ _______/
- /______/
- D ■
-
- Look for the new opposing point inside the scan area, then take this point
- and form a new temporary edge to flip along.
- */
- final Vertex E = scanNextValid(A_B, Z);
- final OrientedEdge X_A = insertEdge(E.getIndex(), A.getIndex(), false);
- if (X_A.getStart().getIndex() == Z.getIndex()) {
- //exact match
- return X_A.reverse();
- }
- final double side = Maths.lineSide(X_A.getStart().getPosition(), A.getPosition(), Z.getPosition());
- if (side > 0) {
- return insertEdge(X_A.getTriangle().getEdge(A), Z, isContraint);
- } else {
- return insertEdge(X_A.reverse(), Z, isContraint);
- }
- }
-
- }
-
- /**
- * @throws OperationException if an algorithm exception occurs
- */
- private Vertex scanNextValid(OrientedEdge A_B, Vertex Z) throws OperationException {
- final OrientedTriangle ABC = A_B.getTriangle();
- final Vertex A = A_B.getStart();
- final Vertex B = A_B.getEnd();
- final Vertex C = ABC.oppositePoint(A_B);
- final OrientedEdge B_C = ABC.getEdge(B);
-
- OrientedEdge V_T = B_C.reverse();
- for (;;) {
- final OrientedTriangle triangle = V_T.getTriangle();
- final Vertex T = V_T.getEnd();
- final Vertex U = triangle.oppositePoint(V_T);
-
- if (U.getIndex() == Z.getIndex() || inScanArea(A, B, C, U)) {
- return U;
- } else {
- //find the edge with intersect A_Z
- if (Maths.lineSide(A.getPosition(), Z.getPosition(), U.getPosition()) >= 0) {
- /*
- A
- ■
- / 🡰
- T ■⎻⎻⎻/⎻⎻⎻⎻⎻⎻⎻■ V
- \_/ _/
- 🡶/\_ _/ 🡵
- / \ /
- / ■
- ■ U
- Z
- */
- V_T = triangle.getEdge(T).reverse();
- } else {
- /*
- A
- ■
- 🡰 \
- T ■⎻⎻⎻⎻⎻⎻⎻⎻⎻\⎻■ V
- \_ _\
- 🡶 \_ _/ 🡵\
- \ / \
- ■ \
- U ■
- Z
- */
- V_T = triangle.getEdge(U).reverse();
- }
- }
- }
-
- }
-
- /**
- * @param index vertex index
- * @return true if vertex index is a root vertex
- */
- private boolean isRootVertex(int index) {
- return index >= rootOffset;
- }
-
- private static Envelope buffer(Envelope env, double margin) {
- final GeneralEnvelope buffer = new GeneralEnvelope(env);
- final int dimension = buffer.getDimension();
- for (int i = 0; i < dimension; i++) {
- buffer.setRange(i, buffer.getMinimum(i) - margin, buffer.getMaximum(i) + margin);
- }
- return buffer;
- }
-
- /**
- * Divide triangle in three using given vertex as center.
- *
- * <pre>{@code
- * A
- * ■__
- * |\ \__
- * | \ \__🡴
- * | 🡴\🡶 \__
- * | \ 🡲 \
- * 🡳 | X ■ ⎻⎻⎻⎻⎻⎻■ C
- * | / 🡰__/
- * | 🡵/🡷 __/
- * | / __/ 🡵
- * |/_/
- * ■
- * B
- * }</pre>
- *
- * @param ABC triangle, not null
- * @param X splitting center, not null
- * @throws OperationException if an algorithm exception occurs
- */
- private void splitCenter(OrientedTriangle ABC, Vertex X) throws OperationException {
-
- final Vertex A = ABC.a;
- final Vertex B = ABC.b;
- final Vertex C = ABC.c;
- final OrientedEdge A_B = ABC.getEdge(A);
- final OrientedEdge B_C = ABC.getEdge(B);
- final OrientedEdge C_A = ABC.getEdge(C);
- //create the three new triangles
- final OrientedEdge A_X = new OrientedEdge(A, X);
- final OrientedEdge C_X = new OrientedEdge(C, X);
- final OrientedEdge B_X = new OrientedEdge(B, X);
- final OrientedEdge X_A = A_X.reverse(true);
- final OrientedEdge X_B = B_X.reverse(true);
- final OrientedEdge X_C = C_X.reverse(true);
- final OrientedTriangle ABX = new OrientedTriangle(A_B, B_X, X_A);
- final OrientedTriangle BCX = new OrientedTriangle(B_C, C_X, X_B);
- final OrientedTriangle CAX = new OrientedTriangle(C_A, A_X, X_C);
- assert ABX.validate();
- assert BCX.validate();
- assert CAX.validate();
-
- triangles.remove(ABC);
- triangles.add(ABX);
- triangles.add(BCX);
- triangles.add(CAX);
-
- //ensure we have delaunay triangles
- triangulationStackEdges.addFirst(A_B);
- triangulationStackEdges.addFirst(B_C);
- triangulationStackEdges.addFirst(C_A);
- }
-
- /**
- *
- * Before
- * <pre>{@code
- * C
- * ■
- * / \
- * / \
- * 🡷 / \ 🡴
- * / 🡲 \
- * A ■⎻⎻⎻⎻⎻⎻⎻⎻⎻■ B
- * \ 🡰 /
- * 🡶 \ / 🡵
- * \ /
- * \ /
- * ■
- * D
- * }</pre>
- *
- * After
- * <pre>{@code
- * C
- * ■
- * /|\
- * / | \
- * 🡷 / 🡱|🡳 \ 🡴
- * / 🡲 | 🡲 \
- * A ■⎻⎻⎻⎻■X⎻⎻⎻■ B
- * \ 🡰 |🡰 /
- * 🡶 \ | / 🡵
- * \ | /
- * \|/
- * ■
- * D
- * }</pre>
- *
- * @param A_B edge to split not null
- * @param X splitting point on the edge not null
- * @throws OperationException if an algorithm exception occurs
- */
- private void splitOnEdge(OrientedEdge A_B, Vertex X) throws OperationException {
- final OrientedTriangle ABC = A_B.getTriangle();
- final Vertex A = A_B.getStart();
- final Vertex B = A_B.getEnd();
- final Vertex C = ABC.oppositePoint(A_B);
- final OrientedEdge B_C = ABC.getEdge(B);
- final OrientedEdge C_A = ABC.getEdge(C);
- /*
- */
-
- //split edge in two
- final OrientedEdge A_X = new OrientedEdge(A, X);
- final OrientedEdge X_B = new OrientedEdge(X, B);
- final OrientedEdge C_X = new OrientedEdge(C, X);
- final OrientedEdge X_C = C_X.reverse(true);
- //inherit constraint from parent edge
- A_X.setConstraint(A_B.isConstraint());
- X_B.setConstraint(A_B.isConstraint());
- //create the two new triangles
- final OrientedTriangle AXC = new OrientedTriangle(A_X, X_C, C_A);
- final OrientedTriangle XBC = new OrientedTriangle(X_B, B_C, C_X);
- assert AXC.validate();
- assert XBC.validate();
-
- ABC.obsolete();
- triangles.remove(ABC);
- triangles.add(AXC);
- triangles.add(XBC);
-
- triangulationStackEdges.addFirst(B_C);
- triangulationStackEdges.addFirst(C_A);
-
- final OrientedEdge B_A = A_B.reverse();
- if (B_A != null) {
- final OrientedTriangle BAD = B_A.getTriangle();
- final Vertex D = BAD.oppositePoint(B_A);
- final OrientedEdge A_D = BAD.getEdge(A);
- final OrientedEdge D_B = BAD.getEdge(D);
- /*
- 🡰 X 🡰
- A ■⎻⎻⎻⎻■⎻⎻⎻⎻■ B
- \ | /
- 🡶 \ 🡱|🡳 / 🡵
- \ | /
- \|/
- ■
- D
- */
- final OrientedEdge D_X = new OrientedEdge(D, X);
- final OrientedEdge X_D = D_X.reverse(true);
- final OrientedEdge X_A = A_X.reverse(true);
- final OrientedEdge B_X = X_B.reverse(true);
-
- final OrientedTriangle XAD = new OrientedTriangle(X_A, A_D, D_X);
- final OrientedTriangle BXD = new OrientedTriangle(B_X, X_D, D_B);
- assert XAD.validate();
- assert BXD.validate();
-
- BAD.obsolete();
- triangles.remove(BAD);
- triangles.add(XAD);
- triangles.add(BXD);
-
- triangulationStackEdges.addFirst(A_D);
- triangulationStackEdges.addFirst(D_B);
- }
- //ensure edge wont be used anymore
- A_B.makeObsolete();
- }
-
- /**
- * Ensure the 2 triangles on each side of the edge are delaunay triangles.
- * if it's not the case the edge will be swapped.
- *
- * @param B_D
- * @param pt
- * @throws OperationException if an algorithm exception occurs
- */
- private void testDelaunay(OrientedEdge B_D) throws OperationException {
- if (B_D.isConstraint()) {
- //edge is a constraint, it can not be removed
- return;
- }
- final OrientedEdge D_B = B_D.reverse();
- if (D_B == null) {
- //single triangle
- return;
- }
-
- final OrientedTriangle BDA = B_D.getTriangle();
- final OrientedTriangle DBC = D_B.getTriangle();
- final Vertex C = DBC.oppositePoint(D_B);
-
- final double BDAradius = BDA.getDelaunayCircleRadiusSquare();
- final double BDADistance = BDA.distanceToDelaunayCircleCenterSquare(C.getPosition().get(0), C.getPosition().get(1));
- if (BDADistance < BDAradius) {
- /*
- In the Delaunay algorithm we may encounter the case where two triangles
- can be flipped infinitely. This happens when the four points of two adjacent
- triangles are contained in the two circle formed by each triangle.
- Ensure this is not an infinite loop where triangles are both valid.
- */
- final Vertex A = BDA.oppositePoint(B_D);
- final Vertex D = B_D.getEnd();
- final OrientedTriangle BCA = new OrientedTriangle(B_D.getStart(), C, A);
- if (!BCA.isInDelaunayCircle(D.getPosition().get(0), D.getPosition().get(1))) {
- swapTriangles(B_D, true, false);
- }
- }
- }
-
- /**
- * Flip the edge connecting two triangles.<p>
- *
- * Before
- * <pre>{@code
- * D
- * ■
- * /|\
- * 🡷 / | \ 🡴
- * / | \
- * A ■ 🡱|🡳 ■ C
- * \ | /
- * 🡶 \ | / 🡵
- * \|/
- * ■
- * B
- * }</pre>
- *
- * After
- * <pre>{@code
- * D
- * ■
- * / \
- * 🡷 / \ 🡴
- * / 🡲 \
- * A ■⎻⎻⎻⎻⎻⎻⎻■ C
- * \ 🡰 /
- * 🡶 \ / 🡵
- * \ /
- * ■
- * B
- * }</pre>
- *
- * @param cascade true to add candidate edges to the working list.
- * @param constraintAddMode true to force flipping even if edge is a constraint.
- * if the edge was a constraint it is added in the list for futur reconstruction
- * @return the created edge, starting at the opposite point of given edge
- * @throws OperationException if edge can be swapped because it has a constraint set.
- */
- private OrientedEdge swapTriangles(OrientedEdge B_D, boolean cascade, boolean constraintAddMode) throws OperationException {
- if (B_D.isConstraint()) {
- if (constraintAddMode) {
- constraintStackEdges.addFirst(B_D);
- } else {
- throw new OperationException("Can not swap a constraint edge.");
- }
- }
-
- final OrientedEdge D_B = B_D.reverse();
- final OrientedTriangle BDA = B_D.getTriangle();
- final OrientedTriangle DBC = D_B.getTriangle();
- final Vertex A = BDA.oppositePoint(B_D);
- final Vertex B = B_D.getStart();
- final Vertex C = DBC.oppositePoint(D_B);
- final Vertex D = B_D.getEnd();
-
- /* swap edge
-
- D
- ■
- / \
- 🡷 / \ 🡴
- / 🡲 \
- A ■⎻⎻⎻⎻⎻⎻⎻■ C
- \ 🡰 /
- 🡶 \ / 🡵
- \ /
- ■
- B
- */
-
- //create new triangles
- final OrientedEdge D_A = BDA.getEdge(D);
- final OrientedEdge C_D = DBC.getEdge(C);
- final OrientedEdge B_C = DBC.getEdge(B);
- final OrientedEdge A_B = BDA.getEdge(A);
- final OrientedEdge A_C = new OrientedEdge(A, C);
- final OrientedEdge C_A = A_C.reverse(true);
- final OrientedTriangle ACD = new OrientedTriangle(A_C, C_D, D_A);
- final OrientedTriangle ABC = new OrientedTriangle(A_B, B_C, C_A);
-
- B_D.makeObsolete();
- BDA.obsolete();
- DBC.obsolete();
-
- //remove old and add new triangles in the stack
- triangles.remove(BDA);
- triangles.remove(DBC);
- triangles.add(ACD);
- triangles.add(ABC);
-
- assert ACD.validate();
- assert ABC.validate();
-
- if (cascade) {
- triangulationStackEdges.addFirst(D_A);
- triangulationStackEdges.addFirst(C_D);
- triangulationStackEdges.addFirst(B_C);
- triangulationStackEdges.addFirst(A_B);
- }
-
- return A_C;
- }
-
- /**
- * Find one triangle edge of the triangle intersecting the given segment.
- * @param index searched vertex index
- * @return triangle edge using this index, the edge may be colinear to the segment,
- * or the triangle may intersection the segment,
- * but the adjacent edge will not be colinear to the segment.
- * @throws OperationException if an algorithm exception occurs
- */
- private OrientedEdge searchTriangle(int startIndex, int endIndex) throws OperationException {
- final Vertex end = new Vertex(pointsPlusRoot, endIndex);
- final Tuple endPosition = end.getPosition();
-
- OrientedEdge edge = indexToEdge[startIndex];
-
- for (;;) {
- if (edge.getEnd().getIndex() == endIndex) {
- //edge already exist
- return edge;
- }
-
- //check if line intersect the triangle
- final double leftSide = Maths.lineSide(edge.getStart().getPosition(), edge.getEnd().getPosition(), endPosition);
- if (leftSide > 0) {
- //on the left side, check the adjacent edge
- final OrientedEdge adjacent = edge.getTriangle().adjacentEdge(edge);
- //end to start, we are on an oriented triangle, adjacent edge goes in the opposite direction
- final double rightSide = Maths.lineSide(adjacent.getEnd().getPosition(), adjacent.getStart().getPosition(), endPosition);
- if (rightSide > 0) {
- //on the left side of adjacent edge, pick the left triangle and continue
- edge = adjacent.reverse();
- } else if (rightSide < 0) {
- //in the triangle
- return edge;
- } else {
- //on the adjacent edge
- edge = adjacent.reverse();
- }
- } else if (leftSide < 0) {
- //on the right side, pick the right triangle and continue
- edge = edge.reverse();
- edge = edge.getTriangle().getEdge(edge.getEnd());
- } else {
- //point is perfectly aligned with the edge
- //but may not be on the edge
-
- //verify it with the adjacent edge
- /*
- C
- ■
- / \
- 🡷 / \ 🡴
- / \
- ■⎻⎻■⎻⎻⎻■⎻⎻⎻■
- X1 A X2 B
- */
- final OrientedEdge A_C = edge.getTriangle().adjacentEdge(edge).reverse();
- final double side = Maths.lineSide(A_C.getStart().getPosition(), A_C.getEnd().getPosition(), endPosition);
- if (side < 0) {
- //on the right side, this is X2 on the edge
- return edge;
- } else if (side > 0) {
- //on the left side, this is X1 not on the edge, continue the search
- edge = A_C;
- } else {
- //this is a flat triangle, rare, but may happen with border edges when processing constraints edges.
- if (A_C.getEnd().getIndex() == endIndex) {
- return A_C;
- }
- throw new IllegalStateException("Flat triangle case not supported");
- }
- }
- }
- }
-
- /**
- * Test if D point is in the angle format by vectors ab and ac.<p>
- * A,B,C must be placed ordered in counter clockwise direction.
- *
- * <pre>{@code
- * A
- * ■
- * / \
- * 🡷 / \ 🡴
- * / \
- * B ■⎻⎻⎻⎻⎻⎻⎻■ C
- * 🡲
- *
- * ■
- * D
- * }</pre>
- *
- * @return true if d is in the angle format by vectors ab and ac.
- */
- private static boolean inScanArea(Vertex a, Vertex b, Vertex c, Vertex d) {
- return Maths.lineSide(a.getPosition(), b.getPosition(), d.getPosition()) >= 0
- && Maths.lineSide(a.getPosition(), c.getPosition(), d.getPosition()) < 0;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedEdge.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedEdge.java
deleted file mode 100644
index 7fc6ef1..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedEdge.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * 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.geometries.triangulate.delaunay;
-
-import java.util.Iterator;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.math.Maths;
-import org.apache.sis.geometries.math.Tuple;
-
-
-/**
- * A oriented edge is a straight line between from a start point to an end point.
- * The opposite oriented edge shares the same start and end points.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class OrientedEdge extends AbstractGeometry implements LineString, PointSequence {
-
- /**
- * Structure is shared by the two opposite directional edges.
- */
- private final Structure structure;
-
- /**
- * Triangle on the left side of the edge.
- * Edges form a counter clockwise triangle.
- */
- private OrientedTriangle triangle;
-
- /**
- * Reverse directional edge.
- */
- private OrientedEdge reverse;
-
- private boolean reversed = false;
-
- /**
- * Set to true if this edge is a constraint.
- * If true this edge should not be removed in the TIN creation process.
- * Still this edge can be split, each resulting edge will inherit the constraint.
- */
- private boolean constraint = false;
-
- /**
- * @param start starting vertex
- * @param end ending vertex
- */
- public OrientedEdge(MeshPrimitive.Vertex start, MeshPrimitive.Vertex end) {
- this.structure = new Structure(start, end);
- }
-
- /**
- * Start and end vertices are part of given triangle, created edge is in
- * counter-clockwise direction in the triangle.
- * This constructor makes no verificiations.
- *
- * @param start starting vertex
- * @param end ending vertex
- * @param triangle parent triangle
- */
- public OrientedEdge(MeshPrimitive.Vertex start, MeshPrimitive.Vertex end, OrientedTriangle triangle) {
- this.structure = new Structure(start, end);
- this.triangle = triangle;
- }
-
- private OrientedEdge(OrientedEdge reverse) {
- this.structure = reverse.structure;
- this.reverse = reverse;
- this.reversed = true;
- }
-
- public OrientedTriangle getTriangle() {
- return triangle;
- }
-
- public Vertex getStart() {
- return getPoint(0);
- }
-
- public Vertex getEnd() {
- return getPoint(1);
- }
-
- public OrientedEdge reverse() {
- return reverse;
- }
-
- public OrientedEdge reverse(boolean create) {
- if (create) {
- if (reverse != null) {
- throw new RuntimeException("Opposite edge already exist");
- }
- this.reverse = new OrientedEdge(this);
- }
- return reverse;
- }
-
- void makeObsolete() {
- this.structure.obsolete = true;
- }
-
- boolean isObsolete() {
- return structure.obsolete;
- }
-
- /**
- * @return true if point is on the edge
- */
- public boolean isOnEdge(MeshPrimitive.Vertex pt) {
- assert (!structure.obsolete);
- return Maths.isOnLine(structure.start.getPosition(), structure.end.getPosition(), pt.getPosition());
- }
-
- /**
- * @return greater than 0 if point is on the left side
- * equal 0 if point is on the line
- * inferior than 0 if point is on the right side
- */
- public double getSide(MeshPrimitive.Vertex pt) {
- return Maths.lineSide(
- getStart().getPosition(),
- getEnd().getPosition(),
- pt.getPosition());
- }
-
- /**
- * Set to true if this edge is a constraint.
- * If true this edge should not be removed in the TIN creation process.
- * Still this edge can be split, each resulting edge will inherit the constraint.
- *
- * @param constraint true for a constraint edge
- */
- public void setConstraint(boolean constraint) {
- this.constraint = constraint;
- }
-
- /**
- * @return true if edge is a constraint
- */
- public boolean isConstraint() {
- return constraint;
- }
-
- void changeTriangle(OrientedTriangle after) {
- assert (!structure.obsolete);
- this.triangle = after;
- }
-
- /**
- * @return true if one of the two edge vertices is the same as given vertex.
- */
- public boolean hasPoint(MeshPrimitive.Vertex pt) {
- assert (!structure.obsolete);
- return structure.start.getIndex() == pt.getIndex() || structure.end.getIndex() == pt.getIndex();
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public PointSequence getPoints() {
- return this;
- }
-
- /**
- * Get an iterator which rotates around the edge starting point.
- * Returned edges starts by this edge followed by edges in counter-clockwise
- * direction until a loop is done. If not a loop, edges in clockwise direction
- * are iterated afterward.
- * All edges start on this edge starting vertex.
- */
- public Iterator<OrientedEdge> rotatingIterator() {
- return new RotatingIterator();
- }
-
- ////////////////////////////////////////////////////////////////////////////
- // PointSequence ///////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return structure.start.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public int getDimension() {
- return structure.start.getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
- }
-
- /**
- * Get the geometry bounding envelope.
- *
- * @return Envelope in geometry coordinate reference system.
- */
- @Override
- public Envelope getEnvelope() {
- return PointSequence.super.getEnvelope();
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
- @Override
- public int size() {
- return 2;
- }
-
- @Override
- public Vertex getPoint(int index) {
- switch (index) {
- case 0 : return reversed ? structure.end : structure.start;
- case 1 : return reversed ? structure.start : structure.end;
- default : throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- @Override
- public Tuple getPosition(int index) {
- switch (index) {
- case 0 : return (reversed ? structure.end : structure.start).getPosition().copy();
- case 1 : return (reversed ? structure.start : structure.end).getPosition().copy();
- default : throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- return getPosition(index);
- }
- return null;
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- setPosition(index, value);
- return;
- }
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public int hashCode() {
- int result = 31 + structure.start.getIndex();
- result = 31 * result + structure.end.getIndex();
- return result;
- }
-
- private static class Structure {
-
- private boolean obsolete = false;
- final MeshPrimitive.Vertex start;
- final MeshPrimitive.Vertex end;
-
- public Structure(MeshPrimitive.Vertex start, MeshPrimitive.Vertex end) {
- this.start = start;
- this.end = end;
- }
- }
-
- private class RotatingIterator implements Iterator<OrientedEdge> {
-
- private OrientedEdge search = OrientedEdge.this;
- private OrientedEdge candidate = search;
- private boolean goingCounterClockwise = true;
-
- @Override
- public boolean hasNext() {
- findNext();
- return candidate != null;
- }
-
- private void findNext() {
- if (candidate != null) return;
- if (search == null) return;
-
- //search the triangles turning clockwise until we make a loop
- if (goingCounterClockwise) {
- final OrientedTriangle t = search.getTriangle();
- //get next triangle edge
- search = t.adjacentEdge(search).reverse();
- candidate = search;
- if (search == OrientedEdge.this) {
- //loop finished
- search = null;
- candidate = null;
- return;
- }
- }
-
- if (goingCounterClockwise && search == null) {
- goingCounterClockwise = false;
- search = OrientedEdge.this;
- }
-
- //search the triangles turning counter-clockwise
- //this case can happen only when we didn't make a full loop previously
- //it can happen for the area border triangles.
- if (!goingCounterClockwise) {
- search = search.reverse();
- if (search != null) {
- final OrientedTriangle t = search.getTriangle();
- search = t.getEdge(search.getEnd());
- }
- }
-
- candidate = search;
- }
-
- @Override
- public OrientedEdge next() {
- findNext();
- OrientedEdge edge = candidate;
- candidate = null;
- return edge;
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedTriangle.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedTriangle.java
deleted file mode 100644
index 6d6ba1b..0000000
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/triangulate/delaunay/OrientedTriangle.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * 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.geometries.triangulate.delaunay;
-
-import java.awt.geom.Point2D;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.privy.AbstractGeometry;
-import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.referencing.privy.ShapeUtilities;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-final class OrientedTriangle extends AbstractGeometry implements Triangle, PointSequence {
-
- private final LinearRing ring = GeometryFactory.createLinearRing(this);
-
- private boolean obsolete = false;
- public final OrientedEdge ab;
- public final OrientedEdge bc;
- public final OrientedEdge ca;
- /**
- * triangle points in counter clockwise order
- */
- public final Vertex a;
- public final Vertex b;
- public final Vertex c;
- //cache delaunay triangle informations
- private double circleCenterX = Double.POSITIVE_INFINITY;
- private double circleCenterY;
- private double circleRadius2;
-
- /**
- * Create triangle with vertices in counter clockwise order.
- * This constructor makes no verificiations.
- *
- * @param a first vertex, not null
- * @param b second vertex, not null
- * @param c thord vertex, not null
- */
- public OrientedTriangle(Vertex a, Vertex b, Vertex c) {
- this.a = a;
- this.b = b;
- this.c = c;
- this.ab = new OrientedEdge(a, b, this);
- this.bc = new OrientedEdge(b, c, this);
- this.ca = new OrientedEdge(c, a, this);
- }
-
- /**
- * Create triangle with edges in counter clockwise order.
- * This constructor makes no verificiations.
- *
- * @param ab first edge, not null
- * @param bc second edge, not null
- * @param ca thord edge, not null
- */
- public OrientedTriangle(OrientedEdge ab, OrientedEdge bc, OrientedEdge ca) {
- this.ab = ab;
- this.bc = bc;
- this.ca = ca;
- this.ab.changeTriangle(this);
- this.bc.changeTriangle(this);
- this.ca.changeTriangle(this);
- this.a = ab.getStart();
- this.b = bc.getStart();
- this.c = ca.getStart();
- }
-
- public boolean isObsolete() {
- return obsolete;
- }
-
- public void obsolete(){
- this.obsolete = true;
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public LinearRing getExteriorRing() {
- return ring;
- }
-
- public OrientedEdge getEdge(Vertex start) {
- assert (!obsolete);
- if (a == start) {
- return ab;
- } else if (b == start) {
- return bc;
- } else if (c == start) {
- return ca;
- } else {
- throw new OperationException("Vertex is not from this triangle");
- }
- }
-
- /**
- * Returns the opposite vertex of given edge.
- */
- MeshPrimitive.Vertex oppositePoint(OrientedEdge edge) {
- assert (!obsolete);
- if (edge == ab) {
- return c;
- } else if (edge == bc) {
- return a;
- } else if (edge == ca) {
- return b;
- } else {
- throw new OperationException("Edge is not from this triangle");
- }
- }
-
- /**
- * Returns the adjacent edge, sharing the starting vertex.
- */
- OrientedEdge adjacentEdge(OrientedEdge edge) {
- assert (!obsolete);
- if (edge == ab) {
- return ca;
- } else if (edge == bc) {
- return ab;
- } else if (edge == ca) {
- return bc;
- } else {
- throw new OperationException("Edge is not from this triangle");
- }
- }
-
- public boolean validate() throws OperationException {
- assert (!obsolete);
-
- if (ab.getStart() == ab.getEnd() || bc.getStart() == bc.getEnd() || ca.getStart() == ca.getEnd()) throw new OperationException("Unvalid edges",null);
-
- if (ab.getStart() != a) throw new OperationException("Unvalid edge " + ab);
- if (ab.getEnd() != b) throw new OperationException("Unvalid edge " + ab);
-
- if (bc.getStart() != b) throw new OperationException("Unvalid edge " + bc);
- if (bc.getEnd() != c) throw new OperationException("Unvalid edge " + bc);
-
- if (ca.getStart() != c) throw new OperationException("Unvalid edge " + ca);
- if (ca.getEnd() != a) throw new OperationException("Unvalid edge " + ca);
-
- if (ab.getTriangle() != this) throw new OperationException("Unvalid edge " + ab);
- if (bc.getTriangle() != this) throw new OperationException("Unvalid edge " + bc);
- if (ca.getTriangle() != this) throw new OperationException("Unvalid edge " + ca);
-
- if (ab.isObsolete()) throw new OperationException("Obsolete edge " + ab);
- if (bc.isObsolete()) throw new OperationException("Obsolete edge " + bc);
- if (ca.isObsolete()) throw new OperationException("Obsolete edge " + ca);
- return true;
- }
-
- public boolean isInDelaunayCircle(double x, double y) {
- return distanceToDelaunayCircleCenterSquare(x,y) < circleRadius2;
- }
-
- public double distanceToDelaunayCircleCenterSquare(double x, double y) {
- getDelaunayCircleRadiusSquare();
- final double rx = x - circleCenterX;
- final double ry = y - circleCenterY;
- return rx*rx + ry*ry;
- }
-
- public double getDelaunayCircleRadiusSquare() {
- if (circleCenterX == Double.POSITIVE_INFINITY) {
- //sort vertex starting by lowest index, this ensure more consistancy in the tests
- Vertex A = a;
- Vertex B = b;
- Vertex C = c;
- if (A.getIndex() > B.getIndex()) {
- Vertex T = A;
- A = B;
- B = C;
- C = T;
- }
- if (A.getIndex() > B.getIndex()) {
- Vertex T = A;
- A = B;
- B = C;
- C = T;
- }
- final Tuple posA = A.getPosition();
- final Tuple posB = B.getPosition();
- final Tuple posC = C.getPosition();
- final double ax = posA.get(0);
- final double ay = posA.get(1);
- final Point2D.Double circleCentre = ShapeUtilities.circleCentre(ax, ay, posB.get(0), posB.get(1), posC.get(0), posC.get(1));
- final double rx = ax - circleCentre.x;
- final double ry = ay - circleCentre.y;
- this.circleCenterX = circleCentre.x;
- this.circleCenterY = circleCentre.y;
- this.circleRadius2 = rx*rx + ry*ry;
- }
- return circleRadius2;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- // PointSequence ///////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return a.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) throws IllegalArgumentException {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public int getDimension() {
- return a.getCoordinateReferenceSystem().getCoordinateSystem().getDimension();
- }
-
- /**
- * Get the geometry bounding envelope.
- *
- * @return Envelope in geometry coordinate reference system.
- */
- @Override
- public Envelope getEnvelope() {
- return PointSequence.super.getEnvelope();
- }
-
- @Override
- public AttributesType getAttributesType() {
- return AttributesType.EMPTY;
- }
-
- @Override
- public int size() {
- return 4;
- }
-
- @Override
- public Point getPoint(final int index) {
- return switch (index) {
- case 0, 3 -> a;
- case 1 -> b;
- case 2 -> c;
- default -> throw new ArrayIndexOutOfBoundsException();
- };
- }
-
- @Override
- public Tuple getPosition(int index) {
- return switch (index) {
- case 0, 3 -> a.getPosition().copy();
- case 1 -> b.getPosition().copy();
- case 2 -> c.getPosition().copy();
- default -> throw new ArrayIndexOutOfBoundsException();
- };
- }
-
- @Override
- public void setPosition(int index, Tuple value) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public Tuple getAttribute(int index, String name) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- return getPosition(index);
- }
- return null;
- }
-
- @Override
- public void setAttribute(int index, String name, Tuple value) {
- if (AttributesType.ATT_POSITION.equals(name)) {
- setPosition(index, value);
- return;
- }
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public int hashCode() {
- int result = 31 + a.getIndex();
- result = 31 * result + b.getIndex();
- result = 31 * result + c.getIndex();
- return result;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometriesTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometriesTest.java
deleted file mode 100644
index 3e1f395..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometriesTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.util.FactoryException;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class GeometriesTest {
-
- /**
- * Test creation of undefined CRS.
- */
- @Test
- public void testUndefinedCrs() {
-
- for (int i = 1; i < 10; i++) {
- CoordinateReferenceSystem crs = Geometries.getUndefinedCRS(i);
-
- assertTrue(Geometries.isUndefined(crs));
-
- try {
- CRS.findOperation(crs, CommonCRS.WGS84.geographic(), null);
- fail("Conversion to geographic crs should have fail");
- } catch (FactoryException ex) {
- //ok
- }
- }
- }
-
- /**
- * Test transform between cartesian crs
- */
- @Test
- @Disabled
- public void testCartesianCrsTransform() throws FactoryException {
-
- MathTransform trs = CRS.findOperation(Geometries.RIGHT_HAND_3D, Geometries.PSEUDOGEO_3D, null).getMathTransform();
- System.out.println(trs);
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/PreparedTINTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/PreparedTINTest.java
deleted file mode 100644
index e2a19d7..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/PreparedTINTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.geometries;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class PreparedTINTest {
-
- private static final CoordinateReferenceSystem CRS3D;
- static {
- try {
- CRS3D = CRS.compound(CommonCRS.WGS84.normalizedGeographic(), CommonCRS.Vertical.ELLIPSOIDAL.crs());
- } catch (FactoryException ex) {
- throw new RuntimeException(ex.getMessage(), ex);
- }
- }
-
- /**
- * Test single prepared tin.
- */
- @Test
- public void testSingle() throws TransformException {
-
- final MeshPrimitive.Triangles geometry = new MeshPrimitive.Triangles();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 2, 2, 3, 1));
-
- final PreparedTIN tin = PreparedTIN.create(geometry);
- assertEquals(2, tin.getPatches(null).count());
-
- GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
- env.setRange(0, 8.9, 10);
- env.setRange(1, 8, 9);
- assertEquals(1, tin.getPatches(env).count());
-
- }
-
- /**
- * Test multi prepared tin.
- */
- @Test
- public void testMulti() throws TransformException {
-
- final MeshPrimitive.Triangles geometry = new MeshPrimitive.Triangles();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 2, 2, 3, 1));
-
- final PreparedTIN tin = PreparedTIN.create(geometry, geometry);
- assertEquals(4, tin.getPatches(null).count());
-
- GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
- env.setRange(0, 8.9, 10);
- env.setRange(1, 8, 9);
- assertEquals(2, tin.getPatches(env).count());
-
- assertEquals(4, tin.getNumPatches());
- assertEquals("TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))", tin.getPatchN(0).asText());
- assertEquals("TRIANGLE ((6.0 7.0 8.0,9.0 10.0 11.0,3.0 4.0 5.0))", tin.getPatchN(1).asText());
- assertEquals("TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))", tin.getPatchN(2).asText());
- assertEquals("TRIANGLE ((6.0 7.0 8.0,9.0 10.0 11.0,3.0 4.0 5.0))", tin.getPatchN(3).asText());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/TriangleTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/TriangleTest.java
deleted file mode 100644
index 48ea40a..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/TriangleTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.geometries;
-
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TriangleTest {
-
- /**
- * LinearRing constructor test.
- */
- @Test
- public void constructorTest() {
-
- final TupleArray positions = TupleArrays.of(CommonCRS.WGS84.normalizedGeographic(), new double[]{0,0, 1,0, 0,1, 0,0});
- final PointSequence points = GeometryFactory.createSequence(positions);
- final LinearRing exterior = GeometryFactory.createLinearRing(points);
- final Triangle triangle = GeometryFactory.createTriangle(exterior);
-
- assertNotNull(triangle.getExteriorRing());
- assertTrue(triangle.getInteriorRings().isEmpty());
- assertEquals(exterior, triangle.getExteriorRing());
- }
-
- /**
- * Barycentric coordinate tests.
- */
- @Test
- public void barycentreTest() {
-
- double x1,y1,x2,y2,x3,y3,x,y,epsilon;
- double tolerance = 0.0;
- double[] b;
-
- {
- x1 = 0;
- y1 = 0;
- x2 = 1;
- y2 = 0;
- x3 = 0;
- y3 = 1;
- epsilon = 0;
- /*
- * 3 +
- * |\
- * | \
- * 1 o--+ 2
- */
- x = 0;
- y = 0;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{1,0,0}, b, tolerance);
- /*
- * 3 +
- * |\
- * | \
- * 1 +--o 2
- */
- x = 1;
- y = 0;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0,1,0}, b, tolerance);
- /*
- * 3 o
- * |\
- * | \
- * 1 +--+ 2
- */
- x = 0;
- y = 1;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0,0,1}, b, tolerance);
- /*
- * 3 + o
- * |\
- * | \
- * 1 +--+ 2
- */
- x = 1;
- y = 1;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNull(b);
- /*
- * 3 +
- * |\
- * | o
- * | \
- * 1 +---+ 2
- */
- x = 0.5;
- y = 0.5;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0,0.5,0.5}, b, tolerance);
- /*
- * 3 +
- * |\
- * | \
- * | \
- * 1 +-o-+ 2
- */
- x = 0.5;
- y = 0;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0.5,0.5,0}, b, tolerance);
- /*
- * 3 +
- * |\
- * o \
- * | \
- * 1 +---+ 2
- */
- x = 0;
- y = 0.5;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0.5,0,0.5}, b, tolerance);
- /*
- * 3 +
- * |\
- * | \
- * |o \
- * 1 +---+ 2
- */
- x = 0.3;
- y = 0.3;
- tolerance = 0.1;
- b = Triangle.getBarycentricValue2D(x1, y1, x2, y2, x3, y3, x, y, epsilon, true);
- assertNotNull(b);
- assertArrayEquals(new double[]{0.4,0.3,0.3}, b, tolerance);
- }
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/index/MortonIteratorTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/index/MortonIteratorTest.java
deleted file mode 100644
index d8160b8..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/index/MortonIteratorTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.geometries.index;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class MortonIteratorTest {
-
- /**
- * Test 2D indexing.
- */
- @Test
- public void testIndex2() {
- assertEquals(0b00000101L, MortonIterator.index(0b0011, 0b0000));
- assertEquals(0b01001110L, MortonIterator.index(0b1010, 0b0011));
- assertEquals(0b00110110L, MortonIterator.index(0b0110, 0b0101));
- }
-
- /**
- * Test 3D indexing.
- */
- @Test
- public void testIndex3() {
- assertEquals(0b100010001L, MortonIterator.index(0b001, 0b010, 0b100));
- assertEquals(0b101101101L, MortonIterator.index(0b111, 0b000, 0b111));
- }
-
- /**
- * Test 1 bit spacing.
- */
- @Test
- public void testSpace1() {
-
- { //check correct values
- assertEquals(0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000L, MortonIterator.space1bit(0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000L));
- assertEquals(0b01010100_01010001_01010101_01010101_00000001_01010101_01010101_00000101L, MortonIterator.space1bit(0b00000000_00000000_00000000_00000000_11101101_11111111_00011111_11110011L));
- assertEquals(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101L, MortonIterator.space1bit(0b00000000_00000000_00000000_00000000_11111111_11111111_11111111_11111111L));
- }
-
- { //check incorrect values
- try {
- MortonIterator.space1bit(Long.MAX_VALUE);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- try {
- MortonIterator.space1bit(-1);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- try {
- MortonIterator.space1bit(0b00000000_00000000_00000000_00000001_11111111_11111111_11111111_11111111L);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- }
- }
-
- /**
- * Test 2 bits spacing.
- */
- @Test
- public void testSpace2() {
-
- { //check correct values
- assertEquals(0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000L, MortonIterator.space2bit(0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000L));
- assertEquals(0b00010000_00001001_00100100_10010010_01001001_00100100_00010010_00001001L, MortonIterator.space2bit(0b00000000_00000000_00000000_00000000_00000000_00010011_11111111_11011011L));
- assertEquals(0b00010010_01001001_00100100_10010010_01001001_00100100_10010010_01001001L, MortonIterator.space2bit(0b00000000_00000000_00000000_00000000_00000000_00011111_11111111_11111111L));
- }
-
- { //check incorrect values
- try {
- MortonIterator.space2bit(Long.MAX_VALUE);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- try {
- MortonIterator.space2bit(-1);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- try {
- MortonIterator.space2bit(0b00000000_00000000_00000000_00000000_00000000_00111111_11111111_11111111L);
- fail("Invalid value should fail");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleArrayTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleArrayTest.java
deleted file mode 100644
index 111e7b1..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleArrayTest.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.transform.MathTransforms;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class AbstractTupleArrayTest {
-
- protected static final double TOLERANCE = 0.0000001;
- protected static final String UNVALID_INDEX_EXPECTED = "Accessing value our of tuple size must cause an IndexOutOfBoundsException";
-
- protected abstract int[] getSupportedDimensions();
-
- /**
- * Created tuple array must have all values at zero.
- */
- protected abstract TupleArray create(int dim, int length);
-
-
- /**
- * Root test method, delegates to other methods.
- */
- @Test
- public void testTupleArray() throws TransformException{
-
- final int[] supportedDimensions = getSupportedDimensions();
-
- for (int i = 0; i < supportedDimensions.length; i++) {
- final int dim = supportedDimensions[i];
- final TupleArray array = create(dim, 5);
- assertEquals(dim, array.getDimension());
- assertEquals(5, array.getLength());
- testTupleArray(array);
- }
-
- }
-
- /**
- * Test a single tuple array.
- */
- private void testTupleArray(TupleArray array) throws TransformException {
- testGetSet(array);
- testToArray(array);
- testToArrayWithRange(array);
- testCopy(array);
- testResize(array);
- testCursor(array);
- testTransform(array);
- }
-
- /**
- * Test array resizing.
- */
- private void testResize(TupleArray array) {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0, dn = array.getDimension(); d < dn; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- final TupleArray resized = array.resize(array.getLength() + 10);
- assertEquals(length + 10, resized.getLength());
-
- //test values are still here
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- resized.get(i, tuple);
- for (int d = 0, dn = array.getDimension(); d < dn; d++) {
- assertEquals(inc++, tuple.get(d), TOLERANCE);
- }
- }
- }
-
- /**
- * Test array copy.
- */
- private void testCopy(TupleArray array) {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0, dn = array.getDimension(); d < dn; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- final TupleArray copy = array.copy();
-
- //test values are still here
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- copy.get(i, tuple);
- for (int d = 0, dn = array.getDimension(); d < dn; d++) {
- assertEquals(inc++, tuple.get(d), TOLERANCE);
- }
- }
-
- assertEquals(array, copy);
- assertFalse(array == copy);
- }
-
- /**
- * Test tuple array to arrays.
- */
- private void testToArray(TupleArray array) {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- {//to short array
- final short[] table = array.toArrayShort();
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to int array
- final int[] table = array.toArrayInt();
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to float array
- final float[] table = array.toArrayFloat();
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to double array
- final double[] table = array.toArrayDouble();
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
- }
-
- /**
- * Test tuple array range to arrays.
- */
- private void testToArrayWithRange(TupleArray array) {
- final int length = array.getLength();
- if (length < 3) return;
-
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- int clip = 1;
- int rangeStart = clip;
- int rangeEnd = length - 2 * clip;
- int rangeLength = rangeEnd - rangeStart;
- {//to short array
- final short[] table = array.toArrayShort(rangeStart, rangeLength);
- inc = rangeStart*dimension;
- for (int i = 0; i < rangeLength; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to int array
- final int[] table = array.toArrayInt(rangeStart, rangeLength);
- inc = rangeStart*dimension;
- for (int i = 0; i < rangeLength; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to float array
- final float[] table = array.toArrayFloat(rangeStart, rangeLength);
- inc = rangeStart*dimension;
- for (int i = 0; i < rangeLength; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
-
- {//to double array
- final double[] table = array.toArrayDouble(rangeStart, rangeLength);
- inc = rangeStart*dimension;
- for (int i = 0; i < rangeLength; i++) {
- for (int d = 0; d < dimension; d++) {
- assertEquals(inc++, table[i * dimension + d], TOLERANCE);
- }
- }
- }
- }
-
- /**
- * Test array getter and setter methods.
- */
- private void testGetSet(TupleArray array) {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- final Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
-
- assertEquals(tuple, array.get(i));
- final Vector buffer = Vectors.createDouble(dimension);
- array.get(i, buffer);
- assertEquals(tuple, buffer);
- }
- }
-
- /**
- * Test array cursor.
- */
- private void testCursor(TupleArray array) {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- final TupleArrayCursor cursor = array.cursor();
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- assertTrue(cursor.next());
-
- final Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
-
- assertEquals(tuple, cursor.samples());
- }
- assertFalse(cursor.next());
-
- //check error on wrong index
- try {
- cursor.moveTo(-1);
- fail(UNVALID_INDEX_EXPECTED);
- } catch (IndexOutOfBoundsException ex) {
- //ok
- }
- try {
- cursor.moveTo(length);
- fail(UNVALID_INDEX_EXPECTED);
- } catch (IndexOutOfBoundsException ex) {
- //ok
- }
- }
-
- /**
- * Test array transform.
- */
- private void testTransform(TupleArray array) throws TransformException {
- final int length = array.getLength();
- final int dimension = array.getDimension();
- int inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.createDouble(dimension);
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++);
- }
- array.set(i, tuple);
- }
-
- //add 2 to each sample
- final MatrixSIS matrix = Matrices.createIdentity(dimension +1);
- for (int d = 0; d < dimension; d++) {
- matrix.setElement(d, dimension, 2);
- }
- array.transform(MathTransforms.linear(matrix));
-
- inc = 0;
- for (int i = 0, n = length; i < n; i++) {
- Vector tuple = Vectors.create(dimension, array.getDataType());
- for (int d = 0; d < dimension; d++) {
- tuple.set(d, inc++ + 2);
- }
- assertEquals(tuple, array.get(i));
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleTest.java
deleted file mode 100644
index 7153f06..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractTupleTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * 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.geometries.math;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class AbstractTupleTest {
-
- protected static final double TOLERANCE = 0.0000001;
- protected static final String UNVALID_INDEX_EXPECTED = "Accessing value our of tuple size must cause an IndexOutOfBoundsException";
-
- protected abstract int[] getSupportedDimensions();
-
- /**
- * Created tuple must have all values at zero.
- */
- protected abstract Tuple<?> create(int dim);
-
- /**
- * Root test method, delegates to other methods.
- */
- @Test
- public void testTuple() throws Throwable{
-
- final int[] supportedDimensions = getSupportedDimensions();
-
- for (int i = 0; i < supportedDimensions.length; i++) {
- final int dim = supportedDimensions[i];
- final Tuple<?> tuple = create(dim);
- try {
- assertEquals(dim, tuple.getDimension());
- testTuple(tuple);
- } catch (Throwable ex) {
- throw new Throwable(tuple.getClass().getName() +" " + ex.getMessage(), ex);
- }
- }
-
- }
-
- /**
- * Test a single tuple.
- */
- protected void testTuple(Tuple<?> tuple) {
- testAllValue(tuple, 0.0);
- assertTrue(tuple.isAll(0.0));
- testCellGetSet(tuple);
- testToArray(tuple);
- testEquality(tuple);
-
- switch (tuple.getDataType()) {
- case BYTE :
- testExtremum(tuple, Byte.MIN_VALUE);
- testExtremum(tuple, Byte.MAX_VALUE);
- break;
- case SHORT :
- testExtremum(tuple, Short.MIN_VALUE);
- testExtremum(tuple, Short.MAX_VALUE);
- break;
- case USHORT :
- testExtremum(tuple, 0);
- testExtremum(tuple, 65535);
- break;
- case INT :
- testExtremum(tuple, Integer.MIN_VALUE);
- testExtremum(tuple, Integer.MAX_VALUE);
- break;
- case FLOAT :
- testExtremum(tuple, Float.MIN_VALUE);
- testExtremum(tuple, Float.MAX_VALUE);
- break;
- case DOUBLE :
- testExtremum(tuple, Double.MIN_VALUE);
- testExtremum(tuple, Double.MAX_VALUE);
- break;
- }
- }
-
- /**
- * Test all tuple values equal the expected value.
- */
- private void testAllValue(Tuple<?> tuple, double expectedValue) {
- final int dim = tuple.getDimension();
-
- for (int c = 0; c < dim; c++) {
- double value = tuple.get(c);
- assertEquals(expectedValue, value, TOLERANCE, "Value different at ["+c+"]");
- }
-
- assertTrue(tuple.isAll(expectedValue));
- assertFalse(tuple.isAll(expectedValue+1));
- }
-
- /**
- * Test tuple value getters and setters.
- */
- private void testCellGetSet(Tuple<?> tuple) {
- final int dim = tuple.getDimension();
-
- for (int i = 0; i < dim; i++) {
- tuple.set(i, i+1);
- assertEquals(i+1, tuple.get(i), TOLERANCE);
- }
-
- //test out of range
- try {
- tuple.set(-1, 10);
- fail(UNVALID_INDEX_EXPECTED);
- } catch (IndexOutOfBoundsException ex) {
- //ok
- }
- try {
- tuple.set(dim, 10);
- fail(UNVALID_INDEX_EXPECTED);
- } catch (IndexOutOfBoundsException ex) {
- //ok
- }
-
- }
-
- /**
- * Test tuple value to array methods.
- */
- private void testToArray(Tuple<?> tuple) {
- final int dim = tuple.getDimension();
-
- for (int i = 0; i < dim; i++) {
- tuple.set(i, i+1);
- }
-
- {//test toShort
- final short[] values = tuple.toArrayShort();
- assertEquals(dim, values.length);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i], TOLERANCE);
- }
- }
- {//test toShort with buffer
- final short[] values = new short[dim + 3];
- tuple.toArrayShort(values, 3);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i + 3], TOLERANCE);
- }
- }
- {//test to int
- final int[] values = tuple.toArrayInt();
- assertEquals(dim, values.length);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i], TOLERANCE);
- }
- }
- {//test to int with buffer
- final int[] values = new int[dim + 3];
- tuple.toArrayInt(values, 3);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i + 3], TOLERANCE);
- }
- }
- {//test to float
- final float[] values = tuple.toArrayFloat();
- assertEquals(dim, values.length);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i], TOLERANCE);
- }
- }
- {//test to float with buffer
- final float[] values = new float[dim + 3];
- tuple.toArrayFloat(values, 3);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i + 3], TOLERANCE);
- }
- }
- {//test to double
- final double[] values = tuple.toArrayDouble();
- assertEquals(dim, values.length);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i], TOLERANCE);
- }
- }
- {//test to double with buffer
- final double[] values = new double[dim + 3];
- tuple.toArrayDouble(values, 3);
- for (int i = 0; i < dim; i++) {
- assertEquals(i+1, values[i + 3], TOLERANCE);
- }
- }
-
- }
-
- private void testEquality(Tuple<?> tuple) {
- for (int i = 0; i < tuple.getDimension(); i++) {
- tuple.set(i, i+1);
- }
-
- //test equals itself
- assertEquals(tuple, tuple);
-
- //test equals a copy
- final Tuple<?> copy = tuple.copy();
- assertEquals(tuple, copy);
-
- //test a equals a newly created tuple
- final Tuple<?> newtuple = create(tuple.getDimension());
- assertFalse(newtuple.equals(tuple));
- newtuple.set(tuple);
- assertEquals(tuple, newtuple);
-
- if (tuple.getDataType() == DataType.FLOAT
- || tuple.getDataType() == DataType.DOUBLE) {
- //test NaN equality
- copy.set(0, Double.NaN);
- assertFalse(copy.equals(tuple));
- tuple.set(0, Double.NaN);
- assertEquals(copy, tuple);
- }
-
- }
-
- private void testExtremum(Tuple<?> tuple, double value) {
-
- for (int i=0;i<tuple.getDimension();i++) {
- //test get set
- tuple.set(i, value);
- assertEquals(value, tuple.get(i), 0.0);
- tuple.set(i, 0);
-
- //test copy
- tuple.set(i, value);
- Tuple copy = tuple.copy();
- assertEquals(value, copy.get(i), 0.0);
- tuple.set(i, 0);
-
- //test array
- tuple.set(i, value);
- double[] array = tuple.toArrayDouble();
- assertEquals(value, array[i], 0.0);
- tuple.set(0, 0);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractVectorTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractVectorTest.java
deleted file mode 100644
index a917dd3..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/AbstractVectorTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.geometries.math;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class AbstractVectorTest extends AbstractTupleTest {
-
- @Override
- protected void testTuple(Tuple<?> tuple) {
- super.testTuple(tuple);
-
- final Vector vector = (Vector) tuple;
- testLength(vector);
- testLengthSquare(vector);
- testNormalize(vector);
- testAdd(vector);
- testSubtract(vector);
- testScale(vector);
- testCross(vector);
- testDot(vector);
- }
-
- /**
- * Test vector length.
- */
- private void testLength(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- }
-
- assertEquals(Vectors.length(vector.toArrayDouble()), vector.length(), TOLERANCE);
- }
-
- /**
- * Test vector length squared.
- */
- private void testLengthSquare(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- }
-
- assertEquals(Vectors.lengthSquare(vector.toArrayDouble()), vector.lengthSquare(), TOLERANCE);
- }
-
- /**
- * Test vector normalize.
- *
- * Only tested if vector type is Float or Double.
- * This operation requiere floating point precision.
- */
- private void testNormalize(Vector<?> vector) {
- final int dim = vector.getDimension();
- if (!(vector.getDataType() == DataType.FLOAT || vector.getDataType() == DataType.DOUBLE)) {
- return;
- }
-
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- }
-
- final double[] expected = Vectors.normalize(vector.toArrayDouble());
- vector.normalize();
- assertArrayEquals(expected, vector.toArrayDouble(), TOLERANCE);
- }
-
- /**
- * Test vector add operation.
- */
- private void testAdd(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- final Vector<?> second = Vectors.createDouble(dim);
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- second.set(i, 5);
- }
-
- final double[] expected = Vectors.add(vector.toArrayDouble(), second.toArrayDouble());
- vector.add(second);
- assertArrayEquals(expected, vector.toArrayDouble(), TOLERANCE);
-
- }
-
- /**
- * Test vector subtract.
- */
- private void testSubtract(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- final Vector second = Vectors.createDouble(dim);
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+5);
- second.set(i, 5);
- }
-
- final double[] expected = Vectors.subtract(vector.toArrayDouble(), second.toArrayDouble());
- vector.subtract(second);
- assertArrayEquals(expected, vector.toArrayDouble(), TOLERANCE);
- }
-
- /**
- * Test vector scale.
- */
- private void testScale(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- final double scale = 3;
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- }
-
- final double[] expected = Vectors.scale(vector.toArrayDouble(), scale);
- vector.scale(scale);
- assertArrayEquals(expected, vector.toArrayDouble(), TOLERANCE);
- }
-
- /**
- * Test vector cross product.
- * Only tested if vector size is 3.
- */
- private void testCross(Vector<?> vector) {
- final int dim = vector.getDimension();
- if (dim != 3) return;
-
-
- final Vector<?> second = Vectors.createDouble(dim);
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- second.set(i, 5);
- }
-
- final double[] expected = Vectors.cross(vector.toArrayDouble(), second.toArrayDouble());
- final Vector<?> cross = vector.cross(second);
- assertArrayEquals(expected, cross.toArrayDouble(), TOLERANCE);
- }
-
- /**
- * Test vector dot product.
- */
- private void testDot(Vector<?> vector) {
- final int dim = vector.getDimension();
-
- final Vector<?> second = Vectors.createDouble(dim);
- for (int i = 0; i < dim; i++) {
- vector.set(i, i+1);
- second.set(i, 5);
- }
-
- final double expected = Vectors.dot(vector.toArrayDouble(), second.toArrayDouble());
- assertEquals(expected, vector.dot(second), TOLERANCE);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/MathsTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/MathsTest.java
deleted file mode 100644
index 2aa0fbb..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/MathsTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * 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.geometries.math;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class MathsTest {
-
- private static final double EPSILON = 1e-6;
-
- @Test
- public void testProjectionRatio() {
-
- double x1,y1,x2,y2;
-
- /*
- + +
-
- S-E
- */
- x1 = 0.0;
- y1 = 0.0;
- x2 = 1.0;
- y2 = 0.0;
- assertEquals(-7.0, Maths.projectionRatio(x1, y1, x2, y2,-7.0, 0.0), EPSILON);
- assertEquals(-2.0, Maths.projectionRatio(x1, y1, x2, y2,-2.0, 0.0), EPSILON);
- assertEquals( 0.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 0.0), EPSILON);
- assertEquals( 0.5, Maths.projectionRatio(x1, y1, x2, y2, 0.5, 0.0), EPSILON);
- assertEquals( 1.0, Maths.projectionRatio(x1, y1, x2, y2, 1.0, 0.0), EPSILON);
- assertEquals( 2.0, Maths.projectionRatio(x1, y1, x2, y2, 2.0, 0.0), EPSILON);
- assertEquals( 7.0, Maths.projectionRatio(x1, y1, x2, y2, 7.0, 0.0), EPSILON);
- /*
- E +
- |
- S +
- */
- x1 = 0.0;
- y1 = 0.0;
- x2 = 0.0;
- y2 = 1.0;
- assertEquals(-7.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0,-7.0), EPSILON);
- assertEquals(-2.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0,-2.0), EPSILON);
- assertEquals( 0.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 0.0), EPSILON);
- assertEquals( 0.5, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 0.5), EPSILON);
- assertEquals( 1.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 1.0), EPSILON);
- assertEquals( 2.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 2.0), EPSILON);
- assertEquals( 7.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 7.0), EPSILON);
- /*
- + E
- /
- S +
- */
- x1 = 0.0;
- y1 = 0.0;
- x2 = 1.0;
- y2 = 1.0;
- assertEquals(-7.0, Maths.projectionRatio(x1, y1, x2, y2,-7.0,-7.0), EPSILON);
- assertEquals(-2.0, Maths.projectionRatio(x1, y1, x2, y2,-2.0,-2.0), EPSILON);
- assertEquals( 0.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 0.0), EPSILON);
- assertEquals( 1.0, Maths.projectionRatio(x1, y1, x2, y2, 1.0, 1.0), EPSILON);
- assertEquals( 2.0, Maths.projectionRatio(x1, y1, x2, y2, 2.0, 2.0), EPSILON);
- assertEquals( 7.0, Maths.projectionRatio(x1, y1, x2, y2, 7.0, 7.0), EPSILON);
- /*
- + S
- /
- E +
- */
- x1 = 10.0;
- y1 = 15.0;
- x2 = 5.0;
- y2 = 10.0;
- assertEquals(-1.0, Maths.projectionRatio(x1, y1, x2, y2,15.0,20.0), EPSILON);
- assertEquals( 0.0, Maths.projectionRatio(x1, y1, x2, y2,10.0,15.0), EPSILON);
- assertEquals( 1.0, Maths.projectionRatio(x1, y1, x2, y2, 5.0,10.0), EPSILON);
- assertEquals( 2.0, Maths.projectionRatio(x1, y1, x2, y2, 0.0, 5.0), EPSILON);
-
- }
-
- @Test
- public void testDistanceSquare() {
-
- { /* Point exactly on the segment (same Y), to ensure line detection works,
- otherwise we obtain a distance of 1.4551915228366852E-11 */
- double distance = Maths.distanceSquare(
- 976136.1298301395,5118355.120854909,
- 976587.6962741626,5118355.120854909,
- 976420.4186063276,5118355.120854909);
- assertEquals(0.0, distance, 0.0);
- }
-
- { /* Point exactly on the segment (same X), to ensure line detection works,
- otherwise we obtain a distance of 1.4551915228366852E-11 */
- double distance = Maths.distanceSquare(
- 5118355.120854909,976136.1298301395,
- 5118355.120854909,976587.6962741626,
- 5118355.120854909,976420.4186063276);
- assertEquals(0.0, distance, 0.0);
- }
-
- }
-
- @Test
- public void testNormalizedByte() {
- assertEquals(-1.0, Maths.normalizedByte(Byte.MIN_VALUE), 0.0);
- assertEquals(-1.0, Maths.normalizedByte((byte)-127), 0.0);
- assertEquals(0.0, Maths.normalizedByte((byte) 0), 0.0);
- assertEquals(1.0, Maths.normalizedByte(Byte.MAX_VALUE), 0.0);
- }
-
- @Test
- public void testNormalizedUByte() {
- assertEquals(0.0, Maths.normalizedUByte((byte) 0), 0.0);
- assertEquals(1.0, Maths.normalizedUByte((byte) 0xFF), 0.0);
- }
-
- @Test
- public void testNormalizedShort() {
- assertEquals(-1.0, Maths.normalizedShort(Short.MIN_VALUE), 0.0);
- assertEquals(-1.0, Maths.normalizedShort((short)-32767), 0.0);
- assertEquals(0.0, Maths.normalizedShort((short) 0), 0.0);
- assertEquals(1.0, Maths.normalizedShort(Short.MAX_VALUE), 0.0);
- }
-
- @Test
- public void testNormalizedUShort() {
- assertEquals(0.0, Maths.normalizedUShort((short) 0), 0.0);
- assertEquals(1.0, Maths.normalizedUShort((short) 0xFFFF), 0.0);
- }
-
- @Test
- public void testNormalizedInt() {
- assertEquals(-1.0, Maths.normalizedInt(Integer.MIN_VALUE), 0.0);
- assertEquals(-1.0, Maths.normalizedInt(Integer.MIN_VALUE+1), 0.0);
- assertEquals(0.0, Maths.normalizedInt(0), 0.0);
- assertEquals(1.0, Maths.normalizedInt(Integer.MAX_VALUE), 0.0);
- }
-
- @Test
- public void testNormalizedUInt() {
- assertEquals(0.0, Maths.normalizedUInt(0), 0.0);
- assertEquals(1.0, Maths.normalizedUInt(0xFFFFFFFF), 0.0);
- }
-
- @Test
- public void testNormalizedLong() {
- assertEquals(-1.0, Maths.normalizedLong(Long.MIN_VALUE), 0.0);
- assertEquals(-1.0, Maths.normalizedLong(Long.MIN_VALUE+1), 0.0);
- assertEquals(0.0, Maths.normalizedLong(0), 0.0);
- assertEquals(1.0, Maths.normalizedLong(Long.MAX_VALUE), 0.0);
- }
-
- @Test
- public void testNormalizedULong() {
- assertEquals(0.0, Maths.normalizedULong(0L), 0.0);
- assertEquals(1.0, Maths.normalizedULong(~0L), 0.0);
- }
-
- @Test
- public void testToNormalizedByte() {
- assertEquals(Byte.MIN_VALUE+1, Maths.toNormalizedByte(-1.0));
- assertEquals(0, Maths.toNormalizedByte(0.0));
- assertEquals(Byte.MAX_VALUE, Maths.toNormalizedByte(1.0));
- }
-
- @Test
- public void testToNormalizedUByte() {
- assertEquals((byte) 0, Maths.toNormalizedUByte(0.0));
- assertEquals((byte) 0xFF, Maths.toNormalizedUByte(1.0));
- }
-
- @Test
- public void testToNormalizedShort() {
- assertEquals(Short.MIN_VALUE+1, Maths.toNormalizedShort(-1.0));
- assertEquals((short) 0, Maths.toNormalizedByte(0.0));
- assertEquals(Short.MAX_VALUE, Maths.toNormalizedShort(1.0));
- }
-
- @Test
- public void testToNormalizedUShort() {
- assertEquals((short) 0, Maths.toNormalizedUShort(0.0));
- assertEquals((short) 0xFFFF, Maths.toNormalizedUShort(1.0));
- }
-
- @Test
- public void testToNormalizedInt() {
- assertEquals(Integer.MIN_VALUE+1, Maths.toNormalizedInt(-1.0));
- assertEquals(0, Maths.toNormalizedInt(0.0));
- assertEquals(Integer.MAX_VALUE, Maths.toNormalizedInt(1.0));
- }
-
- @Test
- public void testToNormalizedUInt() {
- assertEquals(0, Maths.toNormalizedUInt(0.0));
- assertEquals(0xFFFFFFFF, Maths.toNormalizedUInt(1.0));
- }
-
- @Test
- public void testToNormalizedLong() {
- assertEquals(Long.MIN_VALUE, Maths.toNormalizedLong(-1.0));
- assertEquals(0L, Maths.toNormalizedLong(0.0));
- assertEquals(Long.MAX_VALUE, Maths.toNormalizedLong(1.0));
- }
-
- @Test
- public void testToNormalizedULong() {
- assertEquals(0, Maths.toNormalizedULong(0.0));
- assertEquals(Long.MIN_VALUE, Maths.toNormalizedULong(0.5));
- assertEquals(0xFFFFFFFFFFFFFFFFL, Maths.toNormalizedULong(1.0));
- }
-
- @Test
- public void testInTriangle() {
-
- }
-
- /**
- * A known mathematical problem.
- * TODO : find a more robust way to compute this operation.
- */
- @Test
- @Disabled
- public void testInCircle() {
-
- {
- final double ax = 8.64735;
- final double ay = 41.76673;
- final double bx = 8.64841;
- final double by = 41.7668;
- final double cx = 8.64642;
- final double cy = 41.76692;
- final double dx = 8.64685;
- final double dy = 41.7668;
-
- System.out.println(Maths.inCircle(ax, ay, bx, by, dx, dy, cx, cy));
- System.out.println(Maths.inCircle(bx, by, dx, dy, ax, ay, cx, cy));
- System.out.println(Maths.inCircle(dx, dy, ax, ay, bx, by, cx, cy));
- System.out.println(Maths.inCircle(ax, ay, dx, dy, cx, cy, bx, by));
- System.out.println(Maths.inCircle(dx, dy, cx, cy, ax, ay, bx, by));
- System.out.println(Maths.inCircle(cx, cy, ax, ay, dx, dy, bx, by));
- }
-
- {
- final double ax = 8.68629;
- final double ay = 41.90324;
- final double bx = 8.6874;
- final double by = 41.90363;
- final double cx = 8.6875;
- final double cy = 41.90367;
- final double dx = 8.68772;
- final double dy = 41.90366;
-
- System.out.println(Maths.inCircle(ax, ay, bx, by, dx, dy, cx, cy));
- System.out.println(Maths.inCircle(bx, by, dx, dy, ax, ay, cx, cy));
- System.out.println(Maths.inCircle(dx, dy, ax, ay, bx, by, cx, cy));
- System.out.println(Maths.inCircle(ax, ay, dx, dy, cx, cy, bx, by));
- System.out.println(Maths.inCircle(dx, dy, cx, cy, ax, ay, bx, by));
- System.out.println(Maths.inCircle(cx, cy, ax, ay, dx, dy, bx, by));
- }
- }
-
- /**
- * A known mathematical problem.
- * TODO : find a more robust way to compute this operation.
- */
- @Test
- @Disabled
- public void testIsPointInTriangle_BaryAlgo() {
- //POLYGON ((-88.4521713256836 19.713144302368164, -77.766901 -10.770846, -77.766711 -10.770966, -88.4521713256836 19.713144302368164))
- //POINT (-77.766791 -10.770866)
-
- assertTrue(Maths.isPointInTriangle_BaryAlgo(
- -88.4521713256836, 19.713144302368164,
- -77.766901, -10.770846,
- -77.766711, -10.770966,
- -77.766791, -10.770866
- ));
- }
-
- @Test
- public void testIsPointInTriangle_SideAlgo() {
-
- assertTrue(Maths.isPointInTriangle_SideAlgo(
- -88.4521713256836, 19.713144302368164,
- -77.766901, -10.770846,
- -77.766711, -10.770966,
- -77.766791, -10.770866
- ));
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/QuaternionTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/QuaternionTest.java
deleted file mode 100644
index add2587..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/QuaternionTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * Original code from Unlicense.science
- *
- * @author Johann Sorel
- */
-public class QuaternionTest {
-
- public static final double DELTA = 0.00000001;
-
- @Test
- public void testToMatrix3(){
-
- //test identity
- Quaternion qt = new Quaternion();
- Matrix3 result = qt.toMatrix3();
- assertEquals(new Matrix3( 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1),
- result);
-
-
- qt = new Quaternion(1, 0, 0, 0);
- result = qt.toMatrix3();
- assertEquals(new Matrix3( 1, 0, 0,
- 0, -1, 0,
- 0, 0, -1),
- result);
-
- qt = new Quaternion(0, 1, 0, 0);
- result = qt.toMatrix3();
- assertEquals(new Matrix3(-1, 0, 0,
- 0, 1, 0,
- 0, 0, -1),
- result);
-
- qt = new Quaternion(0, 0, 1, 0);
- result = qt.toMatrix3();
- assertEquals(new Matrix3(-1, 0, 0,
- 0, -1, 0,
- 0, 0, 1),
- result);
- }
-
- @Test
- public void testFromMatrix(){
- final double angle = 12.37;
-
- final Matrix4 m = Matrices.toMatrix4(new double[][]{
- {1, 0, 0, 0},
- {0, Math.cos(angle), -Math.sin(angle), 0},
- {0, Math.sin(angle), Math.cos(angle), 0},
- {0, 0, 0, 1}
- });
-
- Quaternion q = new Quaternion();
- q.fromMatrix(m);
-
- assertArrayEquals(m.getElements(),q.toMatrix4().getElements(), DELTA);
- }
-
- @Test
- public void testFromEuler(){
-
- Vector euler = new Vector3D.Double(0, 0, 0);
- Quaternion q = new Quaternion().fromEuler(euler);
- assertArrayEquals(new double[]{0, 0, 0, 1}, q.values, DELTA);
-
- euler = new Vector3D.Double(Math.PI, 0, 0);
- q = new Quaternion().fromEuler(euler);
- assertArrayEquals(new double[]{0, 0, 1, 0}, q.values, DELTA);
-
- euler = new Vector3D.Double(0, Math.PI / 2.0, 0);
- q = new Quaternion().fromEuler(euler);
- assertArrayEquals(new double[]{0, Math.cos(Math.PI / 4.0), 0, Math.cos(Math.PI / 4.0)}, q.values, DELTA);
- euler = q.toEuler();
- assertArrayEquals(new double[]{0, Math.PI / 2.0, 0}, euler.toArrayDouble(), DELTA);
-
- euler = new Vector3D.Double(0, 0, Math.PI);
- q = new Quaternion().fromEuler(euler);
- assertArrayEquals(new double[]{1, 0, 0, 0}, q.values, DELTA);
-
- }
-
- @Test
- public void testToEuler(){
-
- Quaternion q = new Quaternion(0, 0, 0, 1);
- VectorND.Double euler = q.toEuler();
- assertArrayEquals(new double[]{0, 0, 0}, euler.values, DELTA);
-
- q = new Quaternion(0, 0, 1, 0);
- euler = q.toEuler();
- assertArrayEquals(new double[]{Math.PI, 0, 0}, euler.values, DELTA);
-
- q = new Quaternion(1, 0, 0, 0);
- euler = q.toEuler();
- assertArrayEquals(new double[]{0, 0, Math.PI}, euler.values, DELTA);
- }
-
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayConcatenatedTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayConcatenatedTest.java
deleted file mode 100644
index 55485c3..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayConcatenatedTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.geometries.math;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayConcatenatedTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- final TupleArray[] arrays = new TupleArray[length];
- for (int i = 0; i < length; i++) {
- arrays[i] = TupleArrays.of(dim, new double[dim]);
- }
- return TupleArrays.concatenate(arrays);
- }
-
- @Test
- public void testGetSet() {
- final TupleArray array1 = TupleArrays.of(2, new double[]{0,1,2,3});
- final TupleArray array2 = TupleArrays.of(2, new double[]{4,5,6,7});
- final TupleArray array3 = TupleArrays.of(2, new double[]{8,9,10,11});
- final TupleArray cnt = TupleArrays.concatenate(array1, array2, array3);
-
- assertEquals(new Vector2D.Double(0,1), cnt.get(0));
- assertEquals(new Vector2D.Double(2,3), cnt.get(1));
- assertEquals(new Vector2D.Double(4,5), cnt.get(2));
- assertEquals(new Vector2D.Double(6,7), cnt.get(3));
- assertEquals(new Vector2D.Double(8,9), cnt.get(4));
- assertEquals(new Vector2D.Double(10,11), cnt.get(5));
-
- cnt.set(0, new Vector2D.Double(100,101));
- cnt.set(1, new Vector2D.Double(102,103));
- cnt.set(2, new Vector2D.Double(104,105));
- cnt.set(3, new Vector2D.Double(106,107));
- cnt.set(4, new Vector2D.Double(108,109));
- cnt.set(5, new Vector2D.Double(110,111));
- assertEquals(new Vector2D.Double(100,101), cnt.get(0));
- assertEquals(new Vector2D.Double(102,103), cnt.get(1));
- assertEquals(new Vector2D.Double(104,105), cnt.get(2));
- assertEquals(new Vector2D.Double(106,107), cnt.get(3));
- assertEquals(new Vector2D.Double(108,109), cnt.get(4));
- assertEquals(new Vector2D.Double(110,111), cnt.get(5));
- //check base arrays are modified
- assertEquals(new Vector2D.Double(100,101), array1.get(0));
- assertEquals(new Vector2D.Double(102,103), array1.get(1));
- assertEquals(new Vector2D.Double(104,105), array2.get(0));
- assertEquals(new Vector2D.Double(106,107), array2.get(1));
- assertEquals(new Vector2D.Double(108,109), array3.get(0));
- assertEquals(new Vector2D.Double(110,111), array3.get(1));
- }
-
- @Test
- public void testCursor() {
-
- final TupleArray array1 = TupleArrays.of(2, new double[]{0,1,2,3});
- final TupleArray array2 = TupleArrays.of(2, new double[]{4,5,6,7});
- final TupleArray array3 = TupleArrays.of(2, new double[]{8,9,10,11});
- final TupleArray cnt = TupleArrays.concatenate(array1, array2, array3);
-
- final TupleArrayCursor cursor = cnt.cursor();
- assertTrue(cursor.next());
- assertEquals(0, cursor.coordinate());
- assertEquals(new Vector2D.Double(0,1), cursor.samples());
- assertTrue(cursor.next());
- assertEquals(1, cursor.coordinate());
- assertEquals(new Vector2D.Double(2,3), cursor.samples());
- assertTrue(cursor.next());
- assertEquals(2, cursor.coordinate());
- assertEquals(new Vector2D.Double(4,5), cursor.samples());
- assertTrue(cursor.next());
- assertEquals(3, cursor.coordinate());
- assertEquals(new Vector2D.Double(6,7), cursor.samples());
- assertTrue(cursor.next());
- assertEquals(4, cursor.coordinate());
- assertEquals(new Vector2D.Double(8,9), cursor.samples());
- assertTrue(cursor.next());
- assertEquals(5, cursor.coordinate());
- assertEquals(new Vector2D.Double(10,11), cursor.samples());
- assertFalse(cursor.next());
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNbTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNbTest.java
deleted file mode 100644
index 2201bef..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNbTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNbTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Byte(SampleSystem.ofSize(dim), new byte[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNdTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNdTest.java
deleted file mode 100644
index 958cf1d..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNdTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNdTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Double(SampleSystem.ofSize(dim), new double[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNfTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNfTest.java
deleted file mode 100644
index d5772fe..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNfTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNfTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Float(SampleSystem.ofSize(dim), new float[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNiTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNiTest.java
deleted file mode 100644
index efbf044..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNiTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNiTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Int(SampleSystem.ofSize(dim), new int[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNlTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNlTest.java
deleted file mode 100644
index f6b1529..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNlTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNlTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Long(SampleSystem.ofSize(dim), new long[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNsTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNsTest.java
deleted file mode 100644
index 7bae038..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNsTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNsTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.Short(SampleSystem.ofSize(dim), new short[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNubTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNubTest.java
deleted file mode 100644
index 8017980..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNubTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNubTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.UByte(SampleSystem.ofSize(dim), new byte[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNusTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNusTest.java
deleted file mode 100644
index c5d573a..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArrayNusTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArrayNusTest extends AbstractTupleArrayTest {
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4};
- }
-
- @Override
- protected TupleArray create(int dim, int length) {
- return new TupleArrayND.UShort(SampleSystem.ofSize(dim), new short[length*dim]);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArraysTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArraysTest.java
deleted file mode 100644
index 988a2b9..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/TupleArraysTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.geometries.math;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Stream;
-import org.opengis.util.FactoryException;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TupleArraysTest {
-
- /**
- * Test integer type packing.
- */
- @Test
- public void testPackIntegerDataType() {
-
- final int[] datas = new int[]{0,1,2,3};
- TupleArray array = TupleArrays.of(2, datas);
-
- //test ubyte packing
- TupleArray packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.UBYTE, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
-
- //test byte packing
- datas[1] = -2;
- packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.BYTE, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
-
- //test short packing
- datas[1] = -1000;
- packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.SHORT, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
-
- //test ushort packing
- datas[1] = 10000;
- packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.USHORT, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
-
- //test uint packaging
- datas[1] = 65535 + 20;
- packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.UINT, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
-
- //test no change
- datas[1] = - (65535 + 20);
- packed = TupleArrays.packIntegerDataType(array);
- assertEquals(DataType.INT, packed.getDataType());
- assertArrayEquals(datas, packed.toArrayInt());
- }
-
- /**
- * Test array grouping.
- */
- @Test
- public void testGroup() throws FactoryException {
-
- final TupleArray array1 = TupleArrays.of(1, new double[]{ 0, 1, 2, 3});
- final TupleArray array2 = TupleArrays.of(2, new double[]{10,11,12,13,14,15,16,17});
- final TupleArray array3 = TupleArrays.of(1, new double[]{20,21,22,23});
-
- final TupleArray group = TupleArrays.group(array1, array2, array3);
- assertEquals(null, group.getCoordinateReferenceSystem());
- assertEquals(4, group.getSampleSystem().getSize());
- assertEquals(4, group.getLength());
-
- assertArrayEquals(new double[]{
- 0,10,11,20,
- 1,12,13,21,
- 2,14,15,22,
- 3,16,17,23
- },
- group.toArrayDouble(), 0.0);
- }
-
- /**
- * Test array group size different
- */
- @Test
- public void testGroupWrongSize() throws FactoryException {
- final TupleArray array1 = TupleArrays.of(1, new double[]{ 0, 1, 2, 3});
- final TupleArray array2 = TupleArrays.of(2, new double[]{10,11,12,13,14,15});
-
- assertThrows(IllegalArgumentException.class, ()->{
- final TupleArray group = TupleArrays.group(array1, array2);
- });
- }
-
- /**
- * Test stream over a TupleArray
- */
- @Test
- public void testStream() {
-
- final double[] arr = new double[100];
- for(int i=0;i<100;i++) {
- arr[i] = i;
- }
- final TupleArray array = TupleArrays.of(SampleSystem.ofSize(1), arr);
-
- final Set<Tuple> distinct = Collections.synchronizedSet(new HashSet<>());
- Stream<Tuple> stream = array.stream(true);
- stream.forEach((Tuple t) -> {
- distinct.add(new Vector1D.Double(t));
- });
-
- assertEquals(100, distinct.size());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXbTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXbTest.java
deleted file mode 100644
index afdc96e..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXbTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXbTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Byte();
- case 2 : return new Vector2D.Byte();
- case 3 : return new Vector3D.Byte();
- case 4 : return new Vector4D.Byte();
- default : return new VectorND.Byte(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXdTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXdTest.java
deleted file mode 100644
index 076499f..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXdTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXdTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Double();
- case 2 : return new Vector2D.Double();
- case 3 : return new Vector3D.Double();
- case 4 : return new Vector4D.Double();
- default : return new VectorND.Double(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXfTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXfTest.java
deleted file mode 100644
index 5e32254..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXfTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXfTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Float();
- case 2 : return new Vector2D.Float();
- case 3 : return new Vector3D.Float();
- case 4 : return new Vector4D.Float();
- default : return new VectorND.Float(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXiTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXiTest.java
deleted file mode 100644
index 9787f29..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXiTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXiTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Int();
- case 2 : return new Vector2D.Int();
- case 3 : return new Vector3D.Int();
- case 4 : return new Vector4D.Int();
- default : return new VectorND.Int(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXlTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXlTest.java
deleted file mode 100644
index fe88d6b..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXlTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXlTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Long();
- case 2 : return new Vector2D.Long();
- case 3 : return new Vector3D.Long();
- case 4 : return new Vector4D.Long();
- default : return new VectorND.Long(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXsTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXsTest.java
deleted file mode 100644
index 9467043..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXsTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXsTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.Short();
- case 2 : return new Vector2D.Short();
- case 3 : return new Vector3D.Short();
- case 4 : return new Vector4D.Short();
- default : return new VectorND.Short(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXubTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXubTest.java
deleted file mode 100644
index b0fe4ac..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXubTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXubTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.UByte();
- case 2 : return new Vector2D.UByte();
- case 3 : return new Vector3D.UByte();
- case 4 : return new Vector4D.UByte();
- default : return new VectorND.UByte(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXuiTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXuiTest.java
deleted file mode 100644
index ad2fd8a..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXuiTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXuiTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.UInt();
- case 2 : return new Vector2D.UInt();
- case 3 : return new Vector3D.UInt();
- case 4 : return new Vector4D.UInt();
- default : return new VectorND.UInt(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXusTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXusTest.java
deleted file mode 100644
index 6906c7d..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorXusTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.geometries.math;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorXusTest extends AbstractVectorTest{
-
- @Override
- protected int[] getSupportedDimensions() {
- return new int[]{1,2,3,4,5,6};
- }
-
- @Override
- protected Tuple create(int dim) {
- switch (dim) {
- case 1 : return new Vector1D.UShort();
- case 2 : return new Vector2D.UShort();
- case 3 : return new Vector3D.UShort();
- case 4 : return new Vector4D.UShort();
- default : return new VectorND.UShort(dim);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorsTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorsTest.java
deleted file mode 100644
index 93ae447..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/VectorsTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.geometries.math;
-
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometry.GeneralEnvelope;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class VectorsTest {
-
- @Test
- public void octEncodingTest(){
-
- Vector3D.Float normal = new Vector3D.Float(1,0,0);
- byte[] bytes = Vectors.toOctByte(normal);
- Vector3D.Float res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0,1,0);
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0,0,1);
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0.5f,0,0.5f);
- normal.normalize();
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(-1,0,0);
- normal.normalize();
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0,-1,0);
- normal.normalize();
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0,0,-1);
- normal.normalize();
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .01f);
-
- normal = new Vector3D.Float(0,-0.5f,0.5f);
- normal.normalize();
- bytes = Vectors.toOctByte(normal);
- res = Vectors.octToNormal(bytes[0], bytes[1]);
- assertArrayEquals(normal.toArrayFloat(), res.toArrayFloat(), .02f);
- }
-
- @Test
- public void quantizeTransformTupleTest() throws MismatchedDimensionException, TransformException {
-
- final GeneralEnvelope quantizeBox = new GeneralEnvelope(3);
- quantizeBox.setRange(0, 0, 100);
- quantizeBox.setRange(1, 100, 300);
- quantizeBox.setRange(2, -300, -100);
-
- final Vector3D.Double coord1 = new Vector3D.Double(0,100,-300);
- final Vector3D.Double coord2 = new Vector3D.Double(100,300,-100);
-
- final Tuple dp1 = Vectors.toQuantizedEncoding(coord1, quantizeBox, 32767, null);
- final Tuple dp2 = Vectors.toQuantizedEncoding(coord2, quantizeBox, 32767, null);
-
- assertEquals(new Vector3D.Double(0, 0, 0), dp1);
- assertEquals(new Vector3D.Double(32767, 32767, 32767), dp2);
- assertEquals(DataType.USHORT, dp1.getDataType());
- assertEquals(DataType.USHORT, dp2.getDataType());
-
- }
-
- private static final double DELTA = 1e-8;
-
- @Test
- public void quantizeTransformTest() throws MismatchedDimensionException, TransformException {
-
- final GeneralEnvelope quantizeBox = new GeneralEnvelope(3);
- quantizeBox.setRange(0, 0, 100);
- quantizeBox.setRange(1, 100, 300);
- quantizeBox.setRange(2, -300, -100);
-
- MathTransform trs = Vectors.quantizedTransform(quantizeBox, 32767);
-
- final Vector3D.Double coord1 = new Vector3D.Double(0,100,-300);
- final Vector3D.Double coord2 = new Vector3D.Double(100,300,-100);
-
- coord1.transform(trs);
- coord2.transform(trs);
-
- assertArrayEquals(new double[] {0, 0, 0}, coord1.toArrayDouble(), DELTA);
- assertArrayEquals(new double[] {32767, 32767, 32767}, coord2.toArrayDouble(), DELTA);
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveIndexesTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveIndexesTest.java
deleted file mode 100644
index 976bf77..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveIndexesTest.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveIndexes;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- * In those tests created index may change because of hash maps and set sorting.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class PrimitiveIndexesTest {
-
- /**
- * Check the solution creation methods generated the expected solutions.
- */
- @Test
- public void testCreateSolutions() {
-
- //case where a winding extra triangle is needed
- final int[] s1 = new int[]{0,1,2};
- final int[] s2 = new int[]{3,4,5};
- final int[] s3 = new int[]{6,7,8};
-
- final List<int[]> solutions1 = createSolutions(s1, s2, s3);
- assertEquals(6, solutions1.size());
- assertArrayEquals(new int[]{0,1,2, 2,2,3, 3,4,5, 5,5,6, 6,7,8}, solutions1.get(0));
- assertArrayEquals(new int[]{0,1,2, 2,2,6, 6,7,8, 8,8,3, 3,4,5}, solutions1.get(1));
- assertArrayEquals(new int[]{3,4,5, 5,5,0, 0,1,2, 2,2,6, 6,7,8}, solutions1.get(2));
- assertArrayEquals(new int[]{3,4,5, 5,5,6, 6,7,8, 8,8,0, 0,1,2}, solutions1.get(3));
- assertArrayEquals(new int[]{6,7,8, 8,8,0, 0,1,2, 2,2,3, 3,4,5}, solutions1.get(4));
- assertArrayEquals(new int[]{6,7,8, 8,8,3, 3,4,5, 5,5,0, 0,1,2}, solutions1.get(5));
-
-
- //case where a winding extra triangle is not needed
- final int[] s4 = new int[]{0,1,2,3};
- final int[] s5 = new int[]{4,5,6,7};
-
- final List<int[]> solutions2 = createSolutions(s4, s5);
- assertEquals(2, solutions2.size());
- assertArrayEquals(new int[]{0,1,2,3, 3,4, 4,5,6,7}, solutions2.get(0));
- assertArrayEquals(new int[]{4,5,6,7, 7,0, 0,1,2,3}, solutions2.get(1));
- }
-
- /**
- * Single triangle sanity test case.
- *
- * 1
- * +
- * |\
- * | \
- * +--+
- * 0 2
- *
- * possible solutions : [0,1,2] or [1,2,0] or [2,0,1]
- */
- @Test
- public void testToStripSingleTriangle() {
-
- final TupleArray index = TupleArrays.of(1, 0, 1, 2);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- assertTrue(matchAny(ts,
- new int[]{0,1,2},
- new int[]{1,2,0},
- new int[]{2,0,1}
- ));
- }
-
- /**
- * Simplest case with two triangles already in strip order.
- * triangles are in clockwise direction.
- *
- * 1 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 2
- *
- * possible solutions : [0,1,2,3] or [3,2,1,0]
- */
- @Test
- public void testToStripTwoNeighorTriangles() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2,
- 2, 1, 3);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- assertTrue(matchAny(ts,
- new int[]{0,1,2,3},
- new int[]{3,2,1,0}
- ));
- }
-
- /**
- * Two complete separate triangles.
- *
- * 1 4
- * + +
- * |\ |\
- * | \ | \
- * +--+ +--+
- * 0 2 3 5
- *
- * possible solutions :
- * [0,1,2] or [1,2,0] or [2,0,1]
- * and
- * [3,4,5] or [4,5,3] or [5,3,4]
- *
- */
- @Test
- public void testToStripTwoSeparateTriangles() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2,
- 3, 4, 5);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- final int[] s1_0 = new int[]{0,1,2};
- final int[] s1_1 = new int[]{1,2,0};
- final int[] s1_2 = new int[]{2,0,1};
- final int[] s2_0 = new int[]{3,4,5};
- final int[] s2_1 = new int[]{4,5,3};
- final int[] s2_2 = new int[]{5,3,4};
- assertTrue(
- matchAny(ts, createSolutions(s1_0, s2_0)) ||
- matchAny(ts, createSolutions(s1_0, s2_1)) ||
- matchAny(ts, createSolutions(s1_0, s2_2)) ||
- matchAny(ts, createSolutions(s1_1, s2_0)) ||
- matchAny(ts, createSolutions(s1_1, s2_1)) ||
- matchAny(ts, createSolutions(s1_1, s2_2)) ||
- matchAny(ts, createSolutions(s1_2, s2_0)) ||
- matchAny(ts, createSolutions(s1_2, s2_1)) ||
- matchAny(ts, createSolutions(s1_2, s2_2))
- );
- }
-
- /**
- * Two triangles with incompatible winding.
- * first is clockwise, the second is counter-clockwise.
- *
- * 1 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 2
- *
- * possible solutions :
- * [0,1,2] or [1,2,0] or [2,0,1]
- * and
- * [1,2,3] or [2,3,1] or [3,1,2]
- *
- */
- @Test
- public void testToStripTwoIncompatibleTriangles() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2,
- 1, 2, 3);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- final int[] s1_0 = new int[]{0,1,2};
- final int[] s1_1 = new int[]{1,2,0};
- final int[] s1_2 = new int[]{2,0,1};
- final int[] s2_0 = new int[]{1,2,3};
- final int[] s2_1 = new int[]{2,3,1};
- final int[] s2_2 = new int[]{3,1,2};
- assertTrue(
- matchAny(ts, createSolutions(s1_0, s2_0)) ||
- matchAny(ts, createSolutions(s1_0, s2_1)) ||
- matchAny(ts, createSolutions(s1_0, s2_2)) ||
- matchAny(ts, createSolutions(s1_1, s2_0)) ||
- matchAny(ts, createSolutions(s1_1, s2_1)) ||
- matchAny(ts, createSolutions(s1_1, s2_2)) ||
- matchAny(ts, createSolutions(s1_2, s2_0)) ||
- matchAny(ts, createSolutions(s1_2, s2_1)) ||
- matchAny(ts, createSolutions(s1_2, s2_2))
- );
- }
-
- /**
- * Triangle triangles linked as a single strip.
- * triangles are in clockwise direction.
- *
- * 6 3 0 2
- * +--+--+--+
- * |\ |\ |\ |
- * | \| \| \|
- * +--+--+--+
- * 4 1 5 7
- *
- * Because winding order must be preserved
- * expected indexes can be :
- * - [4,6,1,3,5,0,7,2]
- * - [2,7,0,5,3,1,6,4]
- */
- @Test
- public void testToStripNeighborTriangles() {
- final TupleArray index = TupleArrays.of(1,
- 7, 0, 2,
- 5, 0, 7,
- 5, 3, 0,
- 1, 3, 5,
- 1, 6, 3,
- 4, 6, 1);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- final int[] s0 = new int[]{4,6,1,3,5,0,7,2};
- final int[] s1 = new int[]{2,7,0,5,3,1,6,4};
-
- assertTrue(matchAny(ts,s0, s1));
- }
-
- /**
- * Triangle strips side by side must be linked with degenerated triangles.
- * triangles are in counterclockwise direction.
- *
- * 6 3 0 2
- * +--+--+--+
- * |\ |\ |\ |
- * | \| \| \|
- * +--+--+--+
- * 4 1 5 7
- *
- * Because winding order must be preserved
- * expected indexes are 3 strips :
- * - [4,1,6,3] or [3,6,1,4]
- * - [1,5,3,0] or [0,3,5,1]
- * - [5,7,0,2] or [2,0,7,5]
- * each connected by a degenerated triangle
- */
- @Test
- public void testToStripNeighborTrianglesDegenerate() {
- final TupleArray index = TupleArrays.of(1,
- 7, 2, 0,
- 5, 7, 0,
- 5, 0, 3,
- 1, 5, 3,
- 1, 3, 6,
- 4, 1, 6);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangleStrip(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
-
- final int[] s1_0 = new int[]{4,1,6,3};
- final int[] s1_1 = new int[]{3,6,1,4};
- final int[] s2_0 = new int[]{1,5,3,0};
- final int[] s2_1 = new int[]{0,3,5,1};
- final int[] s3_0 = new int[]{5,7,0,2};
- final int[] s3_1 = new int[]{2,0,7,5};
-
- assertTrue(
- matchAny(ts,createSolutions(s1_0, s2_0, s3_0)) ||
- matchAny(ts,createSolutions(s1_0, s2_0, s3_1)) ||
- matchAny(ts,createSolutions(s1_0, s2_1, s3_0)) ||
- matchAny(ts,createSolutions(s1_0, s2_1, s3_1)) ||
- matchAny(ts,createSolutions(s1_1, s2_0, s3_0)) ||
- matchAny(ts,createSolutions(s1_1, s2_0, s3_1)) ||
- matchAny(ts,createSolutions(s1_1, s2_1, s3_0)) ||
- matchAny(ts,createSolutions(s1_1, s2_1, s3_1)
- ));
- }
-
- /**
- * Simplest case with two triangles strip.
- * triangles are in clockwise direction.
- *
- * 1 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 2
- *
- * possible solutions : [0,1,2,3] or [3,2,1,0]
- */
- @Test
- public void testToTriangles() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2, 3);
-
- final int[] ts = MeshPrimitiveIndexes.toTriangles(index, MeshPrimitive.Type.TRIANGLE_STRIP).toArrayInt();
- assertArrayEquals(new int[]{0,1,2,1,3,2}, ts);
- }
-
- /**
- * Simplest case with two triangles.
- * triangles are in clockwise direction.
- *
- * 1 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 2
- *
- * a possible solution : [0,2,1,2,3,1]
- */
- @Test
- public void testReverseTriangles() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2,
- 2, 1, 3);
-
- final int[] ts = MeshPrimitiveIndexes.reverseTriangles(index, MeshPrimitive.Type.TRIANGLES).toArrayInt();
- assertArrayEquals(new int[]{0,2,1,2,3,1}, ts);
- }
-
- /**
- * Simplest case with two triangles strip already in strip order.
- * triangles are in clockwise direction.
- *
- * 1 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 2
- *
- * possible solutions : [0,1,2,3] or [3,2,1,0]
- */
- @Test
- public void testReverseTriangleStrip() {
-
- final TupleArray index = TupleArrays.of(1,
- 0, 1, 2, 3);
-
- final int[] ts = MeshPrimitiveIndexes.reverseTriangles(index, MeshPrimitive.Type.TRIANGLE_STRIP).toArrayInt();
- matchAny(ts, new int[]{0,2,1,3});
- }
-
- private static boolean matchAny(int[] result, int[] ... solutions) {
- return matchAny(result, Arrays.asList(solutions));
- }
-
- private static boolean matchAny(int[] result, List<int[]> solutions) {
- for (int[] solution : solutions) {
- if (Arrays.equals(result, solution)) {
- return true;
- }
- }
- return false;
- }
-
- private static List<int[]> createSolutions(int[] ... strips) {
- return createSolutions(Arrays.asList(strips));
- }
-
- private static List<int[]> createSolutions(List<int[]> strips) {
- final List<int[]> solutions = new ArrayList<>();
-
- if (strips.size() == 1) {
- solutions.add(strips.get(0));
- return solutions;
- }
-
- for (int i = 0, n = strips.size(); i < n; i++) {
- final int[] strip = strips.get(i);
- List<int[]> subsolutions = new ArrayList<>();
- subsolutions.addAll(strips.subList(0, i));
- subsolutions.addAll(strips.subList(i+1, strips.size()));
- subsolutions = createSolutions(subsolutions);
-
- for (int[] solution : subsolutions) {
- solutions.add(degeneratedStrip(strip, solution));
- }
- }
-
- return solutions;
- }
-
- /**
- * Connect each strip with a degenerated triangle.
- */
- private static int[] degeneratedStrip(int[] ... strips) {
- final List<Integer> ds = new ArrayList<>();
- for (int[] strip : strips) {
- if (!ds.isEmpty()) {
- if (ds.size() % 2 != 0) {
- //extra triangle to preserve winding
- ds.add(ds.get(ds.size()-1));
- }
- //add degenerated triangle
- ds.add(ds.get(ds.size()-1));
- ds.add(strip[0]);
- }
- for (int i : strip) ds.add(i);
- }
- final int[] array = new int[ds.size()];
- for (int i = 0; i < array.length; i++) array[i] = ds.get(i);
- return array;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveTest.java
deleted file mode 100644
index e41360d..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveTest.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.Arrays;
-import java.util.List;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.math.TupleArrays;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class PrimitiveTest {
-
- /**
- * Test remove duplicate method.
- * In this test vertex 0 and 3 are duplicates.
- */
- @Test
- public void testRemoveDuplicatesByPosition() {
-
- final MeshPrimitive primitive = new MeshPrimitive.TriangleStrip();
- primitive.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3),
- 0,0,0, // <- duplicate
- 0,1,0,
- 1,0,0,
- 0,0,0, // <- duplicate
- 2,0,0));
- primitive.setNormals(TupleArrays.of(3,
- 1,0,0, // <- duplicate
- 2,0,0,
- 3,0,0,
- 4,1,1, // <- duplicate, will not be preserved
- 5,0,0));
- primitive.setIndex(TupleArrays.ofUnsigned(1,
- 0, 1, 2, 3,4));
-
- primitive.removeDuplicatesByPosition();
-
- final int[] positions = primitive.getPositions().toArrayInt();
- final int[] normals = primitive.getNormals().toArrayInt();
- final int[] index = primitive.getIndex().toArrayInt();
-
- assertArrayEquals(new int[]{0,1,2,0,3}, index);
- assertArrayEquals(new int[]{0,0,0, 0,1,0, 1,0,0, 2,0,0}, positions);
- assertArrayEquals(new int[]{1,0,0, 2,0,0, 3,0,0, 5,0,0}, normals);
-
- }
-
- /**
- * Test concatenating triangles.
- */
- @Test
- public void testConcatenateTriangles() {
-
- final MeshPrimitive ts0 = new MeshPrimitive.Triangles();
- ts0.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2}));
- ts0.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- -1,-1,-1, //an unused position, must be added anyway, not the algo problem at this point
- -1,-1,-1 //an unused position, must be added anyway, not the algo problem at this point
- }));
-
- final MeshPrimitive ts1 = new MeshPrimitive.Triangles();
- ts1.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2}));
- ts1.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- -1,-1,-1 //an unused position, must be added anyway, not the algo problem at this point
- }));
-
- final MeshPrimitive ts2 = new MeshPrimitive.Triangles();
- ts2.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2}));
- ts2.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- -1,-1,-1 //an unused position, must be added anyway, not the algo problem at this point
- }));
-
- final MeshPrimitive ts = Geometries.concatenate(Arrays.asList(ts0, ts1, ts2));
-
- assertArrayEquals(new int[]{
- 0,1,2, // +2 unused positions
- 5,6,7, // +1 unused position
- 9,10,11
- }, ts.getIndex().toArrayInt());
-
- ts.validate();
- }
-
- /**
- * Test concatenating triangle strips.
- * Strips must be joined by a degenerated triangle.
- */
- @Test
- public void testConcatenateTriangleStrip() {
-
- final MeshPrimitive ts0 = new MeshPrimitive.TriangleStrip();
- ts0.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2,3}));
- ts0.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- 5,6,0
- }));
-
- final MeshPrimitive ts1 = new MeshPrimitive.TriangleStrip();
- ts1.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2,3}));
- ts1.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- 5,6,0
- }));
-
- final MeshPrimitive ts2 = new MeshPrimitive.TriangleStrip();
- ts2.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2,3}));
- ts2.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0,
- 5,6,0
- }));
-
- final MeshPrimitive ts = Geometries.concatenate(Arrays.asList(ts0, ts1, ts2));
-
- assertArrayEquals(new int[]{
- 0,1,2,3,
- 3,4, //linking degenerated triangle
- 4,5,6,7,
- 7,8, //linking degenerated triangle
- 8,9,10,11
- }, ts.getIndex().toArrayInt());
-
- ts.validate();
- }
-
- /**
- * Test concatenating triangle strips.
- * strips reuse the same vertices in this test
- * Strips must be joined by a degenerated triangle.
- */
- @Test
- public void testConcatenateTriangleStrip2() {
-
- final MeshPrimitive ts0 = new MeshPrimitive.TriangleStrip();
- ts0.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,2,1}));
- ts0.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0
- }));
-
- final MeshPrimitive ts1 = new MeshPrimitive.TriangleStrip();
- ts1.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,0,0}));
- ts1.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0
- }));
-
- final MeshPrimitive ts2 = new MeshPrimitive.TriangleStrip();
- ts2.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,1,1,2}));
- ts2.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- 2,3,0,
- 4,5,0
- }));
-
- final MeshPrimitive ts = Geometries.concatenate(Arrays.asList(ts0, ts1, ts2));
-
- assertArrayEquals(new int[]{
- 0,1,2,1,
- 1,3, //linking degenerated triangle
- 3,4,3,3,
- 3,5, //linking degenerated triangle
- 5,6,6,7
- }, ts.getIndex().toArrayInt());
-
- ts.validate();
- }
-
- /**
- * Test splitting triangles.
- */
- @Test
- public void testSplitTriangles() {
-
- final MeshPrimitive ts0 = new MeshPrimitive.Triangles();
- ts0.setIndex(TupleArrays.ofUnsigned(1, new int[]{0,2,3, 3,0,2}));
- ts0.setPositions(TupleArrays.of(Geometries.getUndefinedCRS(3), new float[]{
- 0,1,0,
- -1,-1,-1, //an unused position, must be added anyway, not the algo problem at this point
- 2,3,0,
- 4,5,0,
- -1,-1,-1 //an unused position, must be added anyway, not the algo problem at this point
- }));
-
- final List<MeshPrimitive> primitives = Geometries.split(ts0, 3);
- assertEquals(2, primitives.size());
- final MeshPrimitive p0 = primitives.get(0);
- final MeshPrimitive p1 = primitives.get(1);
-
- assertEquals(1, p0.getAttributesType().getAttributeNames().size());
- assertEquals(1, p1.getAttributesType().getAttributeNames().size());
- assertEquals(MeshPrimitive.Type.TRIANGLES, p0.getType());
- assertEquals(MeshPrimitive.Type.TRIANGLES, p1.getType());
-
- assertArrayEquals(new int[]{0,1,2}, p0.getIndex().toArrayInt());
- assertArrayEquals(new int[]{0,1,2}, p1.getIndex().toArrayInt());
- assertArrayEquals(new int[]{0,1,0, 2,3,0, 4,5,0}, p0.getPositions().toArrayInt());
- assertArrayEquals(new int[]{4,5,0, 0,1,0, 2,3,0}, p1.getPositions().toArrayInt());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveVisitorTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveVisitorTest.java
deleted file mode 100644
index 0bc8986..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/mesh/PrimitiveVisitorTest.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * 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.geometries.mesh;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.TIN;
-import org.apache.sis.geometries.Triangle;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveVisitor;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector3D;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- * Tests for MeshGeometry visitor.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class PrimitiveVisitorTest {
-
- private static final CoordinateReferenceSystem CRS3D = Geometries.getUndefinedCRS(3);
- private static final SampleSystem SS3D = SampleSystem.of(CRS3D);
-
-
- /**
- * Test visiting Points.
- */
- @Test
- public void testPoints() {
-
- final MeshPrimitive.Points geometry = new MeshPrimitive.Points();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5));
-
- final List<String> expected = Arrays.asList(
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry collection
- assertEquals(2, geometry.getNumGeometries());
- assertEquals(new Vector3D.Double(SS3D, 0, 1, 2), geometry.getGeometryN(0).getPosition());
- assertEquals(new Vector3D.Double(SS3D, 3, 4, 5), geometry.getGeometryN(1).getPosition());
- }
-
- /**
- * Test visiting indexed Points.
- */
- @Test
- public void testIndexedPoints() {
-
- final MeshPrimitive.Points geometry = new MeshPrimitive.Points();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 0));
-
- final List<String> expected = Arrays.asList(
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:0 POSITION[0.0, 1.0, 2.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry collection
- assertEquals(3, geometry.getNumGeometries());
- assertEquals(new Vector3D.Double(SS3D, 0, 1, 2), geometry.getGeometryN(0).getPosition());
- assertEquals(new Vector3D.Double(SS3D, 3, 4, 5), geometry.getGeometryN(1).getPosition());
- assertEquals(new Vector3D.Double(SS3D, 0, 1, 2), geometry.getGeometryN(2).getPosition());
- }
-
- /**
- * Test visiting Lines.
- */
- @Test
- public void testLines() {
-
- final MeshPrimitive.Lines geometry = new MeshPrimitive.Lines();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
-
- final List<String> expected = Arrays.asList(
- "LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry collection
- assertEquals(2, geometry.getNumGeometries());
- assertEquals("LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)", geometry.getGeometryN(0).asText());
- assertEquals("LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)", geometry.getGeometryN(1).asText());
- }
-
- /**
- * Test visiting indexed Lines.
- */
- @Test
- public void testIndexedLines() {
-
- final MeshPrimitive.Lines geometry = new MeshPrimitive.Lines();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 2, 3, 1, 3));
-
- final List<String> expected = Arrays.asList(
- "LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]",
- "LINESTRING (3.0 4.0 5.0, 9.0 10.0 11.0)",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry collection
- assertEquals(3, geometry.getNumGeometries());
- assertEquals("LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)", geometry.getGeometryN(0).asText());
- assertEquals("LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)", geometry.getGeometryN(1).asText());
- assertEquals("LINESTRING (3.0 4.0 5.0, 9.0 10.0 11.0)", geometry.getGeometryN(2).asText());
- }
-
- /**
- * Test visiting Line strip.
- */
- @Test
- public void testLineStrip() {
-
- final MeshPrimitive.LineStrip geometry = new MeshPrimitive.LineStrip();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
-
- final List<String> expected = Arrays.asList(
- "LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "LINESTRING (3.0 4.0 5.0, 6.0 7.0 8.0)",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]"
- );
- visit(geometry, expected);
-
- //test geometry as LineString
- assertTrue(geometry instanceof LineString);
- assertEquals("LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0, 6.0 7.0 8.0, 9.0 10.0 11.0)", geometry.asText());
- }
-
- /**
- * Test visiting indexed Line strip.
- */
- @Test
- public void testIndexedLineStrip() {
-
- final MeshPrimitive.LineStrip geometry = new MeshPrimitive.LineStrip();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 2, 3, 0, 2));
-
- final List<String> expected = Arrays.asList(
- "LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0)",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "LINESTRING (3.0 4.0 5.0, 6.0 7.0 8.0)",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "LINESTRING (6.0 7.0 8.0, 9.0 10.0 11.0)",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]",
- "LINESTRING (9.0 10.0 11.0, 0.0 1.0 2.0)",
- "V:3 POSITION[9.0, 10.0, 11.0]",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "LINESTRING (0.0 1.0 2.0, 6.0 7.0 8.0)",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:2 POSITION[6.0, 7.0, 8.0]"
- );
- visit(geometry, expected);
-
- //test geometry as LineString
- assertTrue(geometry instanceof LineString);
- assertEquals("LINESTRING (0.0 1.0 2.0, 3.0 4.0 5.0, 6.0 7.0 8.0, 9.0 10.0 11.0, 0.0 1.0 2.0, 6.0 7.0 8.0)", geometry.asText());
- }
-
- /**
- * Test visiting Triangles.
- */
- @Test
- public void testTriangles() {
-
- final MeshPrimitive.Triangles geometry = new MeshPrimitive.Triangles();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11,
- 12,13,14,
- 15,16,17));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "TRIANGLE ((9.0 10.0 11.0,12.0 13.0 14.0,15.0 16.0 17.0))",
- "V:3 POSITION[9.0, 10.0, 11.0]",
- "V:4 POSITION[12.0, 13.0, 14.0]",
- "V:5 POSITION[15.0, 16.0, 17.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(2, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((9.0 10.0 11.0,12.0 13.0 14.0,15.0 16.0 17.0))", geometry.getPatchN(1).asText());
- }
-
- /**
- * Test visiting indexed Triangles.
- */
- @Test
- public void testIndexedTriangles() {
-
- final MeshPrimitive.Triangles geometry = new MeshPrimitive.Triangles();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,1,2,
- 3,4,5,
- 6,7,8,
- 9,10,11));
- geometry.setIndex(TupleArrays.ofUnsigned(1, 0, 1, 2, 2, 3, 1));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))",
- "V:0 POSITION[0.0, 1.0, 2.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "TRIANGLE ((6.0 7.0 8.0,9.0 10.0 11.0,3.0 4.0 5.0))",
- "V:2 POSITION[6.0, 7.0, 8.0]",
- "V:3 POSITION[9.0, 10.0, 11.0]",
- "V:1 POSITION[3.0, 4.0, 5.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(2, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 1.0 2.0,3.0 4.0 5.0,6.0 7.0 8.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((6.0 7.0 8.0,9.0 10.0 11.0,3.0 4.0 5.0))", geometry.getPatchN(1).asText());
- }
-
- /**
- * Test visiting Triangle Fan.
- * Triangles index is clockwise.
- *
- * 1 2
- * +--+
- * | /|
- * |/ |
- * 0 +--+ 3
- * |\ |
- * | \|
- * +--+
- * 5 4
- */
- @Test
- public void testTriangleFan() {
-
- final MeshPrimitive.TriangleFan geometry = new MeshPrimitive.TriangleFan();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0, 0,0,
- 0, 1,0,
- 1, 1,0,
- 1, 0,0,
- 1,-1,0,
- 0,-1,0));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:2 POSITION[1.0, 1.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:2 POSITION[1.0, 1.0, 0.0]",
- "V:3 POSITION[1.0, 0.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 0.0 0.0,1.0 -1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 0.0, 0.0]",
- "V:4 POSITION[1.0, -1.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 -1.0 0.0,0.0 -1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:4 POSITION[1.0, -1.0, 0.0]",
- "V:5 POSITION[0.0, -1.0, 0.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(4, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0))", geometry.getPatchN(1).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 0.0 0.0,1.0 -1.0 0.0))", geometry.getPatchN(2).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 -1.0 0.0,0.0 -1.0 0.0))", geometry.getPatchN(3).asText());
- }
-
- /**
- * Test visiting Triangle Fan.
- * Triangles index is clockwise.
- *
- * 1 2
- * +--+
- * | /|
- * |/ |
- * 0 +--+ 3
- * |\ |
- * | \|
- * +--+
- * 5 4
- */
- @Test
- public void testIndexedTriangleFan() {
-
- final MeshPrimitive.TriangleFan geometry = new MeshPrimitive.TriangleFan();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0, 0,0,
- 0, 1,0,
- 1, 1,0,
- 1, 0,0,
- 1,-1,0,
- 0,-1,0));
- geometry.setIndex(TupleArrays.ofUnsigned(1,
- 0, 1, 2, 3, 4, 5, 2));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:2 POSITION[1.0, 1.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:2 POSITION[1.0, 1.0, 0.0]",
- "V:3 POSITION[1.0, 0.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 0.0 0.0,1.0 -1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 0.0, 0.0]",
- "V:4 POSITION[1.0, -1.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,1.0 -1.0 0.0,0.0 -1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:4 POSITION[1.0, -1.0, 0.0]",
- "V:5 POSITION[0.0, -1.0, 0.0]",
- "TRIANGLE ((0.0 0.0 0.0,0.0 -1.0 0.0,1.0 1.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:5 POSITION[0.0, -1.0, 0.0]",
- "V:2 POSITION[1.0, 1.0, 0.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(5, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0))", geometry.getPatchN(1).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 0.0 0.0,1.0 -1.0 0.0))", geometry.getPatchN(2).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,1.0 -1.0 0.0,0.0 -1.0 0.0))", geometry.getPatchN(3).asText());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,0.0 -1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(4).asText());
- }
-
- /**
- * Test visiting Triangle Strip.
- * Triangles index is clockwise.
- *
- * 1 3 5 7
- * +--+--+--+
- * |\ |\ |\ |
- * | \| \| \|
- * +--+--+--+
- * 0 2 4 6
- */
- @Test
- public void testTriangleStrip() {
-
- final MeshPrimitive.TriangleStrip geometry = new MeshPrimitive.TriangleStrip();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,0,0,
- 0,1,0,
- 1,0,0,
- 1,1,0,
- 2,0,0,
- 2,1,0,
- 3,0,0,
- 3,1,0));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 0.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "TRIANGLE ((1.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "TRIANGLE ((1.0 0.0 0.0,1.0 1.0 0.0,2.0 0.0 0.0))",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "TRIANGLE ((2.0 0.0 0.0,1.0 1.0 0.0,2.0 1.0 0.0))",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "TRIANGLE ((2.0 0.0 0.0,2.0 1.0 0.0,3.0 0.0 0.0))",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "V:6 POSITION[3.0, 0.0, 0.0]",
- "TRIANGLE ((3.0 0.0 0.0,2.0 1.0 0.0,3.0 1.0 0.0))",
- "V:6 POSITION[3.0, 0.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "V:7 POSITION[3.0, 1.0, 0.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(6, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 0.0 0.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((1.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(1).asText());
- assertEquals("TRIANGLE ((1.0 0.0 0.0,1.0 1.0 0.0,2.0 0.0 0.0))", geometry.getPatchN(2).asText());
- assertEquals("TRIANGLE ((2.0 0.0 0.0,1.0 1.0 0.0,2.0 1.0 0.0))", geometry.getPatchN(3).asText());
- assertEquals("TRIANGLE ((2.0 0.0 0.0,2.0 1.0 0.0,3.0 0.0 0.0))", geometry.getPatchN(4).asText());
- assertEquals("TRIANGLE ((3.0 0.0 0.0,2.0 1.0 0.0,3.0 1.0 0.0))", geometry.getPatchN(5).asText());
- }
-
- /**
- * Test visiting Triangle Strip.
- * Triangles index is clockwise.
- *
- * 1 3 5
- * +--+--+
- * |\ |\ |\
- * | \| \| \
- * +--+--+--+
- * 0 2 4 6
- */
- @Test
- public void testIndexedTriangleStrip() {
-
- final MeshPrimitive.TriangleStrip geometry = new MeshPrimitive.TriangleStrip();
- geometry.setPositions(TupleArrays.of(CRS3D,
- 0,0,0,
- 0,1,0,
- 1,0,0,
- 1,1,0,
- 2,0,0,
- 2,1,0,
- 3,0,0,
- 3,1,0));
- geometry.setIndex(TupleArrays.ofUnsigned(1,
- 0, 1, 2, 3, 4, 5, 6, 3));
-
- final List<String> expected = Arrays.asList(
- "TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 0.0 0.0))",
- "V:0 POSITION[0.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "TRIANGLE ((1.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "V:1 POSITION[0.0, 1.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "TRIANGLE ((1.0 0.0 0.0,1.0 1.0 0.0,2.0 0.0 0.0))",
- "V:2 POSITION[1.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "TRIANGLE ((2.0 0.0 0.0,1.0 1.0 0.0,2.0 1.0 0.0))",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "TRIANGLE ((2.0 0.0 0.0,2.0 1.0 0.0,3.0 0.0 0.0))",
- "V:4 POSITION[2.0, 0.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "V:6 POSITION[3.0, 0.0, 0.0]",
- "TRIANGLE ((3.0 0.0 0.0,2.0 1.0 0.0,1.0 1.0 0.0))",
- "V:6 POSITION[3.0, 0.0, 0.0]",
- "V:5 POSITION[2.0, 1.0, 0.0]",
- "V:3 POSITION[1.0, 1.0, 0.0]"
- );
-
- visit(geometry, expected);
-
- //test geometry as TIN
- assertTrue(geometry instanceof TIN);
- assertEquals(6, geometry.getNumPatches());
- assertEquals("TRIANGLE ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 0.0 0.0))", geometry.getPatchN(0).asText());
- assertEquals("TRIANGLE ((1.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(1).asText());
- assertEquals("TRIANGLE ((1.0 0.0 0.0,1.0 1.0 0.0,2.0 0.0 0.0))", geometry.getPatchN(2).asText());
- assertEquals("TRIANGLE ((2.0 0.0 0.0,1.0 1.0 0.0,2.0 1.0 0.0))", geometry.getPatchN(3).asText());
- assertEquals("TRIANGLE ((2.0 0.0 0.0,2.0 1.0 0.0,3.0 0.0 0.0))", geometry.getPatchN(4).asText());
- assertEquals("TRIANGLE ((3.0 0.0 0.0,2.0 1.0 0.0,1.0 1.0 0.0))", geometry.getPatchN(5).asText());
- }
-
- private void visit(MeshPrimitive geometry, List<String> exp) {
- final List<String> expected = new ArrayList<>(exp);
-
- final MeshPrimitiveVisitor visitor = new MeshPrimitiveVisitor(geometry) {
- @Override
- protected void visit(Triangle candidate) {
- assertEquals(expected.remove(0), candidate.toString());
- super.visit(candidate);
- }
-
- @Override
- protected void visit(LineString candidate) {
- assertEquals(expected.remove(0), candidate.toString());
- super.visit(candidate);
- }
-
- @Override
- protected void visit(Point candidate) {
- assertEquals(expected.remove(0), candidate.toString());
- super.visit(candidate);
- }
-
- @Override
- protected void visit(MeshPrimitive.Vertex vertex) {
- assertEquals(expected.remove(0), vertex.toString());
- }
- };
- visitor.visit();
-
- assertEquals(0, expected.size());
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/SutherlandHogmanTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/SutherlandHogmanTest.java
deleted file mode 100644
index 04e0d94..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/SutherlandHogmanTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.geometries.operation;
-
-import java.util.List;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector2D;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SutherlandHogmanTest {
-
- @Test
- public void testRectangleClip(){
-
- final TupleArray subject = TupleArrays.of(2,
- 0.0, 0.0,
- 10.0, 0.0,
- 10.0, 20.0,
- 0.0, 20.0,
- 0.0, 0.0);
-
- final TupleArray clip = TupleArrays.of(2,
- 5.0, 8.0,
- 15.0, 8.0,
- 15.0, 24.0,
- 5.0, 24.0,
- 5.0, 8.0
- );
-
- final List<Tuple> result = SutherlandHodgman.clip(TupleArrays.asList(subject), TupleArrays.asList(clip));
- assertEquals(4,result.size());
- assertEquals(new Vector2D.Double( 5, 8),result.get(0));
- assertEquals(new Vector2D.Double(10, 8),result.get(1));
- assertEquals(new Vector2D.Double(10, 20),result.get(2));
- assertEquals(new Vector2D.Double( 5, 20),result.get(3));
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/spatialanalysis2d/IsoBandTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/spatialanalysis2d/IsoBandTest.java
deleted file mode 100644
index 20ba0b2..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/operation/spatialanalysis2d/IsoBandTest.java
+++ /dev/null
@@ -1,662 +0,0 @@
-/*
- * 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.geometries.operation.spatialanalysis2d;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Polygon;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.Geometries;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArrays;
-import static org.apache.sis.geometries.operation.spatialanalysis2d.ISOLine.interpolateToCoord2D;
-import org.apache.sis.measure.NumberRange;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-
-public class IsoBandTest {
-
- static double tolerance;
-
- @BeforeAll
- public static void setUp() {
- tolerance = 0.0001;
- }
-
- @Test
- public void testInterpolateToCoord2D() {
-
- final double[] p0 = new double[]{0, 0, 1.5};
- final double[] p1 = new double[]{2, 0, 1.5};
- assertThrows(IllegalStateException.class, () -> interpolateToCoord2D(p0, p1, 1));
-
- double[] pX = new double[]{2, 0, 0.5};
- Coordinate interpolated = interpolateToCoord2D(p0, pX, 1);
- assertNotNull(interpolated);
- assertArrayEquals(new double[]{1, 0, 1}, new double[]{interpolated.getX(), interpolated.getY(), interpolated.getZ()}, tolerance);
-
- pX = new double[]{0, 2, 0.5};
- interpolated = interpolateToCoord2D(p0, pX, 1);
- assertNotNull(interpolated);
- assertArrayEquals(new double[]{0, 1, 1}, new double[]{interpolated.getX(), interpolated.getY(), interpolated.getZ()}, tolerance);
-
- pX = new double[]{2, 2, 0.5};
- interpolated = interpolateToCoord2D(p0, pX, 1);
- assertNotNull(interpolated);
- assertArrayEquals(new double[]{1, 1, 1}, new double[]{interpolated.getX(), interpolated.getY(), interpolated.getZ()}, tolerance);
-
- assertThrows(IllegalStateException.class, () -> interpolateToCoord2D(p0, new double[]{2, 2, 1}, 0.5));
-
- final double[] p2 = new double[]{0, 0, 2};
- final double[] p3 = new double[]{2, 0, 0.5};
- Coordinate interpolated1 = interpolateToCoord2D(p2, p3, 1);
- Coordinate interpolated2 = interpolateToCoord2D(p3, p2, 1);
- assertArrayEquals(new double[]{interpolated1.getX(), interpolated1.getY(), interpolated1.getZ()},
- new double[]{interpolated2.getX(), interpolated2.getY(), interpolated2.getZ()},
- tolerance);
- }
-
- @Test
- public void testAllOnBand() {
- List<Polygon> testedPolygons = new ArrayList<>();
-
- final double minStep = 1.;
- final double maxStep = 2.;
-
- final double[] p0 = new double[]{0, 0, 1.5};
- final double[] p1 = new double[]{2, 0, 1.5};
- final double[] p2 = new double[]{1, 1, 1.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
-
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
- assertEquals(4, coordinates.length);
-
- // Check coordinates
- Coordinate[] expected = new Coordinate[]{
- new Coordinate(p0[0], p0[1], p0[2]),
- new Coordinate(p1[0], p1[1], p1[2]),
- new Coordinate(p2[0], p2[1], p2[2]),
- new Coordinate(p0[0], p0[1], p0[2])
- };
-
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- testedPolygons.clear();
-
- ISOBand.computeStepBand(minStep, maxStep, p1, p2, p0, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
-
- testedPolygon = testedPolygons.get(0);
- coordinates = testedPolygon.getCoordinates();
-
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- testedPolygons.clear();
-
- ISOBand.computeStepBand(minStep, maxStep, p1, p0, p2, testedPolygons);
-
- assertNotNull(testedPolygons);
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
-
- testedPolygon = testedPolygons.get(0);
- coordinates = testedPolygon.getCoordinates();
-
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- testedPolygons.clear();
- }
-
- @Test
- public void testAllBelow() {
- List<Polygon> testedPolygons = new ArrayList<>();
-
- final double minStep = 1.;
- final double maxStep = 2.;
-
-
- final double[] p0 = new double[]{0, 0, 0.5};
- final double[] p1 = new double[]{2, 0, 0.5};
- final double[] p2 = new double[]{1, 1, 0.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(0, testedPolygons.size(), "No polygon intersect the band.");
- }
-
- @Test
- public void testAllAbove() {
- List<Polygon> testedPolygons = new ArrayList<>();
-
- final double minStep = 1.;
- final double maxStep = 2.;
-
-
- double[] p0 = new double[]{0, 0, 2.1};
- double[] p1 = new double[]{2, 0, 2.1};
- double[] p2 = new double[]{1, 1, 2.1};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(0, testedPolygons.size(), "No polygon should intersect the band.");
- testedPolygons.clear();
-
- p0 = new double[]{0, 0, 2.5};
- p1 = new double[]{2, 0, 2.5};
- p2 = new double[]{1, 1, 2.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(0, testedPolygons.size(), "No polygon should intersect the band.");
- }
-
- @Test
- public void test1In2Under() {
- List<Polygon> testedPolygons = new ArrayList<>();
-
- final double minStep = 1.;
- final double maxStep = 2.;
-
-
- double[] p0 = new double[]{0, 0, 1.5};
- double[] p1 = new double[]{2, 0, 0.5};
- double[] p2 = new double[]{1, 1, 0.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
-
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- // Check each coordinate
- Coordinate[] expected = new Coordinate[]{
- new Coordinate(p0[0], p0[1], p0[2]),
- interpolateToCoord2D(p1, p0, minStep),
- interpolateToCoord2D(p2, p0, minStep),
- new Coordinate(p0[0], p0[1], p0[2])
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order."
- );
- testedPolygons.clear();
-
- p0 = new double[]{2, 0, 1.5};
- p1 = new double[]{0, 0, 0.5};
- p2 = new double[]{1, 1, 0.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
-
- testedPolygon = testedPolygons.get(0);
- coordinates = testedPolygon.getCoordinates();
-
- // Check each coordinate
- expected = new Coordinate[]{
- new Coordinate(p0[0], p0[1], p0[2]),
- interpolateToCoord2D(p1, p0, minStep),
- interpolateToCoord2D(p2, p0, minStep),
- new Coordinate(p0[0], p0[1], p0[2])
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
- @Test
- public void test2In1Under() {
- List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{0, 0, 1.5};
- double[] p1 = new double[]{2, 0, 1.5};
- double[] p2 = new double[]{1, 1, 0.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- // Check each coordinate
- Coordinate[] expected = new Coordinate[]{
- new Coordinate(p0[0], p0[1], p0[2]),
- new Coordinate(p1[0], p1[1], p1[2]),
- interpolateToCoord2D(p1, p2, minStep),
- interpolateToCoord2D(p2, p0, minStep),
- new Coordinate(p0[0], p0[1], p0[2])
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- testedPolygons.clear();
-
-
- p0 = new double[]{2, 0, 1.6};
- p1 = new double[]{1, 1, 1.5};
- p2 = new double[]{0, 0, 0.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
- testedPolygon = testedPolygons.get(0);
- coordinates = testedPolygon.getCoordinates();
-
-
- // Check each coordinate
- expected = new Coordinate[]{
- new Coordinate(p0[0], p0[1], p0[2]),
- new Coordinate(p1[0], p1[1], p1[2]),
- interpolateToCoord2D(p1, p2, minStep),
- interpolateToCoord2D(p2, p0, minStep),
- new Coordinate(p0[0], p0[1], p0[2])
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
- @Test
- public void test2In1Above() {
- List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{0, 0, 2.5};
- double[] p1 = new double[]{2, 0, 1.5};
- double[] p2 = new double[]{1, 1, 1.2};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- // Check each coordinate
- Coordinate[] expected = new Coordinate[]{
- new Coordinate(p1[0], p1[1], p1[2]),
- new Coordinate(p2[0], p2[1], p2[2]),
- interpolateToCoord2D(p0, p2, maxStep),
- interpolateToCoord2D(p1, p0, maxStep),
- new Coordinate(p1[0], p1[1], p1[2])
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
- @Test
- public void test2Above1In() {
- List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{2, 0, 4.5};
- double[] p1 = new double[]{0, 0, 3.5};
- double[] p2 = new double[]{1, 1, 1.5};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(),
- "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- assertCoordinateEquals(
- interpolateToCoord2D(p0, p2, maxStep),
- interpolateToCoord2D(p2, p0, maxStep), tolerance);
-
- // Check each coordinate
- Coordinate[] expected = new Coordinate[]{
- new Coordinate(p2[0], p2[1], p2[2]),
- interpolateToCoord2D(p1, p2, maxStep),
- interpolateToCoord2D(p0, p2, maxStep),
- new Coordinate(p2[0], p2[1], p2[2]),
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
- @Test
- public void test1Above2Below() {
- List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{2, 0, 4.5};
- double[] p1 = new double[]{0, 0, 0.5};
- double[] p2 = new double[]{1, 1, 0.1};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- // Check each coordinate
- Coordinate p0_p1_max = interpolateToCoord2D(p0, p1, maxStep);
- Coordinate[] expected = new Coordinate[]{
- p0_p1_max,
- interpolateToCoord2D(p0, p1, minStep),
- interpolateToCoord2D(p0, p2, minStep),
- interpolateToCoord2D(p0, p2, maxStep),
- p0_p1_max
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
-
- @Test
- public void test2Above1Below() {
- final List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{2, 0, 4.5};
- double[] p1 = new double[]{0, 0, 3.5};
- double[] p2 = new double[]{1, 1, 0.1};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(),
- "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- assertEquals(5, coordinates.length);
-
- // Check each coordinate
- Coordinate p0_p2_min = interpolateToCoord2D(p0, p2, minStep);
- Coordinate[] expected = new Coordinate[]{
- p0_p2_min,
- interpolateToCoord2D(p0, p2, maxStep),
- interpolateToCoord2D(p1, p2, maxStep),
- interpolateToCoord2D(p1, p2, minStep),
- p0_p2_min
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
- }
-
-
- @Test
- public void test1Above1In1Below() {
- final List<Polygon> testedPolygons = new ArrayList<>();
- final double minStep = 1.;
- final double maxStep = 2.;
-
- double[] p0 = new double[]{2, 0, 4.5};
- double[] p1 = new double[]{0, 0, 1.5};
- double[] p2 = new double[]{1, 1, 0.1};
-
- ISOBand.computeStepBand(minStep, maxStep, p0, p1, p2, testedPolygons);
-
- assertEquals(1, testedPolygons.size(), "There should be exactly one polygon");
- Polygon testedPolygon = testedPolygons.get(0);
- Coordinate[] coordinates = testedPolygon.getCoordinates();
-
- assertEquals(6, coordinates.length);
-
- // Check each coordinate
- final Coordinate p0_p1_max = interpolateToCoord2D(p1, p0, maxStep);
- Coordinate[] expected = new Coordinate[]{
- p0_p1_max,
- new Coordinate(p1[0], p1[1], p1[2]),
- interpolateToCoord2D(p1, p2, minStep),
- interpolateToCoord2D(p2, p0, minStep),
- interpolateToCoord2D(p2, p0, maxStep),
- p0_p1_max
- };
- assertTrue(assertPolygonEquals(expected, coordinates, tolerance),
- "Computed Polygon vertices "+Arrays.toString(coordinates)+"\ndoesn't match the expected polygon's coordinate " +Arrays.toString(expected)+"\nup to permutation and order.");
-
- }
-
- @Test
- public void testBandStrategy() throws FactoryException {
-
- /*
- 3 2
- +--+
- |\ |
- | \|
- +--+
- 0 1
- */
- final double[] positions = new double[]{0, 0, 1., 1, 0, 1., 1, 1, 2., 0, 1, 1.};
- final int[] index = new int[]{3, 1, 0, 3, 2, 1};
-
- final SampleSystem ss = SampleSystem.of(Geometries.PSEUDOGEO_3D);
-
- final MeshPrimitive.Triangles triangles = new MeshPrimitive.Triangles();
- triangles.setPositions(TupleArrays.of(ss, positions));
- triangles.setIndex(TupleArrays.ofUnsigned(1, index));
-
- //Check BOTH
- final double[] steps = new double[]{0., 1., 2.};
- Map<NumberRange<Double>, List<Polygon>> resultBothIn = ISOBand.create(triangles, steps, IsoInclusion.BOTH);
-
- NumberRange<Double> expectedRange0 = NumberRange.create(0., true, 1., true);
- NumberRange<Double> expectedRange1 = NumberRange.create(1., true, 2., true);
-
- List<Polygon> b0 = resultBothIn.get(expectedRange0);
- assertNotNull(b0);
- assertEquals(1, b0.size());
- Coordinate[] expectedB0 = new Coordinate[]{
- new Coordinate(0, 0, 1.),
- new Coordinate(1, 0, 1.),
- new Coordinate(0, 1, 1.),
- new Coordinate(0, 0, 1.),
- };
- Coordinate[] expectedB1 = new Coordinate[]{
- new Coordinate(0, 0, 1.),
- new Coordinate(1, 0, 1.),
- new Coordinate(1, 1, 2.),
- new Coordinate(0, 1, 1.),
- new Coordinate(0, 0, 1.),
- };
-
- assertTrue(assertPolygonEquals(expectedB0, b0.get(0).getCoordinates(), tolerance));
- List<Polygon> b1 = resultBothIn.get(expectedRange1);
-
- assertNotNull(b1);
- assertEquals(1, b1.size());
- assertTrue(assertPolygonEquals(expectedB1, b1.get(0).getCoordinates(), tolerance));
-
-
- //Check MAX
- Map<NumberRange<Double>, List<Polygon>> resultMinOut = ISOBand.create(triangles, steps, IsoInclusion.MAX);
-
- b0 = resultMinOut.get(expectedRange0);
- assertNotNull(b0);
- assertEquals(1, b0.size());
-
- expectedB0 = new Coordinate[]{
- new Coordinate(0, 0, 1.),
- new Coordinate(1, 0, 1.),
- new Coordinate(0, 1, 1.),
- new Coordinate(0, 0, 1.),
- };
-
- assertTrue(assertPolygonEquals(expectedB0, b0.get(0).getCoordinates(), tolerance));
-
-
- /*
- 3 2
- +--+
- \ |
- \|
- +
- 1
- check triangle 3, 1, 0 on iso of z =1. is excluded
- */
- expectedB1 = new Coordinate[]{
- new Coordinate(1, 0, 1.),
- new Coordinate(1, 1, 2.),
- new Coordinate(0, 1, 1.),
- new Coordinate(1, 0, 1.),
- };
- b1 = resultMinOut.get(expectedRange1);
-
- assertNotNull(b1);
- assertEquals(1, b1.size());
-
- assertTrue(assertPolygonEquals(expectedB1, b1.get(0).getCoordinates(), tolerance));
-
-
- //Check MIN
- Map<NumberRange<Double>, List<Polygon>> resultMaxOut = ISOBand.create(triangles, steps, IsoInclusion.MIN);
-
- b0 = resultMaxOut.get(expectedRange0);
- assertNotNull(b0);
- assertEquals(0, b0.size());
- expectedB1 = new Coordinate[]{
- new Coordinate(1, 0, 1.),
- new Coordinate(1, 1, 2.),
- new Coordinate(0, 1, 1.),
- new Coordinate(0, 0, 1.),
- new Coordinate(1, 0, 1.),
- };
-
- b1 = resultMaxOut.get(expectedRange1);
-
- assertTrue(assertPolygonEquals(expectedB1, b1.get(0).getCoordinates(), tolerance));
- }
-
- @Test
- public void testExcludeMaxStrategy() throws FactoryException {
-
- /*
- 3 2
- +--+
- |\ |
- | \|
- +--+
- 0 1
- */
- final double[] positions = new double[]{0, 0, 1., 1, 0, 2., 1, 1, 2., 0, 1, 2.};
- final int[] index = new int[]{3, 1, 0, 3, 2, 1};
-
- final SampleSystem ss = SampleSystem.of(Geometries.PSEUDOGEO_3D);
-
- final MeshPrimitive.Triangles triangles = new MeshPrimitive.Triangles();
- triangles.setPositions(TupleArrays.of(ss, positions));
- triangles.setIndex(TupleArrays.ofUnsigned(1, index));
-
- final double[] steps = new double[]{0., 1., 2.};
-
- NumberRange<Double> expectedRange0 = NumberRange.create(0., true, 1., true);
- NumberRange<Double> expectedRange1 = NumberRange.create(1., true, 2., true);
-
- Map<NumberRange<Double>, List<Polygon>> resultMaxOut = ISOBand.create(triangles, steps, IsoInclusion.MIN);
-
- List<Polygon> b0 = resultMaxOut.get(expectedRange0);
- assertNotNull(b0);
- assertEquals(0, b0.size());
-
- /*
- 3
- +
- |\
- | \
- +--+
- 0 1
- Check triangle 3, 2, 1 on iso of z =2. is excluded
- */
- Coordinate[] expectedB1 = new Coordinate[]{
- new Coordinate(0, 0, 1.),
- new Coordinate(0, 1, 2.),
- new Coordinate(1, 0, 2.),
- new Coordinate(0, 0, 1.),
- };
-
- List<Polygon> b1 = resultMaxOut.get(expectedRange1);
-
- assertTrue(assertPolygonEquals(expectedB1, b1.get(0).getCoordinates(), tolerance));
- }
-
- private void assertCoordinateEquals(Coordinate expected, Coordinate actual, double tolerance) {
- assertEquals(expected.x, actual.x, tolerance, "(x-coordinate miss match)");
- assertEquals(expected.y, actual.y, tolerance, "(y-coordinate miss match)");
- assertEquals(expected.z, actual.z, tolerance, "(z-coordinate miss match)");
- }
-
- private boolean isCoordinateEquals(Coordinate expected, Coordinate actual, double tolerance) {
- return (Math.abs(expected.getX() - actual.getX()) <= tolerance)
- && (Math.abs(expected.getY() - actual.getY()) <= tolerance)
- && (!Double.isNaN(expected.getZ()) ? Math.abs(expected.getZ() - actual.getZ()) <= tolerance : Double.isNaN(actual.getZ()));
- }
-
- private boolean assertPolygonEquals(Coordinate[] expectedCoordinates, Coordinate[] checkCoordinates, final double tolerance) {
- return assertPolygonEquals(
- new ArrayList(Arrays.asList(expectedCoordinates)), // can be modified in assertion method.
- Arrays.asList(checkCoordinates), tolerance);
- }
-
- /**
- * Check that 2 list of coordinates associated with closed polygons' vertices match each other.
- * The comparison accepts a precision gap (according to the input tolerance value) as well as permutation and vertex
- * ordering
- * @param expectedCoordinates expected list of coordinates (not null or empty)
- * @param checkCoordinates compared list of coordinates (not null or empty)
- * @param tolerance tolerance value for the ordinates values.
- * @return true if the list of coordinates are matching
- */
- private boolean assertPolygonEquals(List<Coordinate> expectedCoordinates, List<Coordinate> checkCoordinates, final double tolerance) {
- int size = checkCoordinates.size();
- assert size > 1;
- Coordinate check = checkCoordinates.get(0);
- if (expectedCoordinates.size() != size) throw new RuntimeException("Computed polygon doesn't match the expected polygon's size.\nExpected :"+expectedCoordinates+"\nActual :"+checkCoordinates);
- final int maxI = size-1;
- if (!isCoordinateEquals(check, checkCoordinates.get(size-1), tolerance)) throw new RuntimeException("Expected polygon to be closed : first coordinate must match the last coordinate.\nExpected :"+expectedCoordinates+"\nActual :"+checkCoordinates);
-
- int start= -1;
- boolean sameOrder = false;
-
- for (int j = 0; j < maxI ; j++) {// do not re-check closing vertex
- if (isCoordinateEquals(expectedCoordinates.get(j), check, tolerance)) {
- start = j;
- sameOrder = isCoordinateEquals(expectedCoordinates.get(j+1), checkCoordinates.get(1), tolerance);
- break;
- }
- }
- if (start == -1) throw new RuntimeException("No vertex of expected coordinates match checked coordinate.\nExpected :"+check+"\nActual :"+checkCoordinates);
-
- assert isCoordinateEquals(expectedCoordinates.get(0), expectedCoordinates.get(maxI), tolerance);
- expectedCoordinates.remove(maxI); // Remove last point as it is equal to first coordinate before permuting the elements.
- Collections.rotate(expectedCoordinates, -start);
-
- for (int i = 1; i < maxI ; i++) {
- check = checkCoordinates.get(i);
- if (!isCoordinateEquals(check, expectedCoordinates.get(sameOrder? i: maxI-i), tolerance))
- return false;
- }
- return true;
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/privy/ArraySequenceTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/privy/ArraySequenceTest.java
deleted file mode 100644
index 7daa978..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/privy/ArraySequenceTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.geometries.privy;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.math.Vector2D;
-import org.apache.sis.geometries.math.Vector3D;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class ArraySequenceTest {
-
- /**
- * Failing test, positions must have a crs.
- */
- @Test
- public void constructorNoCrsTest() {
- final TupleArray positions = TupleArrays.of(2, new double[]{0,0, 1,0, 0,1, 0,0});
- assertThrows(NullPointerException.class, ()->{
- ArraySequence array = new ArraySequence(positions);
- });
- }
-
- /**
- * Valid construction, positions have a crs.
- */
- @Test
- public void constructorCrsTest() {
- final TupleArray positions = TupleArrays.of(CommonCRS.WGS84.normalizedGeographic(), new double[]{0,0, 1,0, 0,1, 0,0});
- ArraySequence array = new ArraySequence(positions);
- }
-
- /**
- * Failing test, no positions.
- */
- @Test
- public void constructorAttributesNoPositionTest() {
- final TupleArray normals = TupleArrays.of(3, new double[]{1,0,0, 0,1,0, 0,0,1, 1,0,0});
- final Map<String,TupleArray> attributes = new HashMap<>();
- attributes.put(AttributesType.ATT_NORMAL, normals);
- assertThrows(NullPointerException.class, ()->{
- ArraySequence array = new ArraySequence(attributes);
- });
- }
-
- /**
- * Valid construction, positions have a crs.
- */
- @Test
- public void constructorAttributesTest() {
- final TupleArray positions = TupleArrays.of(CommonCRS.WGS84.normalizedGeographic(), new double[]{0,0, 1,0, 0,1, 0,0});
- final TupleArray normals = TupleArrays.of(3, new double[]{1,0,0, 0,1,0, 0,0,1, 1,0,0});
- final Map<String,TupleArray> attributes = new HashMap<>();
- attributes.put(AttributesType.ATT_POSITION, positions);
- attributes.put(AttributesType.ATT_NORMAL, normals);
- ArraySequence array = new ArraySequence(attributes);
- }
-
- /**
- * Test point attributes.
- */
- @Test
- public void pointsTest() {
-
- final CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic();
- final TupleArray positions = TupleArrays.of(crs, new double[]{0,0, 1,0, 0,1, 0,0});
- final TupleArray normals = TupleArrays.of(3, new double[]{1,0,0, 0,1,0, 0,0,1, 1,0,0});
- final Map<String,TupleArray> attributes = new HashMap<>();
- attributes.put(AttributesType.ATT_POSITION, positions);
- attributes.put(AttributesType.ATT_NORMAL, normals);
- final ArraySequence array = new ArraySequence(attributes);
-
- assertEquals(CommonCRS.WGS84.normalizedGeographic(), array.getCoordinateReferenceSystem());
- assertEquals(2, array.getDimension());
- assertEquals(positions, array.getAttribute(AttributesType.ATT_POSITION));
- assertEquals(normals, array.getAttribute(AttributesType.ATT_NORMAL));
- assertEquals(2, array.getAttributeNames().size());
-
- final SampleSystem ss = SampleSystem.of(crs);
- assertEquals(new Vector2D.Double(ss, 0, 0), array.getAttribute(0, AttributesType.ATT_POSITION));
- assertEquals(new Vector2D.Double(ss, 1, 0), array.getAttribute(1, AttributesType.ATT_POSITION));
- assertEquals(new Vector2D.Double(ss, 0, 1), array.getAttribute(2, AttributesType.ATT_POSITION));
- assertEquals(new Vector2D.Double(ss, 0, 0), array.getAttribute(3, AttributesType.ATT_POSITION));
- assertEquals(new Vector2D.Double(ss, 0, 0), array.getPosition(0));
- assertEquals(new Vector2D.Double(ss, 1, 0), array.getPosition(1));
- assertEquals(new Vector2D.Double(ss, 0, 1), array.getPosition(2));
- assertEquals(new Vector2D.Double(ss, 0, 0), array.getPosition(3));
- assertEquals(new Vector3D.Double(1, 0, 0), array.getAttribute(0, AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(0, 1, 0), array.getAttribute(1, AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(0, 0, 1), array.getAttribute(2, AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(1, 0, 0), array.getAttribute(3, AttributesType.ATT_NORMAL));
-
- Point pt0 = array.getPoint(0);
- Point pt1 = array.getPoint(1);
- Point pt2 = array.getPoint(2);
- Point pt3 = array.getPoint(3);
- assertEquals(new Vector2D.Double(ss, 0, 0), pt0.getPosition());
- assertEquals(new Vector2D.Double(ss, 1, 0), pt1.getPosition());
- assertEquals(new Vector2D.Double(ss, 0, 1), pt2.getPosition());
- assertEquals(new Vector2D.Double(ss, 0, 0), pt3.getPosition());
- assertEquals(new Vector3D.Double(1, 0, 0), pt0.getAttribute(AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(0, 1, 0), pt1.getAttribute(AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(0, 0, 1), pt2.getAttribute(AttributesType.ATT_NORMAL));
- assertEquals(new Vector3D.Double(1, 0, 0), pt3.getAttribute(AttributesType.ATT_NORMAL));
-
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/DistanceTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/DistanceTest.java
deleted file mode 100644
index 910f9c9..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/DistanceTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.geometries.processor.spatialanalysis2d;
-
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.math.SampleSystem;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.geometries.operation.OperationException;
-import org.apache.sis.geometries.operation.spatialanalysis2d.Distance;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DistanceTest {
-
- private static final SampleSystem CRS2D = SampleSystem.of(CommonCRS.WGS84.geographic());
-
- /**
- * Test point to point distance.
- */
- @Test
- public void PointPoint() {
-
- { //different CRS
- final Point point1 = GeometryFactory.createPoint(CommonCRS.WGS84.geographic());
- final Point point2 = GeometryFactory.createPoint(CommonCRS.WGS84.normalizedGeographic());
- try {
- new Distance(point1, point2).eval();
- fail("evaluation should fail");
- } catch (OperationException ex) {
- //ok
- }
- }
-
- { //at same position
- final Point point1 = GeometryFactory.createPoint(CRS2D, 10.0, 5.0);
- final Point point2 = GeometryFactory.createPoint(CRS2D, 10.0, 5.0);
- assertEquals(0.0, GeometryOperations.SpatialAnalysis2D.distance(point1, point2), 0.0);
- }
-
- { //at 1.0 of distance
- final Point point1 = GeometryFactory.createPoint(CRS2D, 10, 5);
- final Point point2 = GeometryFactory.createPoint(CRS2D, 10, 6);
- assertEquals(1.0, GeometryOperations.SpatialAnalysis2D.distance(point1, point2), 0.0);
- }
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/IntersectionTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/IntersectionTest.java
deleted file mode 100644
index e8f2353..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialanalysis2d/IntersectionTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.geometries.processor.spatialanalysis2d;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class IntersectionTest {
-
- private static final CoordinateReferenceSystem CRS2D = CommonCRS.WGS84.normalizedGeographic();
-
- /**
- * Test primitives triangles against primitive points.
- * - 2 triangles.
- * - 4 points, one in triangle, one on vertex, one on edge, one outside.
- *
- * 2-4 5
- * +---o
- * |\ |
- * | o | o
- * |o \|
- * +---+
- * 0 1-3
- */
- @Test
- public void testPrimitiveTrianglesPrimitivePoints() {
-
- final MeshPrimitive geom1 = new MeshPrimitive.Triangles();
- geom1.setPositions(TupleArrays.of(CRS2D,
- 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
- 1.0, 0.0, 1.0, 1.0, 0.0, 1.0
- ));
- geom1.setAttribute("test", TupleArrays.of(1,
- 0.0, 1.0, 2.0,
- 1.0, 8.0, 2.0
- ));
-
- final MeshPrimitive geom2 = new MeshPrimitive.Points();
- geom2.setPositions(TupleArrays.of(CRS2D,
- 0.2, 0.2,
- 0.5, 0.5,
- 1.0, 1.0,
- 0.5, 2.0
- ));
-
- final Geometry intersection = GeometryOperations.SpatialAnalysis2D.intersection(geom1, geom2);
- assertTrue(intersection instanceof MeshPrimitive.Points);
- final MeshPrimitive result = (MeshPrimitive) intersection;
- final TupleArray positions = result.getPositions();
- final TupleArray test = result.getAttribute("test");
-
- assertArrayEquals(new double[]{
- 0.2, 0.2,
- 0.5, 0.5,
- 1.0, 1.0
- }, positions.toArrayDouble(), 0.0);
- assertArrayEquals(new double[]{
- 0.6,
- 1.5,
- 8.0,
- }, test.toArrayDouble(), 0.0001);
- }
-
- /**
- * Test primitives triangles against primitive lines.
- * - 2 triangles.
- * - 3 lines, one inside triangles, one crossing outward, one outside
- *
- * 2-4 5
- * +---+
- * |\ ++--+
- * |+-+|
- * | \| +--+
- * +---+
- * 0 1-3
- */
- @Test
- public void testPrimitiveTrianglesPrimitiveLines() {
-
- final MeshPrimitive geom1 = new MeshPrimitive.Triangles();
- geom1.setPositions(TupleArrays.of(CRS2D,
- 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
- 1.0, 0.0, 1.0, 1.0, 0.0, 1.0
- ));
- geom1.setAttribute("test", TupleArrays.of(1,
- 0.0, 1.0, 2.0,
- 1.0, 8.0, 2.0
- ));
-
- final MeshPrimitive geom2 = new MeshPrimitive.Lines();
- geom2.setPositions(TupleArrays.of(CRS2D,
- 0.1, 0.5, 0.9, 0.5, //crossing 2 triangles
- 0.8, 0.9, 1.2, 0.9, //crossout 1 triangle
- 3.0, 0.2, 4.0, 0.2 //outside
- ));
-
- final Geometry intersection = GeometryOperations.SpatialAnalysis2D.intersection(geom1, geom2);
- assertTrue(intersection instanceof MeshPrimitive.Lines);
- final MeshPrimitive.Lines result = (MeshPrimitive.Lines) intersection;
- final TupleArray positions = result.getPositions();
- final TupleArray test = result.getAttribute("test");
-
- assertArrayEquals(new double[]{
- //first line, cut in two
- 0.1, 0.5, 0.5, 0.5,
- 0.5, 0.5, 0.9, 0.5,
- //second line, truncated
- 0.8, 0.9, 1.0, 0.9
- //no third line
- }, positions.toArrayDouble(), 0.0001);
- assertArrayEquals(new double[]{
- 1.1, 1.5,
- 1.5, 3.9,
- 6.1, 7.3
- }, test.toArrayDouble(), 0.0001);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/To3DTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/To3DTest.java
deleted file mode 100644
index b44ebbc..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/To3DTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.math.Tuple;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class To3DTest {
-
- private static final CoordinateReferenceSystem CRS2D = CommonCRS.WGS84.normalizedGeographic();
- private static final CoordinateReferenceSystem CRS2DZ;
- private static final CoordinateReferenceSystem CRS3D = CommonCRS.WGS84.geocentric();
-
- static {
- try {
- CRS2DZ = CRS.compound(CRS2D, CommonCRS.Vertical.ELLIPSOIDAL.crs());
- } catch (FactoryException ex) {
- throw new RuntimeException(ex.getMessage(), ex);
- }
- }
-
- @Test
- public void testPrimitive() {
-
- final MeshPrimitive primitive = new MeshPrimitive.Points();
- primitive.setPositions(TupleArrays.of(CRS2D,
- 0.0, 1.0,
- 2.0, 3.0,
- 4.0, 5.0,
- 6.0, 7.0
- ));
-
- Geometry result = GeometryOperations.SpatialEdition.to3D(primitive, CRS3D, (Tuple t) -> t.set(2, 15));
- assertTrue(result instanceof MeshPrimitive);
- assertEquals(CRS3D, result.getCoordinateReferenceSystem());
- MeshPrimitive p = (MeshPrimitive) result;
-
- assertArrayEquals(new double[]{
- 0.0, 1.0, 15.0,
- 2.0, 3.0, 15.0,
- 4.0, 5.0, 15.0,
- 6.0, 7.0, 15.0
- },
- p.getPositions().toArrayDouble(), 0.0);
-
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/ToPrimitiveTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/ToPrimitiveTest.java
deleted file mode 100644
index 98e0a4f..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/ToPrimitiveTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.AttributesType;
-import org.apache.sis.geometries.Geometry;
-import org.apache.sis.geometries.GeometryFactory;
-import org.apache.sis.geometries.LineString;
-import org.apache.sis.geometries.LinearRing;
-import org.apache.sis.geometries.MultiLineString;
-import org.apache.sis.geometries.MultiPoint;
-import org.apache.sis.geometries.Point;
-import org.apache.sis.geometries.PointSequence;
-import org.apache.sis.geometries.Polygon;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MultiMeshPrimitive;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class ToPrimitiveTest {
-
- private static final CoordinateReferenceSystem CRS2D = CommonCRS.WGS84.normalizedGeographic();
-
- @Test
- public void testPoint() {
- final Point point = GeometryFactory.createPoint(CRS2D, 1, 2);
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(point);
- assertTrue(result instanceof MeshPrimitive);
- final MeshPrimitive primitive = (MeshPrimitive) result;
- assertEquals(MeshPrimitive.Type.POINTS, primitive.getType());
- }
-
- @Test
- public void testLineString() {
- final TupleArray positions = TupleArrays.of(CRS2D, new double[]{0,1,2,3});
- final PointSequence points = GeometryFactory.createSequence(positions);
- final LineString line = GeometryFactory.createLineString(points);
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(line);
- assertTrue(result instanceof MeshPrimitive);
- final MeshPrimitive primitive = (MeshPrimitive) result;
- assertEquals(MeshPrimitive.Type.LINE_STRIP, primitive.getType());
- }
-
- @Test
- public void testPolygon() {
- final TupleArray positions = TupleArrays.of(CRS2D, new double[]{0,1,2,3});
- final PointSequence points = GeometryFactory.createSequence(positions);
- final LinearRing exterior = GeometryFactory.createLinearRing(points);
- final Polygon point = GeometryFactory.createPolygon(exterior, null);
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(point);
- assertTrue(result instanceof MeshPrimitive);
- final MeshPrimitive primitive = (MeshPrimitive) result;
- assertEquals(MeshPrimitive.Type.TRIANGLES, primitive.getType());
- }
-
- @Test
- public void testMultiLineString() {
- { //one line has 3 points, so we must obtain a MultiPrimitive
- final TupleArray positions1 = TupleArrays.of(CRS2D, new double[]{0,1,2,3});
- final PointSequence points1 = GeometryFactory.createSequence(positions1);
- final LineString line1 = GeometryFactory.createLineString(points1);
-
- final TupleArray positions2 = TupleArrays.of(CRS2D, new double[]{3,4,5,6,7,8});
- final PointSequence points2 = GeometryFactory.createSequence(positions2);
- final LineString line2 = GeometryFactory.createLineString(points2);
-
- final MultiLineString mlines = GeometryFactory.createMultiLineString(line1, line2);
-
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(mlines);
- assertTrue(result instanceof MultiMeshPrimitive);
- final MultiMeshPrimitive mp = (MultiMeshPrimitive) result;
- assertEquals(2, mp.getNumGeometries());
- assertTrue(mp.getGeometryN(0) instanceof MeshPrimitive);
- assertTrue(mp.getGeometryN(1) instanceof MeshPrimitive);
-
- final MeshPrimitive primitive1 = (MeshPrimitive) mp.getGeometryN(0);
- assertEquals(MeshPrimitive.Type.LINE_STRIP, primitive1.getType());
-
- final MeshPrimitive primitive2 = (MeshPrimitive) mp.getGeometryN(1);
- assertEquals(MeshPrimitive.Type.LINE_STRIP, primitive2.getType());
- }
- { //all linestrings are lines, we must obtain a Primitive.Lines
- final TupleArray positions1 = TupleArrays.of(CRS2D, new double[]{0,1,2,3});
- final PointSequence points1 = GeometryFactory.createSequence(positions1);
- final LineString line1 = GeometryFactory.createLineString(points1);
-
- final TupleArray positions2 = TupleArrays.of(CRS2D, new double[]{3,4,5,6});
- final PointSequence points2 = GeometryFactory.createSequence(positions2);
- final LineString line2 = GeometryFactory.createLineString(points2);
-
- final MultiLineString mlines = GeometryFactory.createMultiLineString(line1, line2);
-
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(mlines);
- assertTrue(result instanceof MeshPrimitive.Lines);
- final MeshPrimitive.Lines mp = (MeshPrimitive.Lines) result;
- assertEquals(2, mp.getNumGeometries());
- LineString l1 = mp.getGeometryN(0);
- LineString l2 = mp.getGeometryN(1);
- assertArrayEquals(new double[]{0,1,2,3}, l1.getPoints().getAttributeArray(AttributesType.ATT_POSITION).toArrayDouble(), 0.0);
- assertArrayEquals(new double[]{3,4,5,6}, l2.getPoints().getAttributeArray(AttributesType.ATT_POSITION).toArrayDouble(), 0.0);
- }
- }
-
- @Test
- public void testMultiPoint() {
- final TupleArray positions1 = TupleArrays.of(CRS2D, new double[]{0,1,2,3});
- final PointSequence points = GeometryFactory.createSequence(positions1);
- final MultiPoint mpoints = GeometryFactory.createMultiPoint(points);
-
- final Geometry result = GeometryOperations.SpatialEdition.toPrimitive(mpoints);
- assertTrue(result instanceof MeshPrimitive);
- final MeshPrimitive primitive1 = (MeshPrimitive) result;
- assertEquals(MeshPrimitive.Type.POINTS, primitive1.getType());
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/TransformTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/TransformTest.java
deleted file mode 100644
index 906e6dc..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/processor/spatialedition/TransformTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.geometries.processor.spatialedition;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MultiMeshPrimitive;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.geometries.operation.GeometryOperations;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TransformTest {
-
- private static final CoordinateReferenceSystem CRS_SOURCE;
- private static final CoordinateReferenceSystem CRS_TARGET = CommonCRS.WGS84.geocentric();
- private static final MathTransform TRANSFORM;
- static {
- try {
- CRS_SOURCE = CRS.compound(CommonCRS.WGS84.normalizedGeographic(), CommonCRS.Vertical.ELLIPSOIDAL.crs());
- TRANSFORM = CRS.findOperation(CRS_SOURCE, CRS_TARGET, null).getMathTransform();
- } catch (FactoryException ex) {
- throw new RuntimeException(ex.getMessage(), ex);
- }
- }
-
- private static MeshPrimitive createPrimitive() throws FactoryException {
-
- final MeshPrimitive primitive = new MeshPrimitive.Points();
- primitive.setPositions(TupleArrays.of(CRS_SOURCE,
- 0.0, 0.0, 0.0, //point on earth equator, lon 0
- 90.0, 0.0, 0.0, //point on earth equator, lon 90
- 180.0, 0.0, 0.0, //point on earth equator, lon 180
- 45.0, 45.0, 0.0 //point in east-europe
- ));
- primitive.setNormals(TupleArrays.of(3,
- 0.0, 0.0, 1.0,
- 0.0, 0.0, 1.0,
- 0.0, 0.0, 1.0,
- 0.0, 0.0, 1.0
- ));
- primitive.setTangents(TupleArrays.of(3,
- 1.0, 0.0, 0.0,
- 1.0, 0.0, 0.0,
- 1.0, 0.0, 0.0,
- 1.0, 0.0, 0.0
- ));
- primitive.setTexCoords(0,TupleArrays.of(2,
- 1.0, 2.0,
- 3.0, 4.0,
- 5.0, 6.0,
- 7.0, 8.0
- ));
-
- return primitive;
- }
-
- private static void testPrimitive(MeshPrimitive result) {
- assertEquals(CRS_TARGET, result.getCoordinateReferenceSystem());
- assertTrue(TupleArrays.of(CRS_TARGET,
- 6378137.0, 0.0, 0.0,
- 0.0, 6378137.0, 0.0,
- -6378137.0, 0.0, 0.0,
- 3194419.145, 3194419.145, 4487348.408
- ).equals(result.getPositions(), 1e-3));
- assertTrue(TupleArrays.of(3,
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- -1.0, 0.0, 0.0,
- 0.5, 0.5, 0.707
- ).equals(result.getNormals(), 1e-3));
- assertTrue(TupleArrays.of(3,
- 0.0, 1.0, 0.0,
- -1.0, 0.0, 0.0,
- 0.0,-1.0, 0.0,
- -0.707,0.707, 0.0
- ).equals(result.getTangents(), 1e-3));
- assertTrue(TupleArrays.of(2,
- 1.0, 2.0,
- 3.0, 4.0,
- 5.0, 6.0,
- 7.0, 8.0
- ).equals(result.getTexCoords(0), 0.0));
- }
-
-
- /**
- * Test geometry transform modify position, normal, tangent attributes
- * and other attributes are left unchanged.
- */
- @Test
- public void Primitive() throws FactoryException, TransformException {
- final MeshPrimitive primitive = createPrimitive();
- final MeshPrimitive result = (MeshPrimitive) GeometryOperations.SpatialEdition.transform(primitive, CRS_TARGET, TRANSFORM);
- testPrimitive(result);
- }
-
- @Test
- public void MultiPrimitive() throws FactoryException, TransformException {
- final MultiMeshPrimitive mp = new MultiMeshPrimitive(createPrimitive());
- final MultiMeshPrimitive result = (MultiMeshPrimitive) GeometryOperations.SpatialEdition.transform(mp, CRS_TARGET, TRANSFORM);
- assertEquals(1, result.getNumGeometries());
- testPrimitive(result.getGeometryN(0));
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/simplify/TextureAtlasTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/simplify/TextureAtlasTest.java
deleted file mode 100644
index d31e1e0..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/simplify/TextureAtlasTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.geometries.simplify;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import org.apache.sis.coverage.grid.GridExtent;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class TextureAtlasTest {
-
- /**
- * Test atlas image creation.
- */
- @Test
- public void atlasCreationTest() {
-
- final TextureAtlas atlas = new TextureAtlas(10, 10, 0);
-
- { //add image too big for atlas
- final BufferedImage image1 = createImage(30, 5, Color.BLACK);
- assertEquals("image1", atlas.add("image1", image1));
- assertEquals(1, atlas.getPages().size());
- assertEquals(0, atlas.getPageIndex("image1"));
- GridExtent extent = atlas.getPages().get(0).index().get("image1");
- assertEquals(new GridExtent(30, 5), extent);
- assertEquals(atlas.getPages().get(0).image(), image1);
- }
-
- { //add small images
- final BufferedImage image2 = createImage(5, 4, Color.BLUE);
- assertEquals("image2", atlas.add("image2", image2));
- assertEquals(2, atlas.getPages().size());
- assertEquals(1, atlas.getPageIndex("image2"));
- GridExtent extent = atlas.getPages().get(1).index().get("image2");
- assertEquals(new GridExtent(null, new long[]{0,0}, new long[]{5,4}, false), extent);
-
- //image3 must be placed under image2
- final BufferedImage image3 = createImage(7, 3, Color.YELLOW);
- assertEquals("image3", atlas.add("image3", image3));
- assertEquals(2, atlas.getPages().size());
- assertEquals(1, atlas.getPageIndex("image3"));
- extent = atlas.getPages().get(1).index().get("image3");
- assertEquals(new GridExtent(null, new long[]{0,4}, new long[]{7,4+3}, false), extent);
-
- //image4 must be placed on the right of image2
- final BufferedImage image4 = createImage(4, 2, Color.GREEN);
- assertEquals("image4", atlas.add("image4", image4));
- assertEquals(2, atlas.getPages().size());
- assertEquals(1, atlas.getPageIndex("image4"));
- extent = atlas.getPages().get(1).index().get("image4");
- assertEquals(new GridExtent(null, new long[]{5,0}, new long[]{5+4,2}, false), extent);
-
- //image5 must be placed on a new page
- final BufferedImage image5 = createImage(1, 9, Color.RED);
- assertEquals("image5", atlas.add("image5", image5));
- assertEquals(3, atlas.getPages().size());
- assertEquals(2, atlas.getPageIndex("image5"));
- extent = atlas.getPages().get(2).index().get("image5");
- assertEquals(new GridExtent(null, new long[]{0,0}, new long[]{1,9}, false), extent);
-
- //check images
- final RenderedImage page1 = atlas.getPages().get(1).image();
- final RenderedImage page2 = atlas.getPages().get(2).image();
-
- assertEquals(Color.BLUE, getPixel(page1, 0, 0));
- assertEquals(Color.BLUE, getPixel(page1, 4, 3));
- assertEquals(Color.YELLOW, getPixel(page1, 0, 4));
- assertEquals(Color.YELLOW, getPixel(page1, 6, 6));
- assertEquals(Color.GREEN, getPixel(page1, 5, 0));
- assertEquals(Color.GREEN, getPixel(page1, 8, 1));
- assertEquals(Color.RED, getPixel(page2, 0, 0));
- assertEquals(Color.RED, getPixel(page2, 0, 8));
- }
-
- { //add image with al existing name, must raise an exception
- final BufferedImage image4 = createImage(8, 5, Color.WHITE);
- try {
- atlas.add("image4", image4);
- fail("image4 already exist, should have caused an exception");
- } catch (IllegalArgumentException ex) {
- //ok
- }
- }
- }
-
- private static BufferedImage createImage(int width, int height, Color color) {
- final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- final Graphics2D g = image.createGraphics();
- g.setColor(color);
- g.fillRect(0, 0, width, height);
- g.dispose();
- return image;
- }
-
- private static Color getPixel(RenderedImage image, int x, int y) {
- return new Color(((BufferedImage) image).getRGB(x, y));
- }
-
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/DelaunayTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/DelaunayTest.java
deleted file mode 100644
index ae8f63e..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/DelaunayTest.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * 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.geometries.triangulate.delaunay;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitiveComparator;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class DelaunayTest {
-
- private static final CoordinateReferenceSystem CRS = CommonCRS.WGS84.normalizedGeographic();
-
- /**
- * Test triangulation of 3 points.
- * 2
- * +
- * |\
- * | \
- * +--+
- * 0 1
- */
- @Test
- public void testTriangle() {
-
- final TupleArray positions = TupleArrays.of(CRS,
- 0,0,
- 1,0,
- 0,1);
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{0,1,2}, triangles);
- }
-
- /**
- * Test triangulation of 4 points.
- * 2 3
- * +--+
- * |\ |
- * | \|
- * +--+
- * 0 1
- */
- @Test
- public void testQuad() {
-
- final TupleArray positions = TupleArrays.of(CRS,
- 0,0,
- 1,0,
- 0,1,
- 1,1);
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{0,1,2, 1,3,2}, triangles);
- }
-
- /**
- * Test triangulation of 4 points.
- * 2
- * +
- * /|\
- * / | \
- * +--+--+
- * 0 3 1
- */
- @Test
- public void testEdgeSplit() {
-
- final TupleArray positions = TupleArrays.of(CRS,
- 0,0,
- 2,0,
- 1,1,
- 1,0);
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{2,0,3, 1,2,3}, triangles);
- }
-
- /**
- * Test triangulation of 5 points.split edge on two sides
- * 2
- * +
- * /|\
- * / | \
- * 0 +--4--+ 1
- * \ | /
- * \|/
- * +
- * 3
- */
- @Test
- public void testTwoEdgeSplit() {
-
- final TupleArray positions = TupleArrays.of(CRS,
- 0,0,
- 2,0,
- 1,2,
- 1,-2,
- 1,0
- );
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{0,4,2, 4,1,2, 0,3,4, 4,3,1}, triangles);
- }
-
- /**
- * Test from example A of https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- */
- @Test
- public void testFlipScanA() {
- final TupleArray positions = TupleArrays.of(CRS,
- 69,-157, //start
- 38,-192,
- 96,-199,
- 70,-237 //end
- );
- final TupleArray constraints = TupleArrays.ofUnsigned(1,
- new int[]{0,3});
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- delaunay.pushConstraint(constraints, true);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{
- 0,1,3,
- 0,3,2
- }, triangles);
- }
-
- /**
- * Test from example B of https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- */
- @Test
- public void testFlipScanB() {
- final TupleArray positions = TupleArrays.of(CRS,
- 73,-252, //start
- 40,-286,
- 39,-313,
- 73,-360, //end
- 99,-322,
- 99,-294
- );
- final TupleArray constraints = TupleArrays.ofUnsigned(1,
- new int[]{0,3});
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- delaunay.pushConstraint(constraints, true);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{
- 0,1,2,
- 0,2,3,
- 0,3,4,
- 0,4,5
- }, triangles);
- }
-
- /**
- * Test from example C of https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- *
- * Note : we need to insert a soft constraint from 2 to 5 to match the example
- */
- @Test
- public void testFlipScanC() {
- final TupleArray positions = TupleArrays.of(CRS,
- 84,-368, //start
- 53,-402,
- 20,-413,
- 51,-466,
- 86,-510, //end
- 112,-439,
- 111,-411
- );
- final TupleArray constraints = TupleArrays.ofUnsigned(1,
- new int[]{0,4});
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- //add a soft constraint to match the example
- delaunay.pushConstraint(2,5, false);
- delaunay.pushConstraint(constraints, true);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{
- 0,1,3,
- 1,2,3,
- 0,3,4,
- 0,4,5,
- 0,5,6,
- //an additional triangle create here to have all delaunay triangles
- 0,2,1
- }, triangles);
- }
-
- /**
- * Test from example D of https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- *
- * Note : we need to insert soft constraints 1-5 and 2-5 to match the example
- */
- @Test
- public void testFlipScanD() {
- final TupleArray positions = TupleArrays.of(CRS,
- 91,-524, //start
- 82,-559,
- 37,-578,
- 64,-605,
- 92,-660, //end
- 128,-611,
- 104,-571
- );
- final TupleArray constraints = TupleArrays.ofUnsigned(1,
- new int[]{0,4});
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- //add a soft constraint to match the example
- delaunay.pushConstraint(1,5, false);
- delaunay.pushConstraint(2,5, false);
- delaunay.pushConstraint(constraints, true);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{
- 0,1,4,
- 1,2,3,
- 1,3,4,
- 0,4,6,
- 4,5,6,
- //an additional triangle create here to have all delaunay triangles
- 0,2,1
- }, triangles);
- }
-
- /**
- * Test from example E of https://github.com/jhasse/poly2tri/blob/master/doc/FlipScan.png
- *
- * Note : we need to insert soft constraints 1-5 and 2-5 to match the example
- */
- @Test
- public void testFlipScanE() {
- final TupleArray positions = TupleArrays.of(CRS,
- 84,-674, //start
- 80,-715,
- 55,-731,
- 52,-778,
- 85,-837, //end
- 94,-806,
- 124,-749,
- 97,-724
- );
- final TupleArray constraints = TupleArrays.ofUnsigned(1,
- new int[]{0,4});
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- final Delaunay delaunay = new Delaunay();
- delaunay.build(points);
- delaunay.pushConstraint(constraints, true);
- final TupleArray triangles = delaunay.getTrianglesIndex();
-
- compare(positions, new int[]{
- 0,1,4,
- 1,2,4,
- 2,3,4,
- 0,4,5,
- 0,5,7,
- 5,6,7,
- //additional triangles create here to have all delaunay triangles
- 0,2,1,
- 0,7,6
- }, triangles);
- }
-
- /**
- * Compare created index, ignoring order of elements.
- */
- private static void compare(TupleArray positions, int[] expected, TupleArray actual) {
- final MeshPrimitive.Triangles exp = new MeshPrimitive.Triangles();
- exp.setPositions(positions);
- exp.setIndex(TupleArrays.ofUnsigned(1, expected));
- final MeshPrimitive.Triangles act = new MeshPrimitive.Triangles();
- act.setPositions(positions);
- act.setIndex(actual);
-
- final MeshPrimitiveComparator comparator = new MeshPrimitiveComparator();
- comparator.compareByElement(true);
- comparator.compare(exp, act);
- }
-}
diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/OrientedEdgeTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/OrientedEdgeTest.java
deleted file mode 100644
index ab16774..0000000
--- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/triangulate/delaunay/OrientedEdgeTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.geometries.triangulate.delaunay;
-
-import java.util.Iterator;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.geometries.mesh.MeshPrimitive;
-import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
-import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.geometries.math.TupleArrays;
-import org.apache.sis.referencing.CommonCRS;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public class OrientedEdgeTest {
-
- private static final CoordinateReferenceSystem CRS = CommonCRS.WGS84.normalizedGeographic();
-
- @Test
- public void testRotatingIterator() {
- /*
- C
- +
- /|\
- / | \
- D +--A--+ B
- \ | /
- \|/
- +
- E
- */
- final TupleArray positions = TupleArrays.of(CRS,
- 0,0,
- 2,0,
- 1,2,
- 1,-2,
- 1,0
- );
-
- final MeshPrimitive.Points points = new MeshPrimitive.Points();
- points.setPositions(positions);
-
- Vertex A = points.getVertex(4);
- Vertex B = points.getVertex(1);
- Vertex C = points.getVertex(2);
- Vertex D = points.getVertex(0);
- Vertex E = points.getVertex(3);
-
- { //test full loop
- final OrientedTriangle ABC = new OrientedTriangle(A, B, C);
- final OrientedTriangle ACD = new OrientedTriangle(ABC.ca.reverse(true), new OrientedEdge(C, D), new OrientedEdge(D, A));
- final OrientedTriangle ADE = new OrientedTriangle(ACD.ca.reverse(true), new OrientedEdge(D, E), new OrientedEdge(E, A));
- final OrientedTriangle AEB = new OrientedTriangle(ADE.ca.reverse(true), new OrientedEdge(E, B), ABC.ab.reverse(true));
-
- final Iterator<OrientedEdge> ite = ABC.ab.rotatingIterator();
- assertEquals(ABC.ab, ite.next());
- assertEquals(ACD.ab, ite.next());
- assertEquals(ADE.ab, ite.next());
- assertEquals(AEB.ab, ite.next());
- assertNull(ite.next());
- }
-
- { //test partial counterclockwise loop
- final OrientedTriangle ABC = new OrientedTriangle(A, B, C);
- final OrientedTriangle ACD = new OrientedTriangle(ABC.ca.reverse(true), new OrientedEdge(C, D), new OrientedEdge(D, A));
- final OrientedTriangle ADE = new OrientedTriangle(ACD.ca.reverse(true), new OrientedEdge(D, E), new OrientedEdge(E, A));
-
- final Iterator<OrientedEdge> ite1 = ABC.ab.rotatingIterator();
- assertEquals(ABC.ab, ite1.next());
- assertEquals(ACD.ab, ite1.next());
- assertEquals(ADE.ab, ite1.next());
- assertNull(ite1.next());
-
- final Iterator<OrientedEdge> ite2 = ACD.ab.rotatingIterator();
- assertEquals(ACD.ab, ite2.next());
- assertEquals(ADE.ab, ite2.next());
- assertEquals(ABC.ab, ite2.next());
- assertNull(ite2.next());
-
- final Iterator<OrientedEdge> ite3 = ADE.ab.rotatingIterator();
- assertEquals(ADE.ab, ite3.next());
- assertEquals(ACD.ab, ite3.next());
- assertEquals(ABC.ab, ite3.next());
- assertNull(ite3.next());
- }
-
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.StylePainter b/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.StylePainter
deleted file mode 100644
index 40215bf..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.StylePainter
+++ /dev/null
@@ -1,5 +0,0 @@
-# Workaround for Maven bug https://issues.apache.org/jira/browse/MNG-7855
-# The content of this file is automatically derived from module-info.class file.
-# Should be used only if the JAR file was on class-path rather than module-path.
-org.apache.sis.map.service.se1.SEPainter
-
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.se1.SymbolizerToScene2D$Spi b/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.se1.SymbolizerToScene2D$Spi
deleted file mode 100644
index 9ccdc25..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/META-INF/services/org.apache.sis.map.service.se1.SymbolizerToScene2D$Spi
+++ /dev/null
@@ -1,9 +0,0 @@
-# Workaround for Maven bug https://issues.apache.org/jira/browse/MNG-7855
-# The content of this file is automatically derived from module-info.class file.
-# Should be used only if the JAR file was on class-path rather than module-path.
-org.apache.sis.map.service.se1.PointToScene2D$Spi
-org.apache.sis.map.service.se1.LineToScene2D$Spi
-org.apache.sis.map.service.se1.PolygonToScene2D$Spi
-org.apache.sis.map.service.se1.TextToScene2D$Spi
-org.apache.sis.map.service.se1.RasterToScene2D$Spi
-
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/module-info.java b/incubator/src/org.apache.sis.portrayal.map/main/module-info.java
deleted file mode 100644
index 128b11c..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/module-info.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Raster imagery and geometry features.
- *
- * @author Johann Sorel (Geomatys)
- */
-module org.apache.sis.portrayal.map {
- requires transitive org.apache.sis.portrayal;
- requires static org.locationtech.jts;
-
- exports org.apache.sis.map;
- exports org.apache.sis.map.service;
-
- uses org.apache.sis.map.service.StylePainter;
- uses org.apache.sis.map.service.se1.SymbolizerToScene2D.Spi;
-
- provides org.apache.sis.map.service.StylePainter
- with org.apache.sis.map.service.se1.SEPainter;
- provides org.apache.sis.map.service.se1.SymbolizerToScene2D.Spi
- with org.apache.sis.map.service.se1.PointToScene2D.Spi,
- org.apache.sis.map.service.se1.LineToScene2D.Spi,
- org.apache.sis.map.service.se1.PolygonToScene2D.Spi,
- org.apache.sis.map.service.se1.TextToScene2D.Spi,
- org.apache.sis.map.service.se1.RasterToScene2D.Spi;
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ExceptionPresentation.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ExceptionPresentation.java
deleted file mode 100644
index dbaebca..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ExceptionPresentation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Objects;
-import org.opengis.feature.Feature;
-import org.apache.sis.storage.Resource;
-
-
-/**
- * Produced by the portrayal engines when an exception occurred.
- * Exception presentations are placed in the Stream of presentation leaving
- * the user the choice to log, ignore or stop rendering as needed.
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @author Johann Sorel (Geomatys)
- */
-public class ExceptionPresentation extends Presentation {
-
- private final Exception exception;
-
- /**
- * @param exception not null.
- */
- public ExceptionPresentation(Exception exception) {
- this.exception = Objects.requireNonNull(exception);
- }
-
- /**
- * @param exception not null.
- */
- public ExceptionPresentation(MapLayer layer, Resource resource, Feature candidate, Exception exception) {
- super(layer, resource, candidate);
- this.exception = Objects.requireNonNull(exception);
- }
-
- /**
- * @return exception, never null
- */
- public Exception getException() {
- return exception;
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ListChangeEvent.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ListChangeEvent.java
deleted file mode 100644
index 41a5554..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ListChangeEvent.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.map;
-
-import java.util.List;
-import java.beans.PropertyChangeEvent;
-import org.apache.sis.measure.NumberRange;
-
-
-/**
- * Event generated by modified list properties.
- *
- * @author Johann Sorel (Geomatys)
- */
-@SuppressWarnings("serial") // TODO
-public final class ListChangeEvent<T> extends PropertyChangeEvent {
-
- public enum Type {
- ADDED,
- REMOVED,
- CHANGED
- }
-
- private final NumberRange<Integer> range;
- private final Type type;
- private final List<T> items;
-
- private ListChangeEvent(final Object source, String propertyName, List<T> originalList, final List<? extends T> items, final NumberRange<Integer> range, final Type type){
- super(source, propertyName, originalList, originalList);
- this.range = range;
- this.type = type;
- this.items = (items != null) ? List.copyOf(items) : null;
- }
-
- /**
- * Returns the range index of the affected items.
- * If the event type is Added, the range correspond to the index range after insertion.
- * If the event type is Removed, the range correspond to the index before deletion.
- * @return NumberRange added or removed range.
- */
- public NumberRange<Integer> getRange(){
- return range;
- }
-
- /**
- * Returns event type.
- */
- public Type getType(){
- return type;
- }
-
- /**
- * Returns the affected items of this event.
- * This property is set if event is of type added or removed.
- *
- * @return List
- */
- public List<T> getItems(){
- return items;
- }
-
- public static <T> ListChangeEvent<T> added(Object source, String propertyName, List<T> originalList, T newItem, final int index) {
- return added(source, propertyName, originalList, List.of(newItem),
- NumberRange.create(index, true, index, true));
- }
-
- public static <T> ListChangeEvent<T> added(Object source, String propertyName, List<T> originalList, List<T> newItems, final NumberRange<Integer> range) {
- return new ListChangeEvent<>(source, propertyName, originalList, newItems, range, Type.ADDED);
- }
-
- public static <T> ListChangeEvent<T> removed(Object source, String propertyName, List<T> originalList, T newItem, final int index) {
- return removed(source, propertyName, originalList, List.of(newItem),
- NumberRange.create(index, true, index, true));
- }
-
- public static <T> ListChangeEvent<T> removed(Object source, String propertyName, List<T> originalList, List<T> oldItems, final NumberRange<Integer> range) {
- return new ListChangeEvent<>(source, propertyName, originalList, oldItems, range, Type.REMOVED);
- }
-
- public static <T> ListChangeEvent<T> changed(Object source, String propertyName, List<T> originalList) {
- return new ListChangeEvent<>(source, propertyName, originalList, null, null, Type.CHANGED);
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
deleted file mode 100644
index 2ba0cd4..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * 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.map;
-
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import org.opengis.geometry.Envelope;
-import org.opengis.util.InternationalString;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.portrayal.Observable;
-
-
-/**
- * Base class of map layer or group of map layers. This base class does not represent graphical elements.
- * Instead, it contains information (data and style) for creating a tree of portrayal objects.
- * A {@code MapItem} contains the following properties:
- *
- * <ul>
- * <li>An {@linkplain #getIdentifier() identifier}, which can be any {@link String} at developer choice.</li>
- * <li>A human-readable {@linkplain #getTitle() title} for pick lists, for example in GUI.</li>
- * <li>A {@linkplain #getAbstract() narrative description} providing more details.</li>
- * </ul>
- *
- * Additional information can be added in a map of {@linkplain #getUserProperties() user properties}.
- * The actual feature or coverage data, together with styling information, are provided by subclasses.
- *
- * <h2>Synchronization</h2>
- * {@code MapItem} instances are not thread-safe. Synchronization, if desired, is caller responsibility.
- *
- * @todo Rename as {@code LayerNode}? "Item" suggests an element in a list, while {@link MapLayers} actually
- * creates a tree. Furthermore, having {@code Layer} in the name would add emphasis that this is a tree
- * of layers and not a tree of arbitrary objects.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class MapItem extends Observable {
- /**
- * The {@value} property name, used for notifications about changes in map item identifier.
- * The identifier (or name) can be used to reference the item externally.
- * Associated values are instances of {@link String}.
- *
- * @see #getIdentifier()
- * @see #setIdentifier(String)
- * @see #addPropertyChangeListener(String, PropertyChangeListener)
- *
- * @todo This property seems to be named {@code "se:Name"} in SLD specification. Should we rename?
- */
- public static final String IDENTIFIER_PROPERTY = "identifier";
-
- /**
- * The {@value} property name, used for notifications about changes in map item title.
- * The title is a short description for item that might be displayed in a GUI pick list.
- * Associated values are instances of {@link String} or {@link InternationalString}.
- *
- * @see #getTitle()
- * @see #setTitle(CharSequence)
- * @see #addPropertyChangeListener(String, PropertyChangeListener)
- */
- public static final String TITLE_PROPERTY = "title";
-
- /**
- * The {@value} property name, used for notifications about changes in map item description.
- * The abstract is a narrative description providing additional information.
- * It is more detailed than the {@value #TITLE_PROPERTY} property and may be a few paragraphs long.
- * Associated values are instances of {@link String} or {@link InternationalString}.
- *
- * @see #getAbstract()
- * @see #setAbstract(CharSequence)
- * @see #addPropertyChangeListener(String, PropertyChangeListener)
- */
- public static final String ABSTRACT_PROPERTY = "abstract";
-
- /**
- * The {@value} property name, used for notifications about changes in map item visibility state.
- * Associated values are instances of {@link Boolean}.
- */
- public static final String VISIBLE_PROPERTY = "visible";
-
- /**
- * Identifier of this map item.
- *
- * @see #IDENTIFIER_PROPERTY
- * @see #getIdentifier()
- */
- private String identifier;
-
- /**
- * The title of this map item, for display to the user.
- *
- * @see #TITLE_PROPERTY
- * @see #getTitle()
- */
- private CharSequence title;
-
- /**
- * A description of this map item, for display to the user. The property name is
- * {@value #ABSTRACT_PROPERTY} but we use a different field name because "abstract"
- * is a reserved keyword.
- *
- * @see #ABSTRACT_PROPERTY
- * @see #getAbstract()
- */
- private CharSequence description;
-
- /**
- * Whether this item should be shown on the map.
- *
- * @see #VISIBLE_PROPERTY
- * @see #isVisible()
- */
- private boolean visible;
-
- /**
- * Additional user defined properties, created when first requested.
- *
- * @see #getUserProperties()
- */
- private Map<String,Object> userMap;
-
- /**
- * Only used by classes in this package.
- */
- MapItem() {
- visible = true;
- }
-
- /**
- * Returns the identifier of this map item. The identifier can be any character string at developer choice;
- * there is currently no restriction on identifier syntax and no restriction about identifier uniqueness.
- * That identifier is currently not used by Apache SIS; it is made available as a user convenience for
- * referencing {@code MapItem} instances externally.
- *
- * <p>NOTE: restriction about identifier syntax and uniqueness may be added in a future version.</p>
- *
- * @return identifier, or {@code null} if none.
- *
- * @see #IDENTIFIER_PROPERTY
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * Sets a new identifier for this map item. If this method is never invoked, the default value is {@code null}.
- * If the given value is different than the previous value, then a change event is sent to all listeners
- * registered for the {@value #IDENTIFIER_PROPERTY} property.
- *
- * @param newValue the new identifier, or {@code null} if none.
- */
- public void setIdentifier(final String newValue) {
- final String oldValue = identifier;
- if (!Objects.equals(oldValue, newValue)) {
- identifier = newValue;
- firePropertyChange(IDENTIFIER_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns a human-readable short description for pick lists.
- * This title should be user friendly and may be a {@link String} or {@link InternationalString} instance.
- * It shall not be used as an identifier.
- *
- * @return a short description to be shown to the user, or {@code null} if none.
- *
- * @see #TITLE_PROPERTY
- */
- public CharSequence getTitle() {
- return title;
- }
-
- /**
- * Sets a new human-readable short description for pick lists. If this method is never invoked,
- * the default value is {@code null}. If the given value is different than the previous value,
- * then a change event is sent to all listeners registered for the {@value #TITLE_PROPERTY} property.
- *
- * @param newValue a short description to be shown to the user, or {@code null} if none.
- */
- public void setTitle(final CharSequence newValue) {
- final CharSequence oldValue = title;
- if (!Objects.equals(oldValue, newValue)) {
- title = newValue;
- firePropertyChange(TITLE_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns a narrative description providing additional information.
- * The abstract is more detailed than the {@linkplain #getTitle() title} property and may be a few paragraphs long.
- * This abstract should be user friendly and may be a {@link String} or {@link InternationalString} instance.
- *
- * @return narrative description to be shown to the user, or {@code null} if none.
- *
- * @see #ABSTRACT_PROPERTY
- */
- public CharSequence getAbstract() {
- return description;
- }
-
- /**
- * Sets a new a narrative description providing additional information. If this method is never invoked,
- * the default value is {@code null}. If the given value is different than the previous value, then
- * a change event is sent to all listeners registered for the {@value #ABSTRACT_PROPERTY} property.
- *
- * @param newValue a narrative description to be shown to the user, or {@code null} if none.
- */
- public void setAbstract(final CharSequence newValue) {
- final CharSequence oldValue = description;
- if (!Objects.equals(oldValue, newValue)) {
- description = newValue;
- firePropertyChange(ABSTRACT_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns whether this item should be shown on the map. If this item is a {@code MapGroup},
- * then a {@code false} visibility status implies that all group components are also hidden.
- *
- * @return {@code true} if this item is visible.
- *
- * @see #VISIBLE_PROPERTY
- */
- public boolean isVisible() {
- return visible;
- }
-
- /**
- * Sets whether this item should be shown on the map.
- * If this method is never invoked, the default value is {@code true}.
- * If the given value is different than the previous value, then a change event
- * is sent to all listeners registered for the {@value #VISIBLE_PROPERTY} property.
- *
- * <p>If this item is a {@code MapLayers}, then hiding this group should hide all components in this group,
- * but without changing the individual {@value #VISIBLE_PROPERTY} property of those components.
- * Consequently, making the group visible again restore each component to the visibility state
- * it has before the group was hidden (assuming those states have not been changed in other ways).</p>
- *
- * @param newValue {@code false} to hide this item and all it's components.
- */
- public void setVisible(final boolean newValue) {
- final boolean oldValue = visible;
- if (oldValue != newValue) {
- visible = newValue;
- firePropertyChange(VISIBLE_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns the envelope of this {@code MapItem}.
- * If this instance is a {@code MapLayers} the envelope is the concatenation of all it's components,
- * in case of multiple CRS for each MapLayer, the resulting envelope CRS is unpredictable.
- * If this instance is a {@code MapLayer} the envelope is the resource data envelope.
- *
- * @return the spatiotemporal extent. May be absent if none or too costly to compute.
- * @throws DataStoreException if an error occurred while reading or computing the envelope.
- */
- public Optional<Envelope> getEnvelope() throws DataStoreException {
- return Optional.empty();
- }
-
- /**
- * Returns a modifiable map of user properties.
- * The content of this map is left to users; Apache SIS does not use it in any way.
- * This map is not thread-safe; synchronization if desired is user responsibility.
- *
- * @return map of user properties. This map is live: changes in this map
- * are immediately reflected in this {@code MapItem}.
- */
- @SuppressWarnings("ReturnOfCollectionOrArrayField")
- public Map<String,Object> getUserProperties() {
- if (userMap == null) {
- userMap = new HashMap<>();
- }
- return userMap;
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayer.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayer.java
deleted file mode 100644
index dae591e..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayer.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Objects;
-import java.util.Optional;
-import org.opengis.coverage.Coverage;
-import org.opengis.feature.Feature;
-import org.opengis.geometry.Envelope;
-import org.apache.sis.storage.Aggregate;
-import org.apache.sis.storage.DataSet;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.Query;
-import org.apache.sis.storage.Resource;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.style.Style;
-
-
-/**
- * Data (resource) associated to rules for visual representation (symbology).
- * Layers are the key elements of a map: they link data (given by {@link Resource}s) or a subset of
- * those data (filtered by {@link Query}) to their visual representation (defined by {@link Style}s).
- * The visual appearance of a layer should be similar with any rendering engine.
- * Some details may very because of different rendering strategies for label placements, 2D or 3D,
- * but the fundamentals aspect of each {@link Feature} or {@link Coverage} should be unchanged.
- *
- * @author Johann Sorel (Geomatys)
- * @version 1.2
- * @since 1.2
- */
-public class MapLayer extends MapItem {
- /**
- * The {@value} property name, used for notifications about changes in map layer resource.
- * The data resource provides the digital data to be rendered. Note that not all kinds of resources
- * are digital data. For example, a resource may be a citation of facts or figures printed on paper,
- * photographic material, or other media (see all {@link org.opengis.metadata.citation.PresentationForm}
- * values having the {@code _HARDCOPY} suffix in their name).
- * Associated values should be instances of {@link DataSet} or {@link Aggregate}.
- *
- * @see #getData()
- * @see #setData(Resource)
- */
- public static final String DATA_PROPERTY = "data";
-
- /**
- * The {@value} property name, used for notifications about changes in map layer query.
- * The query can filter resource data for rendering only a subset of available data.
- * Associated values are instances of {@link Query}.
- *
- * @see #getQuery()
- * @see #setQuery(Query)
- */
- public static final String QUERY_PROPERTY = "query";
-
- /**
- * The {@value} property name, used for notifications about changes in map layer style.
- * The style specifies the appearance of the filtered data to be rendered.
- * Associated values are instances of {@link Style}.
- *
- * @see #getStyle()
- * @see #setStyle(Style)
- */
- public static final String STYLE_PROPERTY = "style";
-
- /**
- * The {@value} property name, used for notifications about changes in map layer opacity.
- * The opacity specifies the gloabal opacity of the data to be rendered.
- *
- * @see #getOpacity()
- * @see #setOpacity(double)
- */
- public static final String OPACITY_PROPERTY = "opacity";
-
- /**
- * Data to be rendered, or {@code null} if unavailable.
- *
- * @see #DATA_PROPERTY
- * @see #getData()
- */
- private Resource resource;
-
- /**
- * Filter for rendering a subset of available data, or {@code null} if none.
- *
- * @see #QUERY_PROPERTY
- * @see #getQuery()
- */
- private Query query;
-
- /**
- * Visual representation of data, or {@code null} if none.
- *
- * @see #STYLE_PROPERTY
- * @see #getStyle()
- */
- private Style style;
-
- /**
- * Visual transparency of data, or {@code null} if none.
- *
- * @see #OPACITY_PROPERTY
- * @see #getOpacity()
- */
- private double opacity = 1.0;
-
- /**
- * Constructs an initially empty map layer.
- *
- * @todo Expect {@code Resource} and {@code Style} in argument, for discouraging
- * the use of {@code MapLayer} with null resource and null style?
- */
- public MapLayer() {
- }
-
- /**
- * Returns the data (resource) represented by this layer.
- * The resource should be a {@link DataSet}, but {@link Aggregate} is also accepted.
- * The behavior in aggregate case depends on the rendering engine.
- *
- * @return data to be rendered, or {@code null} is unavailable.
- *
- * @see #DATA_PROPERTY
- */
- public Resource getData() {
- return resource;
- }
-
- /**
- * Sets the data (resource) to be rendered.
- * The resource should never be null, still the null case is tolerated to indicate
- * that the layer should have existed but is unavailable for an unspecified reason.
- * This case may happen with processing or distant services resources.
- *
- * <p>The given resource should be a {@link DataSet} or an {@link Aggregate} of data sets.
- * However, this base class does not enforce those types. Subclasses may restrict the set
- * of resource types accepted by this method.</p>
- *
- * <p>Note that not all kinds of resources are digital data. For example, a resource may be an organization,
- * or citation of facts, tables and figures printed on paper, photographic material, or other media
- * (see all {@link org.opengis.metadata.citation.PresentationForm} values having the {@code _HARDCOPY}
- * suffix in their name). The kind of resources in {@code MapLayer} shall be one of those representing
- * digital data.</p>
- *
- * @param newValue the new data, or {@code null} if unavailable.
- */
- public void setData(final Resource newValue) {
- final Resource oldValue = resource;
- if (!Objects.equals(oldValue, newValue)) {
- resource = newValue;
- firePropertyChange(DATA_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns the filter for reducing the amount of data to render. Query filters can be
- * specified for rendering a smaller amount of data than what the resource can provide.
- * If the query is undefined, then all data will be rendered.
- *
- * @return filter for reducing data, or {@code null} for rendering all data.
- *
- * @see #QUERY_PROPERTY
- */
- public Query getQuery() {
- return query;
- }
-
- /**
- * Sets a filter for reducing the amount of data to render. If this method is never invoked, the default value
- * is {@code null}. If the given value is different than the previous value, then a change event is sent to all
- * listeners registered for the {@value #QUERY_PROPERTY} property.
- *
- * @param newValue filter for reducing data, or {@code null} for rendering all data.
- */
- public void setQuery(final Query newValue) {
- final Query oldValue = query;
- if (!Objects.equals(oldValue, newValue)) {
- query = newValue;
- firePropertyChange(QUERY_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns the visual appearance of the data.
- * If the style is undefined, the behavior is left to the rendering engine.
- * It is expected that a default style should be used.
- *
- * @return description of data visual appearance, or {@code null} if unspecified.
- */
- public Style getStyle() {
- return style;
- }
-
- /**
- * Sets the visual appearance of the data. If this method is never invoked, the default value is {@code null}.
- * If the given value is different than the previous value, then a change event is sent to all listeners
- * registered for the {@value #STYLE_PROPERTY} property.
- *
- * @param newValue description of data visual appearance, or {@code null} if unspecified.
- */
- public void setStyle(final Style newValue) {
- final Style oldValue = style;
- if (!Objects.equals(oldValue, newValue)) {
- style = newValue;
- firePropertyChange(STYLE_PROPERTY, oldValue, newValue);
- }
- }
-
- /**
- * Returns the global opacity of this layer.
- * Based on the rendering context this property may be impossible to implement,
- * it is therefore recommended to modify the style symbolizer opacity properties.
- *
- * @return opacity between 0.0 and 1.0
- */
- public double getOpacity() {
- return opacity;
- }
-
- /**
- * Sets the global rendering opacity of this layer.
- *
- * @param opacity must be betwen 0.0 and 1.0
- */
- public void setOpacity(double opacity) {
- ArgumentChecks.ensureBetween(OPACITY_PROPERTY, 0.0, 1.0, opacity);
- if (this.opacity != opacity) {
- double old = this.opacity;
- this.opacity = opacity;
- firePropertyChange(OPACITY_PROPERTY, old, opacity);
- }
- }
-
- /**
- * Returns the envelope of this {@code MapLayer}.
- * The envelope is the resource data envelope.
- *
- * @return the spatiotemporal extent. May be absent if none or too costly to compute.
- * @throws DataStoreException if an error occurred while reading or computing the envelope.
- */
- @Override
- public Optional<Envelope> getEnvelope() throws DataStoreException {
- Resource data = getData();
- if (data instanceof DataSet) {
- return ((DataSet) data).getEnvelope();
- }
- return Optional.empty();
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayers.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayers.java
deleted file mode 100644
index 0a6fe87..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapLayers.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.map;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometry.Envelopes;
-import org.apache.sis.geometry.ImmutableEnvelope;
-import org.apache.sis.measure.NumberRange;
-import org.apache.sis.storage.DataSet;
-import org.apache.sis.storage.DataStoreException;
-
-
-/**
- * A group of layers to display together.
- * {@code MapLayers} can be used for grouping related layers under a same node.
- * This allows global actions, like {@linkplain #setVisible(boolean) hiding} background layers in one call.
- * A {@code MapLayers} can also contain nested {@code MapLayers}, thus forming a tree.
- * Since {@link MapLayer} and {@code MapLayers} are the only {@link MapItem} subclasses,
- * all leaves in this tree can only be {@link MapLayer} instances (assuming no {@code MapLayers} is empty).
- *
- * <p>A {@code MapLayers} is the root node of the tree of all layers to draw on the map,
- * unless there is only one layer to draw.
- * The {@link MapItem} children are listed by {@link #getComponents()} in <var>z</var> order.
- * In addition, {@code MapLayers} may define an {@linkplain #getAreaOfInterest() area of interest}
- * which should be zoomed by default when the map is rendered.</p>
- *
- * @author Johann Sorel (Geomatys)
- * @version 1.2
- * @since 1.2
- */
-public class MapLayers extends MapItem {
- /**
- * The {@value} property name, used for notifications about changes in area of interest.
- * Associated values are instances of {@link Envelope}.
- *
- * @see #getAreaOfInterest()
- * @see #setAreaOfInterest(Envelope)
- */
- public static final String AREA_OF_INTEREST_PROPERTY = "areaOfInterest";
-
- /**
- * The {@value} property name, used for notifications about changes in map item components.
- *
- * @see #getComponents()
- * @see #addPropertyChangeListener(String, PropertyChangeListener)
- */
- public static final String COMPONENTS_PROPERTY = "components";
-
- /**
- * The components in this group, or an empty list if none.
- *
- * @todo Should be an observable list with event sent when an element is added/removed/modified.
- */
- private final List<MapItem> components = new NotifiedList<MapItem>() {
- @Override
- protected void notifyAdd(MapItem item, int index) {
- firePropertyChange(ListChangeEvent.added(MapLayers.this, COMPONENTS_PROPERTY, components, item, index));
- }
-
- @Override
- protected void notifyAdd(List<MapItem> items, NumberRange<Integer> range) {
- firePropertyChange(ListChangeEvent.added(MapLayers.this, COMPONENTS_PROPERTY, components, items, range));
- }
-
- @Override
- protected void notifyRemove(MapItem item, int index) {
- firePropertyChange(ListChangeEvent.removed(MapLayers.this, COMPONENTS_PROPERTY, components, item, index));
- }
-
- @Override
- protected void notifyRemove(List<MapItem> items, NumberRange<Integer> range) {
- firePropertyChange(ListChangeEvent.removed(MapLayers.this, COMPONENTS_PROPERTY, components, items, range));
- }
-
- @Override
- protected void notifyReplace(MapItem olditem, MapItem newitem, int index) {
- firePropertyChange(ListChangeEvent.changed(MapLayers.this, COMPONENTS_PROPERTY, components));
- }
- };
-
- /**
- * The area of interest, or {@code null} if unspecified.
- */
- private ImmutableEnvelope areaOfInterest;
-
- /**
- * Creates an initially empty group of layers.
- */
- public MapLayers() {
- }
-
- /**
- * Gets the modifiable list of children contained in this group.
- * The elements in the list are sorted in rendering order.
- * This means that the first rendered element, which will be below
- * all other elements on the rendered map, is located at index zero.
- *
- * <p>The returned list is modifiable: changes in the returned list will
- * be immediately reflected in this {@code MapLayers}, and conversely.</p>
- *
- * @return modifiable list of children in this group of layers.
- */
- @SuppressWarnings("ReturnOfCollectionOrArrayField")
- public List<MapItem> getComponents() {
- return components;
- }
-
- /**
- * Returns the map area to show by default.
- * This is not necessarily the {@linkplain DataSet#getEnvelope() envelope of data}
- * since one may want to zoom in a different spatiotemporal area.
- *
- * <p>The {@linkplain org.apache.sis.geometry.GeneralEnvelope#getCoordinateReferenceSystem() envelope CRS}
- * provides the reference system to use by default for rendering the map. It may be different than the CRS
- * of data. The returned envelope may have {@linkplain org.apache.sis.geometry.GeneralEnvelope#isAllNaN()
- * all its coordinates set to NaN} if only the {@link CoordinateReferenceSystem} is specified.</p>
- *
- * @return map area to show by default, or {@code null} if unspecified.
- *
- * @see DataSet#getEnvelope()
- */
- public Envelope getAreaOfInterest() {
- return areaOfInterest;
- }
-
- /**
- * Sets the map area to show by default.
- * The given envelope is not necessarily related to the data contained in this group.
- * It may be wider, or smaller, and in a different {@link CoordinateReferenceSystem}.
- *
- * @param newValue new map area to show by default, or {@code null} if unspecified.
- */
- public void setAreaOfInterest(final Envelope newValue) {
- final ImmutableEnvelope imenv = ImmutableEnvelope.castOrCopy(newValue);
- final Envelope oldValue = areaOfInterest;
- if (!Objects.equals(oldValue, imenv)) {
- areaOfInterest = imenv;
- firePropertyChange(AREA_OF_INTEREST_PROPERTY, oldValue, imenv);
- }
- }
-
- /**
- * Returns the envelope of this {@code MapItem}.
- * If this instance is a {@code MapLayers} the envelope is the concatenation of all it's components,
- * in case of multiple CRS for each MapLayer, the resulting envelope CRS is unpredictable.
- * If this instance is a {@code MapLayer} the envelope is the resource data envelope.
- *
- * @return the spatiotemporal extent. May be absent if none or too costly to compute.
- * @throws DataStoreException if an error occurred while reading or computing the envelope.
- */
- @Override
- public Optional<Envelope> getEnvelope() throws DataStoreException {
- List<Envelope> envelopes = new ArrayList<>();
- for (MapItem i : components) {
- i.getEnvelope().ifPresent(envelopes::add);
- }
- switch (envelopes.size()) {
- case 0 : return Optional.empty();
- case 1 : return Optional.of(envelopes.get(0));
- default : {
- try {
- return Optional.ofNullable(Envelopes.union(envelopes.toArray(Envelope[]::new)));
- } catch (TransformException ex) {
- throw new DataStoreException(ex.getMessage(), ex);
- }
- }
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/NotifiedList.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/NotifiedList.java
deleted file mode 100644
index e6ff28f..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/NotifiedList.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.map;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.sis.measure.NumberRange;
-
-
-/**
- * Decorate a CopyOnWriteArrayList and notify changes when elements are added or removed.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class NotifiedList<T> extends AbstractList<T> {
-
- private final CopyOnWriteArrayList<T> parent = new CopyOnWriteArrayList<>();
-
- public NotifiedList() {
- }
-
- @Override
- public T get(int index) {
- return parent.get(index);
- }
-
- @Override
- public int size() {
- return parent.size();
- }
-
- @Override
- public T set(int index, T element) {
- final T old = parent.set(index, element);
- notifyReplace(old, element, index);
- return old;
- }
-
- @Override
- public void add(int index, T element) {
- parent.add(index, element);
- notifyAdd(element, index);
- }
-
- @Override
- public T remove(int index) {
- final T old = parent.remove(index);
- notifyRemove(old, index);
- return old;
- }
-
- protected abstract void notifyAdd(final T item, int index);
-
- protected abstract void notifyAdd(final List<T> items, NumberRange<Integer> range);
-
- protected abstract void notifyRemove(final T item, int index);
-
- protected abstract void notifyRemove(final List<T> items, NumberRange<Integer> range);
-
- protected abstract void notifyReplace(final T olditem, final T newitem, int index);
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/Presentation.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/Presentation.java
deleted file mode 100644
index 040173e..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/Presentation.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Objects;
-import org.opengis.feature.Feature;
-import org.apache.sis.coverage.grid.GridCoverage;
-import org.apache.sis.storage.DataStore;
-import org.apache.sis.storage.Resource;
-
-
-/**
- * Parent class of all elements having a graphical representation on the map.
- * {@code Presentation} instances are organized in a tree closely related to the {@link MapLayer} tree.
- * The {@link MapLayer} tree specifies data and styles in a device-independent way and for all zoom levels.
- * The {@code Presentation} tree can be seen as {@link MapLayer} information filtered for the current rendering
- * context (map projection, zoom level, window size, <i>etc.</i>) and converted to data structures more directly
- * exploitable by the display device. In particular a {@code Presentation} object must encapsulate data without
- * costly evaluation, processing or loading work remaining to do: the {@link Feature} or the {@link GridCoverage}
- * (for instance) should have been read in advance from the {@link DataStore}.
- * The preparation of a {@link Presentation} tree before displaying may be done in a background thread.
- *
- * <p>Note that multiple presentations may be generated for the same feature.
- * Consequently, many {@code Presentation} instances may encapsulate the same {@link Feature} instance.</p>
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @todo Consider renaming as {@code Graphic} for emphasis that this is a graphical representation of something.
- * This would be consistent with legacy GO-1 specification (even if retired, it still have worthy material).
- * @todo Consider renaming as {@code Instruction} for emphasis that this is a rendering operation.
- * IHO S-52 and S-100 specification. S-100 has been build guided by ISO-19117.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class Presentation {
-
- private MapLayer layer;
- private Resource resource;
- private Feature candidate;
-
- public Presentation() {
- }
-
- public Presentation(MapLayer layer, Resource resource, Feature candidate) {
- this.layer = layer;
- this.resource = resource;
- this.candidate = candidate;
- }
-
- /**
- * Returns the original map layer the feature comes from.
- *
- * @return MapLayer can be null if the presentation is not associated to a layer.
- */
- public MapLayer getLayer() {
- return layer;
- }
-
- /**
- * Set map layer this presentation comes from.
- *
- * @param layer may be null
- */
- public void setLayer(MapLayer layer) {
- this.layer = layer;
- }
-
- public Resource getResource() {
- return resource;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- /**
- * Returns the original candidate having this presentation.
- * This is often a Coverage or a Feature.
- *
- * @return can be null if the presentation is not associated to any identifiable object.
- */
- public Feature getCandidate() {
- return candidate;
- }
-
- /**
- * Set feature this presentation comes from.
- *
- * @param feature may be null
- */
- public void setCandidate(Feature feature) {
- this.candidate = feature;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 89 * hash + Objects.hashCode(this.layer);
- hash = 89 * hash + Objects.hashCode(this.resource);
- hash = 89 * hash + Objects.hashCode(this.candidate);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Presentation other = (Presentation) obj;
- if (!Objects.equals(this.layer, other.layer)) {
- return false;
- }
- if (!Objects.equals(this.resource, other.resource)) {
- return false;
- }
- if (!Objects.equals(this.candidate, other.candidate)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/PropertyNameCollector.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/PropertyNameCollector.java
deleted file mode 100644
index faa7813..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/PropertyNameCollector.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Set;
-import java.util.HashSet;
-import org.opengis.filter.ValueReference;
-
-
-/**
- * Collects all properties used in style elements.
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @author Johann Sorel (Geomatys)
- */
-final class PropertyNameCollector extends SymbologyVisitor {
- /**
- * All value references found.
- *
- * @see ValueReference#getXPath()
- */
- final Set<String> references;
-
- /**
- * Creates a new collector.
- */
- PropertyNameCollector() {
- references = new HashSet<>();
- }
-
- /**
- * Invoked for each value reference found.
- */
- @Override
- protected void visitProperty(final ValueReference<?,?> expression) {
- if (expression != null) {
- references.add(expression.getXPath());
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ResourceSymbolizer.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ResourceSymbolizer.java
deleted file mode 100644
index 62a3453..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/ResourceSymbolizer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.map;
-
-import org.apache.sis.style.se1.StyleFactory;
-import org.apache.sis.style.se1.Symbolizer;
-
-
-/**
- * Resource symbolizers act on a resource as a whole, not on individual features.
- * Such symbolizers are not defined by the Symbology Encoding specification but are
- * often required to produce uncommon presentations.
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @author Johann Sorel (Geomatys)
- *
- * @param <R> the type of data to style, such as {@code Feature} or {@code Coverage}.
- */
-public abstract class ResourceSymbolizer<R> extends Symbolizer<R> {
- /**
- * Constructs a new symbolozer.
- *
- * @param context context (features or coverages) in which this style element will be used.
- */
- public ResourceSymbolizer(final StyleFactory<R> context) {
- super(context);
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPortrayer.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPortrayer.java
deleted file mode 100644
index 275a6ff..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPortrayer.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- * 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.map;
-
-import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.function.Predicate;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.LineString;
-import org.locationtech.jts.geom.MultiLineString;
-import org.locationtech.jts.geom.MultiPoint;
-import org.locationtech.jts.geom.MultiPolygon;
-import org.locationtech.jts.geom.Point;
-import org.locationtech.jts.geom.Polygon;
-import org.opengis.util.GenericName;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.PropertyNotFoundException;
-import org.opengis.feature.PropertyType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.Expression;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.coverage.grid.PixelInCell;
-import org.apache.sis.feature.Features;
-import org.apache.sis.filter.DefaultFilterFactory;
-import org.apache.sis.geometry.Envelopes;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.feature.privy.AttributeConvention;
-import org.apache.sis.filter.privy.XPath;
-import org.apache.sis.storage.FeatureQuery;
-import org.apache.sis.storage.Aggregate;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.FeatureSet;
-import org.apache.sis.storage.GridCoverageResource;
-import org.apache.sis.storage.Query;
-import org.apache.sis.storage.Resource;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
-import org.apache.sis.style.se1.FeatureTypeStyle;
-import org.apache.sis.style.se1.Rule;
-import org.apache.sis.style.se1.Symbolizer;
-import org.apache.sis.style.se1.SemanticType;
-import org.apache.sis.style.se1.Symbology;
-
-
-/**
- * Generation a Stream of Presentation for a map.
- *
- * <p>
- * NOTE: this class is experimental and subject to modifications.
- * </p>
- *
- * <p>
- * Style properties ignored :
- * </p>
- * <ul>
- * <li>Style : isDefault : behavior from ISO 19117 which can be replaced by OGC SE Rule.isElseRule</li>
- * <li>Style : defaultSpecification : behavior from ISO 19117 which can be replaced by OGC SE Rule.isElseRule</li>
- * <li>FeatureTypeStyle : instance ids : behavior from ISO 19117 which can be replaced by OGC SE Rule.filter</li>
- * </ul>
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SEPortrayer {
- /**
- * Rule scale tolerance.
- */
- private static final double SE_EPSILON = 1e-6;
-
- /**
- * Used in SLD/SE to calculate scale for degree CRSs.
- */
- private static final double SE_DEGREE_TO_METERS = 6378137.0 * 2.0 * Math.PI / 360.0;
- private static final double DEFAULT_DPI = 90.0; // ~ 0.28 * 0.28mm
- private static final double PIXEL_SIZE = 0.0254;
-
- /**
- * A test to know if a given property is an SIS convention or not. Return true if
- * the property is NOT marked as an SIS convention, false otherwise.
- */
- private static final Predicate<IdentifiedType> IS_NOT_CONVENTION = p -> !AttributeConvention.contains(p.getName());
-
- private final FilterFactory<Feature,Object,Object> filterFactory;
-
- /**
- * Hint to avoid decimating feature properties because they may be used
- * later for other purposes.
- */
- private boolean preserveProperties;
-
- private BiFunction<GridGeometry, Symbolizer<?>, Double> marginSolver;
-
- public SEPortrayer() {
- filterFactory = DefaultFilterFactory.forFeatures();
- marginSolver = (GridGeometry t, Symbolizer<?> u) -> 30.0;
- }
-
- /**
- * Hint to avoid decimating feature properties because they may be used
- * later for other purposes.
- * Default value is false.
- *
- * @return true if all feature properties are preserved in Presentation instances.
- */
- public boolean isPreserveProperties() {
- return preserveProperties;
- }
-
- /**
- * Hint to avoid decimating feature properties because they may be used
- * later for other purposes.
- * Default value is false.
- *
- * @param preserveProperties set to true to preserve all feature properties in Presentation instances.
- */
- public void setPreserveProperties(boolean preserveProperties) {
- this.preserveProperties = preserveProperties;
- }
-
- /**
- * Replace default margin solver.
- * The margin solver try to guess the expected symbolizer size to expand the query bounding box.
- * @param marginSolver
- */
- public void setMarginSolver(BiFunction<GridGeometry, Symbolizer<?>, Double> marginSolver) {
- this.marginSolver = Objects.requireNonNull(marginSolver);
- }
-
- /**
- * Generate presentations for the given map item.
- */
- public Stream<Presentation> present(GridGeometry canvas, final MapItem mapitem) {
- Stream<Presentation> stream = Stream.empty();
- if (mapitem.isVisible()) {
- if (mapitem instanceof MapLayer) {
- final MapLayer layer = (MapLayer) mapitem;
- stream = Stream.concat(stream, present(canvas, layer, layer.getData()));
- } else if (mapitem instanceof MapLayers) {
- final MapLayers layers = (MapLayers) mapitem;
- for (MapItem item : layers.getComponents()) {
- stream = Stream.concat(stream, present(canvas, item));
- }
- }
- }
- return stream;
- }
-
- private Stream<Presentation> present(GridGeometry canvas, MapLayer layer, Resource resource) {
- final Resource refResource = resource;
- Stream<Presentation> stream = Stream.empty();
- final FeatureType type;
- if (resource instanceof FeatureSet) {
- // Apply user query if defined.
- final Query basequery = layer.getQuery();
- if (basequery != null) try {
- resource = ((FeatureSet) resource).subset(basequery);
- } catch (DataStoreException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- return stream;
- }
- try {
- type = ((FeatureSet) resource).getType();
- } catch (DataStoreException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- return stream;
- }
- } else if (resource instanceof GridCoverageResource) {
-
- // Apply user query if defined.
- final Query basequery = layer.getQuery();
- if (basequery != null) try {
- resource = ((GridCoverageResource) resource).subset(basequery);
- } catch (DataStoreException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- return stream;
- }
-
- type = null;
- } else if (resource instanceof Aggregate) {
- try {
- // Combine each component resource in the stream.
- for (final Resource r : ((Aggregate) resource).components()) {
- stream = Stream.concat(stream, present(canvas, layer, r));
- }
- } catch (DataStoreException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- }
- return stream;
- } else {
- // Unknown type.
- return Stream.empty();
- }
- final MathTransform gridToCRS = canvas.getGridToCRS(PixelInCell.CELL_CENTER);
- final AffineTransform dispToObj;
- final AffineTransform objToDisp;
- try {
- dispToObj = AffineTransforms2D.castOrCopy(gridToCRS);
- objToDisp = dispToObj.createInverse();
- } catch (IllegalArgumentException | NoninvertibleTransformException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- return stream;
- }
- final double seScale = getSEScale(canvas, objToDisp);
- final Symbology style = (Symbology) layer.getStyle(); // TODO: we do not yet support other implementations.
- for (FeatureTypeStyle fts : style.featureTypeStyles()) {
- final List<Rule<Feature>> rules = getValidRules(fts, seScale, type);
- if (rules.isEmpty()) continue;
-
- // Prepare the renderers.
- final int elseRuleIndex = sortByElseRule(rules);
- { //special case for resource symbolizers
- //resource symbolizers must be alone in a FTS
- ResourceSymbolizer<?> resourceSymbolizer = null;
- int count = 0;
- for (final Rule<Feature> r : rules) {
- for (final Symbolizer<?> s : r.symbolizers()) {
- count++;
- if (s instanceof ResourceSymbolizer) {
- resourceSymbolizer = (ResourceSymbolizer) s;
- }
- }
- }
- if (resourceSymbolizer != null) {
- if (count > 1) {
- Exception ex = new IllegalArgumentException("A resource symbolizer must be alone in a FeatureTypeStyle element." );
- final ExceptionPresentation presentation = new ExceptionPresentation(ex);
- presentation.setLayer(layer);
- presentation.setResource(resource);
- stream = Stream.concat(stream, Stream.of(presentation));
- } else {
- final SEPresentation presentation = new SEPresentation(layer, resource, null, resourceSymbolizer);
- stream = Stream.concat(stream, Stream.of(presentation));
- }
- continue;
- }
- }
- // Extract the used names.
- Set<String> names;
- if (preserveProperties) {
- names = null;
- } else {
- names = propertiesNames(rules);
- if (names.contains("*")) {
- // We need all properties.
- names = null;
- }
- }
- if (resource instanceof GridCoverageResource) {
- boolean painted = false;
- for (int i = 0; i < elseRuleIndex; i++) {
- final Stream<Presentation> subStream = present(rules.get(i), layer, resource, resource, null);
- if (subStream != null) {
- painted = true;
- stream = Stream.concat(stream, subStream);
- }
- }
- // The data hasn't been painted, paint it with the 'else' rules.
- if (!painted) {
- for (int i = elseRuleIndex, n = rules.size(); i < n; i++) {
- final Stream<Presentation> subStream = present(rules.get(i), layer, resource, resource, null);
- if (subStream != null) {
- stream = Stream.concat(stream, subStream);
- }
- }
- }
- } else if (resource instanceof FeatureSet) {
- final FeatureSet fs = (FeatureSet) resource;
- // Calculate max symbol size, to expand search envelope.
- double symbolsMargin = 0.0;
- for (Rule<Feature> rule : rules) {
- for (Symbolizer<?> symbolizer : rule.symbolizers()) {
- symbolsMargin = Math.max(symbolsMargin, marginSolver.apply(canvas, symbolizer));
- }
- }
- if (Double.isNaN(symbolsMargin) || Double.isInfinite(symbolsMargin)) {
- // Symbol margin cannot be pre calculated, expect a max of 300pixels.
- symbolsMargin = 300f;
- }
- if (symbolsMargin > 0) {
- symbolsMargin *= AffineTransforms2D.getScale(dispToObj);
- }
- try {
- // Optimize query.
- final Query query = prepareQuery(canvas, fs, names, rules, symbolsMargin);
- final Stream<Presentation> s = fs.subset(query)
- .features(false)
- .flatMap((Feature feature) ->
- {
- Stream<Presentation> stream1 = Stream.empty();
- boolean painted = false;
- for (int i = 0; i < elseRuleIndex; i++) {
- final Stream<Presentation> subStream = present(rules.get(i), layer, fs, refResource, feature);
- if (subStream != null) {
- painted = true;
- stream1 = Stream.concat(stream1, subStream);
- }
- }
- // The feature hasn't been painted, paint it with the 'else' rules.
- if (!painted) {
- for (int i = elseRuleIndex, n = rules.size(); i < n; i++) {
- final Stream<Presentation> subStream = present(rules.get(i), layer, fs, refResource, feature);
- if (subStream != null) {
- stream1 = Stream.concat(stream1, subStream);
- }
- }
- }
- return stream1;
- });
- stream = Stream.concat(stream, s);
- } catch (DataStoreException | TransformException ex) {
- stream = Stream.concat(stream, Stream.of(new ExceptionPresentation(ex)));
- }
- }
- }
- return stream;
- }
-
- private static Stream<Presentation> present(Rule<Feature> rule, MapLayer layer,
- Resource resource, Resource refResource, Feature feature)
- {
- final Filter<Feature> ruleFilter = rule.getFilter();
- //test if the rule is valid for this resource/feature
- if (rule.isElseFilter() || ((Filter) ruleFilter).test(feature == null ? resource : feature)) { // TODO: unsafe cast.
- Stream<Presentation> stream = Stream.empty();
- for (final Symbolizer<?> symbolizer : rule.symbolizers()) {
- final SEPresentation presentation = new SEPresentation(layer, refResource, feature, symbolizer);
- stream = Stream.concat(stream, Stream.of(presentation));
- }
- return stream;
- }
- return null;
- }
-
- /**
- * Creates an optimal query to send to the Featureset, knowing which properties are knowned and
- * the appropriate bounding box to filter.
- */
- private FeatureQuery prepareQuery(GridGeometry canvas, FeatureSet fs, Set<String> requiredProperties,
- List<Rule<Feature>> rules, double symbolsMargin) throws DataStoreException, TransformException
- {
- final FeatureQuery query = new FeatureQuery();
- final FeatureType schema = fs.getType();
- /*
- * Check if some used properties are not part of the type.
- * This means the FeatureSet may contain sub types.
- * We cannot optimize the query.
- */
- if (requiredProperties != null) {
- for (String pn : requiredProperties) {
- try {
- schema.getProperty(pn);
- } catch (PropertyNotFoundException e) {
- return query;
- }
- }
- }
- // Search all geometry expression used in the symbols.
- boolean allDefined = true;
- final Set<Expression<Feature,?>> geomProperties = new HashSet<>();
- if (rules != null) {
- for (final Rule<Feature> r : rules) {
- for (final Symbolizer<Feature> s : r.symbolizers()) {
- final Expression<Feature,?> expGeom = s.getGeometry();
- if (expGeom != null) {
- geomProperties.add(expGeom );
- } else {
- allDefined = false;
- }
- }
- }
- } else {
- allDefined = false;
- }
- if (!allDefined) {
- // Add the default geometry property.
- try {
- PropertyType geomDesc = getDefaultGeometry(schema);
- geomProperties.add(filterFactory.property(geomDesc.getName().toString()));
- } catch (PropertyNotFoundException | IllegalStateException ex) {
- // Do nothing.
- }
- }
- if (geomProperties.isEmpty()) {
- // No geometry selected for rendering.
- query.setSelection(Filter.exclude());
- return query;
- }
- final Envelope bbox = optimizeBBox(canvas, symbolsMargin);
- Filter<Feature> filter;
- // Make a bbox filter.
- if (geomProperties.size() == 1) {
- final Expression<Feature,?> geomExp = geomProperties.iterator().next();
- filter = filterFactory.bbox(geomExp, bbox);
- } else {
- // Make an OR filter with all geometries.
- final List<Filter<?>> geomFilters = new ArrayList<>();
- for (final Expression<Feature,?> geomExp : geomProperties) {
- geomFilters.add(filterFactory.bbox(geomExp, bbox));
- }
- filter = filterFactory.or((List) geomFilters); // TODO
- }
- /*
- * Combine the filter with rule filters.
- */
- ruleOpti:
- if (rules != null) {
- final List<Filter<Feature>> rulefilters = new ArrayList<>();
- for (final Rule<Feature> rule : rules) {
- if (rule.isElseFilter()) {
- // We cannot append styling filters, an else rule match all features.
- break ruleOpti;
- } else {
- final Filter<Feature> rf = rule.getFilter();
- if (rf == Filter.<Feature>include()) {
- // We cannot append styling filters, this rule matchs all features.
- break ruleOpti;
- }
- rulefilters.add(rf);
- }
- }
- final Filter<Feature> combined;
- if (rulefilters.size() == 1) {
-// //TODO need a stylefactory in SIS
-// //special case, only one rule and we passed the filter to the query
-// //we can remove it from the rule
-// final Rule original = rules.get(0);
-// Rule rule = styleFactory.rule(null, null, null,
-// original.getMinScaleDenominator(),
-// original.getMaxScaleDenominator(),
-// new ArrayList(original.symbolizers()),
-// Filter.include());
-// rules.set(0, rule);
- combined = rulefilters.get(0);
- } else {
- combined = filterFactory.or(rulefilters);
- }
- if (filter != Filter.<Feature>include()) {
- filter = filterFactory.and(filter, combined);
- } else {
- filter = combined;
- }
- }
- query.setSelection(filter);
- /*
- * Reduce requiered attributes.
- */
- if (requiredProperties == null) {
- // All properties are required.
- } else {
- final Set<String> copy = new HashSet<>();
- // Add used properties.
- for (final String str : requiredProperties) {
- copy.add(stripXpath(str));
- }
- // Add properties used as geometry.
- for (Expression<?,?> exp : geomProperties) {
- final PropertyNameCollector collector = new PropertyNameCollector();
- collector.visit(exp);
- collector.references.stream()
- .map(SEPortrayer::stripXpath)
- .forEach(copy::add);
- }
- try {
- // Always include the identifier if it exist.
- schema.getProperty(AttributeConvention.IDENTIFIER);
- copy.add(AttributeConvention.IDENTIFIER);
- } catch (PropertyNotFoundException ex) {
- // No id, ignore it.
- }
- final List<FeatureQuery.NamedExpression> columns = new ArrayList<>();
- for (String propName : copy) {
- columns.add(new FeatureQuery.NamedExpression(filterFactory.property(propName), propName));
- }
- query.setProjection(columns.toArray(FeatureQuery.NamedExpression[]::new));
- }
- //TODO optimize filter
- //TODO add linear resolution
- return query;
- }
-
- /**
- * Geographic scale calculated using OGC Symbology Encoding specification.
- * This is not the scale Objective to Display.
- * This is not an accurate geographic scale.
- * This is a fake average scale unproper for correct rendering.
- * It is used only to filter SE rules.
- */
- private static double getSEScale(final GridGeometry canvas, final AffineTransform objToDisp) {
- final Envelope envelope = canvas.getEnvelope();
- final CoordinateReferenceSystem objCRS = envelope.getCoordinateReferenceSystem();
- final long width = canvas.getExtent().getSize(0);
- if (AffineTransforms2D.getRotation(objToDisp) != 0.0) {
- final double scale = AffineTransforms2D.getScale(objToDisp);
- if (objCRS instanceof GeographicCRS) {
- return (SE_DEGREE_TO_METERS * DEFAULT_DPI) / (scale*PIXEL_SIZE);
- } else {
- return DEFAULT_DPI / (scale *PIXEL_SIZE);
- }
- } else {
- if (objCRS instanceof GeographicCRS) {
- return (envelope.getSpan(0) * SE_DEGREE_TO_METERS) / (width / DEFAULT_DPI * PIXEL_SIZE);
- } else {
- return envelope.getSpan(0) / (width / DEFAULT_DPI * PIXEL_SIZE);
- }
- }
- }
-
- /**
- * List the valid rules for current scale and type.
- */
- private static List<Rule<Feature>> getValidRules(final FeatureTypeStyle fts, final double scale, final FeatureType type) {
- final Optional<GenericName> name = fts.getFeatureTypeName();
- if (name.isPresent()) {
- // TODO: should we check parent types?
- if (!name.get().equals(type.getName())) {
- return List.of();
- }
- }
- // Check semantic, only if we have a feature type.
- if (type != null) {
- final Collection<SemanticType> semantics = fts.semanticTypeIdentifiers();
- if (!semantics.isEmpty()) {
- Class<?> ctype;
- try {
- ctype = Features.toAttribute(getDefaultGeometry(type))
- .map(AttributeType::getValueClass)
- .orElse(null);
- } catch (PropertyNotFoundException e) {
- ctype = null;
- }
- boolean valid = false;
- for (SemanticType semantic : semantics) {
- if (semantic == SemanticType.ANY) {
- valid = true;
- break;
- } else if (semantic == SemanticType.LINE) {
- if (ctype == LineString.class || ctype == MultiLineString.class || ctype == Geometry.class) {
- valid = true;
- break;
- }
- } else if (semantic == SemanticType.POINT) {
- if (ctype == Point.class || ctype == MultiPoint.class || ctype == Geometry.class) {
- valid = true;
- break;
- }
- } else if (semantic == SemanticType.POLYGON) {
- if (ctype == Polygon.class || ctype == MultiPolygon.class || ctype == Geometry.class) {
- valid = true;
- break;
- }
- } else if (semantic == SemanticType.RASTER) {
- // Cannot test this on feature datas.
- } else if (semantic == SemanticType.TEXT) {
- // Cannot define a `text` type with current API.
- }
- }
- if (!valid) return List.of();
- }
- }
-
- //TODO filter correctly possibilities
- //test if the featutetype is valid
- //we move to next feature type if not valid
- //if (typeName != null && !(typeName.equalsIgnoreCase(fts.getFeatureTypeName())) ) continue;
-
- final List<? extends Rule<Feature>> rules = fts.rules();
- final List<Rule<Feature>> validRules = new ArrayList<>();
- for (final Rule<Feature> rule : rules) {
- //test if the scale is valid for this rule
- if (rule.getMinScaleDenominator() - SE_EPSILON <= scale && rule.getMaxScaleDenominator() + SE_EPSILON > scale) {
- validRules.add(rule);
- }
- }
- return validRules;
- }
-
- /**
- * Lists all properties used in given rules.
- */
- private static Set<String> propertiesNames(final Collection<? extends Rule<Feature>> rules) {
- final PropertyNameCollector collector = new PropertyNameCollector();
- for (final Rule<Feature> r : rules) {
- collector.visit(r);
- collector.visit(r.getFilter());
- }
- return collector.references;
- }
-
- /**
- * Sorts the rules, isolate the else rules, they must be handle differently
- *
- * @return index of starting else rules.
- */
- private static int sortByElseRule(final List<Rule<Feature>> sortedRules){
- int elseRuleIndex = sortedRules.size();
- for (int i = 0; i < elseRuleIndex; i++) {
- final Rule<Feature> r = sortedRules.get(i);
- if (r.isElseFilter()) {
- elseRuleIndex--;
- // Move the rule at the end
- sortedRules.remove(i);
- sortedRules.add(r);
- }
- }
- return elseRuleIndex;
- }
-
- /**
- * Search for the main geometric property in the given type. We'll search
- * for an SIS convention first (see
- * {@link AttributeConvention#GEOMETRY_PROPERTY}. If no convention is set on
- * the input type, we'll check if it contains a single geometric property.
- * If it's the case, we return it. Otherwise (no or multiple geometries), we
- * throw an exception.
- *
- * @param type the data type to search into.
- * @return the main geometric property we've found.
- * @throws PropertyNotFoundException if no geometric property is available in the given type.
- * @throws IllegalStateException if no convention is set (see {@link AttributeConvention#GEOMETRY_PROPERTY}),
- * and we have found more than one geometry.
- */
- private static PropertyType getDefaultGeometry(final FeatureType type) throws PropertyNotFoundException, IllegalStateException {
- PropertyType geometry;
- try {
- geometry = type.getProperty(AttributeConvention.GEOMETRY_PROPERTY.toString());
- } catch (PropertyNotFoundException e) {
- try {
- geometry = searchForGeometry(type);
- } catch (RuntimeException e2) {
- e2.addSuppressed(e);
- throw e2;
- }
- }
- return geometry;
- }
-
- /**
- * Searches for a geometric attribute outside SIS conventions. More accurately,
- * we expect the given type to have a single geometry attribute. If many are
- * found, an exception is thrown.
- *
- * @param type the data type to search into.
- * @return the only geometric property we've found.
- * @throws PropertyNotFoundException if no geometric property is available in the given type.
- * @throws IllegalStateException if we have found more than one geometry.
- */
- private static PropertyType searchForGeometry(final FeatureType type) throws PropertyNotFoundException, IllegalStateException {
- final List<? extends PropertyType> geometries = type.getProperties(true).stream()
- .filter(IS_NOT_CONVENTION)
- .filter(AttributeConvention::isGeometryAttribute)
- .collect(Collectors.toList());
-
- if (geometries.size() < 1) {
- throw new PropertyNotFoundException("No geometric property can be found outside of sis convention.");
- } else if (geometries.size() > 1) {
- throw new IllegalStateException("Multiple geometries found. We don't know which one to select.");
- } else {
- return geometries.get(0);
- }
- }
-
- /**
- * Removes any xpath elements, keep only the root property name.
- */
- private static String stripXpath(String attName) {
- int index = attName.indexOf(XPath.SEPARATOR);
- if (index == 0) {
- attName = attName.substring(1); // Remove first slash
- final Pattern pattern = Pattern.compile("(\\{[^\\{\\}]*\\})|(\\[[^\\[\\]]*\\])|/{1}");
- final Matcher matcher = pattern.matcher(attName);
- final StringBuilder sb = new StringBuilder();
- int position = 0;
-matches: while (matcher.find()) {
- final String match = matcher.group();
- sb.append(attName.substring(position, matcher.start()));
- position = matcher.end();
- switch (match.charAt(0)) {
- case XPath.SEPARATOR: {
- // We do not query precisely sub elements.
- position = attName.length();
- break matches;
- }
- case '{': {
- sb.append(match);
- break;
- }
- case '[': {
- // Strip indexes or xpath searches.
- break;
- }
- }
- }
- sb.append(attName.substring(position));
- attName = sb.toString();
- }
- return attName;
- }
-
- /**
- * Extracts envelope and expand it's horizontal component by given margin.
- */
- private static Envelope optimizeBBox(GridGeometry canvas, double symbolsMargin) throws TransformException {
- Envelope env = canvas.getEnvelope();
- //keep only horizontal component
- env = Envelopes.transform(env, CRS.getHorizontalComponent(env.getCoordinateReferenceSystem()));
-
- //expand the search area by given margin
- if (symbolsMargin > 0) {
- final GeneralEnvelope e = new GeneralEnvelope(env);
- e.setRange(0, e.getMinimum(0) - symbolsMargin, e.getMaximum(0) + symbolsMargin);
- e.setRange(1, e.getMinimum(1) - symbolsMargin, e.getMaximum(1) + symbolsMargin);
- env = e;
- }
- return env;
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPresentation.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPresentation.java
deleted file mode 100644
index f7fe12c..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SEPresentation.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Objects;
-import org.opengis.feature.Feature;
-import org.apache.sis.storage.Resource;
-import org.apache.sis.style.se1.Symbolizer;
-
-
-/**
- * A presentation build with a standard Symbology Encoding Symbolizer.
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SEPresentation extends Presentation {
-
- private Symbolizer<?> symbolizer;
-
- public SEPresentation() {
- }
-
- public SEPresentation(MapLayer layer, Resource resource, Feature candidate, Symbolizer<?> symbolizer) {
- super(layer, resource, candidate);
- this.symbolizer = symbolizer;
- }
-
- /**
- * @return Symbogy Encoding symbolizer
- */
- public Symbolizer<?> getSymbolizer() {
- return symbolizer;
- }
-
- public void setSymbolizer(Symbolizer<?> symbolizer) {
- this.symbolizer = symbolizer;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 71 * hash + Objects.hashCode(this.symbolizer);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final SEPresentation other = (SEPresentation) obj;
- if (!Objects.equals(this.symbolizer, other.symbolizer)) {
- return false;
- }
- return super.equals(obj);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SymbologyVisitor.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SymbologyVisitor.java
deleted file mode 100644
index ee9cd39..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/SymbologyVisitor.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * 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.map;
-
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Literal;
-import org.opengis.filter.ValueReference;
-import org.apache.sis.style.Style;
-import org.apache.sis.style.se1.*;
-import static org.apache.sis.util.privy.CollectionsExt.nonNull;
-
-
-/**
- * Loops on all objects contained in a style.
- * Sub classes are expected to override interested methods to fill their objectives.
- *
- * <p>
- * NOTE: this class is a first draft subject to modifications.
- * </p>
- *
- * @author Johann Sorel (Geomatys)
- */
-abstract class SymbologyVisitor {
- protected SymbologyVisitor() {
- }
-
- protected void visit(final Style candidate) {
- if (candidate instanceof Symbology) {
- visit((Symbology) candidate);
- }
- }
-
- protected void visit(final Symbology candidate) {
- if (candidate != null) {
- nonNull(candidate.featureTypeStyles()).forEach(this::visit);
- }
- }
-
- protected void visit(final FeatureTypeStyle candidate) {
- if (candidate != null) {
- nonNull(candidate.rules()).forEach(this::visit);
- }
- }
-
- protected void visit(final Rule<?> candidate) {
- if (candidate != null) {
- nonNull(candidate.symbolizers()).forEach(this::visit);
- }
- }
-
- protected void visit(final Symbolizer<?> candidate) {
- if (candidate instanceof PointSymbolizer) {
- visit((PointSymbolizer) candidate);
- } else if (candidate instanceof LineSymbolizer) {
- visit((LineSymbolizer) candidate);
- } else if (candidate instanceof PolygonSymbolizer) {
- visit((PolygonSymbolizer) candidate);
- } else if (candidate instanceof TextSymbolizer) {
- visit((TextSymbolizer) candidate);
- } else if (candidate instanceof RasterSymbolizer) {
- visit((RasterSymbolizer) candidate);
- } else if (candidate != null) {
- throw new IllegalArgumentException("Unexpected symbolizer " + candidate);
- }
- }
-
- protected void visit(final PointSymbolizer<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGeometry());
- visit(candidate.getGraphic());
- }
- }
-
- protected void visit(final LineSymbolizer<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGeometry());
- visit(candidate.getPerpendicularOffset());
- visit(candidate.getStroke());
- }
- }
-
- protected void visit(final PolygonSymbolizer<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGeometry());
- visit(candidate.getPerpendicularOffset());
- visit(candidate.getDisplacement());
- candidate.getFill().ifPresent(this::visit);
- candidate.getStroke().ifPresent(this::visit);
- }
- }
-
- protected void visit(final TextSymbolizer<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGeometry());
- visit(candidate.getLabel());
- visit(candidate.getFill());
- visit(candidate.getFont());
- candidate.getHalo().ifPresent(this::visit);
- visit(candidate.getLabelPlacement());
- }
- }
-
- protected void visit(final RasterSymbolizer<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGeometry());
- visit(candidate.getOpacity());
- candidate.getChannelSelection().ifPresent(this::visit);
- candidate.getColorMap().ifPresent(this::visit);
- candidate.getContrastEnhancement().ifPresent(this::visit);
- candidate.getImageOutline().ifPresent(this::visit);
- candidate.getShadedRelief().ifPresent(this::visit);
- }
- }
-
- protected void visit(final GraphicalElement<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGraphic());
- }
- }
-
- protected void visit(final Graphic<?> candidate) {
- if (candidate != null) {
- visit(candidate.getOpacity());
- visit(candidate.getRotation());
- visit(candidate.getSize());
- visit(candidate.getAnchorPoint());
- visit(candidate.getDisplacement());
- nonNull(candidate.graphicalSymbols()).forEach(this::visit);
- }
- }
-
- protected void visit(final GraphicalSymbol<?> candidate) {
- if (candidate instanceof Mark) {
- visit((Mark) candidate);
- } else if (candidate instanceof ExternalGraphic) {
- visit((ExternalGraphic) candidate);
- } else if (candidate != null) {
- throw new IllegalArgumentException("Unexpected GraphicalSymbol " + candidate);
- }
- }
-
- protected void visit(final Mark<?> candidate) {
- if (candidate != null) {
- candidate.getFill().ifPresent(this::visit);
- candidate.getStroke().ifPresent(this::visit);
- visit(candidate.getWellKnownName());
- }
- }
-
- protected void visit(final ExternalGraphic<?> candidate) {
- nonNull(candidate.colorReplacements()).forEach(this::visit);
- }
-
- protected void visit(final Stroke<?> candidate) {
- if (candidate != null) {
- visit(candidate.getColor());
- visit(candidate.getDashOffset());
- candidate.getGraphicFill().ifPresent(this::visit);
- candidate.getGraphicStroke().ifPresent(this::visit);
- visit(candidate.getLineCap());
- visit(candidate.getLineJoin());
- visit(candidate.getOpacity());
- visit(candidate.getWidth());
- }
- }
-
- protected void visit(final Description<?> candidate) {
- }
-
- protected void visit(final Displacement<?> candidate) {
- if (candidate != null) {
- visit(candidate.getDisplacementX());
- visit(candidate.getDisplacementY());
- }
- }
-
- protected void visit(final Fill<?> candidate) {
- if (candidate != null) {
- candidate.getGraphicFill().ifPresent(this::visit);
- visit(candidate.getColor());
- visit(candidate.getOpacity());
- }
- }
-
- protected void visit(final Font<?> candidate) {
- if (candidate != null) {
- candidate.family().forEach(this::visit);
- visit(candidate.getSize());
- visit(candidate.getStyle());
- visit(candidate.getWeight());
- }
- }
-
- protected void visit(final GraphicFill<?> candidate) {
- visit((GraphicalElement) candidate);
- }
-
- protected void visit(final GraphicStroke<?> candidate) {
- if (candidate != null) {
- visit((GraphicalElement) candidate);
- visit(candidate.getGap());
- visit(candidate.getInitialGap());
- }
- }
-
- protected void visit(final LabelPlacement<?> candidate) {
- if (candidate instanceof PointPlacement) {
- visit((PointPlacement) candidate);
- } else if (candidate instanceof LinePlacement) {
- visit((LinePlacement) candidate);
- } else if (candidate != null) {
- throw new IllegalArgumentException("Unexpected Placement " + candidate);
- }
- }
-
- protected void visit(final PointPlacement<?> candidate) {
- if (candidate != null) {
- visit(candidate.getAnchorPoint());
- visit(candidate.getDisplacement());
- visit(candidate.getRotation());
- }
- }
-
- protected void visit(final AnchorPoint<?> candidate) {
- if (candidate != null) {
- visit(candidate.getAnchorPointX());
- visit(candidate.getAnchorPointY());
- }
- }
-
- protected void visit(final LinePlacement<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGap());
- visit(candidate.getInitialGap());
- visit(candidate.getPerpendicularOffset());
- }
- }
-
- protected void visit(final LegendGraphic<?> candidate) {
- visit((GraphicalElement) candidate);
- }
-
- protected void visit(final Halo<?> candidate) {
- if (candidate != null) {
- visit(candidate.getFill());
- visit(candidate.getRadius());
- }
- }
-
- protected void visit(final ColorMap<?> candidate) {
- }
-
- protected void visit(final ColorReplacement<?> candidate) {
- }
-
- protected void visit(final ContrastEnhancement<?> candidate) {
- if (candidate != null) {
- visit(candidate.getGammaValue());
- }
- }
-
- protected void visit(final ChannelSelection<?> candidate) {
- if (candidate != null) {
- SelectedChannel<?>[] channels = candidate.getChannels();
- if (channels != null) {
- for (final SelectedChannel<?> sct : channels) {
- visit(sct);
- }
- }
- }
- }
-
- protected void visit(final SelectedChannel<?> candidate) {
- if (candidate != null) {
- candidate.getContrastEnhancement().ifPresent(this::visit);
- }
- }
-
- protected void visit(final ShadedRelief<?> candidate) {
- if (candidate != null) {
- visit(candidate.getReliefFactor());
- }
- }
-
- /**
- * Find all value references and literal in the given expression and its parameters.
- * This method invokes itself recursively.
- *
- * @param candidate the filter to examine, or {@code null} if none.
- */
- protected void visit(final Filter<?> candidate) {
- if (candidate != null) {
- if (candidate instanceof LogicalOperator<?>) {
- ((LogicalOperator<?>) candidate).getOperands().forEach(this::visit);
- } else {
- candidate.getExpressions().forEach(this::visit);
- }
- }
- }
-
- /**
- * Find all value references and literal in the given expression and its parameters.
- * This method invokes itself recursively.
- *
- * @param candidate the expression to examine, or {@code null} if none.
- */
- protected void visit(final Expression<?,?> candidate) {
- if (candidate != null) {
- if (candidate instanceof ValueReference<?,?>) {
- visitProperty((ValueReference<?,?>) candidate);
- } else if (candidate instanceof Literal<?,?>) {
- visitLiteral((Literal<?,?>) candidate);
- } else {
- candidate.getParameters().forEach(this::visit);
- }
- }
- }
-
- /**
- * Invoked by {@link #visit(Expression)} for each value reference.
- *
- * @param expression a value reference found in a chain of expressions.
- */
- protected void visitProperty(ValueReference<?,?> expression) {
- }
-
- /**
- * Invoked by {@link #visit(Expression)} for each literal.
- *
- * @param expression a literal found in a chain of expressions.
- */
- protected void visitLiteral(Literal<?,?> expression) {
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/package-info.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/package-info.java
deleted file mode 100644
index 414e2de..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-
-/**
- * Symbology and map representations, together with a rendering engine for display.
- *
- * <p><b>WARNING:</b> this package is work in progress and is not yet part of public API.
- * Some classes in this package will move to public API after we gained enough confidence
- * about their stability.</p>
- *
- * <h2>Synchronization</h2>
- * Unless otherwise specified, classes in this package are not thread-safe.
- * Synchronization, if desired, must be done by the caller.
- *
- * @author Johann Sorel (Geomatys)
- */
-package org.apache.sis.map;
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/GraphicsPortrayer.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/GraphicsPortrayer.java
deleted file mode 100644
index 4ed1e56..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/GraphicsPortrayer.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * 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.map.service;
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.image.BufferedImage;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.ServiceLoader;
-import java.util.stream.Stream;
-import org.apache.sis.coverage.grid.GridCoverage2D;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.map.MapItem;
-import org.apache.sis.map.MapLayer;
-import org.apache.sis.map.MapLayers;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.style.Style;
-
-
-/**
- * Produce rendered image of styled resources.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class GraphicsPortrayer {
-
- /**
- * Reference all painters.
- */
- private static final Map<Class<? extends Style>,StylePainter> PAINTERS = new HashMap<>();
- static {
- final ServiceLoader<StylePainter> loader = ServiceLoader.load(StylePainter.class, StylePainter.class.getClassLoader());
- for (StylePainter painter : loader) {
- PAINTERS.put(painter.getStyleClass(), painter);
- }
- }
-
- private Graphics2D graphics;
- private GridGeometry domain;
- private BufferedImage image;
-
- public GraphicsPortrayer(){}
-
- /**
- * Set the output image to render into.
- *
- * @param image not null
- * @return this portrayer
- */
- public GraphicsPortrayer setCanvas(BufferedImage image) {
- this.image = Objects.requireNonNull(image);
- this.graphics = image.createGraphics();
- return this;
- }
-
- /**
- * Set the output Graphics2D to render into.
- *
- * @param graphics not null
- * @return this portrayer
- */
- public GraphicsPortrayer setCanvas(Graphics2D graphics) {
- this.graphics = Objects.requireNonNull(graphics);
- return this;
- }
-
- /**
- * Set the GridGeometry which is rendered.
- *
- * @param domain not null, lower extent coordinates must be on 0.
- */
- public GraphicsPortrayer setDomain(GridGeometry domain) {
- // Implicit null check. As of Java 14, exception message is informative.
- long[] low = domain.getExtent().getLow().getCoordinateValues();
- for (long l : low) {
- Objects.checkIndex((int) l, 1);
- }
-
- this.domain = domain;
- return this;
- }
-
- /**
- *
- * @return created image, may be null
- */
- public BufferedImage getImage() {
- return image;
- }
-
- /**
- * Get the rendering image as a coverage.
- * @return coverage, never null
- */
- public GridCoverage2D toCoverage() {
- return new GridCoverage2D(domain, null, getImage());
- }
-
- /**
- * Validate parameters and create image if needed.
- */
- private Scene2D init() {
- Objects.requireNonNull(domain, "domain"); // Not an argument.
- if (graphics == null) {
- setCanvas(new BufferedImage(
- (int) domain.getExtent().getSize(0),
- (int) domain.getExtent().getSize(1),
- BufferedImage.TYPE_INT_ARGB));
- }
-
- return new Scene2D(domain, graphics);
- }
-
- /**
- * Paint given map.
- *
- * An image is created if not defined.
- *
- * @param map to paint, not null
- * @throws IllegalArgumentException if canvas is not property configured
- * @throws RenderingException if a rendering procedure fails.
- */
- public synchronized GraphicsPortrayer portray(MapItem map) throws RenderingException {
- portray(init(), map);
- return this;
- }
-
- private void portray(Scene2D scene, MapItem map) throws RenderingException {
- if (map == null || !map.isVisible()) return;
- if (map instanceof MapLayer) {
- portray(scene, (MapLayer) map);
- } else if (map instanceof MapLayers) {
- final MapLayers layers = (MapLayers) map;
- for (MapItem item : layers.getComponents()) {
- portray(scene, item);
- }
- }
- }
-
- private void portray(Scene2D scene, MapLayer layer) throws RenderingException {
- final Style style = layer.getStyle();
- if (style == null) return;
- final StylePainter painter = PAINTERS.get(style.getClass());
- if (painter == null) return;
- painter.paint(scene, layer);
- }
-
- /**
- * Present given map.
- *
- * @param map to present, not null
- * @throws IllegalArgumentException if canvas is not property configured
- * @throws RenderingException if a rendering procedure fails.
- */
- public synchronized Stream<Presentation> present(MapItem map) throws RenderingException {
- return present(init(), map);
- }
-
- private Stream<Presentation> present(Scene2D scene, MapItem map) throws RenderingException {
- if (map == null || !map.isVisible()) return Stream.empty();
- if (map instanceof MapLayer) {
- return present(scene, (MapLayer) map);
- } else if (map instanceof MapLayers) {
- final MapLayers layers = (MapLayers) map;
- Stream<Presentation> stream = Stream.empty();
- for (MapItem item : layers.getComponents()) {
- stream = Stream.concat(stream, present(scene, item));
- }
- return stream;
- } else {
- return Stream.empty();
- }
- }
-
- private Stream<Presentation> present(Scene2D scene, MapLayer layer) throws RenderingException {
- final Style style = layer.getStyle();
- if (style == null) return Stream.empty();
- final StylePainter painter = PAINTERS.get(style.getClass());
- if (painter == null) return Stream.empty();
- return painter.present(scene, layer);
- }
-
- /**
- * Compute visual intersection of given map.
- *
- * @param mapItem to be processed, not null.
- * @param mask intersection mask, not null.
- * @return intersecting stream of presentations.
- * @throws IllegalArgumentException if canvas is not property configured
- * @throws RenderingException if a rendering procedure fails.
- */
- public Stream<Presentation> intersects(MapItem mapItem, Shape mask) throws RenderingException {
- return intersects(init(), mapItem, mask);
- }
-
- private Stream<Presentation> intersects(Scene2D scene, MapItem map, Shape mask) throws RenderingException{
- Stream<Presentation> results = Stream.empty();
- if (map == null || !map.isVisible()) return results;
- if (map instanceof MapLayer) {
- results = Stream.concat(results, intersects(scene, (MapLayer) map, mask));
- } else if (map instanceof MapLayers) {
- final MapLayers layers = (MapLayers) map;
- for (MapItem item : layers.getComponents()) {
- results = Stream.concat(results, intersects(scene, item, mask));
- }
- }
- return results;
- }
-
- private Stream<Presentation> intersects(Scene2D scene, MapLayer layer, Shape mask) throws RenderingException {
- final Style style = layer.getStyle();
- if (style == null) return Stream.empty();
- final StylePainter painter = PAINTERS.get(style.getClass());
- if (painter == null) return Stream.empty();
- return painter.intersects(scene, layer, mask);
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/RenderingException.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/RenderingException.java
deleted file mode 100644
index f35ee94..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/RenderingException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.map.service;
-
-
-/**
- * Exception that may be thrown by a portraying operation.
- *
- * @author Johann Sorel (Geomatys)
- */
-public class RenderingException extends Exception {
-
- public RenderingException(String message) {
- super(message);
- }
-
- public RenderingException(Throwable cause) {
- super(cause);
- }
-
- public RenderingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/Scene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/Scene2D.java
deleted file mode 100644
index d58a599..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/Scene2D.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.map.service;
-
-import java.awt.Graphics2D;
-import java.util.Objects;
-import java.util.logging.Logger;
-import javax.measure.Unit;
-import javax.measure.quantity.Length;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.measure.Units;
-
-
-/**
- * Holds the rendering properties.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class Scene2D {
-
- public static final Logger LOGGER = Logger.getLogger("org.apache.sis.internal.renderer");
-
- /**
- * The rendering grid geometry.
- */
- public final GridGeometry grid;
- /**
- * Graphics to render into.
- * When modified by renderers, it must be reset accordingly.
- */
- public final Graphics2D graphics;
-
- /**
- * Definition from OGC SLD/SE :
- * The portrayal unit “pixel” is the default unit of measure.
- * If available, the pixel size depends on the viewer client resolution, otherwise it is equal to 0.28mm * 0.28mm (~ 90 DPI).
- *
- * In facts, all displays have there own DPI, but the common is around 96dpi (old 72dpi x 4/3).
- * This dpi is the default on windows and replicated on different tools such as Apache Batik user agents.
- *
- * TODO : should we use a transform as in GraphicsConfiguration.getNormalizingTransform() ?
- */
- private double dpi = 96;
-
- /**
- * @param grid scene domain
- * @param graphics to paint with
- */
- public Scene2D(GridGeometry grid, Graphics2D graphics) {
- this.grid = Objects.requireNonNull(grid);
- this.graphics = Objects.requireNonNull(graphics);
- }
-
- /**
- * Graphics2D to use for painting data.
- * This instance should be left untouched.
- *
- * @return Graphics2D
- */
- public Graphics2D getGraphics() {
- return graphics;
- }
-
- /**
- * Set current rendering DPI.
- * Default is 96.
- *
- * @param dpi new DPI
- */
- public void setDpi(double dpi) {
- this.dpi = dpi;
- }
-
- /**
- * @return current DPI.
- */
- public double getDpi() {
- return dpi;
- }
-
- /**
- * Convert given distance to pixels.
- *
- * @param distance to convert
- * @param unit distance unit, not null
- * @return distance in pixels
- */
- public double toPixels(double distance, Unit<Length> unit) {
- return unit.getConverterTo(Units.INCH).convert(distance) * dpi;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/StylePainter.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/StylePainter.java
deleted file mode 100644
index 29da097..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/StylePainter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.map.service;
-
-import java.awt.Shape;
-import java.util.stream.Stream;
-import org.apache.sis.map.MapLayer;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.style.Style;
-
-
-/**
- * A Painter is responsible for portraying and querying resource on a scene.
- *
- * @author Johann Sorel (Geomatys)
- */
-public interface StylePainter {
-
- /**
- * Get the supported style implementation this painter can portray.
- *
- * @return supported style class.
- */
- Class<? extends Style> getStyleClass();
-
- /**
- * Stateless portraying of the given map layer.
- *
- * @param scene parameters for rendering
- * @param layer having supported style class.
- * @throws RenderingException if an error occured while rendering
- */
- void paint(Scene2D scene, MapLayer layer) throws RenderingException;
-
- /**
- * Statefull portraying of the given map layer.
- * <p>
- * Any exception should be returned in the stream as ExceptionPresentation, this allows
- * to still have some results even if a data caused an error.
- * <p>
- * The nature of the Presentation instance should be related to the style API used.
- *
- * @param scene parameters for rendering
- * @param layer having supported style class.
- * @return stream of presentation objects.
- */
- Stream<Presentation> present(Scene2D scene, MapLayer layer);
-
- /**
- * Search for elements in the scene which intersect the given area.
- * <p>
- * Any exception should be returned in the stream as ExceptionPresentation, this allows
- * to still have some results even if a data caused an error.
- *
- * @param scene parameters of the scene
- * @param layer to seach in
- * @param mask to search for intersection
- * @return a stream of presentation instances that intersect the searched area.
- */
- Stream<Presentation> intersects(Scene2D scene, MapLayer layer, Shape mask);
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/LineToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/LineToScene2D.java
deleted file mode 100644
index c39e45b..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/LineToScene2D.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Shape;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.locationtech.jts.geom.Geometry;
-import org.opengis.feature.Feature;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.CoordinateOperation;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.coverage.grid.PixelInCell;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.feature.privy.AttributeConvention;
-import org.apache.sis.geometry.wrapper.Geometries;
-import org.apache.sis.geometry.wrapper.GeometryWrapper;
-import org.apache.sis.geometry.wrapper.jts.JTS;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.operation.transform.MathTransforms;
-import org.apache.sis.style.se1.LineSymbolizer;
-
-
-/**
- * Support for LineSymbolizer rendering.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class LineToScene2D extends SymbolizerToScene2D<LineSymbolizer<?>> {
-
- private LineToScene2D(Scene2D state, LineSymbolizer<?> symbolizer) {
- super(state, symbolizer);
- }
-
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- visual.paint(state.getGraphics());
- }
- }
-
- @Override
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- return visual.intersects(mask);
- }
- return false;
- }
-
- private RenderedShape createVisual(SEPresentation presentation) throws RenderingException {
- final Feature feature = presentation.getCandidate();
- Object geometry = feature.getPropertyValue(AttributeConvention.GEOMETRY);
-
- if (geometry instanceof Geometry) {
-
- final MathTransform gridToCRS = state.grid.getGridToCRS(PixelInCell.CELL_CENTER);
-
- final GeometryWrapper geomWrap = Geometries.wrap(geometry).get();
- final CoordinateReferenceSystem geomCrs = geomWrap.getCoordinateReferenceSystem();
-
- final Geometry jts;
- try {
- final CoordinateOperation coop = CRS.findOperation(geomCrs, state.grid.getCoordinateReferenceSystem(), null);
- final MathTransform geomToGrid = MathTransforms.concatenate(coop.getMathTransform(), gridToCRS.inverse());
-
- jts = JTS.transform((Geometry) geometry, geomToGrid);
- } catch (FactoryException | TransformException ex) {
- throw new RenderingException(ex);
- }
-
- Shape shape = JTS.asShape(jts);
-
- //TODO geometry world wrap and styling
-
- RenderedShape rs = new RenderedShape();
- rs.shape = shape;
- rs.stroke = new BasicStroke(1);
- rs.strokePaint = Color.BLACK;
-
- return rs;
- }
-
- return null;
- }
-
- public static final class Spi implements SymbolizerToScene2D.Spi<LineSymbolizer> {
-
- @Override
- public Class<LineSymbolizer> getSymbolizerType() {
- return LineSymbolizer.class;
- }
-
- @Override
- public SymbolizerToScene2D create(Scene2D state, LineSymbolizer symbolizer) throws RenderingException {
- return new LineToScene2D(state, symbolizer);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PointToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PointToScene2D.java
deleted file mode 100644
index f5863c1..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PointToScene2D.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.style.se1.PointSymbolizer;
-
-
-/**
- * Support for PointSymbolizer rendering.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class PointToScene2D extends SymbolizerToScene2D<PointSymbolizer<?>> {
-
- private PointToScene2D(Scene2D state, PointSymbolizer<?> symbolizer) {
- super(state, symbolizer);
- }
-
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- visual.paint(state.getGraphics());
- }
- }
-
- @Override
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- return visual.intersects(mask);
- }
- return false;
- }
-
- private RenderedShape createVisual(SEPresentation presentation) throws RenderingException {
- //todo
- return null;
- }
-
- public static final class Spi implements SymbolizerToScene2D.Spi<PointSymbolizer> {
-
- @Override
- public Class<PointSymbolizer> getSymbolizerType() {
- return PointSymbolizer.class;
- }
-
- @Override
- public SymbolizerToScene2D create(Scene2D state, PointSymbolizer symbolizer) throws RenderingException {
- return new PointToScene2D(state, symbolizer);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PolygonToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PolygonToScene2D.java
deleted file mode 100644
index e617e52..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PolygonToScene2D.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.style.se1.PolygonSymbolizer;
-
-
-/**
- * Support for PointSymbolizer rendering.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class PolygonToScene2D extends SymbolizerToScene2D<PolygonSymbolizer<?>> {
-
- private PolygonToScene2D(Scene2D state, PolygonSymbolizer<?> symbolizer) {
- super(state, symbolizer);
- }
-
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- visual.paint(state.getGraphics());
- }
- }
-
- @Override
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- return visual.intersects(mask);
- }
- return false;
- }
-
- private RenderedShape createVisual(SEPresentation presentation) throws RenderingException {
- //todo
- return null;
- }
-
- public static final class Spi implements SymbolizerToScene2D.Spi<PolygonSymbolizer> {
-
- @Override
- public Class<PolygonSymbolizer> getSymbolizerType() {
- return PolygonSymbolizer.class;
- }
-
- @Override
- public SymbolizerToScene2D create(Scene2D state, PolygonSymbolizer symbolizer) throws RenderingException {
- return new PolygonToScene2D(state, symbolizer);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PresentationToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PresentationToScene2D.java
deleted file mode 100644
index 44d5233..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/PresentationToScene2D.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-import org.opengis.coordinate.MismatchedDimensionException;
-import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.style.se1.Symbolizer;
-
-
-/**
- * Generate a 2D scene from canvas and graphic presentations.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class PresentationToScene2D {
-
- /**
- * Flag instance for missing symbolizers converters.
- */
- private static final SymbolizerToScene2D<?> NONE = new SymbolizerToScene2D<Symbolizer<?>>(null, null){
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- throw new UnsupportedOperationException("Should not called.");
- }
- };
- private static final SymbolizerCache NO_CACHE = new SymbolizerCache(){};
-
- private final Scene2D state;
-
- private final Map<Symbolizer<?>,SymbolizerToScene2D<?>> cache = new HashMap<>();
- private Map<Symbolizer<?>,SymbolizerCache> symbolizerCaches;
-
- /**
- * Prepare parameters for scene creation.The grid geometry will provide the base coordinate system and scale informations.
- * All further presentations must have been build with given grid as base.
- *
- * @param grid, not null
- */
- public PresentationToScene2D(GridGeometry grid, Graphics2D graphics) throws FactoryException, MismatchedDimensionException, TransformException {
- // Null values are verified by the Scene2D constuctor.
- state = new Scene2D(grid, graphics);
- }
-
- /**
- * Create converter from an existing scene state.
- *
- * @param state, not null
- */
- public PresentationToScene2D(Scene2D state) {
- this.state = Objects.requireNonNull(state);
- }
-
- /**
- * Define global shared cache map instance.
- *
- * @param symbolizerCaches
- */
- public void setSymbolizerCaches(Map<Symbolizer<?>, SymbolizerCache> symbolizerCaches) {
- this.symbolizerCaches = symbolizerCaches;
- }
-
- /**
- * Convert and add given presentation to the scene.
- * Exceptions will be logged.
- *
- * @param presentations, not null, will be closed.
- */
- public void render(Stream<Presentation> presentations) {
- try {
- presentations.parallel().forEach(new Consumer<Presentation>() {
- @Override
- public void accept(Presentation t) {
- try {
- render(t);
- } catch (Exception ex) {
- Scene2D.LOGGER.log(Level.INFO, ex.getMessage(), ex);
- }
- }
- });
- } finally {
- presentations.close();
- }
- }
-
- private void render(Presentation presentation) throws RenderingException, IOException, NoninvertibleTransformException, TransformException, URISyntaxException, FactoryException, DataStoreException {
- //standard presentation types
- if (presentation instanceof SEPresentation) {
- render((SEPresentation) presentation);
- } else {
- //unknown type
- }
- }
-
- private void render(SEPresentation presentation) throws MismatchedDimensionException, TransformException, FactoryException, DataStoreException, IOException, RenderingException {
- final SymbolizerToScene2D<?> sts = getRenderer(presentation.getSymbolizer());
-
- if (sts != null) {
- sts.paint(presentation, this::render);
- } else {
- Scene2D.LOGGER.log(Level.INFO, "Unnowned symbolizer {0}", presentation.getSymbolizer().getClass().getName());
- }
- }
-
- /**
- * Process given presentations and retain only thos who intersects the requested shape.
- *
- * @param presentations, not null.
- */
- public Stream<Presentation> intersects(Stream<Presentation> presentations, Shape mask) {
-
- final Consumer<Stream<Presentation>> callback = (Stream<Presentation> t) -> {intersects(t, mask);};
-
- return presentations.parallel().filter(new Predicate<Presentation>() {
- @Override
- public boolean test(Presentation t) {
- try {
- return intersects(t, mask, callback);
- } catch (RenderingException ex) {
- Scene2D.LOGGER.log(Level.WARNING, ex.getMessage(), ex);
- }
- return false;
- }
- });
- }
-
- private boolean intersects(Presentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- //standard presentation types
- if (presentation instanceof SEPresentation) {
- return intersects((SEPresentation) presentation, mask, callback);
- } else {
- //unknown type
- return false;
- }
- }
-
- private boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final SymbolizerToScene2D<?> sts = getRenderer(presentation.getSymbolizer());
-
- if (sts != null) {
- return sts.intersects(presentation, mask, callback);
- } else {
- Scene2D.LOGGER.log(Level.INFO, "Unnowned symbolizer {0}", presentation.getSymbolizer().getClass().getName());
- return false;
- }
- }
-
- private SymbolizerToScene2D<?> getRenderer(Symbolizer<?> symbolizer) throws RenderingException {
- SymbolizerToScene2D<?> sts;
- synchronized (cache) {
- sts = cache.get(symbolizer);
- if (sts == NONE) {
- sts = null;
- } else if (sts == null) {
- sts = SymbolizerToScene2D.create(state, symbolizer);
- if (sts == null) sts = NONE;
- cache.put(symbolizer, sts);
- if (sts == NONE) {
- sts = null;
- } else if (symbolizerCaches != null) {
- // get or create shared cache
- SymbolizerCache cache = symbolizerCaches.get(symbolizer);
- if (cache == null) {
- cache = SymbolizerToScene2D.createCache(symbolizer);
- if (cache == null) {
- cache = NO_CACHE;
- }
- symbolizerCaches.put(symbolizer, cache);
- }
- if (cache != NO_CACHE) {
- sts.sharedCache(cache);
- }
- }
- }
- }
- return sts;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RasterToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RasterToScene2D.java
deleted file mode 100644
index ccf6d5b..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RasterToScene2D.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.awt.geom.AffineTransform;
-import java.awt.image.RenderedImage;
-import java.util.function.Consumer;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.coverage.grid.GridCoverage;
-import org.apache.sis.coverage.grid.GridCoverageBuilder;
-import org.apache.sis.coverage.grid.GridCoverageProcessor;
-import org.apache.sis.coverage.grid.GridDerivation;
-import org.apache.sis.coverage.grid.GridExtent;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.GridCoverageResource;
-import org.apache.sis.storage.NoSuchDataException;
-import org.apache.sis.storage.Resource;
-import org.apache.sis.style.se1.RasterSymbolizer;
-
-
-/**
- * Support for RasterSymbolizer rendering.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class RasterToScene2D extends SymbolizerToScene2D<RasterSymbolizer<?>> {
-
- private RasterToScene2D(Scene2D state, RasterSymbolizer<?> symbolizer) {
- super(state, symbolizer);
- }
-
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- Resource resource = presentation.getResource();
-
- if (resource instanceof GridCoverageResource) {
- final GridCoverageResource gcr = (GridCoverageResource) resource;
-
- try {
- GridCoverage coverage = gcr.read(state.grid);
-
- // naive inefficient implementation to be improved
- // keep only a 2D slice for rendering
- final GridGeometry gridGeometry = coverage.getGridGeometry();
- final GridDerivation sliceGridBuilder = gridGeometry.derive().sliceByRatio(0.5, 0, 1);
- final GridExtent intersection = sliceGridBuilder.getIntersection();
- final GridGeometry sliceGrid = sliceGridBuilder.build().selectDimensions(0,1);
- final RenderedImage image = coverage.render(intersection);
-
- final GridCoverageBuilder gcb = new GridCoverageBuilder();
- gcb.setValues(image);
- gcb.setDomain(sliceGrid);
- gcb.setRanges(coverage.getSampleDimensions());
- final GridCoverage coverage2d = gcb.build();
-
- final GridCoverageProcessor gcp = new GridCoverageProcessor();
- final GridCoverage resampled = gcp.resample(coverage2d, state.grid);
-
- //TODO handle raster symbolizer parameters.
-
- state.graphics.drawRenderedImage(resampled.render(null), new AffineTransform());
-
- } catch (NoSuchDataException ex) {
- //do nothing
- } catch (DataStoreException ex) {
- LOGGER.log(Level.WARNING, ex.getMessage(), ex);
- } catch (TransformException ex) {
- LOGGER.log(Level.WARNING, ex.getMessage(), ex);
- }
-
- }
- }
-
- @Override
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- return false;
- }
-
- public static final class Spi implements SymbolizerToScene2D.Spi<RasterSymbolizer> {
-
- @Override
- public Class<RasterSymbolizer> getSymbolizerType() {
- return RasterSymbolizer.class;
- }
-
- @Override
- public SymbolizerToScene2D create(Scene2D state, RasterSymbolizer symbolizer) throws RenderingException {
- return new RasterToScene2D(state, symbolizer);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RenderedShape.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RenderedShape.java
deleted file mode 100644
index 9f4cb84..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/RenderedShape.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.AlphaComposite;
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.Shape;
-import java.awt.Stroke;
-import java.awt.geom.Area;
-
-
-/**
- * Combine an AWT Shape and it's rendering options.
- *
- * @author Johann Sorel (Geomatys)
- */
-final class RenderedShape {
-
- public static final AlphaComposite ALPHA_COMPOSITE_0F = AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f);
- public static final AlphaComposite ALPHA_COMPOSITE_1F = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f);
-
- public AlphaComposite fillComposite = ALPHA_COMPOSITE_1F;
- public AlphaComposite strokeComposite = ALPHA_COMPOSITE_1F;
-
- /**
- * Shape to render.
- * If null, paint and hit methods will always return false.
- */
- public Shape shape;
- /**
- * The fill paint of the shape.
- * If null, no fill rendering is made.
- */
- public Paint fillPaint;
- /**
- * The stroke paint of the shape.
- * If null, no stroke rendering is made.
- */
- public Paint strokePaint;
- /**
- * The stroke of the shape.
- * If null, no stroke rendering is made.
- */
- public Stroke stroke;
-
- /**
- * Paint this shape with given Graphics2D.
- *
- * @param g2d not null
- * @return true if something was painted.
- */
- public boolean paint(Graphics2D g2d) {
- if (shape == null) return false;
-
- boolean painted = false;
- if (fillPaint != null) {
- g2d.setComposite(fillComposite);
- g2d.setPaint(fillPaint);
- g2d.fill(shape);
- painted = true;
- }
- if (stroke != null && strokePaint != null) {
- g2d.setComposite(strokeComposite);
- g2d.setPaint(strokePaint);
- g2d.setStroke(stroke);
- g2d.draw(shape);
- painted = true;
- }
- return painted;
- }
-
- /**
- * Test intersection of the shape and it's style options with the searched mask.
- * @param mask not null.
- * @return true if rendered shape intersects the mask.
- */
- public boolean intersects(Shape mask) {
-
- //test intersection with fill if defined
- if (fillPaint != null) {
- final Area maskArea = new Area(mask);
- final Area shapeArea = new Area(shape);
- maskArea.intersect(shapeArea);
- if (!maskArea.isEmpty()) {
- return true;
- }
- }
- //test intersection with stroke if defined
- if (stroke != null && strokePaint != null) {
- final Area maskArea = new Area(mask);
- final Area shapeArea = new Area(stroke.createStrokedShape(shape));
- maskArea.intersect(shapeArea);
- return !maskArea.isEmpty();
- }
- return false;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SEPainter.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SEPainter.java
deleted file mode 100644
index d8f9e1d..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SEPainter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.util.stream.Stream;
-import org.apache.sis.map.MapLayer;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPortrayer;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.StylePainter;
-import org.apache.sis.style.Style;
-import org.apache.sis.style.se1.Symbology;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class SEPainter implements StylePainter {
-
-
- @Override
- public Class<? extends Style> getStyleClass() {
- return Symbology.class;
- }
-
- /**
- * Render the given map using default SEPortrayer configuration.
- *
- * @param layer to be rendered, not null.
- * @return this portrayer
- */
- @Override
- public void paint(Scene2D scene, MapLayer layer) {
- try (Stream<Presentation> stream = new SEPortrayer().present(scene.grid, layer)) {
- paint(scene, stream);
- }
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public Stream<Presentation> present(Scene2D scene, MapLayer layer) {
- return new SEPortrayer().present(scene.grid, layer);
- }
-
- /**
- * Render the given stream of Presentations.
- *
- * @param presentations to be rendered, not null.
- * @return this portrayer
- */
- public void paint(Scene2D scene, Stream<Presentation> presentations) {
- final PresentationToScene2D pts = new PresentationToScene2D(scene);
- pts.render(presentations);
- }
-
- /**
- * Compute visual intersection of given map using default SEPortrayer configuration.
- *
- * @param layer to be processed, not null.
- * @param mask intersection mask, not null.
- * @return intersecting stream of presentations.
- */
- @Override
- public Stream<Presentation> intersects(Scene2D scene, MapLayer layer, Shape mask) {
- Stream<Presentation> stream = new SEPortrayer().present(scene.grid, layer);
- return intersects(scene, stream, mask);
- }
-
- /**
- * Compute visual intersection of given map using default SEPortrayer configuration.
- *
- * @param presentations to be processed, not null.
- * @param mask intersection mask, not null.
- * @return intersecting stream of presentations.
- */
- public Stream<Presentation> intersects(Scene2D scene, Stream<Presentation> presentations, Shape mask) {
- final PresentationToScene2D pts = new PresentationToScene2D(scene);
- return pts.intersects(presentations, mask);
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerCache.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerCache.java
deleted file mode 100644
index 0bddfc2..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerCache.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.map.service.se1;
-
-
-/**
- * Subclassed by symbolizer who have resource caches.
- * This could contain images or models.
- * The cache instance may be shared by multiple {@link SymbolizerToScene2D} instances
- * using method {@link SymbolizerToScene2D#sharedCache(org.apache.sis.internal.renderer.SymbolizerCache) }.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class SymbolizerCache {
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerToScene2D.java
deleted file mode 100644
index 09b78ae..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/SymbolizerToScene2D.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.function.Consumer;
-import java.util.logging.Logger;
-import java.util.stream.Stream;
-import org.opengis.feature.Feature;
-import org.opengis.filter.Expression;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.style.se1.Symbolizer;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.ObjectConverters;
-
-
-/**
- * Transforms a {@link Presentation} to Java2D graphics.
- *
- * @author Johann Sorel (Geomatys)
- */
-public abstract class SymbolizerToScene2D<S extends Symbolizer> {
-
- private static final List<SymbolizerToScene2D.Spi<?>> SPIS;
- private static final Map<Class<?>,SymbolizerToScene2D.Spi<?>> SPI_MAP = new HashMap<>();
- static {
- //collect all symbolizer SPI
- List<SymbolizerToScene2D.Spi<?>> spis = new ArrayList<>();
- ServiceLoader.load(SymbolizerToScene2D.Spi.class).iterator().forEachRemaining(spis::add);
- SPIS = Collections.unmodifiableList(spis);
- for (SymbolizerToScene2D.Spi<?> spi : SPIS) {
- if (SPI_MAP.put(spi.getSymbolizerType(), spi) != null) {
- throw new IllegalStateException("More then one SymbolizerToScene2D.Spi is registered for type " + spi.getSymbolizerType().getName());
- }
- }
- }
-
- protected static final Logger LOGGER = Logger.getLogger("com.examind.sdk.render");
- protected final Scene2D state;
- protected final S symbolizer;
-
- protected SymbolizerToScene2D(Scene2D state, S symbolizer) {
- this.state = state;
- this.symbolizer = symbolizer;
- }
-
- /**
- * Define a shared cache instance.
- * Shared caches avoid multiple loading of a resource (example : images, models)
- *
- * @param cache not null
- */
- public void sharedCache(SymbolizerCache cache) {
- }
-
- /**
- * Paint the given {@link SEPresentation}.
- *
- * @param presentation not null
- * @param callback not null, can be used to create new presentation treated in the rendering loop.
- * @throws RenderingException
- */
- public abstract void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException;
-
- /**
- * Test intersection of the given {@link SEPresentation}.
- *
- * @param presentation not null
- * @param callback not null, can be used to test new presentations treated in the rendering loop.
- * @throws RenderingException
- */
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- return false;
- }
-
- static <T> T evaluate(Feature feature, Expression<? super Feature,?> exp, Expression<? super Feature,?> fallback, Class<T> clazz) {
- T value = null;
- if (exp != null) {
- value = ObjectConverters.convert(exp.apply(feature), clazz);
- }
- if (value == null && fallback != null) {
- value = ObjectConverters.convert(fallback.apply(feature), clazz);
- }
- return value;
- }
-
- /**
- * Create a symbolizer to scene processor.
- *
- * @param state not null
- * @param symbolizer not null
- * @return may be null if no Spi support this symbolizer.
- * @throws RenderingException if the symbolizer is incorrectly defined or some assets cannot be resolved.
- */
- public static SymbolizerToScene2D<?> create(Scene2D state, Symbolizer<?> symbolizer) throws RenderingException {
- ArgumentChecks.ensureNonNull("symbolizer", symbolizer);
- final Spi<Symbolizer> spi = (Spi<Symbolizer>) getSpi(symbolizer.getClass());
- return spi == null ? null : spi.create(state, symbolizer);
- }
-
- /**
- * Create a symbolizer cache.
- *
- * @param symbolizer not null
- * @return may be null if no Spi support this symbolizer.
- * @throws RenderingException if the symbolizer is incorrectly defined or some assets cannot be resolved.
- */
- public static SymbolizerCache createCache(Symbolizer symbolizer) throws RenderingException {
- for (SymbolizerToScene2D.Spi spi : SPIS) {
- final SymbolizerCache sts = spi.createCache(symbolizer);
- if (sts != null) {
- return sts;
- }
- }
- return null;
- }
- /**
- * Get the Spi capable to handle given symbolizer.
- *
- * @return may be null if no Spi support this symbolizer.
- */
- public static synchronized <T extends Symbolizer> SymbolizerToScene2D.Spi<T> getSpi(Class<T> clazz) {
- Spi<T> cdt = (Spi<T>) SPI_MAP.get(clazz);
- if (cdt == null) {
- for (SymbolizerToScene2D.Spi spi : SPIS) {
- if (spi.getSymbolizerType().isAssignableFrom(clazz)) {
- SPI_MAP.put(clazz, spi);
- cdt = spi;
- break;
- }
- }
- }
- return cdt;
- }
-
- /**
- * Factory to create new transformation instances.
- *
- * @param <T> symbolizer type supported
- */
- public interface Spi<T extends Symbolizer> {
-
- /**
- * Returns the support symbolizer class.
- * @return supported symbolizer class, not null.
- */
- Class<T> getSymbolizerType();
-
- /**
- * Create a cache for given {@link Symbolizer}.
- *
- * @param symbolizer not null
- * @return cache or null if symbolizer is not supported or no cache is needed.
- * @throws RenderingException if symbolizer declaration contains errors.
- */
- default SymbolizerCache createCache(T symbolizer) throws RenderingException {
- return null;
- }
-
- /**
- * Create a transformation instance.
- *
- * @param state scene state, not null
- * @param symbolizer not null
- * @return instance or null if symbolizer is not supported
- * @throws RenderingException if symbolizer declaration contains errors.
- */
- SymbolizerToScene2D create(Scene2D state, T symbolizer) throws RenderingException;
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/TextToScene2D.java b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/TextToScene2D.java
deleted file mode 100644
index 8378bfd..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/service/se1/TextToScene2D.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.map.service.se1;
-
-import java.awt.Shape;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.map.service.Scene2D;
-import org.apache.sis.map.service.RenderingException;
-import org.apache.sis.style.se1.TextSymbolizer;
-
-
-/**
- * Support for PointSymbolizer rendering.
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class TextToScene2D extends SymbolizerToScene2D<TextSymbolizer<?>> {
-
- private TextToScene2D(Scene2D state, TextSymbolizer<?> symbolizer) {
- super(state, symbolizer);
- }
-
- @Override
- public void paint(SEPresentation presentation, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- visual.paint(state.getGraphics());
- }
- }
-
- @Override
- public boolean intersects(SEPresentation presentation, Shape mask, Consumer<Stream<Presentation>> callback) throws RenderingException {
- final RenderedShape visual = createVisual(presentation);
- if (visual != null) {
- return visual.intersects(mask);
- }
- return false;
- }
-
- private RenderedShape createVisual(SEPresentation presentation) throws RenderingException {
- //todo
- return null;
- }
-
- public static final class Spi implements SymbolizerToScene2D.Spi<TextSymbolizer> {
-
- @Override
- public Class<TextSymbolizer> getSymbolizerType() {
- return TextSymbolizer.class;
- }
-
- @Override
- public SymbolizerToScene2D create(Scene2D state, TextSymbolizer symbolizer) throws RenderingException {
- return new TextToScene2D(state, symbolizer);
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/MapLayersTest.java b/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/MapLayersTest.java
deleted file mode 100644
index 1b8f865..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/MapLayersTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.map;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.sis.measure.NumberRange;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-public final class MapLayersTest {
- /**
- * Creates a new test case.
- */
- public MapLayersTest() {
- }
-
- /**
- * Test the maplayers components list events.
- */
- @Test
- public void testListEvents() {
-
- final MapLayers layers = new MapLayers();
- final MapLayer layer1 = new MapLayer();
- final MapLayer layer2 = new MapLayer();
-
- final AtomicInteger eventNum = new AtomicInteger();
- layers.addPropertyChangeListener(MapLayers.COMPONENTS_PROPERTY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- assertTrue(evt instanceof ListChangeEvent<?>);
- final ListChangeEvent<?> levt = (ListChangeEvent<?>) evt;
- assertEquals(layers.getComponents(), levt.getOldValue());
- assertEquals(layers.getComponents(), levt.getNewValue());
- assertEquals(MapLayers.COMPONENTS_PROPERTY, levt.getPropertyName());
- assertEquals(layers, levt.getSource());
- int eventId = eventNum.incrementAndGet();
- switch (eventId) {
- case 1 :
- assertEquals(ListChangeEvent.Type.ADDED, levt.getType());
- assertEquals(NumberRange.create(0, true, 0, true), levt.getRange());
- assertEquals(1, levt.getItems().size());
- assertEquals(layer1, levt.getItems().get(0));
- break;
- case 2 :
- assertEquals(ListChangeEvent.Type.ADDED, levt.getType());
- assertEquals(NumberRange.create(1, true, 1, true), levt.getRange());
- assertEquals(1, levt.getItems().size());
- assertEquals(layer2, levt.getItems().get(0));
- break;
- case 3 :
- assertEquals(ListChangeEvent.Type.REMOVED, levt.getType());
- assertEquals(NumberRange.create(1, true, 1, true), levt.getRange());
- assertEquals(1, levt.getItems().size());
- assertEquals(layer2, levt.getItems().get(0));
- break;
- case 4 :
- assertEquals(ListChangeEvent.Type.CHANGED, levt.getType());
- assertEquals(null, levt.getRange());
- assertEquals(null, levt.getItems());
- break;
- }
-
- }
- });
-
- layers.getComponents().add(layer1);
- assertEquals(1, eventNum.get());
-
- layers.getComponents().add(layer2);
- assertEquals(2, eventNum.get());
-
- layers.getComponents().remove(layer2);
- assertEquals(3, eventNum.get());
-
- layers.getComponents().set(0, layer2);
- assertEquals(4, eventNum.get());
- }
-
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/SEPortrayerTest.java b/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/SEPortrayerTest.java
deleted file mode 100644
index dfd6b6e..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/SEPortrayerTest.java
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * 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.map;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.locationtech.jts.geom.CoordinateXY;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.Point;
-import org.locationtech.jts.geom.Polygon;
-import org.opengis.util.GenericName;
-import org.opengis.geometry.Envelope;
-import org.opengis.metadata.Metadata;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.MatchAction;
-import org.apache.sis.coverage.grid.GridExtent;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.coverage.grid.GridOrientation;
-import org.apache.sis.feature.builder.AttributeRole;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.filter.DefaultFilterFactory;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.feature.privy.AttributeConvention;
-import org.apache.sis.storage.FeatureQuery;
-import org.apache.sis.storage.Aggregate;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.FeatureSet;
-import org.apache.sis.storage.Resource;
-import org.apache.sis.storage.base.MemoryFeatureSet;
-import org.apache.sis.style.se1.FeatureTypeStyle;
-import org.apache.sis.style.se1.Symbology;
-import org.apache.sis.style.se1.StyleFactory;
-import org.apache.sis.style.se1.Symbolizer;
-import org.apache.sis.style.se1.SemanticType;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.storage.event.StoreEvent;
-import org.apache.sis.storage.event.StoreListener;
-import org.apache.sis.util.iso.Names;
-
-// Test dependencies
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@Execution(ExecutionMode.CONCURRENT)
-@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class SEPortrayerTest {
- /**
- * The factory to use for creating style elements.
- */
- private final StyleFactory<Feature> factory = FeatureTypeStyle.FACTORY;
-
- private final FilterFactory<Feature,Object,Object> filterFactory;
- private final FeatureSet fishes;
- private final FeatureSet boats;
-
- /**
- * Creates a new test case.
- */
- public SEPortrayerTest() {
- filterFactory = DefaultFilterFactory.forFeatures();
-
- final GeometryFactory gf = org.apache.sis.geometry.wrapper.jts.Factory.INSTANCE.factory(false);
- final CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic();
-
- final FeatureTypeBuilder fishbuilder = new FeatureTypeBuilder();
- fishbuilder.setName("fish");
- fishbuilder.addAttribute(String.class).setName("id").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- fishbuilder.addAttribute(Point.class).setCRS(crs).setName("geom").addRole(AttributeRole.DEFAULT_GEOMETRY);
- fishbuilder.addAttribute(String.class).setName("description");
- final FeatureType fishType = fishbuilder.build();
-
- final Point point1 = gf.createPoint(new CoordinateXY(0, 0));
- point1.setUserData(crs);
- final Feature fish1 = fishType.newInstance();
- fish1.setPropertyValue("id", "1");
- fish1.setPropertyValue("geom", point1);
- fish1.setPropertyValue("description", "A red fish");
-
- final Point point2 = gf.createPoint(new CoordinateXY(10, 20));
- point2.setUserData(crs);
- final Feature fish2 = fishType.newInstance();
- fish2.setPropertyValue("id", "2");
- fish2.setPropertyValue("geom", point2);
- fish2.setPropertyValue("description", "A small blue fish");
-
- //a special fish with a sub-type
- final FeatureTypeBuilder sharkbuilder = new FeatureTypeBuilder();
- sharkbuilder.setName("shark");
- sharkbuilder.setSuperTypes(fishType);
- sharkbuilder.addAttribute(String.class).setName("specie");
- sharkbuilder.addAttribute(Double.class).setName("length");
- final FeatureType sharkType = sharkbuilder.build();
-
- final Point point3 = gf.createPoint(new CoordinateXY(30, 40));
- point3.setUserData(crs);
- final Feature shark1 = sharkType.newInstance();
- shark1.setPropertyValue("id", "100");
- shark1.setPropertyValue("geom", point3);
- shark1.setPropertyValue("description", "dangerous fish");
- shark1.setPropertyValue("specie", "White Shark");
- shark1.setPropertyValue("length", 12.0);
-
- fishes = new MemoryFeatureSet(null, sharkType, List.of(fish1, fish2, shark1));
-
- final FeatureTypeBuilder boatbuilder = new FeatureTypeBuilder();
- boatbuilder.setName("boat");
- boatbuilder.addAttribute(String.class).setName("id").addRole(AttributeRole.IDENTIFIER_COMPONENT);
- boatbuilder.addAttribute(Polygon.class).setCRS(crs).setName("geom").addRole(AttributeRole.DEFAULT_GEOMETRY);
- boatbuilder.addAttribute(String.class).setName("description");
- final FeatureType boatType = boatbuilder.build();
-
- final Polygon poly1 = gf.createPolygon(gf.createLinearRing(new CoordinateXY[] {
- new CoordinateXY(0, 0), new CoordinateXY(0, 1), new CoordinateXY(1, 1), new CoordinateXY(0, 0)}));
- poly1.setUserData(crs);
- final Feature boat1 = boatType.newInstance();
- boat1.setPropertyValue("id", "10");
- boat1.setPropertyValue("geom", poly1);
- boat1.setPropertyValue("description", "A fishing boat");
-
- final Polygon poly2 = gf.createPolygon(gf.createLinearRing(new CoordinateXY[] {
- new CoordinateXY(0, 0), new CoordinateXY(0, 1), new CoordinateXY(1, 1), new CoordinateXY(0, 0)}));
- poly2.setUserData(crs);
- final Feature boat2 = boatType.newInstance();
- boat2.setPropertyValue("id", "20");
- boat2.setPropertyValue("geom", poly2);
- boat2.setPropertyValue("description", "A submarine");
-
- boats = new MemoryFeatureSet(null, boatType, List.of(boat1, boat2));
- }
-
- private Set<Match> present(MapItem item) {
- return present(item, CRS.getDomainOfValidity(CommonCRS.WGS84.normalizedGeographic()));
- }
-
- private Set<Match> present(MapItem item, Envelope env) {
- final GridGeometry grid = new GridGeometry(new GridExtent(360, 180), env, GridOrientation.REFLECTION_Y);
- final SEPortrayer portrayer = new SEPortrayer();
- final Stream<Presentation> stream = portrayer.present(grid, item);
- final List<Presentation> presentations = stream.collect(Collectors.toList());
-
- final Set<Match> ids = new HashSet<>();
- presentations.stream().forEach(new Consumer<Presentation>() {
- @Override
- public void accept(Presentation t) {
- if (t instanceof SEPresentation se) {
- Feature Feature = se.getCandidate();
- ids.add(new Match(String.valueOf(Feature.getPropertyValue(AttributeConvention.IDENTIFIER)),
- se.getLayer(),
- se.getResource(),
- se.getSymbolizer()));
- } else if (t instanceof ExceptionPresentation ep) {
- ids.add(new Match(ep.getException()));
- }
- }
- });
- return ids;
- }
-
- /**
- * Portray using no filtering operations
- */
- @Test
- public void testSanity() {
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- final var rule = factory.createRule();
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(5, presentations.size());
- assertTrue(presentations.contains(new Match("1", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("2", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("100", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("10", boatLayer, boats, symbolizer)));
- assertTrue(presentations.contains(new Match("20", boatLayer, boats, symbolizer)));
- }
-
- /**
- * Test portrayer includes the bounding box of the canvas while querying features.
- * Only fish feature with identifier "2" matches in this test.
- */
- @Test
- public void testCanvasBboxfilter() {
- final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
- env.setRange(0, 9, 11);
- env.setRange(1, 19, 21);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- final var rule = factory.createRule();
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers, env);
- assertEquals(1, presentations.size());
- assertTrue(presentations.contains(new Match("2", fishLayer, fishes, symbolizer)));
- }
-
- /**
- * Test portrayer uses the user defined query when portraying.
- * Only fish feature with identifier "1" and boat feature with identifier "20" matches in this test.
- */
- @Test
- public void testUserQuery() {
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- final var rule = factory.createRule();
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final Filter<Feature> filter = filterFactory.or(
- filterFactory.resourceId("1"),
- filterFactory.resourceId("20"));
- final FeatureQuery query = new FeatureQuery();
- query.setSelection(filter);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- fishLayer.setQuery(query);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- boatLayer.setQuery(query);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(2, presentations.size());
- assertTrue(presentations.contains(new Match("1", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("20", boatLayer, boats, symbolizer)));
- }
-
- /**
- * Portray using defined type names.
- * Test expect only boat type features to be rendered.
- */
- @Test
- public void testFeatureTypeStyleTypeNames() {
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- fts.setFeatureTypeName(Names.createLocalName(null, null, "boat"));
- final var rule = factory.createRule();
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(2, presentations.size());
- assertTrue(presentations.contains(new Match("10", boatLayer, boats, symbolizer)));
- assertTrue(presentations.contains(new Match("20", boatLayer, boats, symbolizer)));
- }
-
- /**
- * Portray using defined type names.
- * Test expect only point geometric type to be rendered.
- */
- @Test
- public void testFeatureTypeStyleSemanticType() {
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- fts.semanticTypeIdentifiers().add(SemanticType.POINT);
- final var rule = factory.createRule();
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(3, presentations.size());
- assertTrue(presentations.contains(new Match("1", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("2", fishLayer, fishes, symbolizer)));
- assertTrue(presentations.contains(new Match("100", fishLayer, fishes, symbolizer)));
- }
-
- /**
- * Portray using defined rule filter
- * Test expect only features with identifier equals "2" to match.
- */
- @Test
- public void testRuleFilter() {
- final Filter<Feature> filter = filterFactory.resourceId("2");
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- final var rule = factory.createRule();
- rule.setFilter(filter);
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(1, presentations.size());
- assertTrue(presentations.contains(new Match("2", fishLayer, fishes, symbolizer)));
- }
-
- /**
- * Portray using defined rule scale filter.
- * Test expect only matching scale rule symbolizer to be portrayed.
- */
- @Test
- public void testRuleScale() {
- final var symbolizerAbove = factory.createLineSymbolizer();
- final var symbolizerUnder = factory.createLineSymbolizer();
- final var symbolizerMatch = factory.createLineSymbolizer();
-
- //Symbology rendering scale here is 3.944391406060875E8
- final var ruleAbove = factory.createRule();
- ruleAbove.symbolizers().add(symbolizerAbove);
- ruleAbove.setMinScaleDenominator(4e8);
- ruleAbove.setMaxScaleDenominator(Double.MAX_VALUE);
- final var ruleUnder = factory.createRule();
- ruleUnder.symbolizers().add(symbolizerUnder);
- ruleUnder.setMinScaleDenominator(0.0);
- ruleUnder.setMaxScaleDenominator(3e8);
- final var ruleMatch = factory.createRule();
- ruleMatch.symbolizers().add(symbolizerMatch);
- ruleMatch.setMinScaleDenominator(3e8);
- ruleMatch.setMaxScaleDenominator(4e8);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(ruleAbove);
- fts.rules().add(ruleUnder);
- fts.rules().add(ruleMatch);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(5, presentations.size());
- assertTrue(presentations.contains(new Match( "1", fishLayer, fishes, symbolizerMatch)));
- assertTrue(presentations.contains(new Match( "2", fishLayer, fishes, symbolizerMatch)));
- assertTrue(presentations.contains(new Match("100", fishLayer, fishes, symbolizerMatch)));
- assertTrue(presentations.contains(new Match( "10", boatLayer, boats, symbolizerMatch)));
- assertTrue(presentations.contains(new Match( "20", boatLayer, boats, symbolizerMatch)));
- }
-
- /**
- * Portray using defined rule filter.
- * The rule uses a property only available on the shark sub type.
- * Test expect only features with specy equals "White Shark" to match.
- */
- @Test
- public void testRuleFilterOnSubType() {
- final BinaryComparisonOperator<Feature> filter = filterFactory.equal(
- filterFactory.property("specie", String.class),
- filterFactory.literal("White Shark"),
- true, MatchAction.ANY);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- final var rule = factory.createRule();
- rule.setFilter(filter);
- final var symbolizer = factory.createLineSymbolizer();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
- rule.symbolizers().add(symbolizer);
-
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(1, presentations.size());
- assertTrue(presentations.contains(new Match("100", fishLayer, fishes, symbolizer)));
- }
-
- /**
- * Portray using defined rule 'is else' property.
- * Test expect only feature with identifier "10" to be rendered with the base rule
- * and other features to rendered with the fallback rule.
- */
- @Test
- public void testRuleElseCondition() {
- final Filter<Feature> filter = filterFactory.resourceId("10");
-
- final var symbolizerBase = factory.createLineSymbolizer();
- final var symbolizerElse = factory.createLineSymbolizer();
-
- final var ruleBase = factory.createRule();
- ruleBase.symbolizers().add(symbolizerBase);
- ruleBase.setFilter(filter);
- final var ruleOther = factory.createRule();
- ruleOther.setElseFilter(true);
- ruleOther.symbolizers().add(symbolizerElse);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(ruleBase);
- fts.rules().add(ruleOther);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(5, presentations.size());
- assertTrue(presentations.contains(new Match( "1", fishLayer, fishes, symbolizerElse)));
- assertTrue(presentations.contains(new Match( "2", fishLayer, fishes, symbolizerElse)));
- assertTrue(presentations.contains(new Match("100", fishLayer, fishes, symbolizerElse)));
- assertTrue(presentations.contains(new Match( "10", boatLayer, boats, symbolizerBase)));
- assertTrue(presentations.contains(new Match( "20", boatLayer, boats, symbolizerElse)));
- }
-
- /**
- * Portray using and aggregated resource.
- * Test expect presentations to be correctly associated to each resource but on the same layer.
- */
- @Test
- public void testAggregateResource() {
- final var symbolizerBase = factory.createLineSymbolizer();
-
- final var ruleBase = factory.createRule();
- ruleBase.symbolizers().add(symbolizerBase);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(ruleBase);
-
- final List<Resource> list = List.of(fishes, boats);
- final Aggregate agg = new Aggregate() {
- @Override
- public Collection<? extends Resource> components() throws DataStoreException {
- return list;
- }
-
- @Override
- public Optional<GenericName> getIdentifier() throws DataStoreException {
- return Optional.empty();
- }
-
- @Override
- public Metadata getMetadata() throws DataStoreException {
- return null;
- }
-
- @Override
- public <T extends StoreEvent> void addListener(Class<T> eventType, StoreListener<? super T> listener) {}
-
- @Override
- public <T extends StoreEvent> void removeListener(Class<T> eventType, StoreListener<? super T> listener) {}
- };
-
- final MapLayer aggLayer = new MapLayer();
- aggLayer.setData(agg);
- aggLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(aggLayer);
-
- final Set<Match> presentations = present(layers);
- assertEquals(5, presentations.size());
- assertTrue(presentations.contains(new Match( "1", aggLayer, fishes, symbolizerBase)));
- assertTrue(presentations.contains(new Match( "2", aggLayer, fishes, symbolizerBase)));
- assertTrue(presentations.contains(new Match("100", aggLayer, fishes, symbolizerBase)));
- assertTrue(presentations.contains(new Match( "10", aggLayer, boats, symbolizerBase)));
- assertTrue(presentations.contains(new Match( "20", aggLayer, boats, symbolizerBase)));
- }
-
- /**
- * Portray preserving all feature attributes test.
- */
- @Test
- public void testPreserveProperties() {
- final Filter<Feature> filter = filterFactory.resourceId("2");
- final var symbolizer = factory.createLineSymbolizer();
-
- final var rule = factory.createRule();
- rule.symbolizers().add(symbolizer);
- rule.setFilter(filter);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
-
- final GridGeometry grid = new GridGeometry(new GridExtent(360, 180), CRS.getDomainOfValidity(CommonCRS.WGS84.normalizedGeographic()), GridOrientation.REFLECTION_Y);
- {
- // test without preserve properties
- // we expect only identifier and geometry to be available.
- final SEPortrayer portrayer = new SEPortrayer();
- portrayer.setPreserveProperties(false);
- final Stream<Presentation> stream = portrayer.present(grid, layers);
- final List<Presentation> presentations = stream.collect(Collectors.toList());
- assertEquals(1, presentations.size());
- final SEPresentation presentation = (SEPresentation) presentations.get(0);
- final Feature feature = presentation.getCandidate();
- final FeatureType type = feature.getType();
- assertEquals(2, type.getProperties(true).size());
- assertNotNull(type.getProperty(AttributeConvention.IDENTIFIER));
- assertNotNull(type.getProperty(AttributeConvention.GEOMETRY));
- }
- {
- // test with preserve properties
- // we expect only identifier and geometry to be available.
- final SEPortrayer portrayer = new SEPortrayer();
- portrayer.setPreserveProperties(true);
- final Stream<Presentation> stream = portrayer.present(grid, layers);
- final List<Presentation> presentations = stream.collect(Collectors.toList());
- assertEquals(1, presentations.size());
- final SEPresentation presentation = (SEPresentation) presentations.get(0);
- final Feature feature = presentation.getCandidate();
- final FeatureType type = feature.getType();
- assertEquals(6, type.getProperties(true).size());
- assertNotNull(type.getProperty(AttributeConvention.IDENTIFIER));
- assertNotNull(type.getProperty(AttributeConvention.GEOMETRY));
- assertNotNull(type.getProperty(AttributeConvention.ENVELOPE));
- assertNotNull(type.getProperty("id"));
- assertNotNull(type.getProperty("geom"));
- assertNotNull(type.getProperty("description"));
- }
- }
-
- /**
- * Test all properties used in the style are returned
- * in the presentation features.
- */
- @Test
- public void testStylePropertiesReturned() {
- final BinaryComparisonOperator<Feature> filter = filterFactory.equal(
- filterFactory.property("id", String.class),
- filterFactory.literal("2"),
- true, MatchAction.ANY);
-
- final var symbolizer = factory.createLineSymbolizer();
- symbolizer.setPerpendicularOffset(filterFactory.property("offset", Integer.class));
-
- final var rule = factory.createRule();
- rule.symbolizers().add(symbolizer);
- rule.setFilter(filter);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
-
- final GridGeometry grid = new GridGeometry(new GridExtent(360, 180), CRS.getDomainOfValidity(CommonCRS.WGS84.normalizedGeographic()), GridOrientation.REFLECTION_Y);
-
- // test without preserve properties
- // we expect identifier, geometry, id(used by rule filter), description (used in symbolizer)
- final SEPortrayer portrayer = new SEPortrayer();
- portrayer.setPreserveProperties(false);
- final Stream<Presentation> stream = portrayer.present(grid, layers);
- final List<Presentation> presentations = stream.collect(Collectors.toList());
- assertEquals(1, presentations.size());
- final SEPresentation presentation = (SEPresentation) presentations.get(0);
- final Feature feature = presentation.getCandidate();
- final FeatureType type = feature.getType();
- assertEquals(6, type.getProperties(true).size());
- assertNotNull(type.getProperty(AttributeConvention.IDENTIFIER));
- assertNotNull(type.getProperty(AttributeConvention.GEOMETRY));
- assertNotNull(type.getProperty("id"));
- assertNotNull(type.getProperty("description"));
- }
-
- /**
- * Test a geometry expression do not affect portraying bbox filtering.
- */
- @Test
- public void testGeometryExpression() {
- final var symbolizer = factory.createLineSymbolizer();
- symbolizer.setGeometry(filterFactory.function("ST_Centroid", filterFactory.property("geom")));
-
- final var rule = factory.createRule();
- rule.symbolizers().add(symbolizer);
-
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
- fts.rules().add(rule);
-
- final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
- env.setRange(0, 9, 11);
- env.setRange(1, 19, 21);
-
- final MapLayer fishLayer = new MapLayer();
- fishLayer.setData(fishes);
- fishLayer.setStyle(style);
- final MapLayer boatLayer = new MapLayer();
- boatLayer.setData(boats);
- boatLayer.setStyle(style);
- final MapLayers layers = new MapLayers();
- layers.getComponents().add(fishLayer);
- layers.getComponents().add(boatLayer);
-
- final Set<Match> presentations = present(layers, env);
- assertEquals(1, presentations.size());
- assertTrue(presentations.contains(new Match("2", fishLayer, fishes, symbolizer)));
- }
-
- private static class Match {
- private final String identifier;
- private final MapLayer layer;
- private final Resource resource;
- private final Symbolizer<?> symbolizer;
- private final Exception exception;
-
- public Match(String identifier, MapLayer layer, Resource resource, Symbolizer<?> symbolizer) {
- this.identifier = identifier;
- this.layer = layer;
- this.resource = resource;
- this.symbolizer = symbolizer;
- this.exception = null;
- }
-
- public Match(Exception e) {
- this.identifier = null;
- this.layer = null;
- this.resource = null;
- this.symbolizer = null;
- this.exception = e;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 29 * hash + Objects.hashCode(this.identifier);
- hash = 29 * hash + Objects.hashCode(this.layer);
- hash = 29 * hash + Objects.hashCode(this.resource);
- hash = 29 * hash + Objects.hashCode(this.symbolizer);
- hash = 29 * hash + Objects.hashCode(this.exception);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Match other = (Match) obj;
- if (!Objects.equals(this.identifier, other.identifier)) {
- return false;
- }
- if (!Objects.equals(this.layer, other.layer)) {
- return false;
- }
- if (!Objects.equals(this.resource, other.resource)) {
- return false;
- }
- if (!Objects.equals(this.symbolizer, other.symbolizer)) {
- return false;
- }
- if (!Objects.equals(this.exception, other.exception)) {
- return false;
- }
- return true;
- }
- }
-}
diff --git a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/service/GraphicsPortrayerTest.java b/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/service/GraphicsPortrayerTest.java
deleted file mode 100644
index 94bad9e..0000000
--- a/incubator/src/org.apache.sis.portrayal.map/test/org/apache/sis/map/service/GraphicsPortrayerTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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 andz
- * limitations under the License.
- */
-package org.apache.sis.map.service;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.util.Arrays;
-import java.util.stream.Stream;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.LineString;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.apache.sis.coverage.grid.GridExtent;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.coverage.grid.GridOrientation;
-import org.apache.sis.feature.builder.AttributeRole;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.feature.privy.AttributeConvention;
-import org.apache.sis.map.MapLayer;
-import org.apache.sis.map.Presentation;
-import org.apache.sis.map.SEPresentation;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.storage.FeatureSet;
-import org.apache.sis.storage.base.MemoryFeatureSet;
-import org.apache.sis.style.se1.FeatureTypeStyle;
-import org.apache.sis.style.se1.LineSymbolizer;
-import org.apache.sis.style.se1.Rule;
-import org.apache.sis.style.se1.Symbolizer;
-import org.apache.sis.style.se1.Symbology;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-
-
-/**
- *
- * @author Johann Sorel (Geomatys)
- */
-@Execution(ExecutionMode.CONCURRENT)
-@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class GraphicsPortrayerTest {
-
- private final GridGeometry WORLD = new GridGeometry(
- new GridExtent(360, 180),
- CRS.getDomainOfValidity(CommonCRS.WGS84.normalizedGeographic()),
- GridOrientation.REFLECTION_Y);
-
- private final GeometryFactory GF = new GeometryFactory();
-
- /**
- * Creates a new test case.
- */
- public GraphicsPortrayerTest() {
- }
-
- /**
- * Sanity test for rendering.
- */
- @Test
- public void testPortray() throws RenderingException {
-
- final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
- ftb.setName("test");
- ftb.addAttribute(Geometry.class).setName("geom").addRole(AttributeRole.DEFAULT_GEOMETRY);
- final FeatureType ft = ftb.build();
-
- final Feature feature = ft.newInstance();
- LineString geom = GF.createLineString(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,90)});
- geom.setUserData(WORLD.getCoordinateReferenceSystem());
- feature.setPropertyValue("geom", geom);
-
- final FeatureSet featureSet = new MemoryFeatureSet(null, ft, Arrays.asList(feature));
-
- final LineSymbolizer<Feature> symbolizer = new LineSymbolizer<>(FeatureTypeStyle.FACTORY);
- final Symbology style = createStyle(symbolizer);
-
- final MapLayer item = new MapLayer();
- item.setData(featureSet);
- item.setStyle(style);
-
- BufferedImage image = new GraphicsPortrayer()
- .setDomain(WORLD)
- .portray(item)
- .getImage();
-
- int color1 = image.getRGB(180, 45);
- int color2 = image.getRGB(179, 45);
- assertEquals(color1, Color.BLACK.getRGB());
- assertEquals(color2, new Color(0,0,0,0).getRGB());
- }
-
- /**
- * Sanity test for presentation.
- */
- @Test
- public void testPresent() throws RenderingException {
-
- final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
- ftb.setName("test");
- ftb.addAttribute(String.class).setName(AttributeConvention.IDENTIFIER);
- ftb.addAttribute(Geometry.class).setName("geom").addRole(AttributeRole.DEFAULT_GEOMETRY);
- final FeatureType ft = ftb.build();
-
- final Feature feature = ft.newInstance();
- LineString geom = GF.createLineString(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,90)});
- geom.setUserData(WORLD.getCoordinateReferenceSystem());
- feature.setPropertyValue(AttributeConvention.IDENTIFIER, "test-1");
- feature.setPropertyValue("geom", geom);
-
- final FeatureSet featureSet = new MemoryFeatureSet(null, ft, Arrays.asList(feature));
-
- final LineSymbolizer<Feature> symbolizer = new LineSymbolizer<>(FeatureTypeStyle.FACTORY);
- final Symbology style = createStyle(symbolizer);
-
- final MapLayer item = new MapLayer();
- item.setData(featureSet);
- item.setStyle(style);
-
- try (Stream<Presentation> stream = new GraphicsPortrayer()
- .setDomain(WORLD)
- .present(item)) {
- Object[] presentations = stream.toArray();
- assertEquals(1, presentations.length);
- assertTrue(presentations[0] instanceof SEPresentation);
- final SEPresentation pe = (SEPresentation) presentations[0];
- assertEquals(item, pe.getLayer());
- assertEquals(featureSet, pe.getResource());
- assertEquals("test-1", pe.getCandidate().getPropertyValue(AttributeConvention.IDENTIFIER));
- assertEquals(symbolizer, pe.getSymbolizer());
- }
- }
-
- /**
- * Sanity test for intersection.
- */
- @Test
- public void testIntersects() throws RenderingException {
-
- final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
- ftb.setName("test");
- ftb.addAttribute(Geometry.class).setName("geom").addRole(AttributeRole.DEFAULT_GEOMETRY);
- final FeatureType ft = ftb.build();
-
- final Feature feature = ft.newInstance();
- LineString geom = GF.createLineString(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,90)});
- geom.setUserData(WORLD.getCoordinateReferenceSystem());
- feature.setPropertyValue("geom", geom);
-
- final FeatureSet featureSet = new MemoryFeatureSet(null, ft, Arrays.asList(feature));
-
- final LineSymbolizer<Feature> symbolizer = new LineSymbolizer<>(FeatureTypeStyle.FACTORY);
- final Symbology style = createStyle(symbolizer);
-
- final MapLayer item = new MapLayer();
- item.setData(featureSet);
- item.setStyle(style);
-
- //rectangle outside, no intersection
- try (Stream<Presentation> result = new GraphicsPortrayer()
- .setDomain(WORLD)
- .intersects(item, new Rectangle(7,50,4,4))) {
- assertEquals(0, result.count());
- }
-
- //rectangle overlaps, intersects
- try (Stream<Presentation> result = new GraphicsPortrayer()
- .setDomain(WORLD)
- .intersects(item, new Rectangle(178,50,4,4))) {
- assertEquals(1, result.count());
- }
- }
-
- private static Symbology createStyle(Symbolizer symbolizer) {
- final Symbology style = new Symbology();
- final FeatureTypeStyle fts = new FeatureTypeStyle();
- style.featureTypeStyles().add(fts);
-
- final Rule<Feature> rule = new Rule<>(FeatureTypeStyle.FACTORY);
- rule.symbolizers().add(symbolizer);
- fts.rules().add(rule);
-
- return style;
- }
-
-}
diff --git a/incubator/src/org.apache.sis.storage.coveragejson/main/org/apache/sis/storage/coveragejson/CoverageResource.java b/incubator/src/org.apache.sis.storage.coveragejson/main/org/apache/sis/storage/coveragejson/CoverageResource.java
index 0af27f6..2f60b36 100644
--- a/incubator/src/org.apache.sis.storage.coveragejson/main/org/apache/sis/storage/coveragejson/CoverageResource.java
+++ b/incubator/src/org.apache.sis.storage.coveragejson/main/org/apache/sis/storage/coveragejson/CoverageResource.java
@@ -82,8 +82,8 @@
import org.apache.sis.referencing.operation.transform.LinearTransform;
import org.apache.sis.referencing.operation.transform.MathTransforms;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
+// Specific to the main branch:
+import org.apache.sis.image.SequenceType;
/**
@@ -511,7 +511,10 @@
final MathTransform gridToCrs = gridGeometry.getGridToCRS(PixelInCell.CELL_CENTER);
final int dimension = gridGeometry.getDimension();
- final long[] gridLow = extent.getLow().getCoordinateValues();
+ final long[] gridLow = new long[dimension];
+ for (int i=0; i<dimension; i++) {
+ gridLow[i] = extent.getLow(i);
+ }
final int[] gridSize = new int[dimension];
final List<Integer> gridToCrsIndex = new ArrayList<>(dimension);
final double[] scales = new double[dimension];
diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
index 12c924a..5d7016a 100644
--- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
+++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
@@ -254,7 +254,7 @@
builder.setISOStandards(true);
builder.setPredefinedFormat(GeoHeifStoreProvider.NAME, listeners, true);
builder.addFormatReaderSIS(GeoHeifStoreProvider.NAME);
- builder.addResourceScope(ScopeCode.COVERAGE, null);
+ builder.addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
getIdentifier().ifPresent((id) -> builder.addIdentifier(id, MetadataBuilder.Scope.ALL));
metadata = customizer.customize(new CoverageModifier.Source(this), builder.build());
}
diff --git a/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java b/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
index 6ed52ec..a10d64b 100644
--- a/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
+++ b/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
@@ -46,10 +46,10 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.PropertyType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -107,7 +107,7 @@
FeatureSet fs = getResource(gpkg, "nogeom");
assertPropertiesEqual(fs, null, "sis:identifier", "fid", "id");
{ // For keeping `the features` scope locale.
- final Feature[] features = getFeatures(fs).toArray(Feature[]::new);
+ final AbstractFeature[] features = getFeatures(fs).toArray(AbstractFeature[]::new);
assertEquals(2, features.length);
assertEquals(1, features[0].getPropertyValue("fid"));
assertEquals(1, features[0].getPropertyValue("id"));
@@ -134,7 +134,7 @@
assertGeometryEquals(fs, "OGC:CRS84", "POINT (3.8691634241245 43.64618798638135)");
{ // For keeping the `feature` scope local.
- final Feature feature = getFeatures(fs).get(0);
+ final AbstractFeature feature = getFeatures(fs).get(0);
assertEquals("some text", feature.getPropertyValue("text"));
assertEquals(123, feature.getPropertyValue("int32"));
assertEquals(123456, feature.getPropertyValue("int64"));
@@ -243,13 +243,13 @@
private static void assertPropertiesEqual(final FeatureSet fs, final String geometryType,
final String... propertyNames) throws DataStoreException
{
- final PropertyType[] properties = fs.getType().getProperties(true).toArray(PropertyType[]::new);
+ final AbstractIdentifiedType[] properties = fs.getType().getProperties(true).toArray(AbstractIdentifiedType[]::new);
assertEquals(propertyNames.length, properties.length, "properties.size()");
for (int i=0; i<propertyNames.length; i++) {
assertEquals(propertyNames[i], properties[i].getName().toString());
}
if (geometryType != null) {
- var attribute = assertInstanceOf(AttributeType.class, properties[4]);
+ var attribute = assertInstanceOf(DefaultAttributeType.class, properties[4]);
assertEquals(geometryType, attribute.getValueClass().getSimpleName());
}
}
@@ -260,8 +260,8 @@
* @param fs the feature set from which to get the feature instances.
* @return all feature instances.
*/
- private static List<Feature> getFeatures(final FeatureSet fs) throws DataStoreException {
- try (Stream<Feature> stream = fs.features(false)) {
+ private static List<AbstractFeature> getFeatures(final FeatureSet fs) throws DataStoreException {
+ try (Stream<AbstractFeature> stream = fs.features(false)) {
return stream.toList();
}
}
@@ -277,9 +277,9 @@
private static void assertGeometryEquals(final FeatureSet resource, final String expectedCRS, final String expectedWKT)
throws DataStoreException
{
- final List<Feature> features = getFeatures(resource);
+ final List<AbstractFeature> features = getFeatures(resource);
assertEquals(1, features.size());
- final Feature feature = features.get(0);
+ final AbstractFeature feature = features.get(0);
GeometryWrapper geometry = Geometries.wrap(feature).orElseThrow();
assertEquals(expectedCRS, IdentifiedObjects.getIdentifierOrName(geometry.getCoordinateReferenceSystem()));
diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
index 9c25594..aea823e 100644
--- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
+++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
@@ -57,14 +57,14 @@
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
-import org.opengis.util.FactoryException;
-import org.opengis.util.GenericName;
import org.opengis.geometry.Envelope;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.Identifier;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+import org.opengis.util.GenericName;
import org.apache.sis.geometry.ImmutableEnvelope;
import org.apache.sis.geometry.Envelopes;
import org.apache.sis.geometry.GeneralEnvelope;
@@ -113,20 +113,19 @@
import org.apache.sis.util.Utilities;
import org.apache.sis.util.collection.BackingStoreException;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.CodeList;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.filter.Expression;
-import org.opengis.filter.Filter;
-import org.opengis.filter.Literal;
-import org.opengis.filter.LogicalOperator;
-import org.opengis.filter.LogicalOperatorName;
-import org.opengis.filter.SpatialOperatorName;
-import org.opengis.filter.ValueReference;
-import org.apache.sis.geometry.wrapper.*;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.filter.Expression;
+import org.apache.sis.filter.Filter;
+import org.apache.sis.geometry.wrapper.Geometries;
+import org.apache.sis.pending.geoapi.filter.Literal;
+import org.apache.sis.pending.geoapi.filter.LogicalOperator;
+import org.apache.sis.pending.geoapi.filter.LogicalOperatorName;
+import org.apache.sis.pending.geoapi.filter.SpatialOperatorName;
+import org.apache.sis.pending.geoapi.filter.ValueReference;
/**
@@ -217,7 +216,7 @@
* {@inheritDoc }
*/
@Override
- public FeatureType getType() throws DataStoreException {
+ public DefaultFeatureType getType() throws DataStoreException {
return featureSetView.getType();
}
@@ -233,7 +232,7 @@
* {@inheritDoc }
*/
@Override
- public Stream<Feature> features(boolean parallel) throws DataStoreException {
+ public Stream<AbstractFeature> features(boolean parallel) throws DataStoreException {
return featureSetView.features(parallel);
}
@@ -249,7 +248,7 @@
* {@inheritDoc }
*/
@Override
- public void updateType(FeatureType featureType) throws DataStoreException {
+ public void updateType(DefaultFeatureType featureType) throws DataStoreException {
featureSetView.updateType(featureType);
}
@@ -257,7 +256,7 @@
* {@inheritDoc }
*/
@Override
- public void add(Iterator<? extends Feature> iterator) throws DataStoreException {
+ public void add(Iterator<? extends AbstractFeature> iterator) throws DataStoreException {
featureSetView.add(iterator);
}
@@ -265,7 +264,7 @@
* {@inheritDoc }
*/
@Override
- public void removeIf(Predicate<? super Feature> predicate) throws DataStoreException {
+ public void removeIf(Predicate<? super AbstractFeature> predicate) throws DataStoreException {
featureSetView.removeIf(predicate);
}
@@ -273,7 +272,7 @@
* {@inheritDoc }
*/
@Override
- public void replaceIf(Predicate<? super Feature> predicate, UnaryOperator<Feature> unaryOperator) throws DataStoreException {
+ public void replaceIf(Predicate<? super AbstractFeature> predicate, UnaryOperator<AbstractFeature> unaryOperator) throws DataStoreException {
featureSetView.replaceIf(predicate, unaryOperator);
}
@@ -303,7 +302,7 @@
*/
private String idField;
private CoordinateReferenceSystem crs;
- private FeatureType type;
+ private DefaultFeatureType type;
/**
* @param filter optional shape filter, must be in data CRS
@@ -324,7 +323,7 @@
}
@Override
- public synchronized FeatureType getType() throws DataStoreException {
+ public synchronized DefaultFeatureType getType() throws DataStoreException {
if (type == null) {
if (!Files.isRegularFile(shpPath)) {
throw new DataStoreException("Shape files do not exist. Update FeatureType first to initialize this empty datastore");
@@ -446,8 +445,8 @@
}
@Override
- public Stream<Feature> features(boolean parallel) throws DataStoreException {
- final FeatureType type = getType();
+ public Stream<AbstractFeature> features(boolean parallel) throws DataStoreException {
+ final DefaultFeatureType type = getType();
final ShapeReader shpreader;
final DBFReader dbfreader;
try {
@@ -481,7 +480,7 @@
long offset = (long)header.headerSize + ((long)(shpRecord.recordNumber-1)) * ((long)header.recordSize);
dbfreader.moveToOffset(offset);
final Object[] dbfRecord = dbfreader.next();
- final Feature next = type.newInstance();
+ final AbstractFeature next = type.newInstance();
if (shpRecord.geometry != null) {
shpRecord.geometry.setUserData(crs);
shpRecord.geometry.setSRID(geomSrid);
@@ -505,7 +504,7 @@
try {
final ShapeRecord shpRecord = shpreader.next();
if (shpRecord == null) return false;
- final Feature next = type.newInstance();
+ final AbstractFeature next = type.newInstance();
if (shpRecord.geometry != null) {
shpRecord.geometry.setUserData(crs);
shpRecord.geometry.setSRID(geomSrid);
@@ -527,7 +526,7 @@
try {
final Object[] dbfRecord = dbfreader.next();
if (dbfRecord == null) return false;
- final Feature next = type.newInstance();
+ final AbstractFeature next = type.newInstance();
for (int i = 0; i < dbfPropertiesIndex.length; i++) {
next.setPropertyValue(header.fields[dbfPropertiesIndex[i]].fieldName, dbfRecord[i]);
}
@@ -540,7 +539,7 @@
};
}
- final Stream<Feature> stream = StreamSupport.stream(spliterator, false);
+ final Stream<AbstractFeature> stream = StreamSupport.stream(spliterator, false);
return stream.onClose(new Runnable() {
@Override
public void run() {
@@ -562,7 +561,7 @@
if (query instanceof FeatureQuery) {
final FeatureQuery fq = (FeatureQuery) query;
FeatureQuery.NamedExpression[] projection = fq.getProjection();
- Filter<? super Feature> selection = fq.getSelection();
+ Filter<? super AbstractFeature> selection = fq.getSelection();
if (selection == null && projection == null) {
//no optimisation
@@ -570,7 +569,7 @@
}
//force loading
- final FeatureType type = getType();
+ final DefaultFeatureType type = getType();
//extract bbox
Envelope bbox = null;
@@ -638,10 +637,12 @@
needSubProcessing = true;
subQuery.setOffset(fq.getOffset());
}
+ /* Unsupported on the main branch.
if (fq.getSortBy() != null) {
needSubProcessing = true;
subQuery.setSortBy(fq.getSortBy());
}
+ */
if (selection != null) {
needSubProcessing = true;
subQuery.setSelection(selection);
@@ -662,7 +663,7 @@
}
@Override
- public synchronized void updateType(FeatureType newType) throws DataStoreException {
+ public synchronized void updateType(DefaultFeatureType newType) throws DataStoreException {
if (!isDefaultView()) throw new DataStoreException("Resource not writable in current filter state");
if (Files.exists(shpPath)) {
@@ -690,9 +691,9 @@
final Charset charset = userDefinedCharSet == null ? StandardCharsets.UTF_8 : userDefinedCharSet;
CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic();
- for (PropertyType pt : newType.getProperties(true)) {
- if (pt instanceof AttributeType) {
- final AttributeType at = (AttributeType) pt;
+ for (AbstractIdentifiedType pt : newType.getProperties(true)) {
+ if (pt instanceof DefaultAttributeType) {
+ final DefaultAttributeType at = (DefaultAttributeType) pt;
final Class valueClass = at.getValueClass();
final String attName = at.getName().tip().toString();
@@ -713,8 +714,8 @@
else throw new DataStoreException("Unsupported geometry type " + valueClass);
Object cdt = at.characteristics().get(AttributeConvention.CRS);
- if (cdt instanceof AttributeType) {
- Object defaultValue = ((AttributeType) cdt).getDefaultValue();
+ if (cdt instanceof DefaultAttributeType) {
+ Object defaultValue = ((DefaultAttributeType) cdt).getDefaultValue();
if (defaultValue instanceof CoordinateReferenceSystem) {
crs = (CoordinateReferenceSystem) defaultValue;
}
@@ -809,15 +810,15 @@
}
@Override
- public void add(Iterator<? extends Feature> features) throws DataStoreException {
+ public void add(Iterator<? extends AbstractFeature> features) throws DataStoreException {
if (!isDefaultView()) throw new DataStoreException("Resource not writable in current filter state");
if (!Files.exists(shpPath)) throw new DataStoreException("FeatureType do not exist, use updateType before modifying features.");
final Writer writer = new Writer(charset);
try {
//write existing features
- try (Stream<Feature> stream = features(false)) {
- Iterator<Feature> iterator = stream.iterator();
+ try (Stream<AbstractFeature> stream = features(false)) {
+ Iterator<AbstractFeature> iterator = stream.iterator();
while (iterator.hasNext()) {
writer.write(iterator.next());
}
@@ -840,15 +841,15 @@
}
@Override
- public void removeIf(Predicate<? super Feature> filter) throws DataStoreException {
+ public void removeIf(Predicate<? super AbstractFeature> filter) throws DataStoreException {
if (!isDefaultView()) throw new DataStoreException("Resource not writable in current filter state");
if (!Files.exists(shpPath)) throw new DataStoreException("FeatureType do not exist, use updateType before modifying features.");
final Writer writer = new Writer(charset);
try {
//write existing features not matching filter
- try (Stream<Feature> stream = features(false)) {
- Iterator<Feature> iterator = stream.filter(filter.negate()).iterator();
+ try (Stream<AbstractFeature> stream = features(false)) {
+ Iterator<AbstractFeature> iterator = stream.filter(filter.negate()).iterator();
while (iterator.hasNext()) {
writer.write(iterator.next());
}
@@ -865,17 +866,17 @@
}
@Override
- public void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature> updater) throws DataStoreException {
+ public void replaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) throws DataStoreException {
if (!isDefaultView()) throw new DataStoreException("Resource not writable in current filter state");
if (!Files.exists(shpPath)) throw new DataStoreException("FeatureType do not exist, use updateType before modifying features.");
final Writer writer = new Writer(charset);
try {
//write existing features applying modifications
- try (Stream<Feature> stream = features(false)) {
- Iterator<Feature> iterator = stream.iterator();
+ try (Stream<AbstractFeature> stream = features(false)) {
+ Iterator<AbstractFeature> iterator = stream.iterator();
while (iterator.hasNext()) {
- Feature feature = iterator.next();
+ AbstractFeature feature = iterator.next();
if (filter.test(feature)) {
feature = updater.apply(feature);
}
@@ -1059,7 +1060,7 @@
*/
private static Entry<Envelope,Filter> extractBbox(Filter<?> filter) {
- final CodeList operatorType = filter.getOperatorType();
+ final Enum operatorType = filter.getOperatorType();
if (operatorType == SpatialOperatorName.BBOX) {
Envelope env = isDirectBbox(filter);
@@ -1193,16 +1194,16 @@
}
- private void write(Feature feature) throws IOException {
+ private void write(AbstractFeature feature) throws IOException {
inc++; //number starts at 1
final ShapeRecord shpRecord = new ShapeRecord();
final long recordStartPosition = shpWriter.getSteamPosition();
if (defaultGeomName == null) {
//search for the geometry name
- for (PropertyType pt : feature.getType().getProperties(true)) {
- if (pt instanceof AttributeType) {
- final AttributeType at = (AttributeType) pt;
+ for (AbstractIdentifiedType pt : feature.getType().getProperties(true)) {
+ if (pt instanceof DefaultAttributeType) {
+ final DefaultAttributeType at = (DefaultAttributeType) pt;
final String attName = at.getName().toString();
if (Geometry.class.isAssignableFrom(at.getValueClass())) {
defaultGeomName = attName;
diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
index 56f78b3..39322f7 100644
--- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
+++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
@@ -200,10 +200,10 @@
final double maxY = channel.readDouble();
if (filter != null && maxY < filter.y) return false;
shape.bbox = new GeneralEnvelope(getDimension());
- shape.bbox.getLowerCorner().setCoordinate(0, minX);
- shape.bbox.getLowerCorner().setCoordinate(1, minY);
- shape.bbox.getUpperCorner().setCoordinate(0, maxX);
- shape.bbox.getUpperCorner().setCoordinate(1, maxY);
+ shape.bbox.getLowerCorner().setOrdinate(0, minX);
+ shape.bbox.getLowerCorner().setOrdinate(1, minY);
+ shape.bbox.getUpperCorner().setOrdinate(0, maxX);
+ shape.bbox.getUpperCorner().setOrdinate(1, maxY);
return true;
}
diff --git a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
index 6666f14..c76ed95 100644
--- a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
+++ b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
@@ -45,12 +45,11 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.BinaryComparisonOperator;
-import org.opengis.filter.FilterFactory;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.filter.Filter;
/**
@@ -67,18 +66,18 @@
try (final ShapefileStore store = new ShapefileStore(Paths.get(url.toURI()))) {
//check feature type
- final FeatureType type = store.getType();
+ final DefaultFeatureType type = store.getType();
assertEquals("point", type.getName().toString());
assertEquals(9, type.getProperties(true).size());
assertNotNull(type.getProperty("sis:identifier"));
assertNotNull(type.getProperty("sis:envelope"));
assertNotNull(type.getProperty("sis:geometry"));
- final var geomProp = (AttributeType) type.getProperty("geometry");
- final var idProp = (AttributeType) type.getProperty("id");
- final var textProp = (AttributeType) type.getProperty("text");
- final var integerProp = (AttributeType) type.getProperty("integer");
- final var floatProp = (AttributeType) type.getProperty("float");
- final var dateProp = (AttributeType) type.getProperty("date");
+ final var geomProp = (DefaultAttributeType) type.getProperty("geometry");
+ final var idProp = (DefaultAttributeType) type.getProperty("id");
+ final var textProp = (DefaultAttributeType) type.getProperty("text");
+ final var integerProp = (DefaultAttributeType) type.getProperty("integer");
+ final var floatProp = (DefaultAttributeType) type.getProperty("float");
+ final var dateProp = (DefaultAttributeType) type.getProperty("date");
assertEquals(Point.class, geomProp.getValueClass());
assertEquals(Long.class, idProp.getValueClass());
assertEquals(String.class, textProp.getValueClass());
@@ -86,10 +85,10 @@
assertEquals(Double.class, floatProp.getValueClass());
assertEquals(LocalDate.class, dateProp.getValueClass());
- try (Stream<Feature> stream = store.features(false)) {
- Iterator<Feature> iterator = stream.iterator();
+ try (Stream<AbstractFeature> stream = store.features(false)) {
+ Iterator<AbstractFeature> iterator = stream.iterator();
assertTrue(iterator.hasNext());
- Feature feature1 = iterator.next();
+ AbstractFeature feature1 = iterator.next();
assertEquals(1L, feature1.getPropertyValue("id"));
assertEquals("text1", feature1.getPropertyValue("text"));
assertEquals(10L, feature1.getPropertyValue("integer"));
@@ -99,7 +98,7 @@
assertTrue(pt1.getUserData() instanceof CoordinateReferenceSystem);
assertTrue(iterator.hasNext());
- Feature feature2 = iterator.next();
+ AbstractFeature feature2 = iterator.next();
assertEquals(2L, feature2.getPropertyValue("id"));
assertEquals("text2", feature2.getPropertyValue("text"));
assertEquals(40L, feature2.getPropertyValue("integer"));
@@ -121,7 +120,7 @@
final URL url = ShapefileStoreTest.class.getResource("/org/apache/sis/storage/shapefile/point.shp");
try (final ShapefileStore store = new ShapefileStore(Paths.get(url.toURI()))) {
- final FilterFactory<Feature, Object, Object> ff = DefaultFilterFactory.forFeatures();
+ final DefaultFilterFactory<AbstractFeature, Object, Object> ff = DefaultFilterFactory.forFeatures();
final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
env.setRange(0, 2, 3);
@@ -133,10 +132,10 @@
//ensure we obtained an optimized version
assertEquals("org.apache.sis.storage.shapefile.ShapefileStore$AsFeatureSet", featureset.getClass().getName());
- try (Stream<Feature> stream = featureset.features(false)) {
- Iterator<Feature> iterator = stream.iterator();
+ try (Stream<AbstractFeature> stream = featureset.features(false)) {
+ Iterator<AbstractFeature> iterator = stream.iterator();
assertTrue(iterator.hasNext());
- Feature feature = iterator.next();
+ AbstractFeature feature = iterator.next();
assertEquals(2L, feature.getPropertyValue("id"));
assertEquals("text2", feature.getPropertyValue("text"));
assertEquals(40L, feature.getPropertyValue("integer"));
@@ -163,15 +162,15 @@
//ensure we obtained an optimized version
assertEquals("org.apache.sis.storage.shapefile.ShapefileStore$AsFeatureSet", featureset.getClass().getName());
- try (Stream<Feature> stream = featureset.features(false)) {
- Iterator<Feature> iterator = stream.iterator();
+ try (Stream<AbstractFeature> stream = featureset.features(false)) {
+ Iterator<AbstractFeature> iterator = stream.iterator();
assertTrue(iterator.hasNext());
- Feature feature1 = iterator.next();
+ AbstractFeature feature1 = iterator.next();
assertEquals("text1", feature1.getPropertyValue("text"));
assertEquals(20.0, feature1.getPropertyValue("float"));
assertTrue(iterator.hasNext());
- Feature feature2 = iterator.next();
+ AbstractFeature feature2 = iterator.next();
assertEquals("text2", feature2.getPropertyValue("text"));
assertEquals(60.0, feature2.getPropertyValue("float"));
@@ -205,7 +204,7 @@
assertTrue(store.getFileSet().orElseThrow().getPaths().isEmpty());
{//create type
- final FeatureType type = createType();
+ final DefaultFeatureType type = createType();
store.updateType(type);
}
@@ -220,19 +219,19 @@
}
{// check created type
- FeatureType type = store.getType();
+ DefaultFeatureType type = store.getType();
assertEquals(name, type.getName().toString());
assertEquals(9, type.getProperties(true).size());
assertNotNull(type.getProperty("sis:identifier"));
assertNotNull(type.getProperty("sis:envelope"));
assertNotNull(type.getProperty("sis:geometry"));
- final var geomProp = (AttributeType) type.getProperty("geometry");
- final var idProp = (AttributeType) type.getProperty("id");
- final var textProp = (AttributeType) type.getProperty("text");
- final var integerProp = (AttributeType) type.getProperty("integer");
- final var floatProp = (AttributeType) type.getProperty("float");
- final var dateProp = (AttributeType) type.getProperty("date");
- final AttributeType crsChar = (AttributeType) geomProp.characteristics().get(AttributeConvention.CRS);
+ final var geomProp = (DefaultAttributeType) type.getProperty("geometry");
+ final var idProp = (DefaultAttributeType) type.getProperty("id");
+ final var textProp = (DefaultAttributeType) type.getProperty("text");
+ final var integerProp = (DefaultAttributeType) type.getProperty("integer");
+ final var floatProp = (DefaultAttributeType) type.getProperty("float");
+ final var dateProp = (DefaultAttributeType) type.getProperty("date");
+ final DefaultAttributeType crsChar = (DefaultAttributeType) geomProp.characteristics().get(AttributeConvention.CRS);
assertTrue(Utilities.equalsIgnoreMetadata(CommonCRS.WGS84.geographic(),crsChar.getDefaultValue()));
assertEquals(Point.class, geomProp.getValueClass());
assertEquals(Integer.class, idProp.getValueClass());
@@ -251,12 +250,12 @@
public void testAddFeatures(@TempDir final Path folder) throws URISyntaxException, DataStoreException, IOException {
final Path temp = folder.resolve("test.shp");
try (final ShapefileStore store = new ShapefileStore(temp)) {
- FeatureType type = createType();
+ DefaultFeatureType type = createType();
store.updateType(type);
type = store.getType();
- Feature feature1 = createFeature1(type);
- Feature feature2 = createFeature2(type);
+ AbstractFeature feature1 = createFeature1(type);
+ AbstractFeature feature2 = createFeature2(type);
store.add(List.of(feature1, feature2).iterator());
Object[] result = store.features(false).toArray();
@@ -273,16 +272,16 @@
public void testRemoveFeatures(@TempDir final Path folder) throws DataStoreException, IOException {
final Path temp = folder.resolve("test.shp");
try (final ShapefileStore store = new ShapefileStore(temp)) {
- FeatureType type = createType();
+ DefaultFeatureType type = createType();
store.updateType(type);
type = store.getType();
- Feature feature1 = createFeature1(type);
- Feature feature2 = createFeature2(type);
+ AbstractFeature feature1 = createFeature1(type);
+ AbstractFeature feature2 = createFeature2(type);
store.add(List.of(feature1, feature2).iterator());
//remove first feature
- final FilterFactory<Feature, Object, Object> ff = DefaultFilterFactory.forFeatures();
- final BinaryComparisonOperator<Feature> filter = ff.equal(ff.property("id"), ff.literal(1));
+ final DefaultFilterFactory<AbstractFeature, Object, Object> ff = DefaultFilterFactory.forFeatures();
+ final Filter<AbstractFeature> filter = ff.equal(ff.property("id"), ff.literal(1));
store.removeIf(filter);
Object[] result = store.features(false).toArray();
@@ -298,19 +297,19 @@
public void testReplaceFeatures(@TempDir final Path folder) throws DataStoreException, IOException {
final Path temp = folder.resolve("test.shp");
try (final ShapefileStore store = new ShapefileStore(temp)) {
- FeatureType type = createType();
+ DefaultFeatureType type = createType();
store.updateType(type);
type = store.getType();
- Feature feature1 = createFeature1(type);
- Feature feature2 = createFeature2(type);
+ AbstractFeature feature1 = createFeature1(type);
+ AbstractFeature feature2 = createFeature2(type);
store.add(List.of(feature1, feature2).iterator());
//remove first feature
- final FilterFactory<Feature, Object, Object> ff = DefaultFilterFactory.forFeatures();
- final BinaryComparisonOperator<Feature> filter = ff.equal(ff.property("id"), ff.literal(1));
- store.replaceIf(filter, new UnaryOperator<Feature>() {
+ final DefaultFilterFactory<AbstractFeature, Object, Object> ff = DefaultFilterFactory.forFeatures();
+ final Filter<AbstractFeature> filter = ff.equal(ff.property("id"), ff.literal(1));
+ store.replaceIf(filter, new UnaryOperator<AbstractFeature>() {
@Override
- public Feature apply(Feature feature) {
+ public AbstractFeature apply(AbstractFeature feature) {
feature.setPropertyValue("id",45);
return feature;
}
@@ -318,13 +317,13 @@
Object[] result = store.features(false).toArray();
assertEquals(2, result.length);
- Feature f1 = (Feature) result[0];
+ AbstractFeature f1 = (AbstractFeature) result[0];
assertEquals(45, f1.getPropertyValue("id"));
assertEquals(feature2, result[1]);
}
}
- private static FeatureType createType() {
+ private static DefaultFeatureType createType() {
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.setName("test");
ftb.addAttribute(Integer.class).setName("id");
@@ -336,8 +335,8 @@
return ftb.build();
}
- private static Feature createFeature1(FeatureType type) {
- Feature feature = type.newInstance();
+ private static AbstractFeature createFeature1(DefaultFeatureType type) {
+ AbstractFeature feature = type.newInstance();
feature.setPropertyValue("geometry", GF.createPoint(new Coordinate(10,20)));
feature.setPropertyValue("id", 1);
feature.setPropertyValue("text", "some text 1");
@@ -347,8 +346,8 @@
return feature;
}
- private static Feature createFeature2(FeatureType type) {
- Feature feature = type.newInstance();
+ private static AbstractFeature createFeature2(DefaultFeatureType type) {
+ AbstractFeature feature = type.newInstance();
feature.setPropertyValue("geometry", GF.createPoint(new Coordinate(30,40)));
feature.setPropertyValue("id", 2);
feature.setPropertyValue("text", "some text 2");
diff --git a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/Snippets.java b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/Snippets.java
index ef5acb8..f76cb70 100644
--- a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/Snippets.java
+++ b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/Snippets.java
@@ -30,11 +30,10 @@
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.FeatureQuery;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.filter.BinarySpatialOperator;
-import org.opengis.filter.FilterFactory;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.filter.Filter;
/**
@@ -52,7 +51,7 @@
System.out.println(store.getType());
//print all features
- try (Stream<Feature> features = store.features(false)) {
+ try (Stream<AbstractFeature> features = store.features(false)) {
features.forEach(System.out::println);
}
@@ -60,15 +59,15 @@
GeneralEnvelope bbox = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
bbox.setRange(0, -10, 30);
bbox.setRange(1, 45, 55);
- FilterFactory<Feature, Object, Object> ff = DefaultFilterFactory.forFeatures();
- BinarySpatialOperator<Feature> bboxFilter = ff.bbox(ff.property("geometry"), bbox);
+ DefaultFilterFactory<AbstractFeature, Object, Object> ff = DefaultFilterFactory.forFeatures();
+ Filter<AbstractFeature> bboxFilter = ff.bbox(ff.property("geometry"), bbox);
FeatureQuery query = new FeatureQuery();
query.setProjection("att1", "att4", "att5");
query.setSelection(bboxFilter);
//print selected features
- try (Stream<Feature> features = store.subset(query).features(false)) {
+ try (Stream<AbstractFeature> features = store.subset(query).features(false)) {
features.forEach(System.out::println);
}
@@ -88,14 +87,14 @@
ftb.addAttribute(Integer.class).setName("id");
ftb.addAttribute(String.class).setName("text");
ftb.addAttribute(Point.class).setName("geometry").setCRS(CommonCRS.WGS84.geographic());
- FeatureType type = ftb.build();
+ DefaultFeatureType type = ftb.build();
store.updateType(type);
type = store.getType();
//create features
GeometryFactory gf = new GeometryFactory();
- Feature feature = type.newInstance();
+ AbstractFeature feature = type.newInstance();
feature.setPropertyValue("geometry", gf.createPoint(new Coordinate(10,20)));
feature.setPropertyValue("id", 1);
feature.setPropertyValue("text", "some text 1");
diff --git a/netbeans-project/build.xml b/netbeans-project/build.xml
index 47443fb..44a7f93 100644
--- a/netbeans-project/build.xml
+++ b/netbeans-project/build.xml
@@ -33,10 +33,6 @@
<target name="-pre-compile" depends="dir.check" unless="dir.exists">
<ivy:settings file="ivy-settings.xml"/>
<ivy:retrieve pattern="build/dependencies/[artifact].[ext]" symlink="true" sync="true"/>
- <symlink link="${basedir}/build/dependencies/geoapi-pending.jar"
- resource="../../../geoapi/snapshot/geoapi-pending/target/geoapi-pending-3.1-SNAPSHOT.jar"/>
- <symlink link="${basedir}/build/dependencies/geoapi-conformance.jar"
- resource="../../../geoapi/snapshot/geoapi-conformance/target/geoapi-conformance-3.1-SNAPSHOT.jar"/>
</target>
<!--
Called after compilation. Copies the "*.utf" resources files created by Gradle.
diff --git a/netbeans-project/ivy.xml b/netbeans-project/ivy.xml
index 84d86ca..6d7cb0c 100644
--- a/netbeans-project/ivy.xml
+++ b/netbeans-project/ivy.xml
@@ -11,6 +11,8 @@
<ivy-module version="2.0">
<info organisation="org.apache" module="sis"/>
<dependencies defaultconf="default">
+ <dependency org="org.opengis" name="geoapi" rev="3.0.2"/>
+ <dependency org="org.opengis" name="geoapi-conformance" rev="3.0.2"/>
<dependency org="javax.measure" name="unit-api" rev="2.1.3"/>
<dependency org="org.glassfish.jaxb" name="jaxb-runtime" rev="4.0.5"/>
<dependency org="org.eclipse" name="yasson" rev="3.0.4"/>
diff --git a/netbeans-project/nbproject/build-impl.xml b/netbeans-project/nbproject/build-impl.xml
index c68a938..51639b4 100644
--- a/netbeans-project/nbproject/build-impl.xml
+++ b/netbeans-project/nbproject/build-impl.xml
@@ -19,7 +19,7 @@
- cleanup
-->
-<project xmlns:if="ant:if" xmlns:unless="ant:unless" basedir=".." default="default" name="Apache_SIS_on_GeoAPI_3.1-impl">
+<project xmlns:if="ant:if" xmlns:unless="ant:unless" basedir=".." default="default" name="Apache_SIS_on_GeoAPI_3.0-impl">
<fail message="Please build using Ant 1.9.7 or higher.">
<condition>
<not>
@@ -778,7 +778,7 @@
</fileset>
</union>
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
- <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Apache_SIS_on_GeoAPI_3.1" testname="TestNG tests" workingDir="${work.dir}">
+ <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Apache_SIS_on_GeoAPI_3.0" testname="TestNG tests" workingDir="${work.dir}">
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
<propertyset>
<propertyref prefix="test-sys-prop."/>
@@ -875,7 +875,7 @@
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
<isset property="test.method"/>
</condition>
- <condition else="-suitename Apache_SIS_on_GeoAPI_3.1 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+ <condition else="-suitename Apache_SIS_on_GeoAPI_3.0 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
<matches pattern=".*\.xml" string="@{testClass}"/>
</condition>
<delete dir="${build.test.results.dir}" quiet="true"/>
@@ -1118,7 +1118,7 @@
<delete file="${built-jar.properties}" quiet="true"/>
</target>
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: Apache SIS on GeoAPI 3.1 was already built"/>
+ <echo level="warn" message="Cycle detected: Apache SIS on GeoAPI 3.0 was already built"/>
</target>
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
<mkdir dir="${build.dir}"/>
@@ -1909,7 +1909,7 @@
<delete file="${built-clean.properties}" quiet="true"/>
</target>
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: Apache SIS on GeoAPI 3.1 was already built"/>
+ <echo level="warn" message="Cycle detected: Apache SIS on GeoAPI 3.0 was already built"/>
</target>
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
<mkdir dir="${build.dir}"/>
diff --git a/netbeans-project/nbproject/genfiles.properties b/netbeans-project/nbproject/genfiles.properties
index b5d9e58..f2d42fe 100644
--- a/netbeans-project/nbproject/genfiles.properties
+++ b/netbeans-project/nbproject/genfiles.properties
@@ -3,6 +3,6 @@
build.xml.data.CRC32=d82237a1
build.xml.script.CRC32=9a509f0a
build.xml.stylesheet.CRC32=32069288@1.22
-nbproject/build-impl.xml.data.CRC32=e365e8d0
-nbproject/build-impl.xml.script.CRC32=3c96dd2f
+nbproject/build-impl.xml.data.CRC32=0e40efdb
+nbproject/build-impl.xml.script.CRC32=c509535a
nbproject/build-impl.xml.stylesheet.CRC32=d1ebcf0f@1.22
diff --git a/netbeans-project/nbproject/project.properties b/netbeans-project/nbproject/project.properties
index ee2efd3..c9e4591 100644
--- a/netbeans-project/nbproject/project.properties
+++ b/netbeans-project/nbproject/project.properties
@@ -121,9 +121,8 @@
--add-exports org.apache.sis.metadata/org.apache.sis.metadata.sql.privy=org.apache.sis.referencing.epsg \
--add-exports org.apache.sis.referencing/org.apache.sis.referencing.internal=org.apache.sis.openoffice \
--add-exports org.apache.sis.feature/org.apache.sis.feature.privy=org.apache.sis.storage.sql \
- --add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper.jts=org.apache.sis.storage.sql,org.apache.sis.portrayal.map \
+ --add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper.jts=org.apache.sis.storage.sql \
--add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper=org.apache.sis.storage.geopackage \
- --add-exports org.apache.sis.storage/org.apache.sis.storage.base=org.apache.sis.portrayal.map \
--add-exports org.apache.sis.storage/org.apache.sis.storage.test=${modules.list}
#
diff --git a/netbeans-project/nbproject/project.xml b/netbeans-project/nbproject/project.xml
index 0e92391..22d7148 100644
--- a/netbeans-project/nbproject/project.xml
+++ b/netbeans-project/nbproject/project.xml
@@ -15,7 +15,7 @@
<type>org.netbeans.modules.java.j2semodule</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-modular-project/1">
- <name>Apache SIS on GeoAPI 3.1</name>
+ <name>Apache SIS on GeoAPI 3.0</name>
<source-roots>
<root id="src.dir" pathref="src.dir.path"/>
<root id="optional.main.dir" pathref="optional.main.dir.path"/>
diff --git a/optional/src/org.apache.sis.gui/bundle/conf/imports.jsh b/optional/src/org.apache.sis.gui/bundle/conf/imports.jsh
index fd9764f..c3ad133 100644
--- a/optional/src/org.apache.sis.gui/bundle/conf/imports.jsh
+++ b/optional/src/org.apache.sis.gui/bundle/conf/imports.jsh
@@ -203,6 +203,7 @@
import org.opengis.referencing.crs.DerivedCRS;
import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.crs.EngineeringCRS;
+import org.opengis.referencing.crs.GeneralDerivedCRS;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.crs.SingleCRS;
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
index a60d484..ec87be9 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
@@ -153,7 +153,7 @@
* when data are ready.
*
* <p>Current implementation is restricted to {@link GridCoverage} instances, but a future
- * implementation may generalize to {@link org.opengis.coverage.Coverage} instances.</p>
+ * implementation may generalize to {@code org.opengis.coverage.Coverage} instances.</p>
*
* @see #getCoverage()
* @see #setCoverage(GridCoverage)
@@ -1270,7 +1270,7 @@
+ "POI: %, 16.4f %, 16.4f%n"
+ "Min: %, 16.4f %, 16.4f%n",
aoi.getMaxX(), aoi.getMaxY(),
- poi.getCoordinate(0), poi.getCoordinate(1),
+ poi.getOrdinate(0), poi.getOrdinate(1),
aoi.getMinX(), aoi.getMinY()))
.appendHorizontalSeparator();
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
index 8e6f1b9..a6cc599 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
@@ -69,7 +69,7 @@
*
* <h2>Limitations</h2>
* Current implementation is restricted to {@link GridCoverage} instances, but a future
- * implementation may generalize to {@link org.opengis.coverage.Coverage} instances.
+ * implementation may generalize to {@code org.opengis.coverage.Coverage} instances.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
@@ -173,7 +173,7 @@
* when data are ready.
*
* <p>Current implementation is restricted to {@link GridCoverage} instances, but a future
- * implementation may generalize to {@link org.opengis.coverage.Coverage} instances.</p>
+ * implementation may generalize to {@code org.opengis.coverage.Coverage} instances.</p>
*
* <h4>Relationship with view properties</h4>
* This property is "weakly bound" to {@link CoverageCanvas#coverageProperty}:
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandableList.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandableList.java
index a2476f2..396a4c5 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandableList.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandableList.java
@@ -34,21 +34,20 @@
import org.apache.sis.util.privy.UnmodifiableArrayList;
import org.apache.sis.gui.internal.Styles;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
* Wraps a {@link FeatureList} with the capability to expand the multi-valued properties of
- * a selected {@link Feature}. The expansion appears as additional rows below the feature.
+ * a selected {@code Feature}. The expansion appears as additional rows below the feature.
* This view is used only if the feature type contains at least one property type with a
* maximum number of occurrence greater than 1.
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class ExpandableList extends TransformationList<Feature,Feature>
- implements Callback<TableColumn<Feature,Feature>, TableCell<Feature,Feature>>,
+final class ExpandableList extends TransformationList<AbstractFeature,AbstractFeature>
+ implements Callback<TableColumn<AbstractFeature,AbstractFeature>, TableCell<AbstractFeature,AbstractFeature>>,
EventHandler<MouseEvent>
{
/**
@@ -106,7 +105,7 @@
/**
* Specifies the names of properties that may be multi-valued. This method needs to be invoked
- * only if the {@link FeatureType} changed. This method shall not be invoked if there is any
+ * only if the {@code FeatureType} changed. This method shall not be invoked if there is any
* {@link #expansion} rows. Normally this list will be empty at invocation time.
*
* @param columnNames names of properties that may contain multi-values.
@@ -133,8 +132,8 @@
*
* @return the removed rows, or {@code null} if none.
*/
- private List<Feature> shrink() {
- final List<Feature> removed = (expansion == null) ? null
+ private List<AbstractFeature> shrink() {
+ final List<AbstractFeature> removed = (expansion == null) ? null
: UnmodifiableArrayList.wrap(expansion, 1, expansion.length);
expansion = null;
indexOfExpanded = Integer.MAX_VALUE;
@@ -149,7 +148,7 @@
@Override
public void clear() {
final int removeAfter = indexOfExpanded;
- final List<Feature> removed = shrink();
+ final List<AbstractFeature> removed = shrink();
if (removed != null) {
beginChange();
nextUpdate(removeAfter);
@@ -173,7 +172,7 @@
final IconCell cell = (IconCell) event.getSource();
final int index = getSourceIndex(cell.getIndex()); // Must be invoked before `shrink()`.
final int removeAfter = indexOfExpanded;
- final List<Feature> removed = shrink();
+ final List<AbstractFeature> removed = shrink();
// index = getViewIndex(index); // Not needed for current single-selection model.
/*
* If a new row is selected, extract now all properties. We need at least the number
@@ -215,7 +214,7 @@
/**
* Returns {@code true} if the given feature contains more than one row.
*/
- private boolean isExpandable(final Feature feature) {
+ private boolean isExpandable(final AbstractFeature feature) {
if (feature != null) {
for (final String name : nameToIndex.keySet()) {
final Object value = feature.getPropertyValue(name);
@@ -247,7 +246,7 @@
* except if the given index is for an expanded row.
*/
@Override
- public Feature get(int index) {
+ public AbstractFeature get(int index) {
final int i = index - indexOfExpanded;
if (i >= 0) {
final int n = expansion.length; // A NullPointerException here would be an ExpandableList bug.
@@ -260,7 +259,7 @@
/**
* Given an index in this expanded list, returns the index of corresponding element in the feature list.
* All indices from {@link #indexOfExpanded} inclusive to <code>{@linkplain #indexOfExpanded} +
- * {@linkplain #expansion}.length</code> exclusive map to the same {@link Feature} instance.
+ * {@linkplain #expansion}.length</code> exclusive map to the same {@link AbstractFeature} instance.
*
* @param index index in this expandable list.
* @return index of the corresponding element in {@link FeatureList}.
@@ -297,8 +296,8 @@
* {@link FeatureList} and converts source indices to indices of this expandable list.
*/
@Override
- protected void sourceChanged(final ListChangeListener.Change<? extends Feature> c) {
- fireChange(new ListChangeListener.Change<Feature>(this) {
+ protected void sourceChanged(final ListChangeListener.Change<? extends AbstractFeature> c) {
+ fireChange(new ListChangeListener.Change<AbstractFeature>(this) {
@Override public void reset() {c.reset();}
@Override public boolean next() {return c.next();}
@Override public boolean wasAdded() {return c.wasAdded();}
@@ -325,8 +324,8 @@
@Override
@SuppressWarnings("unchecked")
- public List<Feature> getRemoved() {
- return (List<Feature>) expandRemoved(c.getFrom(), c.getRemoved());
+ public List<AbstractFeature> getRemoved() {
+ return (List<AbstractFeature>) expandRemoved(c.getFrom(), c.getRemoved());
}
});
}
@@ -347,13 +346,13 @@
* @param removed the removed elements provided by the {@link FeatureList}.
* @return the removed elements as seen by this {@code ExpandableList}.
*/
- private List<? extends Feature> expandRemoved(final int sourceFrom, final List<? extends Feature> removed) {
+ private List<? extends AbstractFeature> expandRemoved(final int sourceFrom, final List<? extends AbstractFeature> removed) {
if (!overlapExpanded(sourceFrom, removed.size())) {
return removed;
}
final int s = indexOfExpanded;
final int n = expansion.length; // A NullPointerException here would be an ExpandableList bug.
- final Feature[] features = removed.toArray(new Feature[removed.size() + (n - 1)]);
+ final AbstractFeature[] features = removed.toArray(new AbstractFeature[removed.size() + (n - 1)]);
System.arraycopy(features, s+1, features, s + n, features.length - (s+1));
System.arraycopy(expansion, 0, features, s, n);
return Arrays.asList(features);
@@ -367,7 +366,7 @@
* @param column the column where the cell will be shown.
*/
@Override
- public TableCell<Feature,Feature> call(final TableColumn<Feature,Feature> column) {
+ public TableCell<AbstractFeature,AbstractFeature> call(final TableColumn<AbstractFeature,AbstractFeature> column) {
return new IconCell();
}
@@ -375,7 +374,7 @@
* The cell which represents whether a row is expandable or expanded.
* If visible, this is the first column in the table.
*/
- private final class IconCell extends TableCell<Feature,Feature> {
+ private final class IconCell extends TableCell<AbstractFeature,AbstractFeature> {
/**
* Whether this cell is listening to mouse click events.
*/
@@ -394,7 +393,7 @@
* The call will have a listener only if it has an icon.
*/
@Override
- protected void updateItem(final Feature value, final boolean empty) {
+ protected void updateItem(final AbstractFeature value, final boolean empty) {
super.updateItem(value, empty);
Background b = null;
String text = null;
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandedFeature.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandedFeature.java
index a67208b..9bb03e0 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandedFeature.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ExpandedFeature.java
@@ -21,10 +21,9 @@
import java.util.Collection;
import java.util.List;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Property;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -36,7 +35,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class ExpandedFeature implements Feature {
+final class ExpandedFeature extends AbstractFeature {
/**
* The array for properties having no value.
* This is the fill value for {@link #values} array.
@@ -48,12 +47,12 @@
* This feature may contain a mix of single-valued and multi-valued properties.
* Values of multi-valued properties are copied in the {@link #values} array.
*/
- private final Feature source;
+ private final AbstractFeature source;
/**
* Mapping from property names to index in the {@link #values} array.
* <strong>Do not modify,</strong> because all {@link ExpandedFeature} instances created
- * after a call to {@link FeatureTable#setFeatureType(FeatureType)} share the same map.
+ * after a call to {@link FeatureTable#setFeatureType(DefaultFeatureType)} share the same map.
*/
private final Map<String,Integer> nameToIndex;
@@ -75,9 +74,10 @@
/**
* Creates a new feature wrapping the given source.
*/
- private ExpandedFeature(final Feature source, final Map<String,Integer> nameToIndex,
+ private ExpandedFeature(final AbstractFeature source, final Map<String,Integer> nameToIndex,
final Object[][] values, final int index)
{
+ super(source.getType());
this.source = source;
this.nameToIndex = nameToIndex;
this.values = values;
@@ -94,7 +94,7 @@
* @param nameToIndex mapping from property names to index in the {@code values} array.
* @return pseudo-features for property elements at all indices, or {@code null} if none.
*/
- static ExpandedFeature[] create(final Feature source, final Map<String,Integer> nameToIndex) {
+ static ExpandedFeature[] create(final AbstractFeature source, final Map<String,Integer> nameToIndex) {
if (source != null) {
final Object[][] values = new Object[nameToIndex.size()][];
Arrays.fill(values, EMPTY);
@@ -130,7 +130,7 @@
* Returns the source feature type verbatim.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return source.getType();
}
@@ -139,7 +139,7 @@
* This method is not used by {@link FeatureTable} so we just delegate to the source.
*/
@Override
- public Property getProperty(final String name) {
+ public Object getProperty(final String name) {
return source.getProperty(name);
}
@@ -148,7 +148,7 @@
* This method is not used by {@link FeatureTable} so we just forward to the source.
*/
@Override
- public void setProperty(final Property property) {
+ public void setProperty(final Object property) {
source.setProperty(property);
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureList.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureList.java
index f5dc70e..e1957dd 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureList.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureList.java
@@ -28,8 +28,8 @@
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.privy.UnmodifiableArrayList;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -53,7 +53,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class FeatureList extends ObservableListBase<Feature> {
+final class FeatureList extends ObservableListBase<AbstractFeature> {
/**
* Number of empty rows to show in the bottom of the table when we don't know how many rows still
* need to be read. Those rows do not stay empty for long since they will become valid as soon as
@@ -69,12 +69,12 @@
/**
* The {@link #elements} value when this list is empty.
*/
- private static final Feature[] EMPTY = new Feature[0];
+ private static final AbstractFeature[] EMPTY = new AbstractFeature[0];
/**
* The elements in this list, never {@code null}.
*/
- private Feature[] elements;
+ private AbstractFeature[] elements;
/**
* Number of valid elements in {@link #elements}.
@@ -114,7 +114,7 @@
/**
* Returns the currently valid elements.
*/
- private List<Feature> validElements() {
+ private List<AbstractFeature> validElements() {
return UnmodifiableArrayList.wrap(elements, 0, validCount);
}
@@ -126,7 +126,7 @@
*/
@Override
public void clear() {
- final List<Feature> removed = validElements();
+ final List<AbstractFeature> removed = validElements();
elements = EMPTY;
estimatedSize = 0;
validCount = 0;
@@ -164,7 +164,7 @@
/**
* Invoked by {@link FeatureLoader} for replacing the current content by a new list of features.
* The list size after this method invocation will be {@code expectedSize}, not {@code count}.
- * The missing elements will be implicitly null until {@link #addFeatures(Feature[], int, boolean)}
+ * The missing elements will be implicitly null until {@link #addFeatures(AbstractFeature[], int, boolean)}
* is invoked. If the expected size is unknown (i.e. its value is {@link Long#MAX_VALUE}),
* then an arbitrary size is computed from {@code count}.
*
@@ -176,15 +176,15 @@
*/
@SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter")
final void setFeatures(long remainingCount, int characteristics,
- final Feature[] features, final int count, final boolean hasMore)
+ final AbstractFeature[] features, final int count, final boolean hasMore)
{
assert Platform.isFxApplicationThread();
int newValidCount = 0;
for (int i=0; i<count; i++) {
- final Feature f = features[i];
+ final AbstractFeature f = features[i];
if (f != null) features[newValidCount++] = f; // Exclude null elements.
}
- final List<Feature> removed = validElements(); // Want this call outside {beginChange … endChange}.
+ final List<AbstractFeature> removed = validElements(); // Want this call outside {beginChange … endChange}.
if (remainingCount == Long.MAX_VALUE) {
remainingCount = count + NUM_PENDING_ROWS; // Arbitrary additional amount.
characteristics = 0;
@@ -212,7 +212,7 @@
* @param hasMore if the stream may have more features.
* @throws ArithmeticException if the number of elements exceeds this list capacity.
*/
- final void addFeatures(final Feature[] features, final int count, final boolean hasMore) {
+ final void addFeatures(final AbstractFeature[] features, final int count, final boolean hasMore) {
assert Platform.isFxApplicationThread();
if (count > 0) {
int newValidCount = Math.addExact(validCount, count);
@@ -222,7 +222,7 @@
}
newValidCount = validCount; // Recompute `validCount + count` but excluding null elements.
for (int i=0; i<count; i++) {
- final Feature f = features[i];
+ final AbstractFeature f = features[i];
if (f != null) elements[newValidCount++] = f;
}
/*
@@ -230,7 +230,7 @@
* Only if the new size exceeds the previously expected size, we send a notification about addition.
*/
final int replaceTo = Math.min(newValidCount, estimatedSize);
- final List<Feature> removed = Collections.nCopies(replaceTo - validCount, null);
+ final List<AbstractFeature> removed = Collections.nCopies(replaceTo - validCount, null);
if (newValidCount >= estimatedSize) {
estimatedSize = newValidCount; // Update before we send events.
if (hasMore) {
@@ -274,7 +274,7 @@
if (next == null) {
final int n = estimatedSize - validCount;
if (n != 0) {
- final List<Feature> removed = Collections.nCopies(n, null);
+ final List<AbstractFeature> removed = Collections.nCopies(n, null);
estimatedSize = validCount;
beginChange();
nextRemove(validCount, removed);
@@ -307,7 +307,7 @@
* but has not yet been loaded, returns {@code null}.
*/
@Override
- public Feature get(final int index) {
+ public AbstractFeature get(final int index) {
assert Platform.isFxApplicationThread();
if (index < validCount) {
return elements[index];
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureLoader.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureLoader.java
index 2152b13..c566b57 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureLoader.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureLoader.java
@@ -29,9 +29,9 @@
import org.apache.sis.gui.internal.Resources;
import org.apache.sis.system.Configuration;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -41,7 +41,7 @@
*
* @author Martin Desruisseaux (Geomatys)
*/
-final class FeatureLoader extends Task<Boolean> implements Consumer<Feature> {
+final class FeatureLoader extends Task<Boolean> implements Consumer<AbstractFeature> {
/**
* Maximum number of features to load in a background task.
* If there is more features to load, we will use many tasks.
@@ -68,18 +68,18 @@
* The stream to close after we finished to iterate over features.
* This stream should not be used for any other purpose.
*/
- private Stream<Feature> toClose;
+ private Stream<AbstractFeature> toClose;
/**
* If the reading process is not finished, the iterator for reading more feature instances.
*/
- private Spliterator<Feature> iterator;
+ private Spliterator<AbstractFeature> iterator;
/**
* The features loaded by this task. This array is created in a background thread,
* then added to {@link #table} in the JavaFX thread.
*/
- private Feature[] loaded;
+ private AbstractFeature[] loaded;
/**
* Number of features loaded by this task.
@@ -111,7 +111,7 @@
* defined for {@link #call()} internal purpose only.
*/
@Override
- public void accept(final Feature feature) {
+ public void accept(final AbstractFeature feature) {
loaded[count++] = feature;
}
@@ -142,7 +142,7 @@
*/
final long remaining = iterator.estimateSize();
final int stopAt = (remaining > PAGE_SIZE) ? PAGE_SIZE : 1 + (int) remaining;
- loaded = new Feature[stopAt];
+ loaded = new AbstractFeature[stopAt];
try {
while (iterator.tryAdvance(this)) {
if (count >= stopAt) {
@@ -174,7 +174,7 @@
*/
private void close() throws DataStoreException {
iterator = null;
- final Stream<Feature> c = toClose;
+ final Stream<AbstractFeature> c = toClose;
if (c != null) try {
toClose = null; // Clear now in case an exception happens below.
c.close();
@@ -305,7 +305,7 @@
/**
* Invoked when the feature type may have been found. If the given type is non-null,
- * then this method delegates to {@link FeatureTable#setFeatureType(FeatureType)} in
+ * then this method delegates to {@link FeatureTable#setFeatureType(DefaultFeatureType)} in
* the JavaFX thread. This will erase the previous content and prepare new columns.
*
* <p>This method is invoked, directly or indirectly, only from the {@link #call()}
@@ -315,7 +315,7 @@
* @param type the feature type, or {@code null}.
* @return whether the given type was non-null.
*/
- private boolean setType(final FeatureType type) {
+ private boolean setType(final DefaultFeatureType type) {
if (type != null) {
Platform.runLater(() -> table.setFeatureType(type));
return true;
@@ -333,7 +333,7 @@
private void setMissingType(final boolean isTypeKnown) throws DataStoreException {
if (!isTypeKnown) {
for (int i=0; i<count; i++) {
- final Feature f = loaded[i];
+ final AbstractFeature f = loaded[i];
if (f != null && setType(f.getType())) {
return;
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureTable.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureTable.java
index 45c88d7..023dbf9 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureTable.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/FeatureTable.java
@@ -46,12 +46,11 @@
import org.apache.sis.gui.internal.ExceptionReporter;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultAttributeType;
/**
@@ -71,7 +70,7 @@
* <li>The list returned by {@link #getItems()} should be considered read-only.</li>
* </ul>
*
- * @todo This class does not yet handle {@link FeatureAssociationRole}. We could handle them with
+ * @todo This class does not yet handle {@code FeatureAssociationRole}. We could handle them with
* {@link javafx.scene.control.SplitPane} with the main feature table in the upper part and
* the feature table of selected cell in the bottom part. Bottom part could put tables in a
* {@link javafx.scene.control.Accordion} since there is possibly different tables to show
@@ -84,7 +83,7 @@
* @since 1.1
*/
@DefaultProperty("features")
-public class FeatureTable extends TableView<Feature> {
+public class FeatureTable extends TableView<AbstractFeature> {
/**
* The locale to use for texts. This is usually {@link Locale#getDefault()}.
* This value is given to {@link InternationalString#toString(Locale)} calls.
@@ -95,9 +94,9 @@
* The type of features, or {@code null} if not yet determined.
* This type determines the columns that will be shown.
*
- * @see #setFeatureType(FeatureType)
+ * @see #setFeatureType(DefaultFeatureType)
*/
- private FeatureType featureType;
+ private DefaultFeatureType featureType;
/**
* The data shown in this table. Note that setting this property to a non-null value
@@ -112,7 +111,7 @@
/**
* Whether the {@link #getItems()} list may be shared by another {@link FeatureTable} instance.
- * In such case, {@link #setFeatureType(FeatureType)} should create a new list instead of invoking
+ * In such case, {@link #setFeatureType(DefaultFeatureType)} should create a new list instead of invoking
* {@link FeatureList#clear()} on the existing list.
*/
private boolean isSharingList;
@@ -180,7 +179,7 @@
* All methods on the returned list shall be invoked from JavaFX thread.
*/
final FeatureList getFeatureList() {
- final ObservableList<Feature> items = getItems();
+ final ObservableList<AbstractFeature> items = getItems();
if (items instanceof FeatureList) {
return (FeatureList) items;
} else {
@@ -193,7 +192,7 @@
* This method wraps the {@link FeatureList} into an {@link ExpandableList} if needed.
*/
private ExpandableList getExpandableList() {
- final ObservableList<Feature> items = getItems();
+ final ObservableList<AbstractFeature> items = getItems();
if (items instanceof ExpandableList) {
return (ExpandableList) items;
} else {
@@ -257,7 +256,7 @@
* This method clears all rows and replaces all columns by new columns
* determined from the given type.
*/
- final void setFeatureType(final FeatureType type) {
+ final void setFeatureType(final DefaultFeatureType type) {
setPlaceholder(null);
getItems().clear();
final boolean update = (type != null) && !type.equals(featureType);
@@ -275,10 +274,10 @@
* Creates table columns for the current {@link #featureType}.
*/
private void createColumns() {
- final Collection<? extends PropertyType> properties = featureType.getProperties(true);
- final List<TableColumn<Feature,?>> columns = new ArrayList<>(properties.size());
+ final Collection<? extends AbstractIdentifiedType> properties = featureType.getProperties(true);
+ final List<TableColumn<AbstractFeature,?>> columns = new ArrayList<>(properties.size());
final List<String> multiValued = new ArrayList<>(columns.size());
- for (final PropertyType pt : properties) {
+ for (final AbstractIdentifiedType pt : properties) {
/*
* Get localized text to show in column header. Also remember
* the plain property name; it will be needed for ValueGetter.
@@ -298,8 +297,8 @@
* See comment in class javadoc.
*/
boolean isMultiValued = false;
- if (pt instanceof AttributeType<?>) {
- isMultiValued = ((AttributeType<?>) pt).getMaximumOccurs() > 1;
+ if (pt instanceof DefaultAttributeType<?>) {
+ isMultiValued = ((DefaultAttributeType<?>) pt).getMaximumOccurs() > 1;
}
if (isMultiValued) {
multiValued.add(name);
@@ -309,7 +308,7 @@
* gives the whole collection. Fetching a particular element in that collection will
* be ElementCell's work.
*/
- final TableColumn<Feature,Object> column = new TableColumn<>(title);
+ final TableColumn<AbstractFeature,Object> column = new TableColumn<>(title);
column.setCellValueFactory(new ValueGetter(name));
column.setCellFactory(isMultiValued ? ElementCell::new : ValueCell::new);
if (AttributeConvention.contains(qualifiedName)) {
@@ -326,7 +325,7 @@
} else {
final ExpandableList list = getExpandableList();
list.setMultivaluedColumns(multiValued);
- final TableColumn<Feature,Feature> column = new TableColumn<>("▤");
+ final TableColumn<AbstractFeature,AbstractFeature> column = new TableColumn<>("▤");
column.setCellValueFactory(IdentityValueFactory.instance());
column.setCellFactory(list);
column.setReorderable(false);
@@ -344,12 +343,12 @@
/**
- * Given a {@link Feature}, returns the value of the property having the name specified at construction time.
+ * Given a {@code Feature}, returns the value of the property having the name specified at construction time.
* Note that if the property is multi-valued, then this getter returns the whole collection since we have no
* easy way to know the current row number. Fetching a particular element in that collection will be done by
* {@link ExpandedFeature}.
*/
- private static final class ValueGetter implements Callback<TableColumn.CellDataFeatures<Feature,Object>, ObservableValue<Object>> {
+ private static final class ValueGetter implements Callback<TableColumn.CellDataFeatures<AbstractFeature,Object>, ObservableValue<Object>> {
/**
* The name of the feature property for which to fetch values.
*/
@@ -369,9 +368,9 @@
* This method is invoked by JavaFX when a cell needs to be rendered with a new value.
*/
@Override
- public ObservableValue<Object> call(final TableColumn.CellDataFeatures<Feature, Object> cell) {
+ public ObservableValue<Object> call(final TableColumn.CellDataFeatures<AbstractFeature, Object> cell) {
Object value = null;
- final Feature feature = cell.getValue();
+ final AbstractFeature feature = cell.getValue();
if (feature != null) {
value = feature.getPropertyValue(name);
}
@@ -383,13 +382,13 @@
* A cell displaying a value in {@link FeatureTable}. This base class expects single values.
* If the property values are collections, then {@link ElementCell} should be used instead.
*/
- private static class ValueCell extends TableCell<Feature,Object> {
+ private static class ValueCell extends TableCell<AbstractFeature,Object> {
/**
* Creates a new cell for feature property value.
*
* @param column the column where the cell will be shown.
*/
- ValueCell(final TableColumn<Feature,Object> column) {
+ ValueCell(final TableColumn<AbstractFeature,Object> column) {
// Column not used at this time, but we need it in method signature.
}
@@ -431,7 +430,7 @@
*
* @param column the column where the cell will be shown.
*/
- ElementCell(final TableColumn<Feature,Object> column) {
+ ElementCell(final TableColumn<AbstractFeature,Object> column) {
super(column);
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
index 7e29d85..3a2f69b 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
@@ -91,8 +91,8 @@
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
import static org.apache.sis.util.privy.Constants.NANOS_PER_MILLISECOND;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
index 8559048..e98335d 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
@@ -99,8 +99,8 @@
import org.apache.sis.referencing.gazetteer.ReferencingByIdentifiers;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coordinate.MismatchedDimensionException;
+// Specific to the main branch:
+import org.opengis.geometry.MismatchedDimensionException;
/**
@@ -708,7 +708,6 @@
position.setText(null);
if (geometry != null) {
final int dimension = geometry.getDimension();
- ArgumentChecks.ensureDimensionMatches("sliceExtent", dimension, sliceExtent);
ArgumentChecks.ensureBetween("xdim", 0, dimension-1, xdim);
ArgumentChecks.ensureBetween("ydim", xdim+1, dimension-1, ydim);
xDimension = xdim;
@@ -1004,7 +1003,7 @@
final double y = lastY;
lastX = lastY = Double.NaN;
if (!Double.isNaN(x) && !Double.isNaN(y)) {
- if (current == null || current.getCoordinate(0) != x || current.getCoordinate(1) != y) {
+ if (current == null || current.getOrdinate(0) != x || current.getOrdinate(1) != y) {
setLocalCoordinates(x, y);
}
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
index 5fd734d..6f4a816 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
@@ -45,8 +45,8 @@
import org.apache.sis.util.privy.Numerics;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.CannotEvaluateException;
+// Specific to the main branch:
+import org.apache.sis.coverage.CannotEvaluateException;
/**
@@ -369,7 +369,7 @@
* that position should be given as a non-null {@code slice} argument.
*/
Position(final DirectPosition position, final GridExtent slice) {
- coordinates = position.getCoordinates();
+ coordinates = position.getCoordinate();
crs = position.getCoordinateReferenceSystem();
newSlice = slice;
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
index 546974e..13e8f60 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -63,6 +63,9 @@
import static org.apache.sis.util.privy.CollectionsExt.nonNull;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
+// Specific to the main branch:
+import org.opengis.metadata.identification.DataIdentification;
+
/**
* The pane where to show the values of {@link Identification} objects.
@@ -208,8 +211,8 @@
if (isCancelled()) break;
if (metadata != null) {
for (final Identification id : nonNull(metadata.getIdentificationInfo())) {
- if (id != null) {
- for (final Extent extent : id.getExtents()) {
+ if (id instanceof DataIdentification did) {
+ for (final Extent extent : did.getExtents()) {
final GeographicBoundingBox b = Extents.getGeographicBoundingBox(extent);
if (b != null) boxes.add(b);
}
@@ -319,24 +322,19 @@
/*
* Topic category.
*/
- addLine(Vocabulary.Keys.TopicCategory, owner.string(nonNull(info.getTopicCategories())));
- /*
- * Type of resource: vector, grid, table, tin, video, etc. It gives a slight overview
- * of the next section, "Spatial representation". For that reason we put it close to
- * that next section, i.e. last in this section but just before the map.
- */
- addLine(Vocabulary.Keys.TypeOfResource, owner.string(nonNull(info.getSpatialRepresentationTypes())));
+ final DataIdentification dataInfo = (info instanceof DataIdentification) ? (DataIdentification) info : null;
+ if (dataInfo != null) {
+ addLine(Vocabulary.Keys.TopicCategory, owner.string(nonNull(dataInfo.getTopicCategories())));
+ addLine(Vocabulary.Keys.TypeOfResource, owner.string(nonNull(dataInfo.getSpatialRepresentationTypes())));
+ }
/*
* Resource format. Current implementation shows only the first format found.
*/
for (final Format format : nonNull(info.getResourceFormats())) {
- final Citation c = format.getFormatSpecificationCitation();
- if (c != null) {
- text = owner.string(c.getTitle());
- if (text != null) {
- addLine(Vocabulary.Keys.Format, text);
- break;
- }
+ text = owner.string(format.getSpecification());
+ if (text != null) {
+ addLine(Vocabulary.Keys.Format, text);
+ break;
}
}
/*
@@ -351,7 +349,7 @@
final Date cd = c.getDate();
if (cd != null) {
final DateType type = c.getDateType();
- if (type == DateType.PUBLICATION || type == DateType.RELEASED) {
+ if (type == DateType.PUBLICATION || type == DateType.valueOf("RELEASED")) {
label = Vocabulary.Keys.PublicationDate;
date = cd;
break; // Take the first publication or release date.
@@ -375,7 +373,7 @@
Identifier identifier = null;
Range<Date> timeRange = null;
Range<Double> heights = null;
- for (final Extent extent : nonNull(info.getExtents())) {
+ for (final Extent extent : nonNull(dataInfo != null ? dataInfo.getExtents() : null)) {
if (extent != null) {
if (text == null) {
text = owner.string(extent.getDescription());
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
index b63d30c..5bad059 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
@@ -31,8 +31,8 @@
import javafx.scene.image.Image;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-import org.opengis.metadata.Metadata;
import org.opengis.util.InternationalString;
+import org.opengis.metadata.Metadata;
import org.apache.sis.gui.Widget;
import org.apache.sis.gui.internal.BackgroundThreads;
import org.apache.sis.gui.internal.ExceptionReporter;
@@ -45,8 +45,8 @@
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.iso.Types;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.util.ControlledVocabulary;
+// Specific to the main branch:
+import org.opengis.util.CodeList;
/**
@@ -351,9 +351,9 @@
/**
* Returns all code lists in a comma-separated list.
*/
- final String string(final Collection<? extends ControlledVocabulary> codes) {
+ final String string(final Collection<? extends CodeList<?>> codes) {
final StringJoiner buffer = new StringJoiner(", ");
- for (final ControlledVocabulary c : codes) {
+ for (final CodeList<?> c : codes) {
final String text = string(Types.getCodeTitle(c));
if (text != null) buffer.add(text);
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/AuthorityCodes.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/AuthorityCodes.java
index 3eec662..6c80d07 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/AuthorityCodes.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/AuthorityCodes.java
@@ -393,7 +393,7 @@
for (final Code code : snapshot) {
String text;
try {
- var i18n = factory.getDescriptionText(CoordinateReferenceSystem.class, code.code).orElse(null);
+ var i18n = factory.getDescriptionText(code.code);
text = Strings.trimOrNull(Types.toString(i18n, locale));
if (text == null) {
text = Vocabulary.forLocale(locale).getString(Vocabulary.Keys.Unnamed);
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
index 9a11b70..e5f2dac 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
@@ -71,9 +71,6 @@
// 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;
-
/**
* A list of Coordinate Reference Systems (CRS) from which the user can select.
@@ -351,9 +348,8 @@
*/
private void setDomainOfValidity(final CoordinateReferenceSystem crs, final Locale locale) {
String extent = null;
- for (ObjectDomain c : crs.getDomains()) {
- extent = Extents.getDescription(c.getDomainOfValidity(), locale);
- if (extent != null) break;
+ if (crs != null) {
+ extent = Extents.getDescription(crs.getDomainOfValidity(), locale);
}
String tip = extent;
Color color = Styles.NORMAL_TEXT;
@@ -370,7 +366,6 @@
/**
* Returns the text to show of right of the "type" label.
*/
- @SuppressWarnings("deprecation")
private static String typeOf(CoordinateReferenceSystem crs, final Locale locale) {
while (crs instanceof CompoundCRS) {
crs = ((CompoundCRS) crs).getComponents().get(0);
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
index 6336eb1..16981e0 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
@@ -37,6 +37,10 @@
import org.apache.sis.util.logging.Logging;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
+// Specific to the main branch:
+import java.util.List;
+import java.util.ArrayList;
+
/**
* Provider of map projections centered on a point of interest.
@@ -49,6 +53,12 @@
@SuppressWarnings("serial") // We do not guarantee serialization compatibility.
public abstract class PositionableProjection extends CodeList<PositionableProjection> {
/**
+ * List of all enumerations of this type.
+ * Must be declared before any enum declaration.
+ */
+ private static final List<PositionableProjection> VALUES = new ArrayList<>(1);
+
+ /**
* Provides <cite>Orthographic</cite> projection centered on a point of interest.
*/
public static final PositionableProjection ORTHOGRAPHIC =
@@ -137,7 +147,7 @@
* @param nameKey the projection name as a {@link Resources} keys.
*/
PositionableProjection(final String name, final short nameKey) {
- super(name);
+ super(name, VALUES);
this.nameKey = nameKey;
}
@@ -147,7 +157,9 @@
* @return the list of codes declared in the current JVM.
*/
public static PositionableProjection[] values() {
- return values(PositionableProjection.class);
+ synchronized (VALUES) {
+ return VALUES.toArray(PositionableProjection[]::new);
+ }
}
/**
@@ -163,6 +175,16 @@
}
/**
+ * Disables the search for UML identifiers because we do not export this package to GeoAPI.
+ *
+ * @return {@code null}.
+ */
+ @Override
+ public String identifier() {
+ return null;
+ }
+
+ /**
* Returns a name for this enumeration which can be used in a user interface.
*
* @return a human-readable name for the projection created by this enumeration.
@@ -198,8 +220,8 @@
center = CRS.findOperation(inherit, normalizedCRS, null).getMathTransform().transform(center, null);
}
return createProjectedCRS(normalizedCRS,
- Latitude .clamp (center.getCoordinate(0)),
- Longitude.normalize(center.getCoordinate(1)));
+ Latitude .clamp (center.getOrdinate(0)),
+ Longitude.normalize(center.getOrdinate(1)));
}
/**
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
index 4a1e075..69cfca4 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
@@ -32,9 +32,6 @@
import org.apache.sis.referencing.CRS;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.ObjectDomain;
-
/**
* Utility methods shared by classes in this package only.
@@ -86,8 +83,8 @@
static boolean intersects(final ImmutableEnvelope areaOfInterest, final ReferenceSystem crs) {
boolean conservative = true;
if (areaOfInterest != null) {
- for (final ObjectDomain domain : crs.getDomains()) {
- final GeographicBoundingBox bbox = Extents.getGeographicBoundingBox(domain.getDomainOfValidity());
+ if (crs != null) {
+ final GeographicBoundingBox bbox = Extents.getGeographicBoundingBox(crs.getDomainOfValidity());
if (bbox != null) {
if (areaOfInterest.intersects(new ImmutableEnvelope(bbox))) {
return true;
diff --git a/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java b/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java
index 6dee0b4..60292ee 100644
--- a/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java
+++ b/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java
@@ -35,8 +35,8 @@
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
+// Specific to the main branch:
+import org.apache.sis.referencing.crs.AbstractCRS;
/**
@@ -134,7 +134,7 @@
@Test
public void testCrsforCode() throws FactoryException {
assumeDataPresent();
- CoordinateReferenceSystem crs = CRS.forCode("EPSG:6676");
+ var crs = assertInstanceOf(AbstractCRS.class, CRS.forCode("EPSG:6676"));
String area = TestUtilities.getSingleton(crs.getDomains()).getDomainOfValidity().getDescription().toString();
assertTrue(area.contains("Japan"), area);
}
diff --git a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
index db78a6b..e19808a 100644
--- a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
+++ b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
@@ -98,7 +98,7 @@
gradle clean test jar
export CLASSPATH=~/.m2/repository/org/apache/derby/derby/10.14.2.0/derby-10.14.2.0.jar
export CLASSPATH=~/.m2/repository/javax/measure/unit-api/2.1.3/unit-api-2.1.3.jar:$CLASSPATH
-export CLASSPATH=$PWD/geoapi/snapshot/geoapi/target/geoapi-3.1-SNAPSHOT.jar:$CLASSPATH
+export CLASSPATH=$PWD/geoapi/snapshot/geoapi/target/geoapi-3.0.2.jar:$CLASSPATH
export CLASSPATH=$PWD/endorsed/build/libs/org.apache.sis.referencing.jar:$CLASSPATH
export CLASSPATH=$PWD/endorsed/build/libs/org.apache.sis.metadata.jar:$CLASSPATH
export CLASSPATH=$PWD/endorsed/build/libs/org.apache.sis.util.jar:$CLASSPATH
diff --git a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureIterator.java b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureIterator.java
index 13db2ca..13fc7e4 100644
--- a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureIterator.java
+++ b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureIterator.java
@@ -42,8 +42,8 @@
import org.apache.sis.geometry.wrapper.GeometryType;
import org.apache.sis.storage.panama.Resources;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
/**
@@ -54,7 +54,7 @@
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-final class FeatureIterator implements Spliterator<Feature>, Runnable {
+final class FeatureIterator implements Spliterator<AbstractFeature>, Runnable {
/**
* {@code OGRwkbGeometryType} enumeration value specific to <abbr>GDAL</abbr>.
*/
@@ -186,7 +186,7 @@
* Do not split the iterator, because this implementation requires sequential accesses.
*/
@Override
- public Spliterator<Feature> trySplit() {
+ public Spliterator<AbstractFeature> trySplit() {
return null;
}
@@ -222,7 +222,7 @@
* @return whether a feature instance has been found.
*/
@Override
- public boolean tryAdvance(final Consumer<? super Feature> action) {
+ public boolean tryAdvance(final Consumer<? super AbstractFeature> action) {
try {
synchronized (layer.store) {
final OGR ogr = layer.OGR();
@@ -243,7 +243,7 @@
*/
@Override
@SuppressWarnings("empty-statement")
- public void forEachRemaining(final Consumer<? super Feature> action) {
+ public void forEachRemaining(final Consumer<? super AbstractFeature> action) {
try {
synchronized (layer.store) {
final OGR ogr = layer.OGR();
@@ -265,12 +265,12 @@
* @return whether a feature instance has been found.
* @throws Throwable if a call to a native method failed.
*/
- private boolean advance(final OGR ogr, final Consumer<? super Feature> action) throws Throwable {
+ private boolean advance(final OGR ogr, final Consumer<? super AbstractFeature> action) throws Throwable {
final MemorySegment handle = (MemorySegment) ogr.getNextFeature.invokeExact(layer.handle);
if (GDAL.isNull(handle)) {
return false;
}
- final Feature feature;
+ final AbstractFeature feature;
try {
feature = layer.type.newInstance();
for (FieldAccessor<?> field : layer.fields) {
diff --git a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureLayer.java b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureLayer.java
index 0d5b87a..bd6dc7a 100644
--- a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureLayer.java
+++ b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FeatureLayer.java
@@ -41,9 +41,9 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.privy.Strings;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
+// Specific to the main branch:
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
/**
@@ -69,7 +69,7 @@
/**
* Description (list of fields) of all feature instances in this layer.
*/
- final FeatureType type;
+ final DefaultFeatureType type;
/**
* Description of the fields to read with GDAL API. Each {@code FieldAccessor} contains the property name
@@ -255,7 +255,7 @@
* Returns the feature type of this feature set.
*/
@Override
- public final FeatureType getType() {
+ public final DefaultFeatureType getType() {
return type;
}
@@ -314,7 +314,7 @@
* @param parallel ignored since <abbr>GDAL</abbr> is not thread-safe.
*/
@Override
- public Stream<Feature> features(boolean parallel) throws DataStoreException {
+ public Stream<AbstractFeature> features(boolean parallel) throws DataStoreException {
try {
synchronized (store) {
// Ignore the `parallel` argument, as it is not supported by the iterator.
diff --git a/parent/pom.xml b/parent/pom.xml
index 000fb61..211b661 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -38,7 +38,7 @@
============================================================== -->
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>1.x-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Apache SIS</name>
diff --git a/settings.gradle.kts b/settings.gradle.kts
index ff902c5..ec5003c 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -14,14 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-rootProject.name = "Apache SIS on GeoAPI 3.1"
-val geoapiVersion = "3.1-SNAPSHOT"
+rootProject.name = "Apache SIS on GeoAPI 3.0"
+val geoapiVersion = "3.0.2"
/*
* The sub-projects to include in the build.
* They are directory names relative to this file.
*/
-include("geoapi")
include("parent")
include("endorsed")
include("incubator")
@@ -59,7 +58,7 @@
*/
versionCatalogs {
create("libs") {
- library("geoapi", "org.opengis", "geoapi-pending") .version {strictly(geoapiVersion)}
+ library("geoapi", "org.opengis", "geoapi") .version {strictly(geoapiVersion)}
library("units", "javax.measure", "unit-api") .version {strictly("[2.1, 3.0["); prefer("2.1.3")}
library("jaxb.api", "jakarta.xml.bind", "jakarta.xml.bind-api").version {strictly("[4.0, 5.0["); prefer("4.0.2")}
library("jaxb.impl", "org.glassfish.jaxb", "jaxb-runtime") .version {strictly("[4.0, 5.0["); prefer("4.0.5")}