You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/06/22 20:53:45 UTC
[sis] 01/01: Merge branch 'geoapi-3.1' The changes are
simplifications enabled by https://issues.apache.org/jira/browse/SIS-463
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 566157133d9e7e0795bbc9131b8e9080aa255519
Merge: a977d2a e270be9
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sat Jun 22 16:03:25 2019 +0200
Merge branch 'geoapi-3.1'
The changes are simplifications enabled by https://issues.apache.org/jira/browse/SIS-463
.../org/apache/sis/gui/dataset/ResourceTree.java | 4 +-
.../org/apache/sis/coverage/grid/GridExtent.java | 2 +-
.../apache/sis/internal/metadata/Identifiers.java | 273 +++++++++++
.../sis/internal/metadata/NameToIdentifier.java | 14 +
.../sis/internal/metadata/ReferencingServices.java | 384 +--------------
.../sis/internal/metadata/ServicesForUtility.java | 13 +
.../internal/simple/SimpleIdentifiedObject.java | 8 +-
.../sis/internal/simple/SimpleIdentifier.java | 5 +-
.../sis/metadata/iso/citation/Citations.java | 235 ++++++++-
.../metadata/iso/extent/DefaultVerticalExtent.java | 4 +-
.../iso/identification/DefaultCoupledResource.java | 6 +-
.../apache/sis/metadata/sql/MetadataWriter.java | 4 +-
.../org/apache/sis/util/iso/DefaultNameSpace.java | 3 +-
.../sis/internal/metadata/IdentifiersTest.java | 114 +++++
.../sis/metadata/iso/citation/CitationsTest.java | 31 +-
.../apache/sis/test/suite/MetadataTestSuite.java | 3 +-
.../sis/geometry/AbstractDirectPosition.java | 2 +-
.../apache/sis/internal/jaxb/referencing/Code.java | 3 +-
.../sis/internal/referencing}/AxisDirections.java | 5 +-
.../internal/referencing/CoordinateOperations.java | 101 +++-
.../internal/referencing/DefinitionVerifier.java | 4 +-
.../referencing}/EllipsoidalHeightCombiner.java | 74 ++-
.../referencing/GeodeticObjectBuilder.java | 9 +-
.../referencing/ReferencingFactoryContainer.java | 131 ++++-
.../internal/referencing/ReferencingUtilities.java | 19 +-
.../internal/referencing/ServicesForMetadata.java | 387 +++------------
.../internal/referencing}/VerticalDatumTypes.java | 2 +-
.../sis/internal/referencing}/WKTKeywords.java | 2 +-
.../sis/internal/referencing/WKTUtilities.java | 36 ++
.../internal/referencing/WraparoundAdjustment.java | 1 -
.../referencing/provider/GeocentricAffine.java | 2 +-
.../referencing/provider/Geographic3Dto2D.java | 2 +-
.../main/java/org/apache/sis/io/wkt/Element.java | 2 +-
.../main/java/org/apache/sis/io/wkt/Formatter.java | 20 +-
.../apache/sis/io/wkt/GeodeticObjectParser.java | 180 ++++---
.../org/apache/sis/io/wkt/MathTransformParser.java | 32 +-
.../java/org/apache/sis/io/wkt/Transliterator.java | 4 +-
.../main/java/org/apache/sis/io/wkt/WKTFormat.java | 29 +-
.../sis/metadata/iso/ImmutableIdentifier.java | 8 +-
.../sis/parameter/AbstractParameterDescriptor.java | 2 +-
.../sis/parameter/DefaultParameterValue.java | 2 +-
.../apache/sis/parameter/ParameterTableRow.java | 2 +-
.../org/apache/sis/parameter/TensorValues.java | 2 +-
.../main/java/org/apache/sis/referencing/CRS.java | 14 +-
.../sis/referencing/EPSGFactoryFallback.java | 3 +-
.../referencing/EllipsoidalHeightSeparator.java | 6 +-
.../apache/sis/referencing/IdentifiedObjects.java | 29 +-
.../sis/referencing/crs/AbstractDerivedCRS.java | 4 +-
.../sis/referencing/crs/DefaultCompoundCRS.java | 2 +-
.../sis/referencing/crs/DefaultDerivedCRS.java | 2 +-
.../sis/referencing/crs/DefaultEngineeringCRS.java | 2 +-
.../sis/referencing/crs/DefaultGeodeticCRS.java | 4 +-
.../sis/referencing/crs/DefaultImageCRS.java | 2 +-
.../sis/referencing/crs/DefaultParametricCRS.java | 2 +-
.../sis/referencing/crs/DefaultProjectedCRS.java | 4 +-
.../sis/referencing/crs/DefaultTemporalCRS.java | 2 +-
.../sis/referencing/crs/DefaultVerticalCRS.java | 2 +-
.../org/apache/sis/referencing/cs/AbstractCS.java | 4 +-
.../apache/sis/referencing/cs/AxesConvention.java | 2 +-
.../sis/referencing/cs/CoordinateSystems.java | 2 +-
.../apache/sis/referencing/cs/DefaultAffineCS.java | 2 +-
.../sis/referencing/cs/DefaultCompoundCS.java | 2 +-
.../cs/DefaultCoordinateSystemAxis.java | 4 +-
.../sis/referencing/cs/DefaultCylindricalCS.java | 2 +-
.../sis/referencing/cs/DefaultEllipsoidalCS.java | 2 +-
.../apache/sis/referencing/cs/DefaultLinearCS.java | 2 +-
.../apache/sis/referencing/cs/DefaultPolarCS.java | 2 +-
.../sis/referencing/cs/DefaultSphericalCS.java | 2 +-
.../apache/sis/referencing/cs/DefaultTimeCS.java | 2 +-
.../sis/referencing/cs/DefaultVerticalCS.java | 2 +-
.../sis/referencing/cs/DirectionAlongMeridian.java | 4 +-
.../org/apache/sis/referencing/cs/Normalizer.java | 2 +-
.../sis/referencing/datum/AbstractDatum.java | 3 +-
.../sis/referencing/datum/BursaWolfParameters.java | 2 +-
.../sis/referencing/datum/DefaultEllipsoid.java | 2 +-
.../referencing/datum/DefaultEngineeringDatum.java | 2 +-
.../referencing/datum/DefaultGeodeticDatum.java | 6 +-
.../sis/referencing/datum/DefaultImageDatum.java | 2 +-
.../referencing/datum/DefaultParametricDatum.java | 2 +-
.../referencing/datum/DefaultPrimeMeridian.java | 2 +-
.../referencing/datum/DefaultTemporalDatum.java | 2 +-
.../referencing/datum/DefaultVerticalDatum.java | 4 +-
.../factory/AuthorityFactoryIdentifier.java | 6 +-
.../factory/CommonAuthorityFactory.java | 5 +-
.../factory/GeodeticAuthorityFactory.java | 14 +-
.../referencing/factory/GeodeticObjectFactory.java | 4 +-
.../factory/IdentifiedObjectFinder.java | 4 +-
.../factory/MultiAuthoritiesFactory.java | 12 +-
.../referencing/factory/sql/EPSGDataAccess.java | 24 +-
.../sis/referencing/factory/sql/TableInfo.java | 2 +-
.../operation/AbstractCoordinateOperation.java | 2 +-
.../operation/AbstractSingleOperation.java | 4 +-
.../referencing/operation/CompoundCRSBuilder.java | 57 ---
.../operation/CoordinateOperationFinder.java | 7 +-
.../operation/CoordinateOperationRegistry.java | 14 +-
.../DefaultCoordinateOperationFactory.java | 25 +-
.../sis/referencing/operation/DefaultFormula.java | 2 +-
.../operation/DefaultOperationMethod.java | 6 +-
.../operation/InverseOperationMethod.java | 4 +-
.../sis/referencing/operation/matrix/Matrices.java | 2 +-
.../operation/projection/NormalizedProjection.java | 5 +-
.../operation/transform/AbstractMathTransform.java | 2 +-
.../operation/transform/ConcatenatedTransform.java | 2 +-
.../operation/transform/ContextualParameters.java | 2 +-
.../transform/DefaultMathTransformFactory.java | 5 +-
.../operation/transform/PassThroughTransform.java | 2 +-
.../AxisDirectionsTest.java | 8 +-
.../EllipsoidalHeightCombinerTest.java | 13 +-
.../referencing}/VerticalDatumTypesTest.java | 2 +-
.../sis/internal/referencing}/WKTKeywordsTest.java | 2 +-
.../sis/internal/referencing/WKTUtilitiesTest.java | 1 -
.../sis/io/wkt/GeodeticObjectParserTest.java | 4 +-
.../org/apache/sis/referencing/CommonCRSTest.java | 2 +-
.../sis/referencing/crs/DefaultDerivedCRSTest.java | 2 +-
.../sis/referencing/cs/DefaultCompoundCSTest.java | 2 +-
.../referencing/cs/DefaultCylindricalCSTest.java | 2 +-
.../sis/referencing/cs/DefaultPolarCSTest.java | 2 +-
.../sis/referencing/cs/DefaultSphericalCSTest.java | 2 +-
.../referencing/cs/DirectionAlongMeridianTest.java | 2 +-
.../apache/sis/referencing/cs/HardCodedAxes.java | 2 +-
.../datum/DefaultVerticalDatumTest.java | 2 +-
.../sis/referencing/datum/HardCodedDatum.java | 2 +-
.../operation/DefaultConversionTest.java | 4 +-
.../operation/DefaultTransformationTest.java | 4 +-
.../org/apache/sis/test/ReferencingAssert.java | 5 +-
.../sis/test/suite/ReferencingTestSuite.java | 6 +-
.../org/apache/sis/internal/util/Citations.java | 542 ---------------------
.../apache/sis/internal/util/CollectionsExt.java | 22 +
.../org/apache/sis/internal/util/Constants.java | 8 +
.../apache/sis/internal/util/MetadataServices.java | 12 +
.../org/apache/sis/io/IdentifiedObjectFormat.java | 7 +-
.../java/org/apache/sis/measure/UnitFormat.java | 3 +-
.../org/apache/sis/internal/util/CitationMock.java | 101 ----
.../apache/sis/internal/util/CitationsTest.java | 123 -----
.../apache/sis/test/suite/UtilityTestSuite.java | 1 -
.../java/org/apache/sis/storage/gdal/Proj4.java | 2 +-
.../org/apache/sis/storage/gdal/Proj4Factory.java | 20 +-
.../org/apache/sis/storage/geotiff/CRSBuilder.java | 7 +-
.../java/org/apache/sis/internal/netcdf/Axis.java | 2 +-
.../java/org/apache/sis/internal/netcdf/Grid.java | 2 +-
.../apache/sis/internal/netcdf/GridMapping.java | 2 +-
.../sis/internal/netcdf/impl/ChannelDecoder.java | 4 +-
.../apache/sis/internal/netcdf/impl/GridInfo.java | 2 +-
.../apache/sis/storage/netcdf/MetadataReader.java | 2 +-
.../sis/internal/storage/StoreUtilities.java | 6 +-
.../sis/internal/storage/wkt/StoreProvider.java | 2 +-
146 files changed, 1460 insertions(+), 1998 deletions(-)
diff --cc core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
index 0000000,6678f99..17f885b
mode 000000,100644..100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
@@@ -1,0 -1,269 +1,273 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.sis.internal.metadata;
+
+ import java.util.Locale;
+ import java.util.Iterator;
+ import org.opengis.metadata.Identifier;
+ import org.opengis.metadata.citation.Citation;
++import org.opengis.referencing.ReferenceIdentifier;
+ import org.opengis.util.InternationalString;
+ import org.apache.sis.internal.util.Constants;
+ import org.apache.sis.internal.util.CollectionsExt;
+ import org.apache.sis.metadata.iso.citation.Citations;
+ import org.apache.sis.util.CharSequences;
+ import org.apache.sis.util.Characters;
+ import org.apache.sis.util.Deprecable;
+ import org.apache.sis.util.Static;
+
+
+ /**
+ * Methods working on {@link Identifier} instances.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 1.0
+ * @versio 1.0
+ * @module
+ */
+ public final class Identifiers extends Static {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private Identifiers() {
+ }
+
+ /**
+ * Returns {@code true} if the given code is {@code "EPSG"} while the codespace is {@code "IOGP"} or {@code "OGP"}
+ * (ignoring case). This particular combination of code and codespace is handled in a special way.
+ *
+ * <p>This method can be used for identifying where in Apache SIS source code the relationship between
+ * EPSG authority and IOGP code space is hard-coded.</p>
+ *
+ * @param codeSpace the identifier code space, or {@code null}.
+ * @param code the identifier code, or {@code null}.
+ * @return {@code true} if the given identifier is {@code "IOGP:EPSG"}.
+ *
+ * @see org.apache.sis.metadata.iso.citation.Citations#EPSG
+ */
+ public static boolean isEPSG(final String codeSpace, final String code) {
+ return Constants.EPSG.equalsIgnoreCase(code) &&
+ (Constants.IOGP.equalsIgnoreCase(codeSpace) || "OGP".equalsIgnoreCase(codeSpace) ||
+ Constants.EPSG.equalsIgnoreCase(codeSpace));
+ // "OGP" is a legacy abbreviation that existed before "IOGP".
+ }
+
+ /**
+ * Return {@code true} if the given object is deprecated.
+ */
+ private static boolean isDeprecated(final Object object) {
+ return (object instanceof Deprecable) && ((Deprecable) object).isDeprecated();
+ }
+
+ /**
+ * Returns a "unlocalized" string representation of the given international string, or {@code null} if none
+ * or if the string is deprecated. This method is used by {@link #getIdentifier(Citation, boolean)}, which
+ * is why we don't want the localized string.
+ */
+ private static String toString(final InternationalString title) {
+ return (title != null && !isDeprecated(title))
+ ? CharSequences.trimWhitespaces(title.toString(Locale.ROOT)) : null;
+ }
+
+ /**
+ * Infers an identifier from the given citation, or returns {@code null} if no identifier has been found.
+ * This method removes leading and trailing {@linkplain Character#isWhitespace(int) whitespaces}.
+ * See {@link Citations#getIdentifier(Citation)} for the public documentation of this method.
+ *
+ * <p><b>Which method to use:</b></p>
+ * <ul>
+ * <li>For information purpose (e.g. some {@code toString()} methods), use {@code getIdentifier(…, false)}.</li>
+ * <li>For WKT formatting, use {@code getIdentifier(…, true)} in order to preserve formatting characters.</li>
+ * <li>For assigning a value to a {@code codeSpace} field, use {@link Citations#getUnicodeIdentifier(Citation)}.</li>
+ * </ul>
+ *
+ * Use {@code getUnicodeIdentifier(…)} 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
+ * for formatting purpose.
+ *
+ * @param citation the citation for which to get the identifier, or {@code null}.
+ * @param strict {@code true} for returning a non-null value only if the identifier is a valid Unicode identifier.
+ * @return a non-empty identifier for the given citation without leading or trailing whitespaces,
+ * or {@code null} if the given citation is null or does not declare any identifier or title.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-201">SIS-201</a>
+ */
+ public static String getIdentifier(final Citation citation, final boolean strict) {
+ if (citation != null) {
+ boolean isUnicode = false; // Whether 'identifier' is a Unicode identifier.
+ String identifier = null; // The best identifier found so far.
+ String codeSpace = null; // Code space of the identifier, or null if none.
+ final Iterator<? extends Identifier> it = CollectionsExt.nonEmptyIterator(citation.getIdentifiers());
+ if (it != null) while (it.hasNext()) {
+ final Identifier id = it.next();
+ if (id != null && !isDeprecated(id)) {
+ final String candidate = CharSequences.trimWhitespaces(id.getCode());
+ if (candidate != null && !candidate.isEmpty()) {
+ /*
+ * For a non-empty identifier, verify if both the code and its codespace are valid
+ * 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").
+ */
- String cs = CharSequences.trimWhitespaces(id.getCodeSpace());
++ String cs = null;
++ if (id instanceof ReferenceIdentifier) {
++ cs = CharSequences.trimWhitespaces(((ReferenceIdentifier) id).getCodeSpace());
++ }
+ if (cs == null || cs.isEmpty()) {
+ cs = null;
+ isUnicode = CharSequences.isUnicodeIdentifier(candidate);
+ } else {
+ isUnicode = CharSequences.isUnicodeIdentifier(cs);
+ if (isUnicode) for (int i = 0; i < candidate.length();) {
+ final int c = candidate.codePointAt(i);
+ if (!Character.isUnicodeIdentifierPart(c) &&
+ (strict || (c != '.' && c != '-')))
+ {
+ /*
+ * Above special case for '.' and '-' characters is documented
+ * in the public Citations.getIdentifier(Citation) method.
+ */
+ isUnicode = false;
+ break;
+ }
+ i += Character.charCount(c);
+ }
+ }
+ /*
+ * If we found a Unicode identifier, we are done and we can exit the loop.
+ * Otherwise retain the first identifier and continue the search for Unicode identifier.
+ */
+ if (identifier == null || isUnicode) {
+ identifier = candidate;
+ codeSpace = cs;
+ if (isUnicode) break;
+ }
+ }
+ }
+ }
+ /*
+ * If no identifier has been found, fallback on the first title or alternate title.
+ * We search for alternate titles because ISO specification said that those titles
+ * are often used for abbreviations. Again we give preference to Unicode identifiers,
+ * which are typically alternate titles.
+ */
+ if (identifier == null) {
+ identifier = toString(citation.getTitle()); // Whitepaces removed by toString(…).
+ if (identifier != null) {
+ if (identifier.isEmpty()) {
+ identifier = null;
+ } else {
+ isUnicode = CharSequences.isUnicodeIdentifier(identifier);
+ }
+ }
+ if (!isUnicode) {
+ final Iterator<? extends InternationalString> iterator = CollectionsExt.nonEmptyIterator(citation.getAlternateTitles());
+ if (iterator != null) while (iterator.hasNext()) {
+ final String candidate = toString(iterator.next());
+ if (candidate != null && !candidate.isEmpty()) {
+ isUnicode = CharSequences.isUnicodeIdentifier(candidate);
+ if (identifier == null || isUnicode) {
+ identifier = candidate;
+ if (isUnicode) break;
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Finished searching in the identifiers, title and alternate titles. If the identifier that
+ * we found is not a valid Unicode identifier, we will return it only if the caller did not
+ * asked for strictly valid Unicode identifier.
+ */
+ if (isUnicode || !strict) {
+ if (codeSpace != null && !isEPSG(codeSpace, identifier)) {
+ return codeSpace + (strict ? '_' : Constants.DEFAULT_SEPARATOR) + identifier;
+ } else {
+ return identifier;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns {@code true} if the given identifier authority matches the given {@code authority}.
+ * If one of the authority is null, then the comparison fallback on the given {@code codeSpace}.
+ * If the code spaces are also null, then this method conservatively returns {@code false}.
+ *
+ * @param identifier the identifier to compare.
+ * @param authority the desired authority, or {@code null}.
+ * @param codeSpace the desired code space or {@code null}, used as a fallback if an authority is null.
+ * @return {@code true} if the authority or code space (as a fallback only) matches.
+ */
+ private static boolean authorityMatches(final Identifier identifier, final Citation authority, final String codeSpace) {
+ if (authority != null) {
+ final Citation other = identifier.getAuthority();
+ if (other != null) {
+ 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);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determines whether a match or mismatch is found between the two given collections of identifiers.
+ * If any of the given collections is {@code null} or empty, then this method returns {@code null}.
+ *
+ * <p>According ISO 19162 (<cite>Well known text representation of coordinate reference systems</cite>),
+ * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getIdentifiers() identifiers} should have precedence over
+ * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() name} for identifying {@code IdentifiedObject}s,
+ * at least in the case of {@linkplain org.apache.sis.referencing.operation.DefaultOperationMethod operation methods} and
+ * {@linkplain org.apache.sis.parameter.AbstractParameterDescriptor parameters}.</p>
+ *
+ * @param id1 the first collection of identifiers, or {@code null}.
+ * @param id2 the second collection of identifiers, or {@code null}.
+ * @return {@code TRUE} or {@code FALSE} on match or mismatch respectively, or {@code null} if this method
+ * can not 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) {
+ if (authorityMatches(identifier, authority, codeSpace)) {
+ if (CharSequences.equalsFiltered(identifier.getCode(), other.getCode(), Characters.Filter.UNICODE_IDENTIFIER, true)) {
+ return Boolean.TRUE;
+ }
+ hasFound = true;
+ }
+ }
+ }
+ if (hasFound) {
+ return Boolean.FALSE;
+ }
+ }
+ return null;
+ }
+ }
diff --cc core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
index 8ba9b50,891b375..31074d2
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
@@@ -20,7 -20,8 +20,8 @@@ import java.text.Format
import java.util.Locale;
import java.util.TimeZone;
import javax.sql.DataSource;
-import org.opengis.util.ControlledVocabulary;
+import org.opengis.util.CodeList;
+ import org.opengis.metadata.citation.Citation;
import org.apache.sis.internal.util.MetadataServices;
import org.apache.sis.internal.metadata.sql.Initializer;
import org.apache.sis.internal.system.Loggers;
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
index 1a2ee0d,5eaf426..9bde5ce
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
@@@ -18,9 -18,16 +18,17 @@@ package org.apache.sis.metadata.iso.cit
import java.util.List;
import java.util.Arrays;
+ import java.util.Objects;
+ import java.util.Iterator;
+ import java.util.Collection;
+ import java.util.Locale;
+ import org.opengis.util.InternationalString;
+ import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.referencing.IdentifiedObject; // For javadoc
++import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.util.Static;
+ import org.apache.sis.util.Characters;
import org.apache.sis.util.CharSequences;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.internal.util.Constants;
@@@ -580,7 -686,66 +687,67 @@@ public final class Citations extends St
* @return {@code true} if both arguments are non-null, and an identifier matches the given string.
*/
public static boolean identifierMatches(final Citation citation, final String identifier) {
- return org.apache.sis.internal.util.Citations.identifierMatches(citation, null, identifier);
+ return identifierMatches(citation, null, identifier);
+ }
+
+ /**
+ * Returns {@code true} if the given citation has at least one identifier equals to the given string,
+ * ignoring case and non-alphanumeric characters. If and <em>only</em> if the citation does not contain
+ * any identifier, then this method fallback on titles comparison.
+ *
+ * @param citation the citation to check for, or {@code null}.
+ * @param identifier the identifier to compare, or {@code null} if unknown.
+ * @param code value of {@code identifier.getCode()}, or {@code null}.
+ * @return {@code true} if both arguments are non-null, and an identifier matches the given string.
+ */
+ static boolean identifierMatches(final Citation citation, final Identifier identifier, final String code) {
+ if (citation != null && code != null) {
+ final Collection<? extends Identifier> citIds = citation.getIdentifiers();
+ Iterator<? extends Identifier> it = nonEmptyIterator(citIds);
+ if (it == null) {
+ return titleMatches(citation, code);
+ }
+ while (it.hasNext()) {
+ final Identifier citId = it.next();
+ if (citId != null && equalsFiltered(code, citId.getCode())) {
+ /*
+ * 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.
+ }
+ }
+ }
+ return true;
+ }
+ }
+ /*
+ * Before to give up, maybe the given code argument is actually written using a "codeSpace:code" syntax.
+ * Try to parse that syntax only if no Identifier argument were specified (otherwise we require the code
+ * and code space to be splitted as defined in the identifier).
+ */
+ if (identifier == null) {
+ int s = 0;
+ final int length = code.length();
+ while ((s = CharSequences.indexOf(code, Constants.DEFAULT_SEPARATOR, s, length)) >= 0) {
+ final CharSequence codeSpace = code.subSequence(0, s);
+ 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;
+ }
+ }
+ }
+ }
+ }
+ return false;
}
/**
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
index cc1f873,990423f..e334a62
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
@@@ -705,11 -706,9 +705,11 @@@ public class MetadataWriter extends Met
for (final Identifier id : identifiers) {
identifier = nonEmpty(id.getCode());
if (identifier != null) {
- final String cs = nonEmpty(id.getCodeSpace());
- if (cs != null) {
- identifier = cs + Constants.DEFAULT_SEPARATOR + identifier;
+ if (id instanceof ReferenceIdentifier) {
+ final String cs = nonEmpty(((ReferenceIdentifier) id).getCodeSpace());
+ if (cs != null) {
- identifier = cs + DefaultNameSpace.DEFAULT_SEPARATOR + identifier;
++ identifier = cs + Constants.DEFAULT_SEPARATOR + identifier;
+ }
}
break;
}
diff --cc core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/IdentifiersTest.java
index 0000000,38dfb93..2f43a2a
mode 000000,100644..100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/IdentifiersTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/IdentifiersTest.java
@@@ -1,0 -1,106 +1,114 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.sis.internal.metadata;
+
+ import java.util.List;
+ import java.util.Arrays;
+ import java.util.ArrayList;
+ import org.opengis.metadata.Identifier;
++import org.opengis.referencing.ReferenceIdentifier;
+ import org.apache.sis.metadata.iso.DefaultIdentifier;
+ import org.apache.sis.metadata.iso.citation.DefaultCitation;
+ import org.apache.sis.test.TestCase;
+ import org.junit.Test;
+
+ import static org.junit.Assert.*;
+
+
+ /**
+ * Tests {@link Identifiers}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 1.0
+ * @versio 1.0
+ * @module
+ */
+ public final strictfp class IdentifiersTest extends TestCase {
+ /**
+ * Creates a citation with the given title and the given identifiers.
+ */
+ private static DefaultCitation citation(final String title, final Identifier... identifiers) {
+ DefaultCitation cit = new DefaultCitation(title);
+ cit.setIdentifiers(Arrays.asList(identifiers));
+ return cit;
+ }
+
+ /**
+ * 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);
++ }
+ }
+
+ /**
+ * Tests {@link Identifiers#hasCommonIdentifier(Iterable, Iterable)}.
+ */
+ @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:
+ *
+ * - EPSG:9804 — "Mercator (variant A)" (formerly known as "Mercator (1SP)").
+ * - EPSG:1026 — "Mercator (Spherical)"
+ * - GeoTIFF:7 — "CT_Mercator"
+ */
+ id1.add(identifier("EPSG", "9804"));
+ id1.add(identifier("EPSG", "1026"));
+ id1.add(identifier("GeoTIFF", "7"));
+ assertNull(Identifiers.hasCommonIdentifier(id1, id2));
+ /*
+ * EPSG:9841 is a legacy (now deprecated) code for "Mercator (1SP)".
+ * We could have declared it as a deprecated code in the above list,
+ * but for the sake of this test we do not.
+ */
+ id2.add(identifier("EPSG", "9841"));
+ assertEquals(Boolean.FALSE, Identifiers.hasCommonIdentifier(id1, id2));
+ id2.add(identifier("EPSG", "9804"));
+ assertEquals(Boolean.TRUE, Identifiers.hasCommonIdentifier(id1, id2));
+ }
+
+ /**
+ * Tests {@link Identifiers#getIdentifier(Citation, boolean)}.
+ */
+ @Test
+ public void testGetIdentifier() {
+ DefaultCitation citation = new DefaultCitation(" Not an identifier ");
+ assertEquals("Not an identifier", Identifiers.getIdentifier(citation, false));
+ assertNull(Identifiers.getIdentifier(citation, true));
+
+ citation = new DefaultCitation(" ValidIdentifier ");
+ assertEquals("ValidIdentifier", Identifiers.getIdentifier(citation, false));
+ assertEquals("ValidIdentifier", Identifiers.getIdentifier(citation, true));
+ /*
+ * Following test uses '-' in the first identifier, which is an invalid Unicode identifier part.
+ * Consequently the identifier that we get depends on whether we ask for strict Unicode or not.
+ */
+ citation = citation("Web Map Server", identifier("OGC", "06-042"), identifier("ISO", "19128"));
+ assertEquals("OGC:06-042", Identifiers.getIdentifier(citation, false));
+ assertEquals("ISO_19128", Identifiers.getIdentifier(citation, true));
+ }
+ }
diff --cc core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
index e002c55,513862c..9e31c3c
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
@@@ -22,9 -24,9 +24,10 @@@ import java.util.Collection
import java.util.Collections;
import java.util.IdentityHashMap;
import java.lang.reflect.Field;
- import java.util.Collection;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
++import org.opengis.referencing.ReferenceIdentifier;
+ import org.apache.sis.metadata.iso.DefaultIdentifier;
import org.apache.sis.internal.simple.CitationConstant;
import org.apache.sis.internal.simple.SimpleCitation;
import org.apache.sis.internal.util.Constants;
@@@ -279,4 -280,23 +282,30 @@@ public final strictfp class CitationsTe
}
}
}
+
+ /**
+ * Tests {@link Citations#identifierMatches(Citation, Identifier, String)}.
+ */
+ @Test
+ public void testIdentifierMatches() {
- final Identifier ogc = new DefaultIdentifier("OGC", "06-042", null);
- final Identifier iso = new DefaultIdentifier("ISO", "19128", null);
++ final Identifier ogc = new Id("OGC", "06-042");
++ final Identifier iso = new Id("ISO", "19128");
+ final DefaultCitation citation = new DefaultCitation("Web Map Server");
+ citation.setIdentifiers(Arrays.asList(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 code space", Citations.identifierMatches(citation, new DefaultIdentifier("Foo", "19128", null), "19128"));
++ assertFalse("With wrong code", Citations.identifierMatches(citation, new Id("ISO", "19115"), "19115"));
++ assertFalse("With wrong code space", 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 code space", 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 --cc core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingFactoryContainer.java
index 50aa659,78560bc..c27fd14
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingFactoryContainer.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingFactoryContainer.java
@@@ -25,15 -27,14 +27,17 @@@ import org.opengis.referencing.crs.CRSA
import org.opengis.referencing.datum.DatumFactory;
import org.opengis.referencing.datum.DatumAuthorityFactory;
import org.opengis.referencing.operation.MathTransformFactory;
+ import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.operation.CoordinateOperationAuthorityFactory;
import org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException;
+ import org.apache.sis.referencing.CRS;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.Constants;
- import org.apache.sis.referencing.CRS;
+ import org.apache.sis.util.resources.Errors;
+// Branch-dependent imports
+import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
+
/**
* A container of factories frequently used together.
@@@ -96,6 -125,95 +128,95 @@@ public class ReferencingFactoryContaine
}
/**
+ * Creates a new instance which will use the given factories.
+ * Any factory given in argument may be {@code null} if lazy instantiation is desired.
+ *
+ * @param defaultProperties default properties to give to the objects to create (will not be cloned).
+ * @param crsFactory the factory to use for creating coordinate reference systems.
+ * @param csFactory the factory to use for creating coordinate systems.
+ * @param datumFactory the factory to use for creating datum.
+ * @param operationFactory the factory to use for creating (defining) conversions.
+ * @param mtFactory the factory to use for creating transform objects.
+ */
+ public ReferencingFactoryContainer(final Map<String,?> defaultProperties,
+ final CRSFactory crsFactory,
+ final CSFactory csFactory,
+ final DatumFactory datumFactory,
+ final CoordinateOperationFactory operationFactory,
+ final MathTransformFactory mtFactory)
+ {
+ this.defaultProperties = defaultProperties;
+ 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;
+ }
+
+ /**
+ * Sets one of the factories managed by this container.
+ * The given {@code type} argument can be one of the following values:
+ *
+ * <ul>
+ * <li><code>{@linkplain CRSFactory}.class</code></li>
+ * <li><code>{@linkplain CSFactory}.class</code></li>
+ * <li><code>{@linkplain DatumFactory}.class</code></li>
+ * <li><code>{@linkplain CoordinateOperationFactory}.class</code></li>
+ * <li><code>{@linkplain MathTransformFactory}.class</code></li>
+ * </ul>
+ *
+ * Note that authority factories are not yet handled by this method
+ * for consistency with {@link #getFactory(Class)}.
+ *
+ * @param <T> the compile-time type of the {@code type} argument.
+ * @param type the factory type.
+ * @param factory the factory to use for the given type, or {@code null} for the default.
+ * @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) {
+ if (type == CRSFactory.class) return crsFactory != (crsFactory = (CRSFactory) factory);
+ if (type == CSFactory.class) return csFactory != (csFactory = (CSFactory) factory);
+ if (type == DatumFactory.class) return datumFactory != (datumFactory = (DatumFactory) 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.format(Errors.Keys.IllegalArgumentValue_2, "type", type));
+ }
+
+ /**
+ * Returns one of the factories managed by this container.
+ * The given {@code type} argument can be one of the following values:
+ *
+ * <ul>
+ * <li><code>{@linkplain CRSFactory}.class</code></li>
+ * <li><code>{@linkplain CSFactory}.class</code></li>
+ * <li><code>{@linkplain DatumFactory}.class</code></li>
+ * <li><code>{@linkplain CoordinateOperationFactory}.class</code></li>
+ * <li><code>{@linkplain MathTransformFactory}.class</code></li>
+ * </ul>
+ *
+ * Note that authority factories are not yet handled by this method, since we would have to expose
+ * the current restriction to EPSG geodetic dataset and to handle {@link FactoryException}.
+ *
+ * @param <T> the compile-time type of the {@code type} argument.
+ * @param type the factory type.
+ * @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;
+ if (type == CRSFactory.class) f = getCRSFactory();
+ else if (type == CSFactory.class) f = getCSFactory();
+ else if (type == DatumFactory.class) f = getDatumFactory();
+ else if (type == CoordinateOperationFactory.class) f = getCoordinateOperationFactory();
+ else if (type == MathTransformFactory.class) f = getMathTransformFactory();
+ else {
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2, "type", type));
+ }
+ return type.cast(f);
+ }
+
+ /**
* Returns the factory for creating coordinate reference systems from authority codes.
* Currently only EPSG codes are supported.
*
@@@ -197,9 -315,10 +318,15 @@@
*
* @return the Coordinate Operation factory (never {@code null}).
*/
- public final CoordinateOperationFactory getCoordinateOperationFactory() {
+ public final DefaultCoordinateOperationFactory getCoordinateOperationFactory() {
if (operationFactory == null) {
- operationFactory = CoordinateOperations.factory();
- 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 = CoordinateOperations.factory();
++ }
}
return operationFactory;
}
diff --cc core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
index 3a9f601,289ff48..6f4beff
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
@@@ -16,44 -16,26 +16,36 @@@
*/
package org.apache.sis.internal.referencing;
+import java.util.Map;
- import java.util.HashMap;
import java.util.Iterator;
import java.util.Collection;
- import java.util.Collections;
import java.util.Locale;
import java.util.TimeZone;
import java.text.Format;
import org.opengis.util.FactoryException;
import org.opengis.util.InternationalString;
++import org.opengis.util.NoSuchIdentifierException;
import org.opengis.parameter.ParameterDescriptor;
- import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.IdentifiedObject;
++import org.opengis.referencing.datum.Datum;
++import org.opengis.referencing.datum.DatumFactory;
import org.opengis.referencing.crs.SingleCRS;
- import org.opengis.referencing.crs.DerivedCRS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.CRSFactory;
+import org.opengis.referencing.cs.CSFactory;
- import org.opengis.referencing.cs.AxisDirection;
- import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
- import org.opengis.referencing.datum.PrimeMeridian;
- import org.opengis.referencing.operation.Matrix;
- import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.OperationMethod;
+import org.opengis.referencing.operation.SingleOperation;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.CoordinateOperationFactory;
-import org.opengis.metadata.Identifier;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.OnLineFunction;
import org.opengis.metadata.citation.OnlineResource;
@@@ -67,53 -49,27 +59,36 @@@ import org.apache.sis.geometry.Envelope
import org.apache.sis.geometry.AbstractEnvelope;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.geometry.CoordinateFormat;
++import org.apache.sis.internal.metadata.NameToIdentifier;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.IdentifiedObjects;
- import org.apache.sis.referencing.AbstractIdentifiedObject;
- import org.apache.sis.referencing.cs.AbstractCS;
- import org.apache.sis.referencing.cs.CoordinateSystems;
- import org.apache.sis.referencing.crs.DefaultDerivedCRS;
++import org.apache.sis.referencing.cs.DefaultParametricCS;
import org.apache.sis.referencing.crs.DefaultTemporalCRS;
- import org.apache.sis.referencing.datum.BursaWolfParameters;
- import org.apache.sis.referencing.operation.transform.MathTransforms;
++import org.apache.sis.referencing.datum.DefaultParametricDatum;
+import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
++import org.apache.sis.referencing.factory.GeodeticObjectFactory;
++import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.parameter.DefaultParameterDescriptor;
- import org.apache.sis.parameter.Parameterized;
- import org.apache.sis.io.wkt.Formatter;
- import org.apache.sis.io.wkt.FormattableObject;
- import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.metadata.iso.extent.DefaultExtent;
import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
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.iso.citation.DefaultCitation;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Longitude;
- import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.internal.metadata.ReferencingServices;
- import org.apache.sis.internal.referencing.provider.Affine;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.TemporalUtilities;
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.Logging;
++import org.apache.sis.util.Deprecable;
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.Utilities;
- import org.apache.sis.util.iso.DefaultNameSpace;
-
- // Branch-dependent imports
- import org.apache.sis.metadata.iso.citation.DefaultCitation;
- import org.apache.sis.referencing.factory.GeodeticObjectFactory;
- import org.apache.sis.referencing.cs.DefaultParametricCS;
- import org.apache.sis.referencing.datum.DefaultParametricDatum;
- import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
- import org.opengis.referencing.datum.Datum;
- import org.opengis.referencing.datum.DatumFactory;
/**
@@@ -535,222 -491,6 +510,86 @@@ public final class ServicesForMetadata
}
/**
- * Converts the given object in a {@code FormattableObject} instance.
- *
- * @param object the object to wrap.
- * @return the given object converted to a {@code FormattableObject} instance.
- */
- public static FormattableObject toFormattableObject(final IdentifiedObject object) {
- return AbstractIdentifiedObject.castOrCopy(object);
- }
-
- /**
- * Converts the given object in a {@code FormattableObject} instance. Callers should verify that the given
- * object is not already an instance of {@code FormattableObject} before to invoke this method. This method
- * returns {@code null} if it can not convert the object.
- *
- * @param object the object to wrap.
- * @param internal {@code true} if the formatting convention is {@code Convention.INTERNAL}.
- * @return the given object converted to a {@code FormattableObject} instance, or {@code null}.
- *
- * @since 0.6
- */
- public static FormattableObject toFormattableObject(final MathTransform object, boolean internal) {
- Matrix matrix;
- final ParameterValueGroup parameters;
- if (internal && (matrix = MathTransforms.getMatrix(object)) != null) {
- parameters = Affine.parameters(matrix);
- } else if (object instanceof Parameterized) {
- parameters = ((Parameterized) object).getParameterValues();
- } else {
- matrix = MathTransforms.getMatrix(object);
- if (matrix == null) {
- return null;
- }
- parameters = Affine.parameters(matrix);
- }
- return new FormattableObject() {
- @Override
- protected String formatTo(final Formatter formatter) {
- WKTUtilities.appendParamMT(parameters, formatter);
- return WKTKeywords.Param_MT;
- }
- };
- }
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- //// ////
- //// SERVICES FOR WKT PARSING ////
- //// ////
- ///////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Returns a coordinate reference system for heights above the mean seal level.
- *
- * @return the "Mean Seal Level (MSL) height" coordinate reference system.
- *
- * @since 0.6
- */
- @Override
- public VerticalCRS getMSLH() {
- return CommonCRS.Vertical.MEAN_SEA_LEVEL.crs();
- }
-
- /**
- * Returns the Greenwich prime meridian.
- *
- * @return the Greenwich prime meridian.
- *
- * @since 0.6
- */
- @Override
- public PrimeMeridian getGreenwich() {
- return CommonCRS.WGS84.primeMeridian();
- }
-
- /**
- * Returns the coordinate system of a geocentric CRS using axes in the given unit of measurement.
- *
- * @param linearUnit the unit of measurement for the geocentric CRS axes.
- * @return the coordinate system for a geocentric CRS with axes using the given unit of measurement.
- *
- * @since 0.6
- */
- @Override
- public CartesianCS getGeocentricCS(final Unit<Length> linearUnit) {
- return Legacy.standard(linearUnit);
- }
-
- /**
- * Converts a geocentric coordinate system from the legacy WKT 1 to the current ISO 19111 standard.
- * This method replaces the (Other, East, North) directions by (Geocentric X, Geocentric Y, Geocentric Z).
- *
- * @param cs the geocentric coordinate system to upgrade.
- * @return the upgraded coordinate system, or {@code cs} if there is no change to apply.
- *
- * @since 0.6
- */
- @Override
- public CartesianCS upgradeGeocentricCS(final CartesianCS cs) {
- return Legacy.forGeocentricCRS(cs, false);
- }
-
- /**
- * Creates a coordinate system of unknown type. This method is used during parsing of WKT version 1,
- * since that legacy format did not specified any information about the coordinate system in use.
- * This method should not need to be invoked for parsing WKT version 2.
- *
- * @param properties the coordinate system name, and optionally other properties.
- * @param axes the axes of the unknown coordinate system.
- * @return an "abstract" coordinate system using the given axes.
- *
- * @since 0.6
- */
- @Override
- public CoordinateSystem createAbstractCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
- return new AbstractCS(properties, axes);
- }
-
- /**
+ * 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.
+ *
+ * @since 0.7
+ */
- @Override
- public CoordinateSystem createParametricCS(final Map<String,?> properties, final CoordinateSystemAxis axis,
++ public static CoordinateSystem createParametricCS(final Map<String,?> properties, final CoordinateSystemAxis axis,
+ CSFactory factory) throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = DefaultFactories.forBuildin(CSFactory.class, GeodeticObjectFactory.class);
+ }
+ 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.
+ *
+ * @since 0.7
+ */
- @Override
- public Datum createParametricDatum(final Map<String,?> properties, DatumFactory factory)
++ public static Datum createParametricDatum(final Map<String,?> properties, DatumFactory factory)
+ throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = DefaultFactories.forBuildin(DatumFactory.class, GeodeticObjectFactory.class);
+ }
+ 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.
+ *
+ * @since 0.7
+ */
- @Override
- public SingleCRS createParametricCRS(final Map<String,?> properties, final Datum datum,
++ public static SingleCRS createParametricCRS(final Map<String,?> properties, final Datum datum,
+ final CoordinateSystem cs, CRSFactory factory) throws FactoryException
+ {
+ if (!(factory instanceof GeodeticObjectFactory)) {
+ factory = DefaultFactories.forBuildin(CRSFactory.class, GeodeticObjectFactory.class);
+ }
+ try {
+ return ((GeodeticObjectFactory) factory).createParametricCRS(properties,
+ (DefaultParametricDatum) datum, (DefaultParametricCS) cs);
+ } catch (ClassCastException e) {
+ throw new InvalidGeodeticParameterException(e.toString(), e);
+ }
+ }
+
+ /**
- * Creates a derived CRS from the information found in a WKT 1 {@code FITTED_CS} element.
- * This coordinate system can not be easily constructed from the information provided by the WKT 1 format.
- * Note that this method is needed only for WKT 1 parsing, since WKT provides enough information for using
- * the standard factories.
- *
- * @param properties the properties to be given to the {@code DerivedCRS} and {@code Conversion} objects.
- * @param baseCRS coordinate reference system to base the derived CRS on.
- * @param method the coordinate operation method (mandatory in all cases).
- * @param baseToDerived transform from positions in the base CRS to positions in this target CRS.
- * @param derivedCS the coordinate system for the derived CRS.
- * @return the newly created derived CRS, potentially implementing an additional CRS interface.
- *
- * @since 0.6
- */
- @Override
- public DerivedCRS createDerivedCRS(final Map<String,?> properties,
- final SingleCRS baseCRS,
- final OperationMethod method,
- final MathTransform baseToDerived,
- final CoordinateSystem derivedCS)
- {
- return DefaultDerivedCRS.create(properties, baseCRS, null, method, baseToDerived, derivedCS);
- }
-
- /**
* Creates a format for {@link DirectPosition} instances.
*
* @param locale the locale for the new {@code Format}, or {@code null} for {@code Locale.ROOT}.
@@@ -894,29 -515,6 +614,70 @@@
}
/**
+ * Returns the coordinate operation method for the given classification.
+ * This method checks if the given {@code opFactory} is a SIS implementation
+ * before to fallback on a slower fallback.
+ *
++ * <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 opFactory The coordinate operation factory to use if it is a SIS implementation.
+ * @param mtFactory The math transform factory to use as a fallback.
+ * @param identifier The name or identifier of the operation method to search.
+ * @return The coordinate operation method for the given name or identifier.
+ * @throws FactoryException if an error occurred which searching for the given method.
+ *
+ * @since 0.6
+ */
- @Override
- public OperationMethod getOperationMethod(final CoordinateOperationFactory opFactory,
++ public static OperationMethod getOperationMethod(final CoordinateOperationFactory opFactory,
+ final MathTransformFactory mtFactory, final String identifier) throws FactoryException
+ {
+ if (opFactory instanceof DefaultCoordinateOperationFactory) {
+ ((DefaultCoordinateOperationFactory) opFactory).getOperationMethod(identifier);
+ }
- return super.getOperationMethod(opFactory, mtFactory, identifier);
++ final OperationMethod method = getOperationMethod(mtFactory.getAvailableMethods(SingleOperation.class), identifier);
++ if (method != null) {
++ return method;
++ }
++ throw new NoSuchIdentifierException("No such operation method: " + identifier, identifier);
++ }
++
++ /**
++ * Returns the operation method for the specified name or identifier. The given argument shall be either a
++ * method name (e.g. <cite>"Transverse Mercator"</cite>) or one of its identifiers (e.g. {@code "EPSG:9807"}).
++ *
++ * @param methods the method candidates.
++ * @param identifier the name or identifier of the operation method to search.
++ * @return the coordinate operation method for the given name or identifier, or {@code null} if none.
++ *
++ * @see org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory#getOperationMethod(String)
++ * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#getOperationMethod(String)
++ *
++ * @since 0.6
++ */
++ private static OperationMethod getOperationMethod(final Iterable<? extends OperationMethod> methods, final String identifier) {
++ OperationMethod fallback = null;
++ for (final OperationMethod method : methods) {
++ if (IdentifiedObjects.isHeuristicMatchForName(method, identifier) ||
++ NameToIdentifier.isHeuristicMatchForIdentifier(method.getIdentifiers(), identifier))
++ {
++ /*
++ * Stop the iteration at the first non-deprecated method.
++ * If we find only deprecated methods, take the first one.
++ */
++ if (!(method instanceof Deprecable) || !((Deprecable) method).isDeprecated()) {
++ return method;
++ }
++ if (fallback == null) {
++ fallback = method;
++ }
++ }
++ }
++ return fallback;
+ }
+
+ /**
* Returns information about the Apache SIS configuration.
* See super-class for a list of keys.
*
diff --cc core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
index bb977e7,6bc1a79..bfeb3f6
--- a/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@@ -65,14 -72,14 +73,15 @@@ import org.apache.sis.metadata.iso.exte
import org.apache.sis.metadata.iso.extent.DefaultGeographicDescription;
import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
- import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.internal.metadata.AxisNames;
- import org.apache.sis.internal.metadata.WKTKeywords;
- import org.apache.sis.internal.metadata.VerticalDatumTypes;
- import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.metadata.TransformationAccuracy;
- import org.apache.sis.internal.metadata.EllipsoidalHeightCombiner;
- import org.apache.sis.internal.system.DefaultFactories;
++import org.apache.sis.internal.referencing.ServicesForMetadata;
+ import org.apache.sis.internal.referencing.ReferencingFactoryContainer;
+ import org.apache.sis.internal.referencing.EllipsoidalHeightCombiner;
+ import org.apache.sis.internal.referencing.VerticalDatumTypes;
+ import org.apache.sis.internal.referencing.AxisDirections;
+ import org.apache.sis.internal.referencing.WKTKeywords;
+ import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.internal.util.Strings;
import org.apache.sis.util.CharSequences;
@@@ -991,7 -952,7 +954,7 @@@ class GeodeticObjectParser extends Math
}
case WKTKeywords.parametric: {
if (axes.length != (dimension = 1)) break;
- return referencing.createParametricCS(csProperties, axes[0], csFactory);
- 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);
@@@ -1293,15 -1259,15 +1261,17 @@@
* not use the identifier.
*/
FactoryException suppressed = null;
+ final CoordinateOperationFactory opFactory = factories.getCoordinateOperationFactory();
- if (id != null) try {
++ final MathTransformFactory mtFactory = factories.getMathTransformFactory();
+ if (id instanceof ReferenceIdentifier) try {
// CodeSpace is a mandatory attribute in ID[…] elements, so we do not test for null values.
- return referencing.getOperationMethod(opFactory, mtFactory,
- ((ReferenceIdentifier) id).getCodeSpace() + DefaultNameSpace.DEFAULT_SEPARATOR + id.getCode());
- return opFactory.getOperationMethod(id.getCodeSpace() + Constants.DEFAULT_SEPARATOR + id.getCode());
++ return ServicesForMetadata.getOperationMethod(opFactory, mtFactory,
++ ((ReferenceIdentifier) id).getCodeSpace() + Constants.DEFAULT_SEPARATOR + id.getCode());
} catch (FactoryException e) {
suppressed = e;
}
try {
- return referencing.getOperationMethod(opFactory, mtFactory, name);
- return opFactory.getOperationMethod(name);
++ return ServicesForMetadata.getOperationMethod(opFactory, mtFactory, name);
} catch (FactoryException e) {
if (suppressed != null) {
e.addSuppressed(suppressed);
@@@ -1511,8 -1481,9 +1485,9 @@@
return null;
}
final String name = element.pullString("name");
+ final DatumFactory datumFactory = factories.getDatumFactory();
try {
- return referencing.createParametricDatum(parseAnchorAndClose(element, name), datumFactory);
- return datumFactory.createParametricDatum(parseAnchorAndClose(element, name));
++ return ServicesForMetadata.createParametricDatum(parseAnchorAndClose(element, name), datumFactory);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@@ -2061,11 -2039,12 +2043,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 referencing.createParametricCRS(properties, datum, cs, crsFactory);
- return crsFactory.createParametricCRS(properties, datum, (ParametricCS) cs);
++ return ServicesForMetadata.createParametricCRS(properties, datum, cs, crsFactory);
}
} catch (FactoryException exception) {
throw element.parseFailed(exception);
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
index 55f0e0c,117c21d..e655bc7
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
@@@ -732,16 -730,11 +731,16 @@@ public final class IdentifiedObjects ex
if (identifier == null) {
return null;
}
- String cs = identifier.getCodeSpace();
+ String cs = null;
+ if (identifier instanceof ReferenceIdentifier) {
+ cs = ((ReferenceIdentifier) identifier).getCodeSpace();
+ }
if (cs == null || cs.isEmpty()) {
- cs = org.apache.sis.internal.util.Citations.getIdentifier(identifier.getAuthority(), true);
+ 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());
}
/**
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
index bf6671b,b49da4b..2633c25
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
@@@ -21,9 -21,9 +21,9 @@@ import javax.xml.bind.annotation.XmlTyp
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.datum.EngineeringDatum;
- import org.apache.sis.internal.metadata.WKTKeywords;
+ import org.apache.sis.internal.referencing.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
index ba4dd69,b4209ce..b788fc2
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
@@@ -23,10 -23,10 +23,10 @@@ import javax.xml.bind.annotation.XmlEle
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.datum.ImageDatum;
import org.opengis.referencing.datum.PixelInCell;
- import org.apache.sis.internal.metadata.WKTKeywords;
+ import org.apache.sis.internal.referencing.WKTKeywords;
import org.apache.sis.internal.metadata.MetadataUtilities;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultParametricDatum.java
index 72fb0ba,7a38be0..e44753f
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultParametricDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultParametricDatum.java
@@@ -20,9 -20,12 +20,9 @@@ import java.util.Date
import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
- import org.apache.sis.internal.metadata.WKTKeywords;
+ import org.apache.sis.internal.referencing.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
-// Branch-dependent imports
-import org.opengis.referencing.datum.ParametricDatum;
-
/**
* Defines the origin of a parametric coordinate reference system.
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
index 727d608,9b0690b..7c6d8d3
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
@@@ -26,9 -26,9 +26,9 @@@ import javax.xml.bind.annotation.XmlRoo
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.datum.TemporalDatum;
- import org.apache.sis.internal.metadata.WKTKeywords;
+ import org.apache.sis.internal.referencing.WKTKeywords;
import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;
import org.apache.sis.internal.metadata.MetadataUtilities;
import org.apache.sis.util.ComparisonMode;
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 325b604,05dde98..accd686
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@@ -52,7 -52,7 +52,6 @@@ import org.opengis.util.GenericName
import org.opengis.util.InternationalString;
import org.opengis.util.FactoryException;
import org.opengis.util.NoSuchIdentifierException;
--import org.opengis.metadata.Identifier;
import org.opengis.metadata.extent.Extent;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.OnLineFunction;
@@@ -78,6 -79,6 +78,7 @@@ import org.apache.sis.internal.referenc
import org.apache.sis.internal.referencing.SignReversalComment;
import org.apache.sis.internal.referencing.Resources;
import org.apache.sis.internal.referencing.Formulas;
++import org.apache.sis.internal.referencing.ServicesForMetadata;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.system.Semaphores;
import org.apache.sis.internal.util.Constants;
@@@ -1561,10 -1557,10 +1561,10 @@@ codes: for (int i=0; i<codes.length; i
* PARAMETRIC CRS
* ---------------------------------------------------------------------- */
case "parametric": {
- final ParametricCS cs = owner.createParametricCS (getString(code, result, 8));
- final ParametricDatum datum = owner.createParametricDatum(getString(code, result, 9));
- crs = crsFactory.createParametricCRS(createProperties("Coordinate Reference System",
- name, epsg, area, scope, remarks, deprecated), datum, cs);
+ final DefaultParametricCS cs = owner.createParametricCS (getString(code, result, 8));
+ final DefaultParametricDatum datum = owner.createParametricDatum(getString(code, result, 9));
- crs = ReferencingServices.getInstance().createParametricCRS(createProperties("Coordinate Reference System",
++ crs = ServicesForMetadata.createParametricCRS(createProperties("Coordinate Reference System",
+ name, epsg, area, scope, remarks, deprecated), datum, cs, crsFactory);
break;
}
/* ----------------------------------------------------------------------
@@@ -1731,7 -1727,7 +1731,7 @@@
break;
}
case "parametric": {
- datum = ReferencingServices.getInstance().createParametricDatum(properties, datumFactory);
- datum = datumFactory.createParametricDatum(properties);
++ datum = ServicesForMetadata.createParametricDatum(properties, datumFactory);
break;
}
default: {
@@@ -2185,7 -2181,7 +2185,7 @@@
}
case WKTKeywords.parametric: {
switch (dimension) {
- case 1: cs = ReferencingServices.getInstance().createParametricCS(properties, axes[0], csFactory); break;
- case 1: cs = csFactory.createParametricCS(properties, axes[0]); break;
++ case 1: cs = ServicesForMetadata.createParametricCS(properties, axes[0], csFactory); break;
}
break;
}
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
index 2590eca,daa232b..585755f
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
@@@ -22,14 -22,9 +22,14 @@@ import org.opengis.referencing.crs.*
import org.opengis.referencing.datum.*;
import org.opengis.referencing.operation.*;
import org.opengis.parameter.ParameterDescriptor;
- import org.apache.sis.internal.metadata.WKTKeywords;
+ import org.apache.sis.internal.referencing.WKTKeywords;
import org.apache.sis.util.CharSequences;
+// Branch-dependent imports
+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. The MS-Access dialect of SQL is assumed;
diff --cc core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
index 3f59b13,b4f61f0..30d6d62
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
@@@ -110,9 -108,9 +109,9 @@@ public strictfp class ReferencingAsser
public static void assertEpsgIdentifierEquals(final String expected, final Identifier actual) {
assertNotNull(actual);
assertEquals("code", expected, actual.getCode());
- assertEquals("codeSpace", Constants.EPSG, actual.getCodeSpace());
+ assertEquals("codeSpace", Constants.EPSG, (actual instanceof ReferenceIdentifier) ? ((ReferenceIdentifier) actual).getCodeSpace() : null);
assertEquals("authority", Constants.EPSG, Citations.toCodeSpace(actual.getAuthority()));
- assertEquals("identifier", Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + expected,
+ assertEquals("identifier", Constants.EPSG + Constants.DEFAULT_SEPARATOR + expected,
IdentifiedObjects.toString(actual));
}
diff --cc core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
index 6dc2885,cc139f7..16bb33e
--- a/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
@@@ -21,10 -21,11 +21,11 @@@ import java.text.Format
import java.text.FieldPosition;
import java.text.ParsePosition;
import org.opengis.util.GenericName;
-import org.opengis.metadata.Identifier;
import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.ReferenceIdentifier;
- import org.apache.sis.internal.util.Citations;
import org.apache.sis.util.resources.Vocabulary;
+ import org.apache.sis.internal.util.Constants;
+ import org.apache.sis.internal.util.MetadataServices;
/**