Class DefinitionVerifier
java.lang.Object
org.apache.sis.internal.referencing.DefinitionVerifier
Verifies the conformance of a given CRS with an authoritative description.
For example if a Well Known Text (WKT) contains an EPSG code, this class verifies that
the CRS created from the WKT is equivalent to the CRS identified by the authority code.
DefinitionVerifier contains two information:
- The recommended CRS to use. May be the given CRS or a CRS created from the authority factory.
- Warnings if the given CRS does not match the authoritative description.
Identifier keyword: "In the event of conflict in values given
in the CRS WKT string and given by an authority through an object’s name or an identifier, reading software should
throw an exception or give users a warning message. The WKT values should be assumed to prevail."
In practice when such conflicts happen, we often see that the given WKT string contains mistakes and the
provider intended to use the authoritative description. We nevertheless comply with ISO 19162 requirement,
but provide a "recommended CRS" field for what we think is the intended CRS.- Since:
- 0.8
- Version:
- 1.1
- Author:
- Martin Desruisseaux (Geomatys)
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal org.opengis.referencing.crs.CoordinateReferenceSystemRecommended CRS. -
Method Summary
Modifier and TypeMethodDescriptionstatic DefinitionVerifiercompare(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.CoordinateReferenceSystem authoritative, Locale locale) Compares the given CRS with an authoritative definition of that CRS.warning(boolean fine) Returns the warning to log, ornullif none.static voidwithAuthority(org.opengis.referencing.crs.CoordinateReferenceSystem crs, String logger, Class<?> classe, String method) Compares the given CRS description with the authoritative description.static DefinitionVerifierwithAuthority(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.CRSAuthorityFactory factory, boolean lookup, Locale locale) Compares the given CRS description with the authoritative description.
-
Field Details
-
recommendation
public final org.opengis.referencing.crs.CoordinateReferenceSystem recommendationRecommended CRS. May be the instance given to thewithAuthority(…)method or an instance created from the authority factory. May also benullif all CRS given to themethod were null. Note that ISO 19162 said "Should any attributes or values given in the cited identifier be in conflict with attributes or values given explicitly in the WKT description, the WKT values shall prevail." So we normally do not use this field.invalid reference
compare(…)
-
-
Method Details
-
withAuthority
public static void withAuthority(org.opengis.referencing.crs.CoordinateReferenceSystem crs, String logger, Class<?> classe, String method) throws org.opengis.util.FactoryException Compares the given CRS description with the authoritative description. If the comparison produces a warning, a message will be recorded to the given logger.- Parameters:
crs- the CRS to compare with the authoritative description.logger- the logger where to report warnings, if any.classe- the class to declare as the source of the warning.method- the method to declare as the source of the warning.- Throws:
org.opengis.util.FactoryException- if an error occurred while querying the authority factory.
-
withAuthority
public static DefinitionVerifier withAuthority(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.CRSAuthorityFactory factory, boolean lookup, Locale locale) throws org.opengis.util.FactoryException Compares the given CRS description with the authoritative description. The authoritative description is inferred from the identifier, if any.- Parameters:
crs- the CRS to compare with the authoritative description.factory- the factory to use for fetching authoritative description, ornullfor the default.lookup- whether this method is allowed to useIdentifiedObjectFinder.locale- the locale for warning messages, ornullfor the system default.- Returns:
- verification result, or
nullif the given CRS should be used as-is. - Throws:
org.opengis.util.FactoryException- if an error occurred while querying the authority factory.
-
compare
public static DefinitionVerifier compare(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.CoordinateReferenceSystem authoritative, Locale locale) Compares the given CRS with an authoritative definition of that CRS. Typically,crsis parsed from a Well-Known Text (WKT) definition whileauthoritativeis provided by a geodetic database from an authority code.The
recommendationCRS is set as below:- If one of given CRS is
null, then the other CRS (which may also be null) is selected. - Otherwise if
crsis compatible withauthoritywith only a change in axis order, a CRS derived fromauthoritybut withcrsaxis order is silently selected. - Otherwise
authorityis selected and a warning message is prepared.
- Parameters:
crs- the CRS to compare against an authoritative definition, ornull.authoritative- the presumed authoritative definition of the given CRS, ornull.locale- the locale for warning messages, ornullfor the system default.- Returns:
- verification result (never
null).
- If one of given CRS is
-
warning
Returns the warning to log, ornullif none. The caller is responsible for setting the logger name, source class name and source method name.- Parameters:
fine-truefor including warnings at fine level, orfalsefor only the warning level.- Returns:
- the warning to log, or
nullif none.
-