Class EPSGCodeFinder
java.lang.Object
org.apache.sis.referencing.factory.IdentifiedObjectFinder
org.apache.sis.referencing.factory.sql.EPSGCodeFinder
An implementation of
IdentifiedObjectFinder
which scans over a smaller set of authority codes.
This is used for finding the EPSG code of a given Coordinate Reference System or other geodetic object.- Since:
- 0.7
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A condition to put in a SQLWHERE
clause.private static final class
A condition for a floating point value with a tolerance.Nested classes/interfaces inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
IdentifiedObjectFinder.Domain
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EPSGDataAccess
The data access object to use for searching EPSG codes.private Class<? extends org.opengis.referencing.IdentifiedObject>
The type of object to search, ornull
for usingobject.getClass()
.Fields inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
factory
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new finder for the given data access object. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
appendFilterByName
(Set<String> namePatterns, String column, StringBuilder buffer) Appends to the given buffer the SQL statement for filtering datum names using a pattern created bytoDatumPattern(String, StringBuilder)
.private <T extends org.opengis.referencing.IdentifiedObject>
EPSGCodeFinder.Conditiondependencies
(String column, Class<T> type, T dependency, boolean ignoreAxes) Returns a description of the condition to put in aWHERE
clause for an object having the given dependency.Set<org.opengis.referencing.IdentifiedObject>
find
(org.opengis.referencing.IdentifiedObject object) Lookups objects which are approximately equal to the specified object.getCodeCandidates
(org.opengis.referencing.IdentifiedObject object) Returns a set of authority codes that may identify the same object than the specified one.private boolean
isInstance
(Class<? extends org.opengis.referencing.IdentifiedObject> type, org.opengis.referencing.IdentifiedObject object) Returnstrue
if the given object implements the given interface, ignoring interfaces that are not subtypes ofdeclaredType
.private static String
toDatumPattern
(String name, StringBuilder buffer) Returns a SQL pattern for the given datum name.Methods inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
findSingleton, getSearchDomain, isIgnoringAxes, setIgnoringAxes, setSearchDomain
-
Field Details
-
dao
The data access object to use for searching EPSG codes. Supplied at construction time and assumed alive for the duration of thisEPSGCodeFinder
life (i.e. this class does not create and does not close DAO by itself). -
declaredType
The type of object to search, ornull
for usingobject.getClass()
. This is set to a non-null value when searching for dependencies, in order to avoid confusion in an implementation class implements more than one GeoAPI interfaces.- See Also:
-
-
Constructor Details
-
EPSGCodeFinder
EPSGCodeFinder(EPSGDataAccess dao) Creates a new finder for the given data access object.
-
-
Method Details
-
find
public Set<org.opengis.referencing.IdentifiedObject> find(org.opengis.referencing.IdentifiedObject object) throws org.opengis.util.FactoryException Lookups objects which are approximately equal to the specified object. This method temporarily disables warnings about deprecated objects.- Overrides:
find
in classIdentifiedObjectFinder
- Parameters:
object
- the object looked up.- Returns:
- the identified objects, or an empty set if not found.
- Throws:
org.opengis.util.FactoryException
- if an error occurred while creating an object.
-
dependencies
private <T extends org.opengis.referencing.IdentifiedObject> EPSGCodeFinder.Condition dependencies(String column, Class<T> type, T dependency, boolean ignoreAxes) throws org.opengis.util.FactoryException Returns a description of the condition to put in aWHERE
clause for an object having the given dependency.Implementation note: Thesuper.find(…)
method performs a check (not documented in public API) for detecting when it is invoked recursively, which is the case here. Consequently, thesuper.find(…)
behavior below is slightly different than usual: since invoked recursively,super.find(…)
checks the cache of theConcurrentAuthorityFactory
wrapper. If found, the dependency will also be stored in the cache. This is desirable because this method may be invoked (indirectly) in a loop for many CRS objects sharing the sameCoordinateSystem
orDatum
dependencies.- Parameters:
column
- column in the SQL query containing EPSG codes of dependency.type
- GeoAPI interface implemented by the dependency to search.dependency
- the dependency for which to search EPSG codes, ornull
.ignoreAxes
- whether to force ignoring axes. Useful for base CRS of projected CRS.- Returns:
- EPSG codes of given dependency, or
null
if no dependency were found. - Throws:
org.opengis.util.FactoryException
-
isInstance
private boolean isInstance(Class<? extends org.opengis.referencing.IdentifiedObject> type, org.opengis.referencing.IdentifiedObject object) Returnstrue
if the given object implements the given interface, ignoring interfaces that are not subtypes ofdeclaredType
. This method is used for avoiding confusion if the given object implements more than one GeoAPI interfaces. Test order matter: CRS should be tested first in order to have precedence over datum types. -
getCodeCandidates
protected Set<String> getCodeCandidates(org.opengis.referencing.IdentifiedObject object) throws org.opengis.util.FactoryException Returns a set of authority codes that may identify the same object than the specified one. This implementation tries to get a smaller set than whatEPSGDataAccess.getAuthorityCodes(Class)
would produce. Deprecated objects must be last in iteration order.- Overrides:
getCodeCandidates
in classIdentifiedObjectFinder
- Parameters:
object
- the object looked up.- Returns:
- a set of code candidates.
- Throws:
org.opengis.util.FactoryException
- if an error occurred while fetching the set of code candidates.
-
toDatumPattern
Returns a SQL pattern for the given datum name. The name is returned in all lower cases for allowing case-insensitive searches. Punctuations are replaced by any sequence of characters ('%'
) and non-ASCII letters are replaced by any single character ('_'
). The returned pattern should be flexible enough for accepting all names considered equal inDefaultGeodeticDatum
comparisons. In case of doubt, it is okay to return a pattern accepting more names.- Parameters:
name
- the datum name for which to return a SQL pattern.buffer
- temporary buffer to use for creating the pattern.- Returns:
- the SQL pattern for the given name.
- See Also:
-
appendFilterByName
private static void appendFilterByName(Set<String> namePatterns, String column, StringBuilder buffer) Appends to the given buffer the SQL statement for filtering datum names using a pattern created bytoDatumPattern(String, StringBuilder)
. This method append a SQL fragment like below: This method assumes thatnamePatterns
contains at least one element.- Parameters:
namePatterns
- the patterns created bytoDatumPattern(String, StringBuilder)
.column
- column where the search for the names.buffer
- buffer where to add the SQL fragment.
-