Changeset 31416 in osm for applications


Ignore:
Timestamp:
2015-07-30T13:17:37+02:00 (9 years ago)
Author:
nokutu
Message:

Added the possibility to do a reverse walk.

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31415 r31416  
    445445   * Returns the 2 closest images belonging to a different sequence.
    446446   *
    447    * @return
     447   * @return An array of length 2 containing the two closest images belonging
     448   *         to different sequences.
    448449   */
    449450  private MapillaryImage[] getClosestImagesFromDifferentSequences() {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java

    r31415 r31416  
    5757        && (int) pane.getValue() == JOptionPane.OK_OPTION) {
    5858      thread = new WalkThread((int) dialog.spin.getValue(),
    59           dialog.waitForPicture.isSelected(), dialog.followSelection.isSelected());
     59          dialog.waitForPicture.isSelected(),
     60          dialog.followSelection.isSelected(), dialog.goForward.isSelected());
    6061      fireWalkStarted();
    6162      thread.start();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java

    r31415 r31416  
    2828  private final boolean waitForFullQuality;
    2929  private final boolean followSelected;
     30  private final boolean goForward;
    3031  private BufferedImage lastImage;
    3132  private volatile boolean paused = false;
     
    3738   * @param waitForPicture
    3839   * @param followSelected
     40   * @param goForward
    3941   */
    40   public WalkThread(int interval, boolean waitForPicture, boolean followSelected) {
     42  public WalkThread(int interval, boolean waitForPicture,
     43      boolean followSelected, boolean goForward) {
    4144    this.interval = interval;
    4245    this.waitForFullQuality = waitForPicture;
    4346    this.followSelected = followSelected;
     47    this.goForward = goForward;
    4448    data = MapillaryLayer.getInstance().getMapillaryData();
    4549    data.addListener(this);
     
    6771              break;
    6872            image = image.next();
    69             Utils.downloadPicture((MapillaryImage) image, Utils.PICTURE.FULL);
     73            Utils.downloadPicture((MapillaryImage) image, Utils.PICTURE.FULL_IMAGE);
    7074          }
    7175        try {
     
    98102              .getImage();
    99103          lock.lock();
    100           data.selectNext(followSelected);
     104          if (goForward)
     105            data.selectNext(followSelected);
     106          else
     107            data.selectPrevious(followSelected);
    101108          lock.unlock();
    102109        } catch (InterruptedException e) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java

    r31401 r31416  
    4545    this.key = key;
    4646    try {
    47       if (type == Type.FULL_IMAGE) {
    48         url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    49             + "/thumb-2048.jpg");
    50         this.key += ".FULL_IMAGE";
    51 
    52       } else if (type == Type.THUMBNAIL) {
    53         url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    54             + "/thumb-320.jpg");
    55         this.key += ".THUMBNAIL";
     47      switch (type) {
     48        case FULL_IMAGE:
     49          url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
     50              + "/thumb-2048.jpg");
     51          this.key += ".FULL_IMAGE";
     52          break;
     53        case THUMBNAIL:
     54          url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
     55              + "/thumb-320.jpg");
     56          this.key += ".THUMBNAIL";
     57          break;
    5658      }
    5759    } catch (MalformedURLException e) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/Utils.java

    r31409 r31416  
    1818  /** Picture quality */
    1919  public enum PICTURE {
    20     /** Thumbnail quality picture () */
     20    /** Thumbnail quality picture (320 p) */
    2121    THUMBNAIL,
    22     /** Full quality picture () */
    23     FULL,
     22    /** Full quality picture (2048 p) */
     23    FULL_IMAGE,
    2424    /** Both of them */
    2525    BOTH;
     
    2727
    2828  /**
    29    * Downloads the picture of the given image and does nothing when it is
    30    * downloaded.
     29   * Downloads the the thumbnail and the full resolution picture of the given
     30   * image. Does nothing if it is already in cache.
    3131   *
    3232   * @param img
     33   *          The image whose picture is going to be downloaded.
    3334   */
    3435  public static void downloadPicture(MapillaryImage img) {
     
    3738
    3839  /**
    39    * Downloads the picture of the given image and does nothing when it is
    40    * downloaded.
     40   * Downloads the picture of the given image. Does nothing when it is already
     41   * in cache.
    4142   *
    4243   * @param img
     
    4647   */
    4748  public static void downloadPicture(MapillaryImage img, PICTURE pic) {
    48     if (pic == PICTURE.BOTH) {
    49       if (new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL).get() == null)
     49    switch (pic) {
     50      case BOTH:
     51        if (new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL)
     52            .get() == null)
     53          new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL)
     54              .submit(IGNORE_DOWNLOAD, false);
     55        if (new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
     56            .get() == null)
     57          new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
     58              .submit(IGNORE_DOWNLOAD, false);
     59        break;
     60      case THUMBNAIL:
    5061        new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL).submit(
    5162            IGNORE_DOWNLOAD, false);
    52       if (new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
    53           .get() == null)
     63        break;
     64      case FULL_IMAGE:
    5465        new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
    5566            .submit(IGNORE_DOWNLOAD, false);
    56     } else if (pic == PICTURE.THUMBNAIL
    57         && new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL)
    58             .get() == null) {
    59       new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL).submit(
    60           IGNORE_DOWNLOAD, false);
    61     } else if (pic == PICTURE.FULL
    62         && new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
    63             .get() == null) {
    64       new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE).submit(
    65           IGNORE_DOWNLOAD, false);
     67        break;
    6668    }
    6769  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryWalkDialog.java

    r31415 r31416  
    2424  /** Whether the view must follow the selected image. */
    2525  public JCheckBox followSelection;
     26  /** Go forward or backwards */
     27  public JCheckBox goForward;
    2628
    2729  /**
     
    4244    followSelection.setSelected(true);
    4345    add(followSelection);
     46
     47    goForward = new JCheckBox("Go forward");
     48    goForward.setSelected(true);
     49    add(goForward);
    4450  }
    4551}
Note: See TracChangeset for help on using the changeset viewer.