Class MultiAuthoritiesFactory

All Implemented Interfaces:
Authority­Factory, CRSAuthority­Factory, CSAuthority­Factory, Datum­Authority­Factory, Coordinate­Operation­Authority­Factory, Factory

A factory that delegates the object creation to another factory determined from the authority part in “authority:code” arguments. The list of factories to use as delegates can be specified at construction time.

This factory requires that every codes given to a create­Foo(String) method are prefixed by a namespace, for example "EPSG:4326" or "EPSG::4326". When a create­Foo(String) method is invoked, this class uses the authority part in the “authority:code” argument for locating a factory capable to create a geodetic object for the code part. If a factory is found in the list of factories given at construction time, then the work is delegated to that factory. Otherwise a No­Such­Authority­Factory­Exception is thrown.

URI syntax

This factory can also parse URNs or URLs of the following forms:
  • "urn:ogc:def:type:authority:version:code"
  • "http://www​.opengis​.net/def/type/authority/version/code"
  • "http://www​.opengis​.net/gml/srs/authority.xml#code"
In such cases, the type specified in the URN may be used for invoking a more specific method. However, Multi­Authorities­Factory uses the type information in the URN only for delegating to a more specific method, never for delegating to a less specific method. An exception will be thrown if the type in the URN is incompatible with the invoked method.

Example

If create­Object("urn:ogc:def:crs:EPSG::4326") is invoked, then Multi­Authorities­Factory will delegate (indirectly, ignoring caching for this example) the object creation to EPSGData­Access​.create­Coordinate­Reference­System(String) instead of EPSGData­Access​.create­Object(String) because of the "crs" part in the URN. The more specific method gives better performances and avoid ambiguities.

Compound URIs

This class accepts also combined URIs of the following forms (only two components shown, but arbitrary number of components is allowed):
  • "urn:ogc:def:type, type₁:authority₁:version₁:code₁, type₂:authority₂:version₂:code₂"
  • "http://www​.opengis​.net/def/crs-compound?
    1=http://www​.opengis​.net/def/crs/authority₁/version₁/code₁&
    2=http://www​.opengis​.net/def/crs/authority₂/version₂/code₂"
Given such URIs, Multi­Authorities­Factory invokes create­Object(String) for each component and combines the result as described by the CRS​.compound(Coordinate­Reference­System...) method. URNs (but not URLs) can also combine a geodetic datum with an ellipsoidal coordinate system for creating a new geographic CRS, or a base geographic CRS with a conversion and a Cartesian coordinate system for creating a new projected coordinate reference system, or coordinate operations for creating a concatenated operation.

Multiple versions for the same authority

Multi­Authorities­Factory accepts an arbitrary number of factories for the same authority, provided that those factories have different version numbers. If a create­Foo(String) method is invoked with a URN containing a version number different than zero, then Multi­Authorities­Factory will search for a factory with that exact version, or throw a No­Such­Authority­Factory­Exception if no suitable factory is found. If a create­Foo(String) method is invoked with the version number omitted, then Multi­Authorities­Factory will use the first factory in iteration order for the requested authority regardless of its version number.

Example

A Multi­Authorities­Factory instance could contain two EPSGFactory instances: one for version 8.2 and another one for version 7.9 of the EPSG dataset. A specific version can be requested in the URN given to create­Foo(String) methods, for example "urn:ogc:def:crs:EPSG:8.2:4326". If no version is given of if the given version is zero, then the first EPSG factory in iteration order is used regardless of its version number.

Multi-threading

This class is thread-safe if all delegate factories are themselves thread-safe. However, the factory providers, which are given to the constructor as Iterable instances, do not need to be thread-safe. See constructor Javadoc for more information.
Since:
0.7
See Also: