This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 67df58995666997ab10925fd8ceed4b34d9cae0e Author: Martin Desruisseaux <[email protected]> AuthorDate: Fri Sep 5 18:00:48 2025 +0200 Fix the existing JUnit tests to the 2015 version of WKT2. It allows us to start implementing the 2019 version without breaking the tests. --- .../main/org/apache/sis/console/CommandRunner.java | 2 +- .../apache/sis/console/FormattedOutputCommand.java | 6 +++ .../main/org/apache/sis/io/wkt/AbstractParser.java | 8 ++++ .../main/org/apache/sis/io/wkt/Convention.java | 34 +++++++++------- .../main/org/apache/sis/io/wkt/Formatter.java | 45 +++++++++++++++++----- .../cs/DefaultCoordinateSystemAxis.java | 2 +- .../apache/sis/referencing/privy/WKTUtilities.java | 2 +- .../org/apache/sis/geometry/ArrayEnvelopeTest.java | 11 ++++-- .../apache/sis/geometry/GeneralEnvelopeTest.java | 3 +- .../DefaultParameterDescriptorGroupTest.java | 7 ++-- .../parameter/DefaultParameterDescriptorTest.java | 6 +-- .../org/apache/sis/parameter/TensorValuesTest.java | 5 ++- .../referencing/AbstractReferenceSystemTest.java | 2 +- .../org/apache/sis/referencing/Assertions.java | 18 ++------- .../referencing/crs/DefaultCompoundCRSTest.java | 2 +- .../sis/referencing/crs/DefaultDerivedCRSTest.java | 2 +- .../referencing/crs/DefaultEngineeringCRSTest.java | 2 +- .../referencing/crs/DefaultGeocentricCRSTest.java | 2 +- .../referencing/crs/DefaultGeographicCRSTest.java | 4 +- .../sis/referencing/crs/DefaultImageCRSTest.java | 2 +- .../referencing/crs/DefaultProjectedCRSTest.java | 2 +- .../referencing/crs/DefaultTemporalCRSTest.java | 2 +- .../referencing/crs/DefaultVerticalCRSTest.java | 2 +- .../cs/DefaultCoordinateSystemAxisTest.java | 39 +++++++++++-------- .../referencing/datum/DefaultEllipsoidTest.java | 5 ++- .../datum/DefaultGeodeticDatumTest.java | 4 +- .../datum/DefaultVerticalDatumTest.java | 4 +- .../factory/CommonAuthorityFactoryTest.java | 2 +- .../operation/DefaultOperationMethodTest.java | 2 +- .../operation/DefaultTransformationTest.java | 2 +- .../referencing/operation/provider/AffineTest.java | 7 ++-- .../operation/provider/LongitudeRotationTest.java | 3 +- .../sis/test/integration/ConsistencyTest.java | 4 +- .../org/apache/sis/storage/base/PRJDataStore.java | 14 +++---- .../apache/sis/storage/esri/WritableStoreTest.java | 2 +- 35 files changed, 153 insertions(+), 106 deletions(-) diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java index cfc28604dc..c17b7f89c6 100644 --- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java +++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java @@ -247,7 +247,7 @@ abstract class CommandRunner { * or to the standard output stream otherwise. */ if (TEST.equals(commandName)) { - final StringWriter s = new StringWriter(); + final var s = new StringWriter(); outputBuffer = s.getBuffer(); out = new PrintWriter(s); err = out; diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/FormattedOutputCommand.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/FormattedOutputCommand.java index 4c1cbb9584..5103b1fc6e 100644 --- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/FormattedOutputCommand.java +++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/FormattedOutputCommand.java @@ -116,6 +116,12 @@ abstract class FormattedOutputCommand extends CommandRunner { } else if (format.equalsIgnoreCase("WKT2")) { outputFormat = OutputFormat.WKT; convention = Convention.WKT2; + } else if (format.equalsIgnoreCase("WKT2:2019")) { // Same name as PROJ. + outputFormat = OutputFormat.WKT; + convention = Convention.WKT2_2019; + } else if (format.equalsIgnoreCase("WKT2:2015")) { // Same name as PROJ. + outputFormat = OutputFormat.WKT; + convention = Convention.WKT2_2015; } else { /* * Separate the format name from its version. We verify right after this block that the format diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/AbstractParser.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/AbstractParser.java index 416a63422f..44a49c5e9e 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/AbstractParser.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/AbstractParser.java @@ -388,6 +388,14 @@ abstract class AbstractParser implements Parser { * This is a helper method for {@link Element} only. * * <p>The WKT 2 format expects dates formatted according the ISO 9075-2 standard.</p> + * + * <h4>Limitations</h4> + * The WKT 2 specification allows dates in the form {@code YYYY-DDD} where {@code DDD} is the ordinal day. + * This is not supported in the current implementation. It can be distinguished from the {@code YYYY-MM} + * case by the fact that the ordinal day must have 3 digits according the specification. + * + * @todo Need to replace {@code Date} by {@code java.time} with the precision used in the WKT string. + * The WKT 2 specification allows any precision. */ final Date parseDate(final String text, final ParsePosition position) { if (dateFormat == null) { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Convention.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Convention.java index 3ec6461a05..d1b1163bf5 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Convention.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/Convention.java @@ -22,8 +22,8 @@ import org.apache.sis.metadata.iso.citation.Citations; /** - * The convention to use for WKT formatting. - * This enumeration specifies whether to use the <i>Well Known Text</i> format defined by ISO 19162 + * The convention to use for <abbr title="Well Known Text">WKT</abbr> formatting. + * This enumeration specifies whether to use the <i>Well Known Text</i> format defined by <abbr>ISO</abbr> 19162 * (also known as “WKT 2”), or whether to use the format previously defined in OGC 01-009 (referenced as “WKT 1”). * * <h2>WKT 1 variants</h2> @@ -61,12 +61,8 @@ public enum Convention { */ /** - * The ISO 19162 format, also known as “WKT 2”. - * This convention follows the ISO recommendations. - * - * <p>Unless otherwise specified by {@link WKTFormat#setNameAuthority(Citation)}, projections - * and parameters formatted with this convention will use the {@linkplain Citations#EPSG EPSG} - * names when available.</p> + * Latest version of the ISO 19162 format (also known as “WKT 2”) supported by Apache SIS. + * In the current version of Apache <abbr>SIS</abbr>, this is synonymous of {@link #WKT2_2019}. * * <p>This is the default convention used by {@link FormattableObject#toWKT()} * and for new {@link WKTFormat} instances.</p> @@ -105,12 +101,24 @@ public enum Convention { WKT2_SIMPLIFIED(false, false, false), /** - * The ISO 19162:2007 format, also known as “WKT 2”. + * The ISO 19162:2019 format, also known as “WKT 2”. + * This version replaces ISO 19162:2015. + * + * <p>Unless otherwise specified by {@link WKTFormat#setNameAuthority(Citation)}, projections + * and parameters formatted with this convention will use the {@linkplain Citations#EPSG EPSG} + * names when available.</p> + * + * @since 1.5 + */ + WKT2_2019(false, true, false), + + /** + * The ISO 19162:2015 format, also known as “WKT 2”. * This version has been replaced by ISO 19162:2019. * This enumeration value can be used when compatibility with this older standard is required. * * <p>This was the default convention used by {@link FormattableObject#toWKT()} - * in Apache <abbr>SIS</abbr> versions prior to 1.5.</p> + * in Apache <abbr>SIS</abbr> versions prior to version 1.5.</p> * * @since 1.5 */ @@ -264,14 +272,12 @@ public enum Convention { /** * Returns {@code true} if this convention is one of the simplified variants of WKT. * The simplifications are documented in the {@link #WKT2_SIMPLIFIED} javadoc. - * - * <p>This methods consider version 1 of WKT as a “simplified” convention, - * since this version was indeed simpler than version 2.</p> + * This method also considers version 1 of WKT as a simplified convention. * * @return {@code true} it this convention uses a simplified variant of WKT. */ public boolean isSimplified() { - return this != WKT2; + return this == WKT2_SIMPLIFIED || ordinal() >= WKT1.ordinal(); } /** 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 86b8fbf7cb..80fa8ce554 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 @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Locale; import java.util.Date; +import java.util.function.Function; import java.text.DateFormat; import java.text.NumberFormat; import java.text.FieldPosition; @@ -80,6 +81,7 @@ import org.apache.sis.metadata.simple.SimpleExtent; import org.apache.sis.metadata.iso.extent.Extents; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.referencing.AbstractIdentifiedObject; +import org.apache.sis.referencing.DefaultObjectDomain; import org.apache.sis.referencing.ImmutableIdentifier; import org.apache.sis.referencing.privy.WKTKeywords; import org.apache.sis.referencing.privy.WKTUtilities; @@ -635,6 +637,23 @@ public class Formatter implements Localized { } } + /** + * Appends the given object as an instance of {@code FormattableObject}. + * This method delegates to {@link #append(FormattableObject)} with an argument which is either + * the {@code object} value if that value is already an instance of {@link FormattableObject}, + * or with the value converted using the given function. The {@code toFormattable} argument is + * usually a lambda function to a {@code castOrCopy(T)} method in an implementation class. + * + * @param <T> type of object to format. + * @param object the formattable object to append to the WKT, or {@code null} if none. + * @param toFormattable the function to invoke for converting the given object to a formattable object. + * + * @since 1.5 + */ + public <T> void appendFormattable(final T object, final Function<T, FormattableObject> toFormattable) { + append((object instanceof FormattableObject) ? (FormattableObject) object : toFormattable.apply(object)); + } + /** * Appends the given {@code FormattableObject}. * This method performs the following steps: @@ -862,10 +881,7 @@ public class Formatter implements Localized { } } for (Identifier id : identifiers) { - if (!(id instanceof FormattableObject)) { - id = ImmutableIdentifier.castOrCopy(id); - } - append((FormattableObject) id); + appendFormattable(id, ImmutableIdentifier::castOrCopy); if (filterID) break; } } @@ -889,14 +905,23 @@ public class Formatter implements Localized { } else if (!(object instanceof ReferenceSystem || object instanceof CoordinateOperation)) { return; } + appendOnNewLine(WKTKeywords.Anchor, anchor, null); + final boolean usage = convention.compareTo(Convention.WKT2_2015) < 0 + && convention != Convention.WKT2_SIMPLIFIED; // TODO: remove that exclusion. for (final ObjectDomain domain : object.getDomains()) { - scope = domain.getScope(); - area = domain.getDomainOfValidity(); - if (area != null) break; - // TODO: in 2019 revision we need to format all USAGE[…] elements, not only the first one. + if (usage) { + // ISO 19162:2019 + appendFormattable(domain, DefaultObjectDomain::castOrCopy); + } else { + // ISO 19162:2015 + scope = domain.getScope(); + area = domain.getDomainOfValidity(); + if (scope != null || area != null) { + append(scope, area); + break; + } + } } - appendOnNewLine(WKTKeywords.Anchor, anchor, null); - append(scope, area); } /** 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 e3f9e39ec8..1eda1dc32e 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 @@ -780,7 +780,7 @@ public class DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implem * to all axes (we do not verify). */ if (!isWKT1) { - if (convention == Convention.WKT2 && cs != null) { + if (cs != null && !convention.isSimplified()) { final Order order = Order.create(cs, this); if (order != null) { formatter.append(order); 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 fe7e6f172e..4ebc07ed6c 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 @@ -69,7 +69,7 @@ import org.opengis.metadata.Identifier; * This class provides a set of {@code toFormattable(…)} for various {@link IdentifiedObject} subtypes. * It is important to <strong>not</strong> provide a generic {@code toFormattable(IdentifiedObject)} * method, because the user may choose to implement more than one GeoAPI interface for the same object. - * We need to be specific in order to select the right "aspect" of the given object. + * We need to be specific in order to select the right aspect of the given object. * * @author Martin Desruisseaux (Geomatys) */ diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ArrayEnvelopeTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ArrayEnvelopeTest.java index ce74bc287d..165a5156e7 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ArrayEnvelopeTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ArrayEnvelopeTest.java @@ -16,6 +16,7 @@ */ package org.apache.sis.geometry; +import org.apache.sis.io.wkt.Convention; import org.apache.sis.io.wkt.Formatter; // Test dependencies @@ -87,11 +88,13 @@ public final class ArrayEnvelopeTest extends TestCase { @Test public void testFormatWKT() { ArrayEnvelope envelope = new ArrayEnvelope(new double[] {4, -10, 50, 2}); - assertWktEquals("BOX[ 4 -10,\n" + - " 50 2]", envelope); + assertWktEquals(Convention.WKT2, // Actually not in WKT2 standard. + "BOX[ 4 -10,\n" + + " 50 2]", envelope); envelope.crs = WGS84; - assertWktEquals("BOX[ 4.00000000 -10.00000000,\n" + - " 50.00000000 2.00000000]", envelope); + assertWktEquals(Convention.WKT2, // Actually not in WKT2 standard. + "BOX[ 4.00000000 -10.00000000,\n" + + " 50.00000000 2.00000000]", envelope); } /** 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 91ecdf53cd..fec78a0ea7 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 @@ -23,6 +23,7 @@ import org.opengis.geometry.DirectPosition; import org.apache.sis.measure.Range; import org.apache.sis.metadata.privy.AxisNames; import org.apache.sis.math.MathFunctions; +import org.apache.sis.io.wkt.Convention; // Test dependencies import org.junit.jupiter.api.Test; @@ -745,7 +746,7 @@ public class GeneralEnvelopeTest extends EPSGDependentTestCase { envelope.setRange(0, 6, 10); envelope.setRange(1, 16, 20); envelope.setRange(2, 23, 50); - assertWktEquals( + assertWktEquals(Convention.WKT2, // Actually not in WKT2 standard. "BOX3D[ 6 16 23,\n" + " 10 20 50]", envelope); } 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 c78574ba9d..8d709ce0f1 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 @@ -198,15 +198,16 @@ public final class DefaultParameterDescriptorGroupTest extends TestCase { * but is reproduced here for easier comparison with the test following it. */ final DefaultParameterDescriptor<Double> descriptor = DefaultParameterDescriptorTest.createEPSG("A0", Constants.EPSG_A0); - assertWktEquals("PARAMETER[“A0”, ID[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor); + assertWktEquals(Convention.WKT2, "PARAMETER[“A0”, ID[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor); /* * When the parameter is part of a larger element, we expect a simplification. * Here, the URI should be omitted because it is a long value which does not * bring new information, since it is computed from other values. */ final var group = new DefaultParameterDescriptorGroup(Map.of(NAME_KEY, "Affine"), 1, 1, descriptor); - assertWktEquals("PARAMETERGROUP[“Affine”,\n" + - " PARAMETER[“A0”, ID[“EPSG”, 8623]]]", group); + assertWktEquals(Convention.WKT2, + "PARAMETERGROUP[“Affine”,\n" + + " PARAMETER[“A0”, ID[“EPSG”, 8623]]]", group); } /** diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorTest.java index 5271cbec00..4763ef06f1 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/DefaultParameterDescriptorTest.java @@ -310,8 +310,8 @@ public final class DefaultParameterDescriptorTest extends TestCase { @Test public void testWKT() { final DefaultParameterDescriptor<Double> descriptor = create("Real number", 4, 8, 5, Units.METRE); - assertWktEquals("PARAMETER[“Integer param”, 5]", create("Integer param", 4, 8, 5)); - assertWktEquals("PARAMETER[“Real number”, 5.0, LENGTHUNIT[“metre”, 1]]", descriptor); + assertWktEquals(Convention.WKT2, "PARAMETER[“Integer param”, 5]", create("Integer param", 4, 8, 5)); + assertWktEquals(Convention.WKT2, "PARAMETER[“Real number”, 5.0, LENGTHUNIT[“metre”, 1]]", descriptor); assertWktEquals(Convention.WKT2_SIMPLIFIED, "Parameter[“Real number”, 5.0, Unit[“metre”, 1]]", descriptor); } @@ -323,6 +323,6 @@ public final class DefaultParameterDescriptorTest extends TestCase { @Test public void testIdentifiedParameterWKT() { final DefaultParameterDescriptor<Double> descriptor = createEPSG("A0", Constants.EPSG_A0); - assertWktEquals("PARAMETER[“A0”, ID[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor); + assertWktEquals(Convention.WKT2, "PARAMETER[“A0”, ID[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor); } } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorValuesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorValuesTest.java index 3518b093c8..4683112c45 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorValuesTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/parameter/TensorValuesTest.java @@ -28,6 +28,7 @@ import org.opengis.parameter.ParameterNotFoundException; import org.opengis.referencing.operation.Matrix; import org.apache.sis.referencing.operation.matrix.Matrices; import org.apache.sis.referencing.operation.provider.Affine; +import org.apache.sis.io.wkt.Convention; import org.apache.sis.util.privy.Constants; import static org.apache.sis.util.privy.Constants.NUM_ROW; import static org.apache.sis.util.privy.Constants.NUM_COL; @@ -309,7 +310,7 @@ public final class TensorValuesTest extends TestCase { final ParameterValueGroup group = TensorParameters.WKT1.createValueGroup( Map.of(TensorValues.NAME_KEY, Constants.AFFINE), matrix); validate(group); - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAMETERGROUP[“Affine”,\n" + " PARAMETER[“num_row”, 3],\n" + // Shall be shown even if equals to the default value. " PARAMETER[“num_col”, 3],\n" + @@ -336,7 +337,7 @@ public final class TensorValuesTest extends TestCase { final ParameterValueGroup group = TensorParameters.ALPHANUM.createValueGroup( Map.of(TensorValues.NAME_KEY, Affine.NAME), matrix); validate(group); - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAMETERGROUP[“Affine parametric transformation”,\n" + " PARAMETER[“A2”, 4.0, ID[“EPSG”, 8625]],\n" + " PARAMETER[“B0”, -2.0, ID[“EPSG”, 8639]],\n" + 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 c6eb2e53d0..e0865ba8f9 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 @@ -126,7 +126,7 @@ public final class AbstractReferenceSystemTest extends TestCase { "ReferenceSystem[“My \"object\".”, AUTHORITY[“EPSG”, “4326”]]", object); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "ReferenceSystem[“My \"object\".”,\n" + // Quotes replaced " SCOPE[“Large scale topographic mapping and cadastre.”],\n" + " AREA[“Netherlands offshore.”],\n" + 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 84497a619b..3c5556d432 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 @@ -66,7 +66,7 @@ import static org.apache.sis.test.Assertions.assertMultilinesEquals; */ public final class Assertions extends Static { /** - * The formatter to be used by {@link #assertWktEquals(String, Object)}. + * The formatter to be used by {@link #assertWktEquals(Convention, String, Object)}. * This formatter uses the {@code “…”} quotation marks instead of {@code "…"} * for easier readability of {@link String} constants in Java code. */ @@ -542,18 +542,6 @@ public final class Assertions extends Static { } } - /** - * Asserts that the WKT 2 of the given object is equal to the expected one. - * This method expected the {@code “…”} quotation marks instead of {@code "…"} - * for easier readability of {@link String} constants in Java code. - * - * @param expected the expected text, or {@code null} if {@code object} is expected to be null. - * @param object the object to format in <i>Well Known Text</i> format, or {@code null}. - */ - public static void assertWktEquals(final String expected, final Object object) { - assertWktEquals(Convention.WKT2, expected, object); - } - /** * Asserts that the WKT of the given object according the given convention is equal to the expected one. * This method expected the {@code “…”} quotation marks instead of {@code "…"} for easier readability of @@ -587,8 +575,8 @@ public final class Assertions extends Static { /** * Asserts that the WKT of the given object according the given convention is equal to the given regular expression. - * This method is like {@link #assertWktEquals(String, Object)}, but the use of regular expression allows some - * tolerance for example on numerical parameter values that may be subject to a limited form of rounding errors. + * This method is like {@link #assertWktEquals(Convention, String, Object)}, but the use of regular expression allows + * some tolerance for example on numerical parameter values that may be subject to a limited form of rounding errors. * * @param convention the WKT convention to use. * @param expected the expected regular expression, or {@code null} if {@code object} is expected to be null. 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 c1cae87a56..d3ff22223e 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 @@ -261,7 +261,7 @@ public final class DefaultCompoundCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "COMPOUNDCRS[“WGS 84 + height + time”,\n" + " GEODCRS[“WGS 84”,\n" + " DATUM[“World Geodetic System 1984”,\n" + 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 84b99e3d04..7630a761e0 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 @@ -189,7 +189,7 @@ public final class DefaultDerivedCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "GEODCRS[“Back to Greenwich”,\n" + " BASEGEODCRS[“NTF (Paris)”,\n" + " DATUM[“Nouvelle Triangulation Francaise”,\n" + 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 76c6258ead..9b78f8428e 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 @@ -89,7 +89,7 @@ public final class DefaultEngineeringCRSTest extends TestCase { @Test public void testWKT2() { final DefaultEngineeringCRS crs = createSpherical(); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "ENGCRS[“A spherical CRS”,\n" + " EDATUM[“Centre”],\n" + " CS[spherical, 3],\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java index 867d1e89f0..07adc06e9f 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java @@ -133,7 +133,7 @@ public final class DefaultGeocentricCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "GEODCRS[“Geocentric”,\n" + " DATUM[“World Geodetic System 1984”,\n" + " ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]],\n" + 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 7030e97219..4f49d51bd7 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 @@ -153,7 +153,7 @@ public final class DefaultGeographicCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "GEODCRS[“WGS 84”,\n" + " DATUM[“World Geodetic System 1984”,\n" + " ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]],\n" + @@ -177,7 +177,7 @@ public final class DefaultGeographicCRSTest extends TestCase { */ @Test public void testWKT2_For3D() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "GEODCRS[“WGS 84 (3D)”,\n" + " DATUM[“World Geodetic System 1984”,\n" + " ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]],\n" + 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 ec4649df72..5da70864d8 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 @@ -72,7 +72,7 @@ public final class DefaultImageCRSTest extends TestCase { @Test public void testWKT2() { final DefaultImageCRS crs = create(true); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "IMAGECRS[“An image CRS”,\n" + " IDATUM[“C1”],\n" + " CS[Cartesian, 2],\n" + 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 c5a4988027..5c1ab298ad 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 @@ -359,7 +359,7 @@ public final class DefaultProjectedCRSTest extends TestCase.WithLogs { @Test public void testWKT2_WithMixedUnits() throws FactoryException { final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "PROJCRS[“NTF (Paris) / Lambert zone II”,\n" + " BASEGEODCRS[“NTF (Paris)”,\n" + " DATUM[“Nouvelle Triangulation Francaise”,\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java index ba28b5ee70..a9ed54231e 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java @@ -64,7 +64,7 @@ public final class DefaultTemporalCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "TIMECRS[“Time”,\n" + " TDATUM[“Modified Julian”, TIMEORIGIN[1858-11-17]],\n" + " CS[temporal, 1],\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java index 3ba1ab919e..efac9e1bc1 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java @@ -54,7 +54,7 @@ public final class DefaultVerticalCRSTest extends TestCase { */ @Test public void testWKT2() { - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "VERTCRS[“Depth”,\n" + " VDATUM[“Mean Sea Level”],\n" + " CS[vertical, 1],\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java index 7a8299290b..4c5cc5e087 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java @@ -88,24 +88,24 @@ public final class DefaultCoordinateSystemAxisTest extends TestCase { */ @Test public void testWKT() { - assertWktEquals("AXIS[“x”, east, LENGTHUNIT[“metre”, 1]]", X); - assertWktEquals("AXIS[“y”, north, LENGTHUNIT[“metre”, 1]]", Y); - assertWktEquals("AXIS[“z”, up, LENGTHUNIT[“metre”, 1]]", Z); - assertWktEquals("AXIS[“Longitude (λ)”, east, ANGLEUNIT[“grad”, 0.015707963267948967]]", LONGITUDE_gon); - assertWktEquals("AXIS[“Latitude (φ)”, north, ANGLEUNIT[“grad”, 0.015707963267948967]]", LATITUDE_gon); - assertWktEquals("AXIS[“Altitude (h)”, up, LENGTHUNIT[“metre”, 1]]", ALTITUDE); - assertWktEquals("AXIS[“Time (t)”, future, TIMEUNIT[“day”, 86400]]", TIME); - assertWktEquals("AXIS[“Longitude (λ)”, east, ANGLEUNIT[“degree”, 0.017453292519943295]]", GEODETIC_LONGITUDE); - assertWktEquals("AXIS[“Spherical longitude (θ)”, east, ANGLEUNIT[“degree”, 0.017453292519943295]]", SPHERICAL_LONGITUDE); - assertWktEquals("AXIS[“Latitude (φ)”, north, ANGLEUNIT[“degree”, 0.017453292519943295]]", GEODETIC_LATITUDE); - assertWktEquals("AXIS[“Spherical latitude (Ω)”, north, ANGLEUNIT[“degree”, 0.017453292519943295]]", SPHERICAL_LATITUDE); + assertWktEquals(Convention.WKT2, "AXIS[“x”, east, LENGTHUNIT[“metre”, 1]]", X); + assertWktEquals(Convention.WKT2, "AXIS[“y”, north, LENGTHUNIT[“metre”, 1]]", Y); + assertWktEquals(Convention.WKT2, "AXIS[“z”, up, LENGTHUNIT[“metre”, 1]]", Z); + assertWktEquals(Convention.WKT2, "AXIS[“Longitude (λ)”, east, ANGLEUNIT[“grad”, 0.015707963267948967]]", LONGITUDE_gon); + assertWktEquals(Convention.WKT2, "AXIS[“Latitude (φ)”, north, ANGLEUNIT[“grad”, 0.015707963267948967]]", LATITUDE_gon); + assertWktEquals(Convention.WKT2, "AXIS[“Altitude (h)”, up, LENGTHUNIT[“metre”, 1]]", ALTITUDE); + assertWktEquals(Convention.WKT2, "AXIS[“Time (t)”, future, TIMEUNIT[“day”, 86400]]", TIME); + assertWktEquals(Convention.WKT2, "AXIS[“Longitude (λ)”, east, ANGLEUNIT[“degree”, 0.017453292519943295]]", GEODETIC_LONGITUDE); + assertWktEquals(Convention.WKT2, "AXIS[“Spherical longitude (θ)”, east, ANGLEUNIT[“degree”, 0.017453292519943295]]", SPHERICAL_LONGITUDE); + assertWktEquals(Convention.WKT2, "AXIS[“Latitude (φ)”, north, ANGLEUNIT[“degree”, 0.017453292519943295]]", GEODETIC_LATITUDE); + assertWktEquals(Convention.WKT2, "AXIS[“Spherical latitude (Ω)”, north, ANGLEUNIT[“degree”, 0.017453292519943295]]", SPHERICAL_LATITUDE); assertWktEquals(Convention.WKT1, "AXIS[“x”, EAST]", X); assertWktEquals(Convention.WKT1, "AXIS[“y”, NORTH]", Y); assertWktEquals(Convention.WKT1, "AXIS[“z”, UP]", Z); - assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic longitude (λ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LONGITUDE); - assertWktEquals(Convention.INTERNAL, "Axis[“Spherical longitude (θ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", SPHERICAL_LONGITUDE); - assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic latitude (φ)”, north, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LATITUDE); + assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic longitude (λ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LONGITUDE); + assertWktEquals(Convention.INTERNAL, "Axis[“Spherical longitude (θ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", SPHERICAL_LONGITUDE); + assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic latitude (φ)”, north, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LATITUDE); assertWktEquals(Convention.INTERNAL, "Axis[“Spherical latitude (Ω)”, north, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", SPHERICAL_LATITUDE); } @@ -114,9 +114,14 @@ public final class DefaultCoordinateSystemAxisTest extends TestCase { */ @Test public void testMeridianWKT() { - assertWktEquals("AXIS[“South along 90°W (x)”, south, MERIDIAN[-90.0, ANGLEUNIT[“degree”, 0.017453292519943295]], LENGTHUNIT[“metre”, 1]]", - new DefaultCoordinateSystemAxis(Map.of(DefaultCoordinateSystemAxis.NAME_KEY, "South along 90°W"), - "x", new DirectionAlongMeridian(AxisDirection.SOUTH, -90).getDirection(), Units.METRE)); + assertWktEquals( + Convention.WKT2, + "AXIS[“South along 90°W (x)”, south, MERIDIAN[-90.0, ANGLEUNIT[“degree”, 0.017453292519943295]], LENGTHUNIT[“metre”, 1]]", + new DefaultCoordinateSystemAxis( + Map.of(DefaultCoordinateSystemAxis.NAME_KEY, "South along 90°W"), + "x", + new DirectionAlongMeridian(AxisDirection.SOUTH, -90).getDirection(), + Units.METRE)); } /** diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java index e702cc400f..0142767b00 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java @@ -18,6 +18,7 @@ package org.apache.sis.referencing.datum; import java.io.InputStream; import jakarta.xml.bind.JAXBException; +import org.apache.sis.io.wkt.Convention; import org.apache.sis.measure.Units; // Test dependencies @@ -117,8 +118,8 @@ public final class DefaultEllipsoidTest extends TestCase { */ @Test public void testToWKT() { - final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid()); - assertWktEquals("ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]", e); + final var e = new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid()); + assertWktEquals(Convention.WKT2, "ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]", e); } /** 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 374c984c92..3c116c9930 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 @@ -244,7 +244,7 @@ public final class DefaultGeodeticDatumTest extends TestCase { @Test public void testToWKT() { final var datum = new DefaultGeodeticDatum(GeodeticDatumMock.WGS84); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "DATUM[“WGS84”,\n" + " ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]]", datum); @@ -326,7 +326,7 @@ public final class DefaultGeodeticDatumTest extends TestCase { " AUTHORITY[“EPSG”, “6326”]]", datum); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "DATUM[“World Geodetic System 1984”,\n" + " ELLIPSOID[“WGS 84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]],\n" + " ID[“EPSG”, 6326, URI[“urn:ogc:def:datum:EPSG::6326”]]]", 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 5a2241fb77..b230467515 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 @@ -76,12 +76,12 @@ public final class DefaultVerticalDatumTest extends TestCase { DefaultVerticalDatum datum; datum = new DefaultVerticalDatum(Map.of(DefaultVerticalDatum.NAME_KEY, "Geoidal"), RealizationMethod.GEOID); assertWktEquals(Convention.WKT1, "VERT_DATUM[“Geoidal”, 2005]", datum); - assertWktEquals(Convention.WKT2, "VDATUM[“Geoidal”]", datum); + assertWktEquals(Convention.WKT2_2015, "VDATUM[“Geoidal”]", datum); assertWktEquals(Convention.WKT2_SIMPLIFIED, "VerticalDatum[“Geoidal”]", datum); datum = new DefaultVerticalDatum(Map.of(DefaultVerticalDatum.NAME_KEY, "Ellipsoidal"), VerticalDatumTypes.ellipsoidal()); assertWktEquals(Convention.WKT1, "VERT_DATUM[“Ellipsoidal”, 2002]", datum); - assertWktEquals(Convention.WKT2, "VDATUM[“Ellipsoidal”]", datum); + assertWktEquals(Convention.WKT2_2015, "VDATUM[“Ellipsoidal”]", datum); assertWktEquals(Convention.WKT2_SIMPLIFIED, "VerticalDatum[“Ellipsoidal”]", datum); } 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 ae0e7d31b5..a8cb6d27ff 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 @@ -391,7 +391,7 @@ public final class CommonAuthorityFactoryTest extends TestCase { " AXIS[“Latitude”, NORTH],\n" + " AUTHORITY[“CRS”, “84”]]\\E", crs); - assertWktEqualsRegex(Convention.WKT2, "(?m)\\Q" + + assertWktEqualsRegex(Convention.WKT2_2015, "(?m)\\Q" + "GEODCRS[" + WGS84 + ",\n" + " DATUM[“World Geodetic System 1984\\E\\s?\\w*\\Q”,\n" + " ELLIPSOID[" + WGS84 + ", 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]],\n" + 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 ddf06770f6..94c6e9d1ac 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 @@ -118,7 +118,7 @@ public final class DefaultOperationMethodTest extends TestCase { @Test public void testWKT() { final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2"); - assertWktEquals("METHOD[“Mercator (variant A)”, ID[“EPSG”, 9804, URI[“urn:ogc:def:method:EPSG::9804”]]]", method); + assertWktEquals(Convention.WKT2, "METHOD[“Mercator (variant A)”, ID[“EPSG”, 9804, URI[“urn:ogc:def:method:EPSG::9804”]]]", method); assertWktEquals(Convention.WKT1, "PROJECTION[“Mercator (variant A)”, AUTHORITY[“EPSG”, “9804”]]", method); } } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultTransformationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultTransformationTest.java index 30f97d0a15..7d25f20155 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultTransformationTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultTransformationTest.java @@ -156,7 +156,7 @@ public final class DefaultTransformationTest extends TestCase { @Test public void testWKT() { final DefaultTransformation op = createGeocentricTranslation(); - assertWktEquals(Convention.WKT2, + assertWktEquals(Convention.WKT2_2015, "COORDINATEOPERATION[“Tokyo to JGD2000 (GSI)”,\n" + " SOURCECRS[GEODCRS[“Tokyo 1918”,\n" + " DATUM[“Tokyo 1918”,\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/AffineTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/AffineTest.java index 91e571ef6f..bd2fddd5d2 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/AffineTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/AffineTest.java @@ -20,6 +20,7 @@ import org.opengis.parameter.GeneralParameterDescriptor; import org.opengis.referencing.operation.SingleOperation; import org.opengis.referencing.operation.Matrix; import org.apache.sis.referencing.operation.matrix.Matrices; +import org.apache.sis.io.wkt.Convention; // Test dependencies import org.junit.jupiter.api.Test; @@ -94,7 +95,7 @@ public final class AffineTest extends TestCase { @Test public void testWKT() { final Matrix matrix = Matrices.createDiagonal(3, 3); - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAMETERGROUP[“Affine parametric transformation”," + " ID[“EPSG”, 9624]]", Affine.parameters(matrix)); /* @@ -103,7 +104,7 @@ public final class AffineTest extends TestCase { matrix.setElement(0, 1, 2); // A1 matrix.setElement(1, 1, 0); // B1 matrix.setElement(1, 2, -1); // B2 - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAMETERGROUP[“Affine parametric transformation”,\n" + " PARAMETER[“A1”, 2.0, ID[“EPSG”, 8624]],\n" + " PARAMETER[“B1”, 0.0, ID[“EPSG”, 8640]],\n" + @@ -114,7 +115,7 @@ public final class AffineTest extends TestCase { * So it should not be anymore EPSG:9624. */ matrix.setElement(2, 0, 3); // C0 - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAMETERGROUP[“Affine”,\n" + " PARAMETER[“num_row”, 3],\n" + " PARAMETER[“num_col”, 3],\n" + 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 9500908f05..ea9485a244 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 @@ -21,6 +21,7 @@ import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.operation.MathTransform; import org.apache.sis.referencing.operation.transform.LinearTransform; import org.apache.sis.referencing.operation.matrix.Matrix3; +import org.apache.sis.io.wkt.Convention; import org.apache.sis.measure.Units; // Test dependencies @@ -80,7 +81,7 @@ public final class LongitudeRotationTest extends TestCase { final LongitudeRotation provider = new LongitudeRotation(); final ParameterValueGroup p = provider.getParameters().createValue(); p.parameter("Longitude offset").setValue(2.5969213, Units.GRAD); - assertWktEquals( + assertWktEquals(Convention.WKT2, "PARAM_MT[“Affine parametric transformation”,\n" + " PARAMETER[“A2”, 2.33722917, ID[“EPSG”, 8625]]]", provider.createMathTransform(null, p)); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/ConsistencyTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/ConsistencyTest.java index e111d7bd47..487645a33a 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/ConsistencyTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/ConsistencyTest.java @@ -110,7 +110,7 @@ public final class ConsistencyTest extends TestCase { final String code = "EPSG::29871"; final CoordinateReferenceSystem crs = CRS.forCode(code); final var format = new WKTFormat(); - format.setConvention(Convention.WKT2); + format.setConvention(Convention.WKT2_2015); lookup(parseAndFormat(format, code, crs), crs); } @@ -149,7 +149,7 @@ public final class ConsistencyTest extends TestCase { final var v2s = new WKTFormat(); v1 .setConvention(Convention.WKT1); v1c.setConvention(Convention.WKT1_COMMON_UNITS); - v2 .setConvention(Convention.WKT2); + v2 .setConvention(Convention.WKT2_2015); v2s.setConvention(Convention.WKT2_SIMPLIFIED); for (final String code : CRS.getAuthorityFactory(null).getAuthorityCodes(CoordinateReferenceSystem.class)) { if (!EXCLUDES.contains(code) && !code.startsWith(Constants.PROJ4 + DefaultNameSpace.DEFAULT_SEPARATOR)) { diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java index dcecea92b8..791eb02829 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java @@ -152,14 +152,14 @@ public abstract class PRJDataStore extends URIDataStore { throw new DataStoreException(s.getMessage(getLocale()), s.exception); } final String wkt = content.toString(); - final StoreFormat format = new StoreFormat(dataLocale, timezone, null, listeners); + final var format = new StoreFormat(dataLocale, timezone, null, listeners); format.setConvention(getConvention()); // Ignored if the format is WKT 2. try { format.setSourceFile(content.getURI()); } catch (URISyntaxException e) { suppressed = e; } - final ParsePosition pos = new ParsePosition(0); + final var pos = new ParsePosition(0); // ClassCastException handled by `catch` statement below. final T result = type.cast(format.parse(wkt, pos)); if (result != null) { @@ -189,7 +189,7 @@ public abstract class PRJDataStore extends URIDataStore { * <h4>WKT version used</h4> * Current version writes the CRS in WKT 2 format. This is not the common practice, which uses WKT 1. * But the WKT 1 variant used by the common practice is not the standard format defined by OGC 01-009. - * It is more like {@link Convention#WKT1_IGNORE_AXES}, which has many ambiguity problems. The WKT 2 + * It is more like {@link Convention#WKT1_IGNORE_AXES}, which has many ambiguity problems. The WKT 2 * format fixes those ambiguities. We hope that major software have updated their referencing engine * and can now parse WKT 2 as well as WKT 1. * @@ -200,8 +200,8 @@ public abstract class PRJDataStore extends URIDataStore { if (crs == null) { deleteAuxiliaryFile(PRJ); } else try (BufferedWriter out = writeAuxiliaryFile(PRJ)) { - final StoreFormat format = new StoreFormat(dataLocale, timezone, null, listeners); - // Keep the default "WKT 2" format (see method javadoc). + final var format = new StoreFormat(dataLocale, timezone, null, listeners); + format.setConvention(Convention.WKT2_2015); // TODO: upgrade to newer version. format.format(crs, out); out.newLine(); } @@ -284,8 +284,8 @@ public abstract class PRJDataStore extends URIDataStore { public static final ParameterDescriptor<CoordinateReferenceSystem> DEFAULT_CRS; static { final ParameterBuilder builder = new ParameterBuilder(); - DEFAULT_CRS = builder.addName(CRS_NAME).setDescription( - Vocabulary.formatInternational(Vocabulary.Keys.CoordinateRefSys)) + DEFAULT_CRS = builder.addName(CRS_NAME) + .setDescription(Vocabulary.formatInternational(Vocabulary.Keys.CoordinateRefSys)) .create(CoordinateReferenceSystem.class, null); } diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/WritableStoreTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/WritableStoreTest.java index 88c66a1833..cbbbf4151e 100644 --- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/WritableStoreTest.java +++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/esri/WritableStoreTest.java @@ -128,7 +128,7 @@ public final class WritableStoreTest extends TestCase { final Path file = Files.createTempFile(null, ".asc"); try { final Path filePRJ = toPRJ(file); - final StorageConnector sc = new StorageConnector(file); + final var sc = new StorageConnector(file); sc.setOption(OptionKey.OPEN_OPTIONS, new StandardOpenOption[] {StandardOpenOption.WRITE}); boolean deleted; try (WritableStore store = new WritableStore(null, sc)) {
