Package org.geotools.referencing.factory
Class TransformedAuthorityFactory
- Object
-
- AbstractFactory
-
- ReferencingFactory
-
- AbstractAuthorityFactory
-
- AuthorityFactoryAdapter
-
- TransformedAuthorityFactory
-
- All Implemented Interfaces:
AuthorityFactory
,Factory
,Factory
,OptionalFactory
,RegistrableFactory
- Direct Known Subclasses:
OrderedAxisCRSAuthorityFactory
public class TransformedAuthorityFactory extends AuthorityFactoryAdapter
An authority factory which returns modified CRS, CS or datum objects from other factory implementations. This class provides a set ofreplace(...)
methods to be overridden by subclasses in order to replace some CRS, CS or datum objects by other ones. The replacement rules are determined by the subclass being used. For example theOrderedAxisAuthorityFactory
subclass can replace coordinate systems using (latitude, longitude) axis order by coordinate systems using (longitude, latitude) axis order.All constructors are protected because this class must be subclassed in order to determine which of the
DatumAuthorityFactory
,CSAuthorityFactory
andCRSAuthorityFactory
interfaces to implement.- Since:
- 2.3
- Author:
- Martin Desruisseaux (IRD)
-
-
Field Summary
-
Fields inherited from class ReferencingFactory
LOGGER
-
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransformedAuthorityFactory(String authority, Hints userHints)
Creates a wrappers around the default factories for the specified authority.protected
TransformedAuthorityFactory(AuthorityFactory factory)
Creates a wrapper around the specified factory.protected
TransformedAuthorityFactory(CRSAuthorityFactory crsFactory, CSAuthorityFactory csFactory, DatumAuthorityFactory datumFactory, CoordinateOperationAuthorityFactory opFactory)
Creates a wrapper around the specified factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<CoordinateOperation>
createFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode)
Creates an operation from coordinate reference system codes.void
dispose()
Releases resources immediately instead of waiting for the garbage collector.int
getPriority()
Returns the priority for this factory.protected Unit<?>
replace(Unit<?> units)
Replaces the specified unit, if applicable.protected CoordinateReferenceSystem
replace(CoordinateReferenceSystem crs)
Replaces (if needed) the specified coordinate reference system.protected AxisDirection
replace(AxisDirection direction)
Replaces the specified direction, if applicable.protected CoordinateSystem
replace(CoordinateSystem cs)
Replaces (if needed) the specified coordinate system by a new one.protected CoordinateSystemAxis
replace(CoordinateSystemAxis axis)
Replaces (if needed) the specified axis by a new one.protected Datum
replace(Datum datum)
Replaces (if needed) the specified datum by a new one.protected CoordinateOperation
replace(CoordinateOperation operation)
Replaces (if needed) the specified coordinate operation.-
Methods inherited from class AuthorityFactoryAdapter
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthority, getAuthorityCodes, getAuthorityFactory, getBackingStoreDescription, getCoordinateOperationAuthorityFactory, getCRSAuthorityFactory, getCSAuthorityFactory, getDatumAuthorityFactory, getDescriptionText, getIdentifiedObjectFinder, getVendor, isAvailable, notifySuccess, toBackingFactoryCode
-
Methods inherited from class AbstractAuthorityFactory
noSuchAuthorityCode, trimAuthority
-
Methods inherited from class ReferencingFactory
ensureNonNull
-
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, hashCode, onDeregistration, onRegistration, toString
-
Methods inherited from interface Factory
getImplementationHints
-
-
-
-
Constructor Detail
-
TransformedAuthorityFactory
protected TransformedAuthorityFactory(AuthorityFactory factory)
Creates a wrapper around the specified factory.- Parameters:
factory
- The factory to wrap.
-
TransformedAuthorityFactory
protected TransformedAuthorityFactory(CRSAuthorityFactory crsFactory, CSAuthorityFactory csFactory, DatumAuthorityFactory datumFactory, CoordinateOperationAuthorityFactory opFactory)
Creates a wrapper around the specified factories.- Parameters:
crsFactory
- The coordinate reference system authority factory, ornull
.csFactory
- The coordinate system authority factory, ornull
.datumFactory
- The datum authority factory, ornull
.opFactory
- The coordinate operation authority factory, ornull
.
-
TransformedAuthorityFactory
protected TransformedAuthorityFactory(String authority, Hints userHints) throws FactoryRegistryException
Creates a wrappers around the default factories for the specified authority. The factories are fetched usingReferencingFactoryFinder
.- Parameters:
authority
- The authority to wraps (example:"EPSG"
). Ifnull
, then all authority factories must be explicitly specified in the set of hints.userHints
- An optional set of hints, ornull
if none.- Throws:
FactoryRegistryException
- if at least one factory can not be obtained.- Since:
- 2.4
-
-
Method Detail
-
getPriority
public int getPriority()
Returns the priority for this factory. Priorities are used byReferencingFactoryFinder
for selecting a preferred factory when many are found for the same service. The default implementation returnspriority + 1
, which implies that this adapter has precedence over the wrapped factories. Subclasses should override this method if they want a different priority order for this instance.- Overrides:
getPriority
in classAbstractFactory
-
replace
protected Unit<?> replace(Unit<?> units) throws FactoryException
Replaces the specified unit, if applicable. This method is invoked automatically by thereplace(CoordinateSystem)
method. The default implementation returns the unit unchanged.- Parameters:
units
- The units to replace.- Returns:
- The new units, or
units
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new units.
-
replace
protected AxisDirection replace(AxisDirection direction) throws FactoryException
Replaces the specified direction, if applicable. This method is invoked automatically by thereplace(CoordinateSystem)
method. The default implementation returns the axis direction unchanged.- Parameters:
direction
- The axis direction to replace.- Returns:
- The new direction, or
direction
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new axis direction.
-
replace
protected CoordinateSystemAxis replace(CoordinateSystemAxis axis) throws FactoryException
Replaces (if needed) the specified axis by a new one. The default implementation invokesreplace(Unit)
andreplace(AxisDirection)
.- Parameters:
axis
- The coordinate system axis to replace.- Returns:
- The new coordinate system axis, or
axis
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new coordinate system axis.
-
replace
protected CoordinateSystem replace(CoordinateSystem cs) throws FactoryException
Replaces (if needed) the specified coordinate system by a new one. The default implementation invokesreplace
for each axis. In addition, axis are sorted if this factory implements theComparator
interface.- Parameters:
cs
- The coordinate system to replace.- Returns:
- The new coordinate system, or
cs
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new coordinate system.
-
replace
protected Datum replace(Datum datum) throws FactoryException
Replaces (if needed) the specified datum by a new one. The default implementation returns the datum unchanged. Subclasses should override this method if some datum replacements are desired.- Parameters:
datum
- The datum to replace.- Returns:
- The new datum, or
datum
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new datum.
-
replace
protected CoordinateReferenceSystem replace(CoordinateReferenceSystem crs) throws FactoryException
Replaces (if needed) the specified coordinate reference system. The default implementation checks if there is a datum replacement or a coordinate system replacement. If there is at least one of those, then this method returns a new coordinate reference system using the new datum and coordinate system.- Parameters:
crs
- The coordinate reference system to replace.- Returns:
- A new CRS, or
crs
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new CRS object.
-
replace
protected CoordinateOperation replace(CoordinateOperation operation) throws FactoryException
Replaces (if needed) the specified coordinate operation. The default implementation checks if there is a source or target CRS replacement. If there is at least one of those, then this method returns a new coordinate operation using the new CRS.- Parameters:
operation
- The coordinate operation to replace.- Returns:
- A new operation, or
operation
if no change were needed. - Throws:
FactoryException
- if an error occured while creating the new operation object.
-
createFromCoordinateReferenceSystemCodes
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode) throws FactoryException
Creates an operation from coordinate reference system codes. The default implementation first invokes the same method from the underlying operation factory, and next invokesreplace
for each operations.- Overrides:
createFromCoordinateReferenceSystemCodes
in classAuthorityFactoryAdapter
- Parameters:
sourceCode
- Coded value of source coordinate reference system.targetCode
- Coded value of target coordinate reference system.- Returns:
- The operations from
sourceCRS
totargetCRS
. - Throws:
FactoryException
- if the object creation failed.
-
dispose
public void dispose() throws FactoryException
Releases resources immediately instead of waiting for the garbage collector. This method do not dispose the resources of wrapped factories (e.g.crsFactory
), because they may still in use by other classes.- Overrides:
dispose
in classAuthorityFactoryAdapter
- Throws:
FactoryException
- if an error occured while disposing the factory.
-
-