Class CommonAuthorityFactory
java.lang.Object
org.apache.sis.util.iso.AbstractFactory
org.apache.sis.referencing.factory.GeodeticAuthorityFactory
org.apache.sis.referencing.factory.CommonAuthorityFactory
- All Implemented Interfaces:
org.opengis.referencing.AuthorityFactory
,org.opengis.referencing.crs.CRSAuthorityFactory
,org.opengis.util.Factory
public class CommonAuthorityFactory
extends GeodeticAuthorityFactory
implements org.opengis.referencing.crs.CRSAuthorityFactory
Creates coordinate reference systems in the "
OGC
", "CRS
" or "AUTO(2)"
namespaces.
All namespaces recognized by this factory are defined by the Open Geospatial Consortium (OGC).
Most codes map to one of the constants in the CommonCRS
enumeration.
Namespace | Code | Name | Datum type | CS type | Axis direction | Units |
---|---|---|---|---|---|---|
CRS | 1 | Computer display | Engineering | Cartesian | (east, south) | pixels |
CRS | 27 | NAD27 | Geographic | Ellipsoidal | (east, north) | degrees |
CRS | 83 | NAD83 | Geographic | Ellipsoidal | (east, north) | degrees |
CRS | 84 | WGS84 | Geographic | Ellipsoidal | (east, north) | degrees |
CRS | 88 | NAVD88 | Vertical | Vertical | up | metres |
AUTO2 | 42001 | WGS 84 / Auto UTM | Projected | Cartesian | (east, north) | user-specified |
AUTO2 | 42002 | WGS 84 / Auto Tr Mercator | Projected | Cartesian | (east, north) | user-specified |
AUTO2 | 42003 | WGS 84 / Auto Orthographic | Projected | Cartesian | (east, north) | user-specified |
AUTO2 | 42004 | WGS 84 / Auto Equirectangular | Projected | Cartesian | (east, north) | user-specified |
AUTO2 | 42005 | WGS 84 / Auto Mollweide | Projected | Cartesian | (east, north) | user-specified |
OGC | JulianDate | Julian | Temporal | Time | (future) | days |
OGC | TruncatedJulianDate | Truncated Julian | Temporal | Time | (future) | days |
OGC | UnixTime | Unix Time | Temporal | Time | (future) | seconds |
Note on codes in CRS namespace
The format is usually "CRS:
n" where n is a number like 27, 83 or 84.
However, this factory is lenient and allows the CRS
part to be repeated as in "CRS:CRS84"
.
It also accepts "OGC"
as a synonymous of the "CRS"
namespace.
Examples:
"CRS:27"
, "CRS:83"
, "CRS:84"
, "CRS:CRS84"
, "OGC:CRS84"
.Note on codes in AUTO(2) namespace
The format is usually "AUTO2:
n,factor,λ₀,φ₀"
where n is a number between 42001 and 42005 inclusive, factor is a conversion
factor from the CRS units to metres (e.g. 0.3048 for a CRS with axes in feet) and (λ₀,φ₀)
is the longitude and latitude of a point in the projection centre.
Examples:
Codes in the "AUTO2:42001,1,-100,45"
identifies a Universal Transverse Mercator (UTM) projection
for a zone containing the point at (45°N, 100°W) with axes in metres."AUTO"
namespace are the same than codes in the "AUTO2"
namespace, except that
the EPSG code of the desired unit of measurement
was used instead of the unit factor.
The "AUTO"
namespace was defined in the Web Map Service (WMS) 1.1.1 specification
while the "AUTO2"
namespace is defined in WMS 1.3.0.
In Apache SIS implementation, the unit parameter (either as factor or as EPSG code) is optional and defaults to metres.
In the AUTO(2):42001
case, the UTM zone is calculated as specified in WMS 1.3 specification,
i.e. without taking in account the Norway and Svalbard special cases and without
switching to polar stereographic projections for high latitudes.
- Since:
- 0.7
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The "AUTO2" prefix for a code identified by parameters.The codes known to this factory, associated with their CRS type.The namespaces of codes defined by OGC.private static final int
First code in the AUTO(2) namespace.private org.opengis.referencing.cs.CartesianCS
The coordinate system for map projection in metres, created when first needed.private static final String[]
Names of objects in the AUTO(2) namespace for codes from 42001 to 42005 inclusive.private static final String[]
Names of temporal CRS in OGC namespace. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default factory for theCRS
authority. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Adds an element in thecodes
map, witch check against duplicated values.private org.opengis.referencing.crs.ProjectedCRS
createAuto
(String code, int projection, boolean isLegacy, double factor, double longitude, double latitude) Creates a projected CRS from parameters in theAUTO(2)
namespace.org.opengis.referencing.crs.CoordinateReferenceSystem
Creates a coordinate reference system from the specified code.private org.opengis.referencing.crs.CoordinateReferenceSystem
createCoordinateReferenceSystem
(String code, CommonAuthorityCode parsed) Implementation ofcreateCoordinateReferenceSystem(String)
after the user supplied code has been parsed.org.opengis.referencing.IdentifiedObject
createObject
(String code) Creates an object from the specified code.private static javax.measure.Unit
<?> createUnitFromEPSG
(double code) Returns the unit of measurement for the given EPSG code.private static String
format
(int code) Formats the given code with a"CRS:"
or"AUTO2:"
prefix.private static String
Formats the given code with an"OGC:"
prefix.org.opengis.metadata.citation.Citation
Returns the specification that defines the codes recognized by this factory.getAuthorityCodes
(Class<? extends org.opengis.referencing.IdentifiedObject> type) Provides a complete set of the known codes provided by this factory.Returns the namespaces defined by the OGC specifications implemented by this factory.org.opengis.util.InternationalString
getDescriptionText
(String code) Returns a description of the object corresponding to a code.private static org.opengis.referencing.NoSuchAuthorityCodeException
noSuchAuthorityCode
(String localCode, String code, Exception cause) Creates an exception for an unknown authority code.(package private) static String
Rewrites the given code in a canonical format and without parameters.Methods inherited from class org.apache.sis.referencing.factory.GeodeticAuthorityFactory
appendStringTo, createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createOperationMethod, createParameterDescriptor, createParametricCRS, createParametricCS, createParametricDatum, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, newIdentifiedObjectFinder, regionMatches, toString, trimNamespace
Methods inherited from class org.apache.sis.util.iso.AbstractFactory
getVendor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.referencing.crs.CRSAuthorityFactory
createCompoundCRS, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
Methods inherited from interface org.opengis.util.Factory
getVendor
-
Field Details
-
AUTO2
The "AUTO2" prefix for a code identified by parameters. This is defined in annexes B.7 to B.11 of WMS 1.3 specification. The"AUTO(2)"
namespaces are not considered by Apache SIS as real authorities.- See Also:
-
CODESPACES
The namespaces of codes defined by OGC.- See Also:
-
FIRST_PROJECTION_CODE
private static final int FIRST_PROJECTION_CODEFirst code in the AUTO(2) namespace.- See Also:
-
PROJECTION_NAMES
Names of objects in the AUTO(2) namespace for codes from 42001 to 42005 inclusive. Those names are defined in annexes B.7 to B.11 of WMS 1.3 specification.- See Also:
-
TEMPORAL_NAMES
Names of temporal CRS in OGC namespace. Those CRS are defined byCommonCRS.Temporal
. Codes in Apache SIS namespace are excluded from this list.- See Also:
-
codes
The codes known to this factory, associated with their CRS type. This is set to an empty map atCommonAuthorityFactory
construction time and filled only when first needed. Keys are of the form "AUTHORITY:IDENTIFIER". -
projectedCS
private volatile org.opengis.referencing.cs.CartesianCS projectedCSThe coordinate system for map projection in metres, created when first needed.
-
-
Constructor Details
-
CommonAuthorityFactory
public CommonAuthorityFactory()Constructs a default factory for theCRS
authority.
-
-
Method Details
-
getAuthority
public org.opengis.metadata.citation.Citation getAuthority()Returns the specification that defines the codes recognized by this factory. The definitive source for this factory is OGC Web Map Service (WMS) specification, also available as the ISO 19128 Geographic Information — Web map server interface standard.While the authority is WMS, the namespace of that authority is set to
"OGC"
. Apache SIS does that for consistency with the namespace used in URNs (for example"urn:ogc:def:crs:OGC:1.3:CRS84"
).- Specified by:
getAuthority
in interfaceorg.opengis.referencing.AuthorityFactory
- Specified by:
getAuthority
in classGeodeticAuthorityFactory
- Returns:
- the "Web Map Service" authority.
- See Also:
-
reformat
Rewrites the given code in a canonical format and without parameters. If the code is not in a known namespace, then this method returnsnull
. -
format
Formats the given code with a"CRS:"
or"AUTO2:"
prefix. This is used for numerical codes such as "CRS:84". -
format
Formats the given code with an"OGC:"
prefix. This is used for non-numerical codes such as "OGC:JulianDate". -
getAuthorityCodes
public Set<String> getAuthorityCodes(Class<? extends org.opengis.referencing.IdentifiedObject> type) throws org.opengis.util.FactoryException Provides a complete set of the known codes provided by this factory. The returned set contains a namespace followed by identifiers like"CRS:84"
,"CRS:27"
,"AUTO2:42001"
, etc.- Specified by:
getAuthorityCodes
in interfaceorg.opengis.referencing.AuthorityFactory
- Parameters:
type
- the spatial reference objects type.- Returns:
- the set of authority codes for spatial reference objects of the given type.
- Throws:
org.opengis.util.FactoryException
- if this method failed to provide the set of codes.
-
add
private void add(int code, Class<? extends org.opengis.referencing.crs.SingleCRS> type) throws org.opengis.util.FactoryException Adds an element in thecodes
map, witch check against duplicated values.- Throws:
org.opengis.util.FactoryException
-
getCodeSpaces
Returns the namespaces defined by the OGC specifications implemented by this factory. At the difference of other factories, the namespaces ofCommonAuthorityFactory
are quite different than the authority title or identifier:- Authority:
"WMS"
(for "Web Map Services") - Namespaces:
"CRS"
,"AUTO"
,"AUTO2"
. The"OGC"
namespace is also accepted for compatibility reason, but its scope is wider than the above-cited namespaces.
- Overrides:
getCodeSpaces
in classGeodeticAuthorityFactory
- Returns:
- a set containing at least the
"CRS"
,"AUTO"
and"AUTO2"
strings. - See Also:
- Authority:
-
getDescriptionText
public org.opengis.util.InternationalString getDescriptionText(String code) throws org.opengis.util.FactoryException Returns a description of the object corresponding to a code. The description can be used for example in a combo box in a graphical user interface.Codes in the
"AUTO(2)"
namespace do not need parameters for this method. But if parameters are nevertheless specified, then they will be taken in account.Examples Argument value Return value CRS:84
WGS 84 AUTO2:42001
WGS 84 / Auto UTM AUTO2:42001,1,-100,45
WGS 84 / UTM zone 47N - Specified by:
getDescriptionText
in interfaceorg.opengis.referencing.AuthorityFactory
- Overrides:
getDescriptionText
in classGeodeticAuthorityFactory
- Parameters:
code
- value in the CRS or AUTO(2) code space.- Returns:
- a description of the object.
- Throws:
org.opengis.referencing.NoSuchAuthorityCodeException
- if the specifiedcode
was not found.org.opengis.util.FactoryException
- if an error occurred while fetching the description.
-
createObject
public org.opengis.referencing.IdentifiedObject createObject(String code) throws org.opengis.util.FactoryException Creates an object from the specified code. The default implementation delegates tocreateCoordinateReferenceSystem(String)
.- Specified by:
createObject
in interfaceorg.opengis.referencing.AuthorityFactory
- Specified by:
createObject
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the object for the given code.
- Throws:
org.opengis.util.FactoryException
- if the object creation failed.- See Also:
-
createCoordinateReferenceSystem
public org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws org.opengis.util.FactoryException Creates a coordinate reference system from the specified code. This method performs the following steps:- Skip the
"OGC"
,"CRS"
,"AUTO"
,"AUTO1"
or"AUTO2"
namespace if present (ignoring case). All other namespaces will cause an exception to be thrown. - Skip the
"CRS"
prefix if present. This additional check is for accepting codes like"OGC:CRS84"
(not a valid CRS code, but seen in practice). - In the remaining text, interpret the integer value as documented in this class javadoc. Note that some codes require coma-separated parameters after the integer value.
- Specified by:
createCoordinateReferenceSystem
in interfaceorg.opengis.referencing.crs.CRSAuthorityFactory
- Overrides:
createCoordinateReferenceSystem
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by OGC.- Returns:
- the coordinate reference system for the given code.
- Throws:
org.opengis.util.FactoryException
- if the object creation failed.- See Also:
- Skip the
-
createCoordinateReferenceSystem
private org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(String code, CommonAuthorityCode parsed) throws org.opengis.util.FactoryException Implementation ofcreateCoordinateReferenceSystem(String)
after the user supplied code has been parsed.- Parameters:
code
- the user supplied code of desired CRS.parsed
- result of parsing the suppliedcode
.- Throws:
org.opengis.util.FactoryException
- if the object creation failed.
-
createAuto
private org.opengis.referencing.crs.ProjectedCRS createAuto(String code, int projection, boolean isLegacy, double factor, double longitude, double latitude) throws org.opengis.util.FactoryException Creates a projected CRS from parameters in theAUTO(2)
namespace.- Parameters:
code
- the user-specified code, used only for error reporting.projection
- the projection code (e.g. 42001).isLegacy
-true
if the code was found in"AUTO"
or"AUTO1"
namespace.factor
- the multiplication factor for the unit of measurement.longitude
- a longitude in the desired projection zone.latitude
- a latitude in the desired projection zone.- Returns:
- the projected CRS for the given projection and parameters.
- Throws:
org.opengis.util.FactoryException
-
createUnitFromEPSG
private static javax.measure.Unit<?> createUnitFromEPSG(double code) throws org.opengis.referencing.NoSuchAuthorityCodeException Returns the unit of measurement for the given EPSG code. This is used only for codes in the legacy"AUTO"
namespace.- Throws:
org.opengis.referencing.NoSuchAuthorityCodeException
-
noSuchAuthorityCode
private static org.opengis.referencing.NoSuchAuthorityCodeException noSuchAuthorityCode(String localCode, String code, Exception cause) Creates an exception for an unknown authority code.- Parameters:
localCode
- the unknown authority code, without namespace.code
- the unknown authority code as specified by the user (may include namespace).cause
- the failure cause, ornull
if none.- Returns:
- an exception initialized with an error message built from the specified information.
-