Class SystemOfMeasurement


  • public class SystemOfMeasurement
    extends Object
    A system of units used to express length and area measurements.

    This class also manages one globally set system of measurement stored in the ProjectionPreference

    Since:
    3406 (creation), 6992 (extraction in this package)
    • Constructor Detail

      • SystemOfMeasurement

        public SystemOfMeasurement​(String name,
                                   double aValue,
                                   String aName,
                                   double bValue,
                                   String bName,
                                   String speedName,
                                   double speedValue)
        System of measurement. Currently covers only length (and area) units. If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as x_a == x_m / aValue
        Parameters:
        name - Translatable name of this system of measurement
        aValue - First value, in meters, used to translate unit according to above formula.
        aName - First unit used to format text.
        bValue - Second value, in meters, used to translate unit according to above formula.
        bName - Second unit used to format text.
        speedName - the most common speed symbol (kmh/h, mph, kn, etc.)
        speedValue - the speed value for the most common speed symbol, for 1 meter per second
        Since:
        15395
      • SystemOfMeasurement

        public SystemOfMeasurement​(String name,
                                   double aValue,
                                   String aName,
                                   double bValue,
                                   String bName,
                                   String speedName,
                                   double speedValue,
                                   double areaCustomValue,
                                   String areaCustomName)
        System of measurement. Currently covers only length (and area) units. If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as x_a == x_m / aValue
        Parameters:
        name - Translatable name of this system of measurement
        aValue - First value, in meters, used to translate unit according to above formula.
        aName - First unit used to format text.
        bValue - Second value, in meters, used to translate unit according to above formula.
        bName - Second unit used to format text.
        speedName - the most common speed symbol (kmh/h, mph, kn, etc.)
        speedValue - the speed value for the most common speed symbol, for 1 meter per second
        areaCustomValue - Specific optional area value, in squared meters, between aValue*aValue and bValue*bValue. Set to -1 if not used.
        areaCustomName - Specific optional area unit. Set to null if not used.
        Since:
        15395
    • Method Detail

      • getSystemOfMeasurement

        public static SystemOfMeasurement getSystemOfMeasurement()
        Returns the current global system of measurement.
        Returns:
        The current system of measurement (metric system by default).
        Since:
        8554
      • getDistText

        public String getDistText​(double dist)
        Returns the text describing the given distance in this system of measurement.
        Parameters:
        dist - The distance in metres
        Returns:
        The text describing the given distance in this system of measurement.
      • getDistText

        public String getDistText​(double dist,
                                  NumberFormat format,
                                  double threshold)
        Returns the text describing the given distance in this system of measurement.
        Parameters:
        dist - The distance in metres
        format - A NumberFormat to format the area value
        threshold - Values lower than this threshold are displayed as "< [threshold]"
        Returns:
        The text describing the given distance in this system of measurement.
        Since:
        6422
      • getAreaText

        public String getAreaText​(double area)
        Returns the text describing the given area in this system of measurement.
        Parameters:
        area - The area in square metres
        Returns:
        The text describing the given area in this system of measurement.
        Since:
        5560
      • getAreaText

        public String getAreaText​(double area,
                                  NumberFormat format,
                                  double threshold)
        Returns the text describing the given area in this system of measurement.
        Parameters:
        area - The area in square metres
        format - A NumberFormat to format the area value
        threshold - Values lower than this threshold are displayed as "< [threshold]"
        Returns:
        The text describing the given area in this system of measurement.
        Since:
        6422
      • getName

        public String getName()
        Returns the translatable name of this system of measurement.
        Returns:
        the translatable name of this system of measurement
        Since:
        15395
      • toString

        public String toString()
        Returns the localized name of this system of measurement
        Overrides:
        toString in class Object
        Returns:
        the localized name
      • getDefault

        public static SystemOfMeasurement getDefault()
        Returns the default system of measurement for the current country.
        Returns:
        the default system of measurement for the current country
        Since:
        15395