org.geotoolkit.referencing.factory
Class OrderedAxisAuthorityFactory

Object
  extended by Factory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by AuthorityFactoryAdapter
                  extended by TransformedAuthorityFactory
                      extended by OrderedAxisAuthorityFactory
All Implemented Interfaces:
Comparator<CoordinateSystemAxis>, AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, Factory
Direct Known Subclasses:
LongitudeFirstEpsgFactory

@ThreadSafe
public class OrderedAxisAuthorityFactory
extends TransformedAuthorityFactory
implements CSAuthorityFactory, 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 exists primarily for compatibility with external data (for example Shapefiles) or applications (for example old WMS specifications) expecting geographic coordinates in (longitude, latitude) order, while most geographic CRS specified in the EPSG database use the opposite axis order.

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_POSITIVE, ROW_POSITIVE, 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, as a right-handed coordinate system if possible.

Notes:


Getting an instance
For some authority factories, an instance of this class can be obtained by passing a FORCE_LONGITUDE_FIRST_AXIS_ORDER hint to the FactoryFinder.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");

Since:
2.2
Version:
3.12
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Hints.FORCE_STANDARD_AXIS_UNITS
Module:
referencing/geotk-referencing (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class Factory
Factory.Availability, Factory.Organizer
 
Field Summary
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 AbstractAuthorityFactory
nameFactory
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class Factory
EMPTY_HINTS, hints
 
Constructor Summary
OrderedAxisAuthorityFactory(AbstractAuthorityFactory factory, Hints userHints, AxisDirection[] axisOrder)
          Creates a factory which will reorder the axis of all objects created by the supplied factory.
OrderedAxisAuthorityFactory(String authority, Hints userHints, AxisDirection[] axisOrder)
          Creates a factory which will reorder the axis of all objects created by the default authority factories.
 
Method Summary
 int compare(CoordinateSystemAxis axis1, CoordinateSystemAxis axis2)
          Compares two axis for order.
protected  AxisDirection replace(AxisDirection direction)
          Replaces the specified direction, if applicable.
protected  Unit<?> replace(Unit<?> units)
          Replaces the specified unit, if applicable.
 
Methods inherited from class TransformedAuthorityFactory
createFromCoordinateReferenceSystemCodes, dispose, replace, replace, replace, replace, replace
 
Methods inherited from class AuthorityFactoryAdapter
availability, 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, getAuthorityFactory, getBackingStoreDescription, getCoordinateOperationAuthorityFactory, getCRSAuthorityFactory, getCSAuthorityFactory, getDatumAuthorityFactory, getDescriptionText, getIdentifiedObjectFinder, getImplementationHints, getVendor, toBackingFactoryCode
 
Methods inherited from class AbstractAuthorityFactory
noSuchAuthorityCode, trimAuthority
 
Methods inherited from class ReferencingFactory
ensureNonNull
 
Methods inherited from class Factory
equals, hasCompatibleHints, hashCode, setOrdering, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface CSAuthorityFactory
createCartesianCS, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createUnit, createVerticalCS
 
Methods inherited from interface CRSAuthorityFactory
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
 
Methods inherited from interface AuthorityFactory
createObject, getAuthority, getAuthorityCodes, getDescriptionText
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface Comparator
equals
 

Field Detail

forceStandardDirections

protected final boolean forceStandardDirections
true if this authority factory should also force the axis to their standard direction. For example if true, then axis with increasing values toward South will be converted to axis with increasing values toward North. The default value is false.

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 is false.

Since:
2.3
See Also:
Hints.FORCE_STANDARD_AXIS_UNITS
Constructor Detail

OrderedAxisAuthorityFactory

public OrderedAxisAuthorityFactory(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 using AuthorityFactoryFinder. This constructor accepts the following hints:

Parameters:
authority - The authority to wrap (example: "EPSG"). If null, then all authority factories must be explicitly specified in the set of hints.
userHints - An optional set of hints, or null if none.
axisOrder - An array of axis directions that determine the axis order wanted, or null 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

OrderedAxisAuthorityFactory

public OrderedAxisAuthorityFactory(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, or null if none.
axisOrder - An array of axis directions that determine the axis order wanted, or null for the default axis order.
Throws:
IllegalArgumentException - If at least two axis directions are colinear.
Since:
2.3
Method Detail

compare

public int compare(CoordinateSystemAxis axis1,
                   CoordinateSystemAxis axis2)
Compares two axis for order. This method is invoked automatically by the replace 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) first, or in an order forming a right-handed coordinate system if the axis direction was not specified at construction time. Subclasses can override this method if they want to define an other axis ordering.

Specified by:
compare in interface Comparator<CoordinateSystemAxis>
Parameters:
axis1 - The first axis to compare.
axis2 - The second axis to compare.
Returns:
A negative integer if axis1 should appears before axis2, or a positive number if axis2 should appears before axis1, or 0 if the two axis are unordered one relative to the other.
Since:
2.3

replace

protected Unit<?> replace(Unit<?> units)
Replaces the specified unit, if applicable. This method is invoked automatically by the TransformedAuthorityFactory.replace(CoordinateSystem) method. The default implementation replaces the unit only if the FORCE_STANDARD_AXIS_UNITS hint was specified as TRUE at construction time. In such case, the default substitution table is:

Overrides:
replace in class TransformedAuthorityFactory
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 the TransformedAuthorityFactory.replace(CoordinateSystem) method. The default implementation replaces the direction only if the FORCE_STANDARD_AXIS_DIRECTIONS hint was specified as TRUE at construction time.

Overrides:
replace in class TransformedAuthorityFactory
Parameters:
direction - The axis direction to replace.
Returns:
The new direction, or direction if no change were needed.
Since:
2.3


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.