Package org.geotools.referencing.factory
Class FallbackAuthorityFactory
Object
AbstractFactory
ReferencingFactory
AbstractAuthorityFactory
AuthorityFactoryAdapter
FallbackAuthorityFactory
- All Implemented Interfaces:
AuthorityFactory
,Factory
,Factory
,OptionalFactory
,RegistrableFactory
A factory which delegates all object creation to a primary factory, and fallback on an other one if the
primary factory failed.
- Since:
- 2.3
- Author:
- Martin Desruisseaux
-
Field Summary
Fields inherited from class ReferencingFactory
LOGGER
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FallbackAuthorityFactory
(AuthorityFactory primary, AuthorityFactory fallback) Wraps a primary and a fallback authority factories. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends AuthorityFactory>
Tcreate
(Class<T> type, Collection<T> factories) Wraps the specified authority factories.static AuthorityFactory
create
(Collection<? extends AuthorityFactory> factories) Wraps the specified authority factories.createCartesianCS
(String code) Creates a cartesian coordinate system from a code.createCompoundCRS
(String code) Creates a 3D coordinate reference system from a code.Creates an operation from a single operation code.Returns an arbitrary coordinate reference system from a code.createCoordinateSystem
(String code) Returns an arbitrary coordinate system from a code.Returns a coordinate system axis from a code.createCylindricalCS
(String code) Creates a cylindrical coordinate system from a code.createDatum
(String code) Returns an arbitrary datum from a code.createDerivedCRS
(String code) Creates a derived coordinate reference system from a code.createEllipsoid
(String code) Returns an ellipsoid from a code.createEllipsoidalCS
(String code) Creates an ellipsoidal coordinate system from a code.createEngineeringCRS
(String code) Creates a engineering coordinate reference system from a code.createEngineeringDatum
(String code) Creates a engineering datum from a code.createExtent
(String code) Returns a extent (usually an area of validity) from a code.createFromCoordinateReferenceSystemCodes
(String sourceCRS, String targetCRS) Creates an operation from coordinate reference system codes.createGeocentricCRS
(String code) Returns a geocentric coordinate reference system from a code.createGeodeticDatum
(String code) Returns a geodetic datum from a code.createGeographicCRS
(String code) Returns a geographic coordinate reference system from a code.createImageCRS
(String code) Creates a image coordinate reference system from a code.createImageDatum
(String code) Creates a image datum from a code.createObject
(String code) Returns an arbitrary object from a code.createOperationMethod
(String code) Creates an operation method from a code.Creates a parameter descriptor from a code.createPolarCS
(String code) Creates a polar coordinate system from a code.createPrimeMeridian
(String code) Returns a prime meridian from a code.createProjectedCRS
(String code) Returns a projected coordinate reference system from a code.createSphericalCS
(String code) Creates a spherical coordinate system from a code.createTemporalCRS
(String code) Creates a temporal coordinate reference system from a code.createTemporalDatum
(String code) Creates a temporal datum from a code.createTimeCS
(String code) Creates a temporal coordinate system from a code.Unit<?>
createUnit
(String code) Returns an unit from a code.createVerticalCRS
(String code) Creates a vertical coordinate reference system from a code.createVerticalCS
(String code) Creates a vertical coordinate system from a code.createVerticalDatum
(String code) Creates a vertical datum from a code.getAuthorityCodes
(Class<? extends IdentifiedObject> type) Returns the set of authority codes for the specified type.getDescriptionText
(String code) Returns a description for the object identified by the specified code.getIdentifiedObjectFinder
(Class<? extends IdentifiedObject> type) Returns a finder which can be used for looking up unidentified objects.protected void
notifySuccess
(String method, String code, CRSAuthorityFactory factory, CoordinateReferenceSystem crs) Log a message when a CRS is found.Methods inherited from class AuthorityFactoryAdapter
dispose, getAuthority, getAuthorityFactory, getBackingStoreDescription, getCoordinateOperationAuthorityFactory, getCRSAuthorityFactory, getCSAuthorityFactory, getDatumAuthorityFactory, getVendor, isAvailable, toBackingFactoryCode
Methods inherited from class AbstractAuthorityFactory
noSuchAuthorityCode, trimAuthority
Methods inherited from class ReferencingFactory
ensureNonNull
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
Methods inherited from interface Factory
getImplementationHints
-
Constructor Details
-
FallbackAuthorityFactory
Wraps a primary and a fallback authority factories.This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory
,CSAuthorityFactory
,CRSAuthorityFactory
andCoordinateOperationAuthorityFactory
interfaces they choose to implement.- Parameters:
primary
- The primary factory.fallback
- The factory to use as a fallback if the primary factory failed.- See Also:
-
-
Method Details
-
create
public static <T extends AuthorityFactory> T create(Class<T> type, Collection<T> factories) throws FactoryNotFoundException, ClassCastException Wraps the specified authority factories. If the specified collection contains more than one element, then a chain ofFallbackAuthorityFactory
instances is created.- Type Parameters:
T
- The interface to implement.- Parameters:
type
- The interface to implement. Should be one ofDatumAuthorityFactory
,CSAuthorityFactory
,CRSAuthorityFactory
orCoordinateOperationAuthorityFactory
.factories
- The factories to wrap, in iteration order.- Returns:
- The given factories as a chain of fallback factories.
- Throws:
FactoryNotFoundException
- if the collection doesn't contains at least one element.ClassCastException
- iftype
is illegal.
-
create
public static AuthorityFactory create(Collection<? extends AuthorityFactory> factories) throws FactoryNotFoundException Wraps the specified authority factories. If the specified collection contains more than one element, then a chain ofFallbackAuthorityFactory
instances is created. The type is inferred from the factories found in the collection.Consider using
create(type, factories)
instead when the type is known at compile time.- Parameters:
factories
- The factories to wrap, in iteration order.- Returns:
- The given factories as a chain of fallback factories.
- Throws:
FactoryNotFoundException
- if the collection doesn't contains at least one element.- Since:
- 2.4
-
getAuthorityCodes
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) throws FactoryException Returns the set of authority codes for the specified type. The default implementation returns the union of the authority codes from the primary and the fallback factories.- Specified by:
getAuthorityCodes
in interfaceAuthorityFactory
- Overrides:
getAuthorityCodes
in classAuthorityFactoryAdapter
- Parameters:
type
- The spatial reference objects type.- Returns:
- The set of authority codes for spatial reference objects of the given type. If this factory doesn't contains any object of the given type, then this method returns an empty set.
- Throws:
FactoryException
- if access to the underlying database failed.
-
getDescriptionText
Returns a description for the object identified by the specified code.- Specified by:
getDescriptionText
in interfaceAuthorityFactory
- Overrides:
getDescriptionText
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- A description of the object, or
null
if the object corresponding to the specifiedcode
has no description. - Throws:
NoSuchAuthorityCodeException
- if the specifiedcode
was not found.FactoryException
- if the query failed for some other reason.
-
createObject
Returns an arbitrary object from a code.- Specified by:
createObject
in interfaceAuthorityFactory
- Overrides:
createObject
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The object for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createDatum
Returns an arbitrary datum from a code.- Overrides:
createDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createEngineeringDatum
Creates a engineering datum from a code.- Overrides:
createEngineeringDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createImageDatum
Creates a image datum from a code.- Overrides:
createImageDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createVerticalDatum
Creates a vertical datum from a code.- Overrides:
createVerticalDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createTemporalDatum
Creates a temporal datum from a code.- Overrides:
createTemporalDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createGeodeticDatum
Returns a geodetic datum from a code.- Overrides:
createGeodeticDatum
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createEllipsoid
Returns an ellipsoid from a code.- Overrides:
createEllipsoid
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The ellipsoid for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createPrimeMeridian
Returns a prime meridian from a code.- Overrides:
createPrimeMeridian
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The prime meridian for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createExtent
Returns a extent (usually an area of validity) from a code.- Overrides:
createExtent
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The extent for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCoordinateSystem
Returns an arbitrary coordinate system from a code.- Overrides:
createCoordinateSystem
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCartesianCS
Creates a cartesian coordinate system from a code.- Overrides:
createCartesianCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createPolarCS
Creates a polar coordinate system from a code.- Overrides:
createPolarCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCylindricalCS
Creates a cylindrical coordinate system from a code.- Overrides:
createCylindricalCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createSphericalCS
Creates a spherical coordinate system from a code.- Overrides:
createSphericalCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createEllipsoidalCS
Creates an ellipsoidal coordinate system from a code.- Overrides:
createEllipsoidalCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createVerticalCS
Creates a vertical coordinate system from a code.- Overrides:
createVerticalCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createTimeCS
Creates a temporal coordinate system from a code.- Overrides:
createTimeCS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCoordinateSystemAxis
Returns a coordinate system axis from a code.- Overrides:
createCoordinateSystemAxis
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The axis for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createUnit
Returns an unit from a code.- Overrides:
createUnit
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The unit for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCoordinateReferenceSystem
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException Returns an arbitrary coordinate reference system from a code.- Overrides:
createCoordinateReferenceSystem
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
AuthorityFactoryAdapter.createGeographicCRS(java.lang.String)
AuthorityFactoryAdapter.createProjectedCRS(java.lang.String)
AuthorityFactoryAdapter.createVerticalCRS(java.lang.String)
AuthorityFactoryAdapter.createTemporalCRS(java.lang.String)
AuthorityFactoryAdapter.createCompoundCRS(java.lang.String)
-
createCompoundCRS
Creates a 3D coordinate reference system from a code.- Overrides:
createCompoundCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createDerivedCRS
Creates a derived coordinate reference system from a code.- Overrides:
createDerivedCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createEngineeringCRS
Creates a engineering coordinate reference system from a code.- Overrides:
createEngineeringCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createGeographicCRS
Returns a geographic coordinate reference system from a code.- Overrides:
createGeographicCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createGeocentricCRS
Returns a geocentric coordinate reference system from a code.- Overrides:
createGeocentricCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createImageCRS
Creates a image coordinate reference system from a code.- Overrides:
createImageCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createProjectedCRS
Returns a projected coordinate reference system from a code.- Overrides:
createProjectedCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createTemporalCRS
Creates a temporal coordinate reference system from a code.- Overrides:
createTemporalCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createVerticalCRS
Creates a vertical coordinate reference system from a code.- Overrides:
createVerticalCRS
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.- See Also:
-
createParameterDescriptor
Creates a parameter descriptor from a code.- Overrides:
createParameterDescriptor
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createOperationMethod
Creates an operation method from a code.- Overrides:
createOperationMethod
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The operation method for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createCoordinateOperation
Creates an operation from a single operation code.- Overrides:
createCoordinateOperation
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The operation for the given code.
- Throws:
FactoryException
- if the object creation failed for all factories.
-
createFromCoordinateReferenceSystemCodes
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS, String targetCRS) throws FactoryException Creates an operation from coordinate reference system codes.- Overrides:
createFromCoordinateReferenceSystemCodes
in classAuthorityFactoryAdapter
- Parameters:
sourceCRS
- Coded value of source coordinate reference system.targetCRS
- Coded value of target coordinate reference system.- Returns:
- The operations from
sourceCRS
totargetCRS
. - Throws:
FactoryException
- if the object creation failed for all factories.
-
getIdentifiedObjectFinder
public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) throws FactoryException Returns a finder which can be used for looking up unidentified objects. The default implementation delegates the lookups to the primary factory, and fallback on the second one if the primary factory can't find a match.- Overrides:
getIdentifiedObjectFinder
in classAuthorityFactoryAdapter
- Parameters:
type
- The type of objects to look for. Should be a GeoAPI interface likeGeographicCRS.class
, but this method accepts also implementation class. If the type is unknown, useIdentifiedObject.class
. A more accurate type may help to speed up the search, since it reduces the amount of tables to scan in some implementations like the factories backed by EPSG database.- Returns:
- A finder to use for looking up unidentified objects.
- Throws:
FactoryException
- if the object creation failed.- Since:
- 2.4
-
notifySuccess
protected void notifySuccess(String method, String code, CRSAuthorityFactory factory, CoordinateReferenceSystem crs) Description copied from class:AuthorityFactoryAdapter
Log a message when a CRS is found. Child objects that doesn't create their own CRS-objects should not report.- Overrides:
notifySuccess
in classAuthorityFactoryAdapter
-