org.geotools.referencing.factory
Class OrderedAxisAuthorityFactory

java.lang.Object
  extended byorg.geotools.factory.AbstractFactory
      extended byorg.geotools.referencing.factory.AbstractFactory
          extended byorg.geotools.referencing.factory.AbstractAuthorityFactory
              extended byorg.geotools.referencing.factory.AuthorityFactoryAdapter
                  extended byorg.geotools.referencing.factory.OrderedAxisAuthorityFactory
All Implemented Interfaces:
org.opengis.referencing.AuthorityFactory, org.opengis.referencing.operation.CoordinateOperationAuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory, org.opengis.referencing.cs.CSAuthorityFactory, org.opengis.referencing.datum.DatumAuthorityFactory, Factory, org.opengis.referencing.Factory, javax.imageio.spi.RegisterableService

public class OrderedAxisAuthorityFactory
extends AuthorityFactoryAdapter

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. Note that using this "ordered axis authority factory" may have a negative impact on performance, accuracy and range of supported CRS.

If you need to override an official factory by an ordered axis instance on a system-wide level, the register convenience method can performs this task for the current Java Virtual Machine running instance. For example an application using the EPSG authority factory with (longitude, latitude) order instead of the official one can invoke the following methods:

 OrderedAxisAuthorityFactory.register("EPSG"); // Invoke this only once (usually at startup time)
 CRSAuthorityFactory f = FactoryFinder.getCRSAuthorityFactory("EPSG", null);
 

Since:
2.2
Version:
$Id: OrderedAxisAuthorityFactory.java 18124 2006-02-20 23:03:09Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class org.geotools.referencing.factory.AuthorityFactoryAdapter
crsFactory, csFactory, datumFactory, opFactory
 
Fields inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
factories
 
Fields inherited from class org.geotools.referencing.factory.AbstractFactory
LOGGER
 
Fields inherited from class org.geotools.factory.AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
OrderedAxisAuthorityFactory(AbstractAuthorityFactory factory, boolean fixUnits)
          Creates a factory which will reorder the axis of all objects created by the supplied factory.
OrderedAxisAuthorityFactory(java.lang.String authority, Hints hints, boolean fixUnits)
          Creates a factory which will reorder the axis of all objects created by the default authority factories.
 
Method Summary
protected  org.opengis.referencing.cs.CoordinateSystem createCS(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystemAxis[] axis)
          Creates a new coordinate system of the same kind than the specified CS, but different axis.
 org.opengis.metadata.citation.Citation getAuthority()
          Returns the organization or party responsible for definition and maintenance of the database.
static void register(java.lang.String authority)
          Registers an ordered axis authority factory as a replacement of the specified authority.
protected  org.opengis.referencing.cs.CoordinateSystem replace(org.opengis.referencing.cs.CoordinateSystem cs)
          Reorder (if needed) the axis in the specified coordinate system.
static void unregister(java.lang.String authority)
          Unregisters an ordered axis authority factory previously registered with the register method.
 
Methods inherited from class org.geotools.referencing.factory.AuthorityFactoryAdapter
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, dispose, getAuthorityCodes, getBackingStoreDescription, getDescriptionText, getVendor, replace, replace, replace
 
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
getImplementationHints, noSuchAuthorityCode, onRegistration, trimAuthority
 
Methods inherited from class org.geotools.referencing.factory.AbstractFactory
ensureNonNull
 
Methods inherited from class org.geotools.factory.AbstractFactory
onDeregistration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderedAxisAuthorityFactory

public OrderedAxisAuthorityFactory(AbstractAuthorityFactory factory,
                                   boolean fixUnits)
Creates a factory which will reorder the axis of all objects created by the supplied factory. The priority level will be equals to the specified factory's priority plus one.

Parameters:
factory - The factory that produces objects using arbitrary axis order.
fixUnits - if this authority factory should also force all angular units to degrees and linear units to meters, or if the units should be left unchanged.

OrderedAxisAuthorityFactory

public OrderedAxisAuthorityFactory(java.lang.String authority,
                                   Hints hints,
                                   boolean fixUnits)
Creates a factory which will reorder the axis of all objects created by the default authority factories. The factories are fetched using FactoryFinder.

Parameters:
authority - The authority to wraps (example: ).
hints - An optional set of hints, or if none.
fixUnits - if this authority factory should also force all angular units to degrees and linear units to meters, or if the units should be left unchanged.
Throws:
FactoryRegistryException - if at least one factory can not be obtained.
Method Detail

register

public static void register(java.lang.String authority)
                     throws FactoryRegistryException
Registers an ordered axis authority factory as a replacement of the specified authority. If this method has already been invoked previously for the same authority, then this method invocation does nothing. Otherwise, it performs the following steps:

WARNING: this method has a system-wide effect. Any user asking for the specified will get an ordered axis authority factory instance. It may be misleading for client code expecting the official factory. Avoid this method unless you really need reordered axis for all code in the current Java Virtual Machine.

Parameters:
authority - The name of the authority factories to override with an ordered axis instance.
Throws:
FactoryRegistryException - if the registration failed.

unregister

public static void unregister(java.lang.String authority)
                       throws FactoryRegistryException
Unregisters an ordered axis authority factory previously registered with the register method.

Parameters:
authority - The authority name given to the register method.
Throws:
FactoryRegistryException - if the unregistration failed.

getAuthority

public org.opengis.metadata.citation.Citation getAuthority()
Returns the organization or party responsible for definition and maintenance of the database. The default implementation returns the authority of the underlying factory with "(modified axis)" label appended.

Note: the title and alternates titles are modified as described above in order to make it clear for human readers that objects to be created are not from the official authority. However, this method copies the identifiers unchanged in order to allow applications to use this factory as a replacement of the official one.

Specified by:
getAuthority in interface org.opengis.referencing.AuthorityFactory
Overrides:
getAuthority in class AuthorityFactoryAdapter

replace

protected org.opengis.referencing.cs.CoordinateSystem replace(org.opengis.referencing.cs.CoordinateSystem cs)
                                                       throws org.opengis.referencing.FactoryException
Reorder (if needed) the axis in the specified coordinate system. The default implementation uses the same axis order than the one returned by AbstractCS.standard(cs).

Implementation note: It would have been possible to reorder axis using some algorithm more generic than standard(cs). But we use the above-cited method anyway in order to get consistent "standard" axis accross the whole Geotools implementation.

Overrides:
replace in class AuthorityFactoryAdapter
Parameters:
cs - The coordinate system to replace.
Returns:
A new coordinate system, or if no change were needed.
Throws:
org.opengis.referencing.FactoryException - If this method can't rearange the axis for the specified .

createCS

protected org.opengis.referencing.cs.CoordinateSystem createCS(org.opengis.referencing.cs.CoordinateSystem cs,
                                                               org.opengis.referencing.cs.CoordinateSystemAxis[] axis)
                                                        throws org.opengis.referencing.FactoryException
Creates a new coordinate system of the same kind than the specified CS, but different axis. This method is invoked automatically by replace(CoordinateSystem) after it determined that the axis order need to be changed. Subclasses can override this method if they want to performs some extra processing on the axis order.

Parameters:
cs - The coordinate system to use as a model.
axis - The axis to give to the new coordinate system. Subclasses are allowed to write directly in this array (no need to copy it).
Returns:
A new coordinate system of the same kind than but with the specified axis.
Throws:
org.opengis.referencing.FactoryException - if the coordinate system can't be created.
java.lang.IndexOutOfBoundsException - if the length of is smaller than the number of dimensions in .


Copyright © GeoTools. All Rights Reserved.