Class CoordinateFormat.Resolution

java.lang.Object
org.apache.sis.geometry.CoordinateFormat.Resolution
Enclosing class:
CoordinateFormat

private static final class CoordinateFormat.Resolution extends Object
Desired resolution in a given units, together with methods for converting to the units of a coordinate system axis. This is a helper class for CoordinateFormat.setGroundPrecision(Quantity) implementation. An execution of that method typically creates two instances of this Resolution class: one for the resolution in metres and another one for the resolution in degrees.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final boolean
    Whether unit is an angular unit.
    private double
    Maximal absolute value that we may format, regardless unit of measurement.
    private double
    The desired resolution in the unit of measurement given by unit.
    private javax.measure.Unit<?>
    Unit of measurement of resolution.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    (package private)
    Resolution(javax.measure.Quantity<?> groundPrecision)
    Creates a new instance initialized to the given precision.
    private
    Resolution(CoordinateFormat.Resolution specified, double radius, javax.measure.Unit<javax.measure.quantity.Length> axisUnit)
    Creates a new instance derived from the given angular or linear resolution.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) CoordinateFormat.Resolution
    derived(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
    If this resolution is in metres, returns equivalent resolution in degrees.
    (package private) final void
    findMaxValue(org.opengis.referencing.cs.CoordinateSystemAxis axis)
    Adjusts the maximal magnitude value, ignoring unit conversion.
    (package private) boolean
    findMinResolution(javax.measure.Unit<?> axisUnit, boolean hasPrevious)
    Adjusts the resolution units for the given coordinate system axis.
    private double
    resolution(javax.measure.Unit<?> target)
    Returns the resolution converted to the specified unit as an absolute value.
    (package private) void
    Configures the NumberFormat or AngleFormat for a number of fraction digits sufficient for the given resolution.

    Methods inherited from class java.lang.Object

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

    • magnitude

      private double magnitude
      Maximal absolute value that we may format, regardless unit of measurement.
    • resolution

      private double resolution
      The desired resolution in the unit of measurement given by unit.
    • unit

      private javax.measure.Unit<?> unit
      Unit of measurement of resolution.
    • isAngular

      final boolean isAngular
      Whether unit is an angular unit.
  • Constructor Details

    • Resolution

      Resolution(javax.measure.Quantity<?> groundPrecision)
      Creates a new instance initialized to the given precision.
    • Resolution

      private Resolution(CoordinateFormat.Resolution specified, double radius, javax.measure.Unit<javax.measure.quantity.Length> axisUnit) throws javax.measure.IncommensurableException
      Creates a new instance derived from the given angular or linear resolution. This constructor computes an angular resolution from a linear one, or conversely. If is caller responsibility to ensure that the specified resolution is either linear or angular.
      Parameters:
      specified - the linear or angular resolution specified by the user.
      radius - authalic radius of CRS ellipsoid.
      axisUnit - radius unit of measurement, which is also ellipsoid axes unit.
      Throws:
      javax.measure.IncommensurableException - should not happen if specified is either linear or angular.
  • Method Details

    • derived

      CoordinateFormat.Resolution derived(org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws javax.measure.IncommensurableException
      If this resolution is in metres, returns equivalent resolution in degrees. Or conversely if this resolution is in degrees, returns an equivalent resolution in metres. Other linear and angular units are accepted too; they will be converted as needed.
      Parameters:
      crs - the CRS for which to derive an equivalent resolution, or null if none.
      Returns:
      the derived resolution, or null if none.
      Throws:
      javax.measure.IncommensurableException - should never happen since this method verifies unit compatibility.
    • resolution

      private double resolution(javax.measure.Unit<?> target) throws javax.measure.IncommensurableException
      Returns the resolution converted to the specified unit as an absolute value.
      Throws:
      javax.measure.IncommensurableException - if the specified unit is not compatible with unit.
    • findMinResolution

      boolean findMinResolution(javax.measure.Unit<?> axisUnit, boolean hasPrevious) throws javax.measure.IncommensurableException
      Adjusts the resolution units for the given coordinate system axis. This methods select the units which result in the smallest absolute value of resolution.
      Parameters:
      axisUnit - CoordinateSystemAxis.getUnit().
      hasPrevious - whether this method has been successfully applied on another axis before.
      Returns:
      whether the given axis unit is compatible with the expected unit.
      Throws:
      javax.measure.IncommensurableException - should never happen since this method verifies unit compatibility.
    • findMaxValue

      final void findMaxValue(org.opengis.referencing.cs.CoordinateSystemAxis axis)
      Adjusts the maximal magnitude value, ignoring unit conversion. We do not apply unit conversion because the axis minimum and maximum values are already in the units of the coordinates that will be formatted. Even if different axes use different units, we want the largest value that NumberFormat may see.
    • setPrecision

      void setPrecision(CoordinateFormat owner)
      Configures the NumberFormat or AngleFormat for a number of fraction digits sufficient for the given resolution. This method configures the shared formats returned by CompoundFormat.getFormat(Class). They are the formats stored in the CoordinateFormat.sharedFormats array.