Class EPSGCodeFinder

java.lang.Object
org.apache.sis.referencing.factory.IdentifiedObjectFinder
org.apache.sis.referencing.factory.sql.EPSGCodeFinder

final class EPSGCodeFinder extends IdentifiedObjectFinder
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
  • Field Details

    • dao

      private final EPSGDataAccess dao
      The data access object to use for searching EPSG codes. Supplied at construction time and assumed alive for the duration of this EPSGCodeFinder life (i.e. this class does not create and does not close DAO by itself).
    • declaredType

      private Class<? extends org.opengis.referencing.IdentifiedObject> declaredType
      The type of object to search, or null for using object.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 class IdentifiedObjectFinder
      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 a WHERE clause for an object having the given dependency.
      Implementation note: The super.find(…) method performs a check (not documented in public API) for detecting when it is invoked recursively, which is the case here. Consequently, the super.find(…) behavior below is slightly different than usual: since invoked recursively, super.find(…) checks the cache of the ConcurrentAuthorityFactory 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 same CoordinateSystem or Datum 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, or null.
      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)
      Returns true if the given object implements the given interface, ignoring interfaces that are not subtypes of declaredType. 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 what EPSGDataAccess.getAuthorityCodes(Class) would produce. Deprecated objects must be last in iteration order.
      Overrides:
      getCodeCandidates in class IdentifiedObjectFinder
      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

      private static String toDatumPattern(String name, StringBuilder buffer)
      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 in DefaultGeodeticDatum 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 by toDatumPattern(String, StringBuilder). This method append a SQL fragment like below: This method assumes that namePatterns contains at least one element.
      Parameters:
      namePatterns - the patterns created by toDatumPattern(String, StringBuilder).
      column - column where the search for the names.
      buffer - buffer where to add the SQL fragment.