Class OrderedAxisCRSAuthorityFactory
- Object
-
- AbstractFactory
-
- ReferencingFactory
-
- AbstractAuthorityFactory
-
- AuthorityFactoryAdapter
-
- TransformedAuthorityFactory
-
- OrderedAxisCRSAuthorityFactory
-
- All Implemented Interfaces:
Comparator<CoordinateSystemAxis>
,AuthorityFactory
,CRSAuthorityFactory
,Factory
,Factory
,OptionalFactory
,RegistrableFactory
- Direct Known Subclasses:
OrderedAxisAuthorityFactory
public class OrderedAxisCRSAuthorityFactory extends TransformedAuthorityFactory implements CRSAuthorityFactory, Comparator<CoordinateSystemAxis>
An authority factory which delegates all the work to an other factory, and reorder the axis in some pre-determined order. This factory is mostly used by application expecting geographic coordinates in (longitude, latitude) order, while most geographic CRS specified in the EPSG database use the opposite axis order.It is better to avoid this class if you can. This class exists primarily for compatibility with external data or applications that assume (longitude, latitude) axis order no matter what the EPSG database said, for example Shapefiles.
The axis order can be specified at construction time as an array of axis directions. If no such array is explicitly specified, then the default order is East, East-North-East, North-East, North-North-East, North, Up, Geocentric X, Geocentric Y, Geocentric Z, Column, Row, Display right, Display up and Future. This means that, for example, axis with East or West direction will be placed before any axis with North or South direction. Axis directions not specified in the table (for example
OTHER
) will be ordered last. This is somewhat equivalent to the ordering ofNaN
values in an array ofdouble
.Notes:
- This class compares only the "absolute" axis directions, so North and South are considered equivalent.
- The default direction order may changes in future Geotools version in order to fit what appears to be the most common usage on the market.
- The actual axis ordering is determined by the
compare
method implementation. Subclasses may override this method if the want to provide a more sophesticated axis ordering.
For some authority factories, an instance of this class can be obtained by passing a
FORCE_LONGITUDE_FIRST_AXIS_ORDER
hint to theFactoryFinder.getCRSAuthorityFactory(...)
method. Whatever this hint is supported or not is authority dependent. Example:Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); CRSAuthorityFactory factory = FactoryFinder.getCRSAuthorityFactory("EPSG", hints); CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326");
This class implements
CRSAuthorityFactory
only. For an implementation that supports alsoCSAuthorityFactory
, seeOrderedAxisAuthorityFactory
.- Since:
- 2.2
- Author:
- Martin Desruisseaux (IRD)
- See Also:
Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER
,Hints.FORCE_STANDARD_AXIS_UNITS
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]
directionRanks
The rank to be given to each axis direction.protected boolean
forceStandardDirections
true
if this authority factory should also force the axis to their standard direction.protected boolean
forceStandardUnits
true
if this authority factory should also force all angular units to decimal degrees and linear units to meters.-
Fields inherited from class ReferencingFactory
LOGGER
-
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
-
Constructor Summary
Constructors Constructor Description OrderedAxisCRSAuthorityFactory(String authority, Hints userHints, AxisDirection... axisOrder)
Creates a factory which will reorder the axis of all objects created by the default authority factories.OrderedAxisCRSAuthorityFactory(AbstractAuthorityFactory factory, Hints userHints, AxisDirection... axisOrder)
Creates a factory which will reorder the axis of all objects created by the supplied factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static boolean
booleanValue(Hints userHints, Hints.Key key)
Returns the boolean value for the specified hint.int
compare(CoordinateSystemAxis axis1, CoordinateSystemAxis axis2)
Compares two axis for order.protected void
completeHints()
Completes the set of hints according the value currently set in this object.protected static int[]
computeDirectionRanks(AxisDirection... axisOrder)
Computes the rank for every direction in the specified.Unit<?>
replace(Unit<?> units)
Replaces the specified unit, if applicable.protected AxisDirection
replace(AxisDirection direction)
Replaces the specified direction, if applicable.-
Methods inherited from class TransformedAuthorityFactory
createFromCoordinateReferenceSystemCodes, dispose, getPriority, replace, replace, replace, replace, replace
-
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 AuthorityFactory
createObject, getAuthority, getAuthorityCodes, getDescriptionText
-
Methods inherited from interface Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface CRSAuthorityFactory
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
-
Methods inherited from interface Factory
getImplementationHints
-
-
-
-
Field Detail
-
directionRanks
protected final int[] directionRanks
The rank to be given to each axis direction. The rank is stored at the indice corresponding to the direction ordinal value.
-
forceStandardDirections
protected final boolean forceStandardDirections
true
if this authority factory should also force the axis to their standard direction. For example iftrue
, then axis with increasing values toward South will be converted to axis with increasing values toward North. The default value isfalse
.- Since:
- 2.3
- See Also:
Hints.FORCE_STANDARD_AXIS_DIRECTIONS
-
forceStandardUnits
protected final boolean forceStandardUnits
true
if this authority factory should also force all angular units to decimal degrees and linear units to meters. The default value isfalse
.- Since:
- 2.3
- See Also:
Hints.FORCE_STANDARD_AXIS_UNITS
-
-
Constructor Detail
-
OrderedAxisCRSAuthorityFactory
public OrderedAxisCRSAuthorityFactory(String authority, Hints userHints, AxisDirection... axisOrder) throws FactoryRegistryException, IllegalArgumentException
Creates a factory which will reorder the axis of all objects created by the default authority factories. The factories are fetched usingReferencingFactoryFinder
. This constructor accepts the following hints:Hints.FORCE_STANDARD_AXIS_UNITS
Hints.FORCE_STANDARD_AXIS_DIRECTIONS
- All hints understood by
ReferencingFactoryFinder
- 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.axisOrder
- An array of axis directions that determine the axis order wanted, ornull
for the default axis order.- Throws:
FactoryRegistryException
- if at least one factory can not be obtained.IllegalArgumentException
- If at least two axis directions are colinear.- Since:
- 2.3
-
OrderedAxisCRSAuthorityFactory
public OrderedAxisCRSAuthorityFactory(AbstractAuthorityFactory factory, Hints userHints, AxisDirection... axisOrder) throws IllegalArgumentException
Creates a factory which will reorder the axis of all objects created by the supplied factory. This constructor accepts the following optional hints:- Parameters:
factory
- The factory that produces objects using arbitrary axis order.userHints
- An optional set of hints, ornull
if none.axisOrder
- An array of axis directions that determine the axis order wanted, ornull
for the default axis order.- Throws:
IllegalArgumentException
- If at least two axis directions are colinear.- Since:
- 2.3
-
-
Method Detail
-
booleanValue
protected static boolean booleanValue(Hints userHints, Hints.Key key)
Returns the boolean value for the specified hint.
-
computeDirectionRanks
protected static int[] computeDirectionRanks(AxisDirection... axisOrder) throws IllegalArgumentException
Computes the rank for every direction in the specified. The rank is stored in an array at the indice corresponding to the direction ordinal value. This method is used by constructors for computing thedirectionRanks
field.- Throws:
IllegalArgumentException
- If at least two axis directions are colinear.
-
completeHints
protected void completeHints()
Completes the set of hints according the value currently set in this object. This method is invoked by constructors only.
-
compare
public int compare(CoordinateSystemAxis axis1, CoordinateSystemAxis axis2)
Compares two axis for order. This method is invoked automatically by thereplace
method for ordering the axis in a coordinate system. The default implementation orders the axis according their direction, using the direction table given at construction time (see also the class description). Subclasses may override this method if they want to define a more sophesticated axis ordering.- Specified by:
compare
in interfaceComparator<CoordinateSystemAxis>
- Parameters:
axis1
- The first axis to compare.axis2
- The second axis to compare.- Returns:
- A negative integer if
axis1
should appears beforeaxis2
, or a positive number ifaxis2
should appears beforeaxis1
, or 0 if the two axis are unordered one relative to the other. - Since:
- 2.3
-
replace
public Unit<?> replace(Unit<?> units)
Replaces the specified unit, if applicable. This method is invoked automatically by theTransformedAuthorityFactory.replace(CoordinateSystem)
method. The default implementation replaces the unit only if theFORCE_STANDARD_AXIS_UNITS
hint was specified asTRUE
at construction time. In such case, the default substitution table is:- Any linear units converted to meters
- Radians and grades converted to decimal degrees
This default substitution table may be expanded in future GeoTools versions.
- Overrides:
replace
in classTransformedAuthorityFactory
- Parameters:
units
- The units to replace.- Returns:
- The new units, or
units
if no change were needed. - Since:
- 2.3
-
replace
protected AxisDirection replace(AxisDirection direction)
Replaces the specified direction, if applicable. This method is invoked automatically by theTransformedAuthorityFactory.replace(CoordinateSystem)
method. The default implementation replaces the direction only if theFORCE_STANDARD_AXIS_DIRECTIONS
hint was specified asTRUE
at construction time. In such case, the default substitution table is as specified in theAxisDirection.absolute()
method. Subclasses may override this method if they want to use a different substitution table.- Overrides:
replace
in classTransformedAuthorityFactory
- Parameters:
direction
- The axis direction to replace.- Returns:
- The new direction, or
direction
if no change were needed. - Since:
- 2.3
-
-