Class MapViewCalculations

java.lang.Object
slash.navigation.mapview.mapsforge.helpers.MapViewCalculations

public class MapViewCalculations extends Object
Pure calculations behind the MapsforgeMapView interaction logic, factored out so they can be unit-tested without a live map view.
Author:
Christian Pesch
  • Method Summary

    Modifier and Type
    Method
    Description
    collectBoundingPositions(BoundingBox mapBoundingBox, BoundingBox routeBoundingBox)
    The corner positions to fit into view when centering and zooming: the route's box if present, plus the map's box when it is limited and does not already cover the route.
    static int
    computeAddRow(NavigationPosition lastSelected, PositionsModel positionsModel)
    The row a new position should be inserted at: after the last selected position, else after the last position in the list, else at the start.
    static double
    thresholdForPixel(double latitude, byte zoomLevel, int tileSize, int selectionCirclePixels)
    The ground distance (meters) that spans the given number of screen pixels at a zoom level - used as the selection tolerance when hit-testing positions near a map click.

    Methods inherited from class java.lang.Object

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

    • thresholdForPixel

      public static double thresholdForPixel(double latitude, byte zoomLevel, int tileSize, int selectionCirclePixels)
      The ground distance (meters) that spans the given number of screen pixels at a zoom level - used as the selection tolerance when hit-testing positions near a map click.
    • collectBoundingPositions

      public static List<NavigationPosition> collectBoundingPositions(BoundingBox mapBoundingBox, BoundingBox routeBoundingBox)
      The corner positions to fit into view when centering and zooming: the route's box if present, plus the map's box when it is limited and does not already cover the route.
    • computeAddRow

      public static int computeAddRow(NavigationPosition lastSelected, PositionsModel positionsModel)
      The row a new position should be inserted at: after the last selected position, else after the last position in the list, else at the start. Kept robust against a missing selection.