Class ServicesForMetadata

All Implemented Interfaces:
EventListener

public final class ServicesForMetadata extends ReferencingServices
Implements the referencing services needed by the "sis-metadata" module.
Since:
0.5
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of an OnLineFunction code list value, used for transferring information about the EPSG database.

    Fields inherited from class org.apache.sis.internal.metadata.ReferencingServices

    AUTHALIC_RADIUS, NAUTICAL_MILE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addElements(org.opengis.geometry.Envelope envelope, DefaultExtent target)
    Initializes a horizontal, vertical and temporal extent with the values inferred from the given envelope.
    Creates a format for DirectPosition instances.
    static org.opengis.referencing.crs.SingleCRS
    createParametricCRS(Map<String,?> properties, org.opengis.referencing.datum.Datum datum, org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.crs.CRSFactory factory)
    Creates a parametric CRS.
    static org.opengis.referencing.cs.CoordinateSystem
    createParametricCS(Map<String,?> properties, org.opengis.referencing.cs.CoordinateSystemAxis axis, org.opengis.referencing.cs.CSFactory factory)
    Creates a parametric CS.
    static org.opengis.referencing.datum.Datum
    createParametricDatum(Map<String,?> properties, org.opengis.referencing.datum.DatumFactory factory)
    Creates a parametric datum.
    private static String
    dimensionNotFound(short resourceKey, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
    Creates an exception message for a spatial, vertical or temporal dimension not found.
    org.opengis.geometry.DirectPosition
    geographic(double λ, double φ)
    Creates a two-dimensional geographic position associated to the default geographic CRS.
    org.opengis.referencing.operation.CoordinateOperationFactory
    Returns the default coordinate operation factory.
    Returns information about the Apache SIS configuration.
    private static org.opengis.referencing.operation.OperationMethod
    getOperationMethod(Iterable<? extends org.opengis.referencing.operation.OperationMethod> methods, String identifier)
    Returns the operation method for the specified name or identifier.
    static org.opengis.referencing.operation.OperationMethod
    getOperationMethod(org.opengis.referencing.operation.CoordinateOperationFactory opFactory, org.opengis.referencing.operation.MathTransformFactory mtFactory, String identifier)
    Returns the coordinate operation method for the given classification.
    getPreferredIdentifier(org.opengis.referencing.IdentifiedObject object)
    Returns an identifier for the given object, giving precedence to EPSG identifier if available.
    org.opengis.util.TypeName
    getValueType(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.
    void
    setBounds(org.opengis.geometry.Envelope envelope, DefaultSpatialTemporalExtent target)
    Sets the geographic, vertical and temporal extents with the values inferred from the given envelope.
    void
    setBounds(org.opengis.geometry.Envelope envelope, DefaultTemporalExtent target)
    Sets a temporal extent with the value inferred from the given envelope.
    void
    setBounds(org.opengis.geometry.Envelope envelope, DefaultVerticalExtent target)
    Sets a vertical extent with the value inferred from the given envelope.
    setGeographicExtent(org.opengis.geometry.Envelope envelope, DefaultGeographicBoundingBox target, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.GeographicCRS normalizedCRS, String findOpCaller)
    Implementation of the public setBounds(…, DefaultGeographicBoundingBox, …) methods for the horizontal extent.
    private static void
    setVerticalExtent(org.opengis.geometry.Envelope envelope, DefaultVerticalExtent target, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.VerticalCRS verticalCRS)
    Implementation of the public setBounds methods for the vertical extent.
    <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.metadata.ReferencingServices

    classpathChanged, getInstance

    Methods inherited from class org.apache.sis.internal.system.OptionalDependency

    getInstance, moduleNotFound

    Methods inherited from class org.apache.sis.internal.system.SystemListener

    add, databaseChanged, fireClasspathChanged, remove

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CONNECTION

      public static final String CONNECTION
      Name of an OnLineFunction code list value, used for transferring information about the EPSG database.
      See Also:
  • Constructor Details

    • ServicesForMetadata

      public ServicesForMetadata()
      Creates a new instance. This constructor is invoked by reflection only.
  • Method Details

    • dimensionNotFound

      private static String dimensionNotFound(short resourceKey, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
      Creates an exception message for a spatial, vertical or temporal dimension not found. The given key must be one of Resources.Keys constants.
    • setGeographicExtent

      private static DefaultGeographicBoundingBox setGeographicExtent(org.opengis.geometry.Envelope envelope, DefaultGeographicBoundingBox target, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.GeographicCRS normalizedCRS, String findOpCaller) throws org.opengis.referencing.operation.TransformException
      Implementation of the public setBounds(…, DefaultGeographicBoundingBox, …) methods for the horizontal extent. If the crs argument is null, then it is caller's responsibility to ensure that the given envelope is two-dimensional.

      If findOpCaller is non-null, then this method will be executed in optional mode: some failures will cause this method to return null instead of throwing an exception. Note that TransformException may 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 from Envelopes — typically Envelopes.findOperation(Envelope, Envelope).

      Parameters:
      envelope - the source envelope.
      target - the target bounding box, or null for creating it automatically.
      crs - the envelope CRS, or null if unknown.
      normalizedCRS - the horizontal component of the given CRS, or null if the crs argument is null.
      findOpCaller - non-null for replacing some (not all) exceptions by null return value.
      Returns:
      the bounding box or null on failure. Never null if findOpCaller argument is null.
      Throws:
      org.opengis.referencing.operation.TransformException - if the given envelope cannot be transformed.
    • setVerticalExtent

      private static void setVerticalExtent(org.opengis.geometry.Envelope envelope, DefaultVerticalExtent target, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.referencing.crs.VerticalCRS verticalCRS)
      Implementation of the public setBounds methods for the vertical extent. If the crs argument is null, then it is caller's responsibility to ensure that the given envelope is one-dimensional.
      Parameters:
      envelope - the source envelope.
      target - the target vertical extent.
      crs - the envelope CRS, or null if unknown.
      verticalCRS - the vertical component of the given CRS, or null if the crs argument is null.
    • 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 has no CRS, then (longitude, latitude) axis order is assumed. If the envelope CRS is not geographic, then the envelope will be transformed to a geographic CRS. If findOpCaller is true, then some failures will cause this method to return null instead of throwing an exception, and warning may be logged with assumption that caller is the named method from Envelopes — typically Envelopes.findOperation(Envelope, Envelope).
      Overrides:
      setBounds in class ReferencingServices
      Parameters:
      envelope - the source envelope.
      target - the target bounding box, or null for creating it automatically.
      findOpCaller - non-null for replacing some (not all) exceptions by null return value.
      Returns:
      the bounding box or null on failure. Never null if findOpCaller argument is null.
      Throws:
      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.
      Overrides:
      setBounds in class ReferencingServices
      Parameters:
      envelope - the source envelope.
      target - the target vertical extent where to store envelope information.
      Throws:
      org.opengis.referencing.operation.TransformException - if no vertical component can be extracted from the given envelope.
    • 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 vertical coordinates are extracted; all other coordinates are ignored.
      Overrides:
      setBounds in class ReferencingServices
      Parameters:
      envelope - the source envelope.
      target - the target temporal extent where to store envelope information.
      Throws:
      org.opengis.referencing.operation.TransformException - if no temporal component can be extracted from the given envelope.
    • 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 given target has more geographic or vertical extents than needed (0 or 1), then the extraneous extents are removed.
      Overrides:
      setBounds in class ReferencingServices
      Parameters:
      envelope - the source envelope.
      target - the target spatiotemporal extent where to store envelope information.
      Throws:
      org.opengis.referencing.operation.TransformException - if no temporal component can be extracted from the given envelope.
    • 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.
      Overrides:
      addElements in class ReferencingServices
      Parameters:
      envelope - the source envelope.
      target - the target extent where to store envelope information.
      Throws:
      org.opengis.referencing.operation.TransformException - if a coordinate transformation was required and failed.
      UnsupportedOperationException - if this method requires an Apache SIS module which has 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).
      Overrides:
      geographic in class ReferencingServices
      Parameters:
      λ - the longitude value.
      φ - 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).
      Overrides:
      getPreferredIdentifier in class ReferencingServices
      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.
      Overrides:
      getValueType in class ReferencingServices
      Parameters:
      parameter - parameter for which to get the name of type of values, or null.
      Returns:
      name of type of values, or null if 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.
      Overrides:
      toImplementation in class ReferencingServices
      Type Parameters:
      T - the type of values.
      Parameters:
      parameter - a partially implemented parameter descriptor, or null.
      Returns:
      a fully implemented parameter descriptor, or null if the given argument was null.
    • createParametricCS

      public static org.opengis.referencing.cs.CoordinateSystem createParametricCS(Map<String,?> properties, org.opengis.referencing.cs.CoordinateSystemAxis axis, org.opengis.referencing.cs.CSFactory factory) throws org.opengis.util.FactoryException
      Creates a parametric CS. This method requires the SIS factory since parametric CRS were not available in GeoAPI 3.0.

      This method is actually not needed anymore for sis-metadata module, but is still defined here for historical reason. This method is removed on SIS branches using a GeoAPI versions more recent than 3.0.

      Parameters:
      properties - the coordinate system name, and optionally other properties.
      axis - the axis of the parametric coordinate system.
      factory - the factory to use for creating the coordinate system.
      Returns:
      a parametric coordinate system using the given axes.
      Throws:
      org.opengis.util.FactoryException - if the parametric object creation failed.
      Since:
      0.7
    • createParametricDatum

      public static org.opengis.referencing.datum.Datum createParametricDatum(Map<String,?> properties, org.opengis.referencing.datum.DatumFactory factory) throws org.opengis.util.FactoryException
      Creates a parametric datum. This method requires the SIS factory since parametric CRS were not available in GeoAPI 3.0.

      This method is actually not needed anymore for sis-metadata module, but is still defined here for historical reason. This method is removed on SIS branches using a GeoAPI versions more recent than 3.0.

      Parameters:
      properties - the datum name, and optionally other properties.
      factory - the factory to use for creating the datum.
      Returns:
      a parametric datum using the given name.
      Throws:
      org.opengis.util.FactoryException - if the parametric object creation failed.
      Since:
      0.7
    • createParametricCRS

      public static org.opengis.referencing.crs.SingleCRS createParametricCRS(Map<String,?> properties, org.opengis.referencing.datum.Datum datum, org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.crs.CRSFactory factory) throws org.opengis.util.FactoryException
      Creates a parametric CRS. This method requires the SIS factory since parametric CRS were not available in GeoAPI 3.0.

      This method is actually not needed anymore for sis-metadata module, but is still defined here for historical reason. This method is removed on SIS branches using a GeoAPI versions more recent than 3.0.

      Parameters:
      properties - the coordinate reference system name, and optionally other properties.
      datum - the parametric datum.
      cs - the parametric coordinate system.
      factory - the factory to use for creating the coordinate reference system.
      Returns:
      a parametric coordinate system using the given axes.
      Throws:
      org.opengis.util.FactoryException - if the parametric object creation failed.
      Since:
      0.7
    • createCoordinateFormat

      public Format createCoordinateFormat(Locale locale, TimeZone timezone)
      Creates a format for DirectPosition instances.
      Overrides:
      createCoordinateFormat in class ReferencingServices
      Parameters:
      locale - the locale for the new Format, or null for Locale.ROOT.
      timezone - the timezone, or null for UTC.
      Returns:
      a CoordinateFormat.
      Since:
      0.8
    • getCoordinateOperationFactory

      public org.opengis.referencing.operation.CoordinateOperationFactory getCoordinateOperationFactory()
      Returns the default coordinate operation factory.
      Overrides:
      getCoordinateOperationFactory in class ReferencingServices
      Returns:
      the coordinate operation factory to use.
    • getOperationMethod

      public static org.opengis.referencing.operation.OperationMethod getOperationMethod(org.opengis.referencing.operation.CoordinateOperationFactory opFactory, org.opengis.referencing.operation.MathTransformFactory mtFactory, String identifier) throws org.opengis.util.FactoryException
      Returns the coordinate operation method for the given classification. This method checks if the given opFactory is a SIS implementation before to fallback on a slower fallback.

      This method is actually not needed anymore for sis-metadata module, but is still defined here for historical reason. This method is removed on SIS branches using a GeoAPI versions more recent than 3.0.

      Parameters:
      opFactory - The coordinate operation factory to use if it is a SIS implementation.
      mtFactory - The math transform factory to use as a fallback.
      identifier - The name or identifier of the operation method to search.
      Returns:
      The coordinate operation method for the given name or identifier.
      Throws:
      org.opengis.util.FactoryException - if an error occurred which searching for the given method.
      Since:
      0.6
    • getOperationMethod

      private static org.opengis.referencing.operation.OperationMethod getOperationMethod(Iterable<? extends org.opengis.referencing.operation.OperationMethod> methods, String identifier)
      Returns the operation method for the specified name or identifier. The given argument shall be either a method name (e.g. "Transverse Mercator") or one of its identifiers (e.g. "EPSG:9807").
      Parameters:
      methods - the method candidates.
      identifier - the name or identifier of the operation method to search.
      Returns:
      the coordinate operation method for the given name or identifier, or null if none.
      Since:
      0.6
      See Also:
    • getInformation

      public String getInformation(String key, Locale locale)
      Returns information about the Apache SIS configuration. See super-class for a list of keys.
      Overrides:
      getInformation in class ReferencingServices
      Parameters:
      key - a key identifying the information to return.
      locale - language to use if possible.
      Returns:
      the information, or null if none.
      See Also: