Class DownloadAlongAction

All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, Destroyable
Direct Known Subclasses:
DownloadAlongTrackAction, DownloadAlongWayAction

public abstract class DownloadAlongAction extends JosmAction
Abstract superclass of DownloadAlongTrackAction and DownloadAlongWayAction
Since:
6054
See Also:
  • Constructor Details

    • DownloadAlongAction

      protected DownloadAlongAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar)
      Constructs a new DownloadAlongAction
      Parameters:
      name - the action's text as displayed in the menu
      iconName - the filename of the icon to use
      tooltip - a longer description of the action that will be displayed in the tooltip. Please note that html is not supported for menu actions on some platforms.
      shortcut - a ready-created shortcut object or null if you don't want a shortcut. But you always do want a shortcut, remember you can always register it with group=none, so you won't be assigned a shortcut unless the user configures one. If you pass null here, the user CANNOT configure a shortcut for your action.
      registerInToolbar - register this action for the toolbar preferences?
  • Method Details

    • createTask

      protected abstract PleaseWaitRunnable createTask()
      Sub classes must override this method.
      Returns:
      the task to start or null if nothing to do
    • addToDownload

      protected static void addToDownload(Area a, Rectangle2D r, Collection<Rectangle2D> results, double maxArea)
    • confirmAndDownloadAreas

      protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title, boolean newLayer)
      Area "a" contains the hull that we would like to download data for. however we can only download rectangles, so the following is an attempt at finding a number of rectangles to download. The idea is simply: Start out with the full bounding box. If it is too large, then split it in half and repeat recursively for each half until you arrive at something small enough to download. The algorithm is improved by always using the intersection between the rectangle and the actual desired area. For example, if you have a track that goes like this: +----+ | /| | / | | / | |/ | +----+ then we would first look at downloading the whole rectangle (assume it's too big), after that we split it in half (upper and lower half), but we do not request the full upper and lower rectangle, only the part of the upper/lower rectangle that actually has something in it. This functions calculates the rectangles, asks the user to continue and downloads the areas if applicable.
      Parameters:
      a - download area hull
      maxArea - maximum area size for a single download
      osmDownload - Set to true if OSM data should be downloaded
      gpxDownload - Set to true if GPX data should be downloaded
      title - the title string for the confirmation dialog
      newLayer - Set to true if all areas should be put into a single new layer
    • calcBetweenPoints

      protected static Collection<LatLon> calcBetweenPoints(LatLon p1, LatLon p2, double bufferDist)
      Calculate list of points between two given points so that the distance between two consecutive points is below a limit.
      Parameters:
      p1 - first point or null
      p2 - second point (must not be null)
      bufferDist - the maximum distance
      Returns:
      a list of points with at least one point (p2) and maybe more.
    • createCalcTask

      protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer)
      Create task that downloads areas along the given path using the values specified in the panel.
      Parameters:
      alongPath - the path along which the areas are to be downloaded
      panel - the panel that was displayed to the user and now contains his selections
      confirmTitle - the title to display in the confirmation panel
      newLayer - Set to true if all areas should be put into a single new layer
      Returns:
      the task or null if canceled by user
    • actionPerformed

      public void actionPerformed(ActionEvent e)