Package org.apache.sis.internal.metadata
Class ReferencingServices
java.lang.Object
org.apache.sis.internal.system.SystemListener
org.apache.sis.internal.system.OptionalDependency
org.apache.sis.internal.metadata.ReferencingServices
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
ServicesForMetadata
Provides access to services defined in the
"sis-referencing" module.
This class searches for the ServicesForMetadata
implementation using Java reflection.
This class also opportunistically defines some methods and constants related to "referencing by coordinates" but needed by metadata.
- Since:
- 0.3
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe GRS80 authalic radius, which is 6371007.0 metres.private static ReferencingServicesThe services, fetched when first needed.static final doubleThe length of one nautical mile, which is 1852.0 metres. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElements(org.opengis.geometry.Envelope envelope, DefaultExtent target) Initializes a horizontal, vertical and temporal extent with the values inferred from the given envelope.protected final voidInvoked when the classpath changed.createCoordinateFormat(Locale locale, TimeZone timezone) Creates a format forDirectPositioninstances.org.opengis.geometry.DirectPositiongeographic(double λ, double φ) Creates a two-dimensional geographic position associated to the default geographic CRS.org.opengis.referencing.operation.CoordinateOperationFactoryReturns the default coordinate operation factory.getInformation(String key, Locale locale) Returns information about the Apache SIS configuration to be reported inAbout.static ReferencingServicesReturns the singleton instance.getPreferredIdentifier(org.opengis.referencing.IdentifiedObject object) Returns an identifier for the given object, giving precedence to EPSG identifier if available.org.opengis.util.TypeNamegetValueType(org.opengis.parameter.ParameterDescriptor<?> parameter) Returns the name of the type of values.setBounds(org.opengis.geometry.Envelope envelope, DefaultGeographicBoundingBox target, String findOpCaller) Sets a geographic bounding box from the specified envelope.voidsetBounds(org.opengis.geometry.Envelope envelope, DefaultSpatialTemporalExtent target) Sets the geographic, vertical and temporal extents with the values inferred from the given envelope.voidsetBounds(org.opengis.geometry.Envelope envelope, DefaultTemporalExtent target) Sets a temporal extent with the value inferred from the given envelope.voidsetBounds(org.opengis.geometry.Envelope envelope, DefaultVerticalExtent target) Sets a vertical extent with the value inferred from the given envelope.<T> org.opengis.parameter.ParameterDescriptor<T>toImplementation(org.opengis.parameter.ParameterDescriptor<T> parameter) Returns a fully implemented parameter descriptor.Methods inherited from class org.apache.sis.internal.system.OptionalDependency
getInstance, moduleNotFoundMethods inherited from class org.apache.sis.internal.system.SystemListener
add, databaseChanged, fireClasspathChanged, remove
-
Field Details
-
NAUTICAL_MILE
public static final double NAUTICAL_MILEThe length of one nautical mile, which is 1852.0 metres.- See Also:
-
AUTHALIC_RADIUS
public static final double AUTHALIC_RADIUSThe GRS80 authalic radius, which is 6371007.0 metres. This is close to the WGS84 authalic radius, which is about 6371007.180918474 when computed withdoubleprecision.- See Also:
-
instance
The services, fetched when first needed.
-
-
Constructor Details
-
ReferencingServices
protected ReferencingServices()For subclass only. This constructor registers this instance as aSystemListenerin order to force a newReferencingServiceslookup if the classpath changes.
-
-
Method Details
-
classpathChanged
protected final void classpathChanged()Invoked when the classpath changed. Resets theinstancetonullin order to force the next call togetInstance()to fetch a new one, which may be different.- Overrides:
classpathChangedin classOptionalDependency
-
getInstance
Returns the singleton instance.- Returns:
- the singleton instance.
-
setBounds
public DefaultGeographicBoundingBox setBounds(org.opengis.geometry.Envelope envelope, DefaultGeographicBoundingBox target, String findOpCaller) throws org.opengis.referencing.operation.TransformException Sets a geographic bounding box from the specified envelope. If the envelope contains a CRS which is not geographic, then the bounding box will be transformed to a geographic CRS (without datum shift if possible). Otherwise, the envelope is assumed already in a geographic CRS using (longitude, latitude) axis order.If
findOpCalleris non-null, then this method will be executed in optional mode: some failures will cause this method to returnnullinstead of throwing an exception. Note thatTransformExceptionmay still be thrown but not directly by this method. Warning may be logged, but in such case this method presumes that public caller is the named method fromEnvelopes— typicallyEnvelopes.findOperation(Envelope, Envelope).- Parameters:
envelope- the source envelope.target- the target bounding box, ornullfor creating it automatically.findOpCaller- non-null for replacing some (not all) exceptions bynullreturn value.- Returns:
- the bounding box or
nullon failure. NevernulliffindOpCallerargument isnull. - Throws:
UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.org.opengis.referencing.operation.TransformException- if the given envelope cannot be transformed.
-
setBounds
public void setBounds(org.opengis.geometry.Envelope envelope, DefaultVerticalExtent target) throws org.opengis.referencing.operation.TransformException Sets a vertical extent with the value inferred from the given envelope. Only the vertical coordinates are extracted; all other coordinates are ignored.- Parameters:
envelope- the source envelope.target- the target vertical extent.- Throws:
org.opengis.referencing.operation.TransformException- if no vertical component can be extracted from the given envelope.UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.
-
setBounds
public void setBounds(org.opengis.geometry.Envelope envelope, DefaultTemporalExtent target) throws org.opengis.referencing.operation.TransformException Sets a temporal extent with the value inferred from the given envelope. Only the temporal coordinates are extracted; all other coordinates are ignored.- Parameters:
envelope- the source envelope.target- the target temporal extent.- Throws:
org.opengis.referencing.operation.TransformException- if no temporal component can be extracted from the given envelope.UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.
-
setBounds
public void setBounds(org.opengis.geometry.Envelope envelope, DefaultSpatialTemporalExtent target) throws org.opengis.referencing.operation.TransformException Sets the geographic, vertical and temporal extents with the values inferred from the given envelope. If the giventargethas more geographic or vertical extents than needed (0 or 1), then the extraneous extents are removed.Behavior regarding missing dimensions:
- If the given envelope has no horizontal component, then all geographic extents are removed
from the given
target. Non-geographic extents (e.g. descriptions and polygons) are left unchanged. - If the given envelope has no vertical component, then the vertical extent is set to
null. - If the given envelope has no temporal component, then the temporal extent is set to
null.
- Parameters:
envelope- the source envelope.target- the target spatiotemporal extent.- Throws:
org.opengis.referencing.operation.TransformException- if no temporal component can be extracted from the given envelope.UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.
- If the given envelope has no horizontal component, then all geographic extents are removed
from the given
-
addElements
public void addElements(org.opengis.geometry.Envelope envelope, DefaultExtent target) throws org.opengis.referencing.operation.TransformException Initializes a horizontal, vertical and temporal extent with the values inferred from the given envelope.- Parameters:
envelope- the source envelope.target- the target extent.- Throws:
org.opengis.referencing.operation.TransformException- if a coordinate transformation was required and failed.UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.
-
geographic
public org.opengis.geometry.DirectPosition geographic(double λ, double φ) Creates a two-dimensional geographic position associated to the default geographic CRS. Axis order is (longitude, latitude).- Parameters:
\u03bb- the longitude value.\u03c6- the latitude value.- Returns:
- the direct position for the given geographic coordinate.
- Since:
- 0.8
-
getPreferredIdentifier
public String getPreferredIdentifier(org.opengis.referencing.IdentifiedObject object) throws org.opengis.util.FactoryException Returns an identifier for the given object, giving precedence to EPSG identifier if available. The returned string should be of the form"AUTHORITY:CODE"if possible (no guarantees).- Parameters:
object- the object for which to get an identifier.- Returns:
- an identifier for the given object, with preference given to EPSG codes.
- Throws:
org.opengis.util.FactoryException- if an error occurred while searching for the EPSG code.- Since:
- 1.0
-
getValueType
public org.opengis.util.TypeName getValueType(org.opengis.parameter.ParameterDescriptor<?> parameter) Returns the name of the type of values.- Parameters:
parameter- parameter for which to get the name of type of values, ornull.- Returns:
- name of type of values, or
nullif not supported by given implementation.
-
toImplementation
public <T> org.opengis.parameter.ParameterDescriptor<T> toImplementation(org.opengis.parameter.ParameterDescriptor<T> parameter) Returns a fully implemented parameter descriptor.- Type Parameters:
T- the type of values.- Parameters:
parameter- a partially implemented parameter descriptor, ornull.- Returns:
- a fully implemented parameter descriptor, or
nullif the given argument was null. - Throws:
UnsupportedOperationException- if the"sis-referencing"module has not been found on the classpath.- Since:
- 0.5
-
createCoordinateFormat
Creates a format forDirectPositioninstances.- Parameters:
locale- the locale for the newFormat, ornullforLocale.ROOT.timezone- the timezone, ornullfor UTC.- Returns:
- a
CoordinateFormat. - Since:
- 0.8
-
getCoordinateOperationFactory
public org.opengis.referencing.operation.CoordinateOperationFactory getCoordinateOperationFactory()Returns the default coordinate operation factory.- Returns:
- the coordinate operation factory to use.
-
getInformation
Returns information about the Apache SIS configuration to be reported inAbout. This method is invoked only for aspects that depends on other modules thansis-utility.Current keys are:
"EPSG": version of EPSG database.
- Parameters:
key- a key identifying the information to return.locale- language to use if possible.- Returns:
- the information, or
nullif none. - Since:
- 0.7
- See Also:
-