Class TLcdMapScale

java.lang.Object
com.luciad.view.TLcdMapScale
All Implemented Interfaces:
Comparable<TLcdMapScale>

public final class TLcdMapScale extends Object implements Comparable<TLcdMapScale>
A ratio of a distance as it is measured on the screen of the device, to the corresponding distance in the real world. This typically corresponds with paper map scales. For example: a map scale of 1 : 50 000 means that 1 centimeter on a map corresponds to 500 meters on the ground. This is created as follows:
// Both statements create a map scale of 1 : 50 000
new TLcdMapScale(1d / 50_000d);
TLcdMapScale.fromDenominator(50_000);

In the case when the unit of measure is of a different type (for example, time or temperature), the scale is the ratio of 1 meter on the screen per units of measure. For example, such a scale might express something like 1 meter equals 5 hours.

This class gives a natural ordering to map scales, from zoomed out to zoomed in, which is easy to check. When a part of the API takes an ordered collection as input, it must be ordered according to this natural ordering (unless stated otherwise).

To interpret map scales values correctly, the view needs to know the DPI value of the screen on which it is rendered. You can override the auto-detected value by passing it using the system property luciad.dpi, e.g. -Dluciad.dpi=120

See the Working with map scales tutorial for more information.

Since:
2021.0
  • Field Details Link icon

    • MAX_ZOOMED_OUT Link icon

      public static final TLcdMapScale MAX_ZOOMED_OUT
      The value that represents a maximally zoomed out map scale (1:inf == 0)
    • MAX_ZOOMED_IN Link icon

      public static final TLcdMapScale MAX_ZOOMED_IN
      The value that represents a maximally zoomed in map scale (1:0 ≈ the maximum double value)
  • Constructor Details Link icon

    • TLcdMapScale Link icon

      public TLcdMapScale(double value)
      Creates a new MapScale based on the given ratio
      Parameters:
      value - a value that represents 1 / denominator. For example: a MapScale of 1:50000 can be created using 0.00002 (=1.0/50_000) as value.
  • Method Details Link icon

    • fromDenominator Link icon

      public static TLcdMapScale fromDenominator(double denominator)
      Creates a map scale defined by the given map scale denominator.
      Parameters:
      denominator - the scale denominator. For example when using 1:50000 as map scale, the denominator is 50000.
      Returns:
      a map scale that corresponds to 1:denominator
    • createScaleRange Link icon

      public static TLcdDimensionInterval<TLcdMapScale> createScaleRange(TLcdMapScale aMostZoomedOutValue, TLcdMapScale aMostZoomedInValue)
      Creates a scale range based on the given minimum and maximum map scale values.
      Parameters:
      aMostZoomedOutValue - the minimum, most zoomed out map scale (included)
      aMostZoomedInValue - the maximum, most zoomed in map scale (excluded)
      Returns:
      an interval defining the scale range
    • zoomOut Link icon

      public TLcdMapScale zoomOut(double factor)
      Parameters:
      factor - the factor using which to zoom out
      Returns:
      a new map scale that is zoomed out using the given factor. For example, when applying this method on a 1 : 50 000 scale, with a factor or 2, the resulting map scale will be 1 : 100 000
    • zoomIn Link icon

      public TLcdMapScale zoomIn(double factor)
      Parameters:
      factor - the factor using which to zoom in
      Returns:
      a new map scale that is zoomed in using the given factor. For example, when applying this method on a 1 : 50 000 scale, with a factor or 2, the resulting map scale will be 1 : 25 000
    • getDenominator Link icon

      public double getDenominator()
      Returns:
      the denominator of this map scale. For example when the Map Scale is 1 : 50 000, this method will return 50000.
    • getValue Link icon

      public double getValue()
      Returns:
      the scale value
    • compareTo Link icon

      public int compareTo(TLcdMapScale aOther)
      Compares this scale with the given one.
      Specified by:
      compareTo in interface Comparable<TLcdMapScale>
      Parameters:
      aOther - the scale to compare this scale with
      Returns:
      zero if both scales are equal, less than zero if this scale is smaller (i.e. more zoomed out), more than zero if this scale is larger (i.e. more zoomed in).
      See Also:
    • is Link icon

      public boolean is(TLcdMapScale.ScaleComparison aComparison, TLcdMapScale aOther)
      Convenience method for readable scale comparisons.
      Parameters:
      aComparison - how to compare the values
      aOther - the other scale to compare with
      Returns:
      true if the comparison statement holds
    • equals Link icon

      public boolean equals(Object aO)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object