Package org.apache.sis.geometry
Class CoordinateFormat.Resolution
java.lang.Object
org.apache.sis.geometry.CoordinateFormat.Resolution
- Enclosing class:
- CoordinateFormat
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
FieldsModifier and TypeFieldDescription(package private) final booleanWhetherunitis an angular unit.private doubleMaximal absolute value that we may format, regardless unit of measurement.private doubleThe desired resolution in the unit of measurement given byunit.private javax.measure.Unit<?>Unit of measurement ofresolution. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Resolution(javax.measure.Quantity<?> groundPrecision) Creates a new instance initialized to the given precision.privateResolution(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 TypeMethodDescription(package private) CoordinateFormat.Resolutionderived(org.opengis.referencing.crs.CoordinateReferenceSystem crs) If this resolution is in metres, returns equivalent resolution in degrees.(package private) final voidfindMaxValue(org.opengis.referencing.cs.CoordinateSystemAxis axis) Adjusts the maximal magnitude value, ignoring unit conversion.(package private) booleanfindMinResolution(javax.measure.Unit<?> axisUnit, boolean hasPrevious) Adjusts the resolution units for the given coordinate system axis.private doubleresolution(javax.measure.Unit<?> target) Returns the resolution converted to the specified unit as an absolute value.(package private) voidsetPrecision(CoordinateFormat owner) Configures theNumberFormatorAngleFormatfor a number of fraction digits sufficient for the given resolution.
-
Field Details
-
magnitude
private double magnitudeMaximal absolute value that we may format, regardless unit of measurement. -
resolution
private double resolutionThe desired resolution in the unit of measurement given byunit. -
unit
private javax.measure.Unit<?> unitUnit of measurement ofresolution. -
isAngular
final boolean isAngularWhetherunitis 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-radiusunit of measurement, which is also ellipsoid axes unit.- Throws:
javax.measure.IncommensurableException- should not happen ifspecifiedis 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, ornullif none.- Returns:
- the derived resolution, or
nullif 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 withunit.
-
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 ofresolution.- 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 thatNumberFormatmay see. -
setPrecision
Configures theNumberFormatorAngleFormatfor a number of fraction digits sufficient for the given resolution. This method configures the shared formats returned byCompoundFormat.getFormat(Class). They are the formats stored in theCoordinateFormat.sharedFormatsarray.
-