Changeset 31355 in osm for applications


Ignore:
Timestamp:
2015-07-09T11:56:57+02:00 (9 years ago)
Author:
nokutu
Message:

New action: Import pictures into a sequence. It imports a set of pictures and makes a sequence with them, ordering them by the time they were taken.

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
1 added
10 edited

Legend:

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

    r31352 r31355  
    2424  /** The time the image was captured, in Epoch format */
    2525  private long capturedAt;
     26  /** Sequence of pictures containing this object */
     27  private MapillarySequence sequence;
    2628  /** Position of the picture */
    2729  public final LatLon latLon;
     
    105107   */
    106108  public void move(double x, double y) {
    107     this.movingLatLon = new LatLon(this.tempLatLon.getY() + y,
    108         this.tempLatLon.getX() + x);
     109    this.movingLatLon = new LatLon(this.tempLatLon.getY() + y, this.tempLatLon.getX() + x);
    109110    this.isModified = true;
    110111  }
     
    203204    SimpleDateFormat formatter = new SimpleDateFormat(format);
    204205    try {
    205       Date dateTime = formatter.parse(date);
     206      Date dateTime = (Date) formatter.parse(date);
    206207      return dateTime.getTime();
    207208    } catch (ParseException e) {
     
    220221    return cal.getTimeInMillis();
    221222  }
     223
     224  /**
     225   * Sets the MapillarySequence object which contains the MapillaryImage.
     226   *
     227   * @param sequence
     228   *          The MapillarySequence that contains the MapillaryImage.
     229   */
     230  public void setSequence(MapillarySequence sequence) {
     231    this.sequence = sequence;
     232  }
     233
     234  /**
     235   * Returns the sequence which contains this image.
     236   *
     237   * @return The MapillarySequence object that contains this MapillaryImage.
     238   */
     239  public MapillarySequence getSequence() {
     240    return this.sequence;
     241  }
     242
     243  /**
     244   * If the MapillaryImage belongs to a MapillarySequence, returns the next
     245   * MapillarySequence in it.
     246   *
     247   * @return The following MapillaryImage, or null if there is none.
     248   */
     249  public MapillaryAbstractImage next() {
     250    synchronized (lock) {
     251      if (this.getSequence() == null)
     252        return null;
     253      return this.getSequence().next(this);
     254    }
     255  }
     256
     257  /**
     258   * If the MapillaryImage belongs to a MapillarySequence, returns the previous
     259   * MapillarySequence in it.
     260   *
     261   * @return The previous MapillaryImage, or null if there is none.
     262   */
     263  public MapillaryAbstractImage previous() {
     264    synchronized (lock) {
     265      if (this.getSequence() == null)
     266        return null;
     267      return this.getSequence().previous(this);
     268    }
     269  }
    222270}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31350 r31355  
    170170      if (selectedImage instanceof MapillaryImage
    171171          && ((MapillaryImage) selectedImage).getSequence() != null) {
    172         MapillaryImage tempImage = (MapillaryImage) selectedImage;
     172        MapillaryAbstractImage tempImage = selectedImage;
    173173        while (tempImage.next() != null) {
    174174          tempImage = tempImage.next();
     
    196196      if (selectedImage instanceof MapillaryImage
    197197          && ((MapillaryImage) selectedImage).getSequence() != null) {
    198         MapillaryImage tempImage = (MapillaryImage) selectedImage;
     198        MapillaryAbstractImage tempImage = selectedImage;
    199199        while (tempImage.previous() != null) {
    200200          tempImage = tempImage.previous();
     
    242242        // Donwloadins thumbnails of surrounding pictures.
    243243        if (mapillaryImage.next() != null) {
    244           new MapillaryCache(mapillaryImage.next().getKey(),
     244          new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(),
    245245              MapillaryCache.Type.THUMBNAIL).submit(this, false);
    246246          if (mapillaryImage.next().next() != null)
    247             new MapillaryCache(mapillaryImage.next().next().getKey(),
     247            new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(),
    248248                MapillaryCache.Type.THUMBNAIL).submit(this, false);
    249249        }
    250250        if (mapillaryImage.previous() != null) {
    251           new MapillaryCache(mapillaryImage.previous().getKey(),
     251          new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(),
    252252              MapillaryCache.Type.THUMBNAIL).submit(this, false);
    253253          if (mapillaryImage.previous().previous() != null)
    254             new MapillaryCache(mapillaryImage.previous().previous().getKey(),
     254            new MapillaryCache(((MapillaryImage) mapillaryImage.previous().previous()).getKey(),
    255255                MapillaryCache.Type.THUMBNAIL).submit(this, false);
    256256        }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java

    r31352 r31355  
    1414  /** Unique identifier of the object */
    1515  private final String key;
    16   /** Sequence of pictures containing this object */
    17   private MapillarySequence sequence;
    1816
    1917  /** The user that made the image */
     
    9189  }
    9290
    93   /**
    94    * Sets the MapillarySequence object which contains the MapillaryImage.
    95    *
    96    * @param sequence
    97    *          The MapillarySequence that contains the MapillaryImage.
    98    */
    99   public void setSequence(MapillarySequence sequence) {
    100     this.sequence = sequence;
    101   }
    102 
    103   /**
    104    * Returns the sequence which contains this image.
    105    *
    106    * @return The MapillarySequence object that contains this MapillaryImage.
    107    */
    108   public MapillarySequence getSequence() {
    109     return this.sequence;
    110   }
    111 
    112   @Override
    11391  public String toString() {
    114     return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon="
    115         + this.latLon.lon() + ";ca=" + this.ca + "]";
    116   }
    117 
    118   /**
    119    * If the MapillaryImage belongs to a MapillarySequence, returns the next
    120    * MapillarySequence in it.
    121    *
    122    * @return The following MapillaryImage, or null if there is none.
    123    */
    124   public MapillaryImage next() {
    125     synchronized (lock) {
    126       if (this.getSequence() == null)
    127         return null;
    128       return this.getSequence().next(this);
    129     }
    130   }
    131 
    132   /**
    133    * If the MapillaryImage belongs to a MapillarySequence, returns the previous
    134    * MapillarySequence in it.
    135    *
    136    * @return The previous MapillaryImage, or null if there is none.
    137    */
    138   public MapillaryImage previous() {
    139     synchronized (lock) {
    140       if (this.getSequence() == null)
    141         return null;
    142       return this.getSequence().previous(this);
    143     }
     92    return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon=" + this.latLon.lon() + ";ca=" + this.ca + "]";
    14493  }
    14594
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31350 r31355  
    302302        continue;
    303303      Point p = mv.getPoint(imageAbs.getLatLon());
     304     
     305      Point nextp = null;
     306      // Draw sequence line
     307      if (imageAbs.getSequence() != null) {
     308        MapillaryAbstractImage tempImage = imageAbs.next();
     309        while (tempImage != null) {
     310          if (tempImage.isVisible()) {
     311            nextp = mv.getPoint(tempImage.getLatLon());
     312            break;
     313          }
     314          tempImage = tempImage.next();
     315        }
     316        if (nextp != null)
     317          g.drawLine(p.x, p.y, nextp.x, nextp.y);
     318      }
     319     
    304320      if (imageAbs instanceof MapillaryImage) {
    305321        MapillaryImage image = (MapillaryImage) imageAbs;
    306         Point nextp = null;
    307         // Draw sequence line
    308         if (image.getSequence() != null) {
    309           MapillaryImage tempImage = image.next();
    310           while (tempImage != null) {
    311             if (tempImage.isVisible()) {
    312               nextp = mv.getPoint(tempImage.getLatLon());
    313               break;
    314             }
    315             tempImage = tempImage.next();
    316           }
    317           if (nextp != null)
    318             g.drawLine(p.x, p.y, nextp.x, nextp.y);
    319         }
    320 
    321322        ImageIcon icon;
    322323        if (!data.getMultiSelectedImages().contains(image))
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java

    r31350 r31355  
    4343      return;
    4444    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    45     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
    46         && closestTemp != null && Main.map.mapMode == Main.map.mapModeSelect) {
     45    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closestTemp != null
     46        && Main.map.mapMode == Main.map.mapModeSelect) {
    4747      this.lastClicked = this.closest;
    4848      MapillaryData.getInstance().setSelectedImage(closestTemp);
    4949      return;
    50     } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
    51         .getInstance())
     50    } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())
    5251      return;
    5352    if (closestTemp instanceof MapillaryImage || closestTemp == null) {
    5453      MapillaryImage closest = (MapillaryImage) closestTemp;
    5554      // Doube click
    56       if (e.getClickCount() == 2 && mapillaryData.getSelectedImage() != null
    57           && closest != null) {
     55      if (e.getClickCount() == 2 && mapillaryData.getSelectedImage() != null && closest != null) {
    5856        for (MapillaryAbstractImage img : closest.getSequence().getImages()) {
    5957          mapillaryData.addMultiSelectedImage(img);
     
    6664        return;
    6765      // ctrl+click
    68       if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)
    69           && closest != null)
     66      if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK) && closest != null)
    7067        mapillaryData.addMultiSelectedImage(closest);
    7168      // shift + click
    7269      else if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)
    73           && this.closest instanceof MapillaryImage
    74           && this.lastClicked instanceof MapillaryImage) {
    75         if (this.closest != null
    76             && this.lastClicked != null
    77             && ((MapillaryImage) this.closest).getSequence() == ((MapillaryImage) this.lastClicked)
    78                 .getSequence()) {
    79           int i = ((MapillaryImage) this.closest).getSequence().getImages()
    80               .indexOf(this.closest);
    81           int j = ((MapillaryImage) this.lastClicked).getSequence().getImages()
    82               .indexOf(this.lastClicked);
     70          && this.closest instanceof MapillaryImage && this.lastClicked instanceof MapillaryImage) {
     71        if (this.closest != null && this.lastClicked != null
     72            && ((MapillaryImage) this.closest).getSequence() == ((MapillaryImage) this.lastClicked).getSequence()) {
     73          int i = ((MapillaryImage) this.closest).getSequence().getImages().indexOf(this.closest);
     74          int j = ((MapillaryImage) this.lastClicked).getSequence().getImages().indexOf(this.lastClicked);
    8375          if (i < j)
    84             mapillaryData
    85                 .addMultiSelectedImage(new ArrayList<MapillaryAbstractImage>(
    86                     ((MapillaryImage) this.closest).getSequence().getImages()
    87                         .subList(i, j + 1)));
     76            mapillaryData.addMultiSelectedImage(new ArrayList<>(((MapillaryImage) this.closest).getSequence()
     77                .getImages().subList(i, j + 1)));
    8878          else
    89             mapillaryData
    90                 .addMultiSelectedImage(new ArrayList<MapillaryAbstractImage>(
    91                     ((MapillaryImage) this.closest).getSequence().getImages()
    92                         .subList(j, i + 1)));
     79            mapillaryData.addMultiSelectedImage(new ArrayList<>(((MapillaryImage) this.closest).getSequence()
     80                .getImages().subList(j, i + 1)));
    9381        }
    9482        // click
     
    10391      if (mapillaryData.getMultiSelectedImages().contains(closest))
    10492        return;
    105       if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)
    106           && closest != null)
     93      if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK) && closest != null)
    10794        mapillaryData.addMultiSelectedImage(closest);
    10895      else
     
    119106      imagePoint.setLocation(imagePoint.getX(), imagePoint.getY());
    120107      double dist = clickPoint.distanceSq(imagePoint);
    121       if (minDistance > dist && clickPoint.distance(imagePoint) < snapDistance
    122           && image.isVisible()) {
     108      if (minDistance > dist && clickPoint.distance(imagePoint) < snapDistance && image.isVisible()) {
    123109        minDistance = dist;
    124110        closest = image;
     
    134120
    135121    if (!Main.pref.getBoolean("mapillary.developer"))
    136       for (MapillaryAbstractImage img : MapillaryData.getInstance()
    137           .getMultiSelectedImages()) {
     122      for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
    138123        if (img instanceof MapillaryImage)
    139124          return;
     
    143128        LatLon to = Main.map.mapView.getLatLon(e.getX(), e.getY());
    144129        LatLon from = Main.map.mapView.getLatLon(start.getX(), start.getY());
    145         for (MapillaryAbstractImage img : MapillaryData.getInstance()
    146             .getMultiSelectedImages()) {
     130        for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
    147131
    148132          img.move(to.getX() - from.getX(), to.getY() - from.getY());
     
    150134        Main.map.repaint();
    151135      } else if (lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) {
    152         this.closest.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
    153             -(e.getY() - start.y)))
    154             - closest.getTempCa());
    155         for (MapillaryAbstractImage img : MapillaryData.getInstance()
    156             .getMultiSelectedImages()) {
    157           img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
    158               -(e.getY() - start.y))) - closest.getTempCa());
     136        this.closest
     137            .turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa());
     138        for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
     139          img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa());
    159140        }
    160141        Main.map.repaint();
     
    167148    if (mapillaryData.getSelectedImage() == null)
    168149      return;
    169     if (mapillaryData.getSelectedImage().getTempCa() != mapillaryData
    170         .getSelectedImage().getCa()) {
     150    if (mapillaryData.getSelectedImage().getTempCa() != mapillaryData.getSelectedImage().getCa()) {
    171151      double from = mapillaryData.getSelectedImage().getTempCa();
    172152      double to = mapillaryData.getSelectedImage().getCa();
    173       record.addCommand(new CommandTurnImage(mapillaryData
    174           .getMultiSelectedImages(), to - from));
    175     } else if (mapillaryData.getSelectedImage().getTempLatLon() != mapillaryData
    176         .getSelectedImage().getLatLon()) {
     153      record.addCommand(new CommandTurnImage(mapillaryData.getMultiSelectedImages(), to - from));
     154    } else if (mapillaryData.getSelectedImage().getTempLatLon() != mapillaryData.getSelectedImage().getLatLon()) {
    177155      LatLon from = mapillaryData.getSelectedImage().getTempLatLon();
    178156      LatLon to = mapillaryData.getSelectedImage().getLatLon();
    179       record.addCommand(new CommandMoveImage(mapillaryData
    180           .getMultiSelectedImages(), to.getX() - from.getX(), to.getY()
     157      record.addCommand(new CommandMoveImage(mapillaryData.getMultiSelectedImages(), to.getX() - from.getX(), to.getY()
    181158          - from.getY()));
    182159    }
     
    193170  public void mouseMoved(MouseEvent e) {
    194171    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    195     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
    196         && Main.map.mapMode != Main.map.mapModeSelect)
    197       return;
    198     if (closestTemp != null
    199         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
    200         && !imageHighlighted) {
     172    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && Main.map.mapMode != Main.map.mapModeSelect)
     173      return;
     174    if (closestTemp != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && !imageHighlighted) {
    201175      Main.map.mapMode.putValue("active", Boolean.FALSE);
    202176      imageHighlighted = true;
    203177
    204     } else if (closestTemp == null
    205         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
    206         && imageHighlighted && nothingHighlighted) {
     178    } else if (closestTemp == null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && imageHighlighted
     179        && nothingHighlighted) {
    207180      nothingHighlighted = false;
    208181      Main.map.mapMode.putValue("active", Boolean.TRUE);
    209182
    210     } else if (imageHighlighted && !nothingHighlighted
    211         && Main.map.mapView != null
    212         && Main.map.mapView.getEditLayer().data != null
    213         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
    214 
    215       for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
    216           .allPrimitives()) {
     183    } else if (imageHighlighted && !nothingHighlighted && Main.map.mapView != null
     184        && Main.map.mapView.getEditLayer().data != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
     185
     186      for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data.allPrimitives()) {
    217187        primivitive.setHighlighted(false);
    218188      }
     
    221191    }
    222192
    223     if (MapillaryData.getInstance().getHoveredImage() != closestTemp
    224         && closestTemp != null) {
     193    if (MapillaryData.getInstance().getHoveredImage() != closestTemp && closestTemp != null) {
    225194      MapillaryData.getInstance().setHighlightedImage(closestTemp);
    226195      MapillaryMainDialog.getInstance().setImage(closestTemp);
    227196      MapillaryMainDialog.getInstance().updateImage();
    228     } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp
    229         && closestTemp == null) {
     197    } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp && closestTemp == null) {
    230198      MapillaryData.getInstance().setHighlightedImage(null);
    231       MapillaryMainDialog.getInstance().setImage(
    232           MapillaryData.getInstance().getSelectedImage());
     199      MapillaryMainDialog.getInstance().setImage(MapillaryData.getInstance().getSelectedImage());
    233200      MapillaryMainDialog.getInstance().updateImage();
    234201    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31350 r31355  
    3535  public static final ImageIcon ICON24 = new ImageProvider("icon24.png").get();
    3636  public static final ImageIcon ICON16 = new ImageProvider("icon16.png").get();
    37   public static final ImageIcon MAP_ICON = new ImageProvider("mapicon.png")
    38       .get();
    39   public static final ImageIcon MAP_ICON_SELECTED = new ImageProvider(
    40       "mapiconselected.png").get();
    41   public static final ImageIcon MAP_ICON_IMPORTED = new ImageProvider(
    42       "mapiconimported.png").get();
     37  public static final ImageIcon MAP_ICON = new ImageProvider("mapicon.png").get();
     38  public static final ImageIcon MAP_ICON_SELECTED = new ImageProvider("mapiconselected.png").get();
     39  public static final ImageIcon MAP_ICON_IMPORTED = new ImageProvider("mapiconimported.png").get();
    4340  public static final ImageIcon MAP_SIGN = new ImageProvider("sign.png").get();
    4441  public static final int ICON_SIZE = 24;
     
    5148  private final MapillaryZoomAction zoomAction;
    5249  private final MapillaryDownloadViewAction downloadViewAction;
     50  private final MapillaryImportIntoSequenceAction importIntoSequenceAction;
    5351
    5452  public static JMenuItem DOWNLOAD_MENU;
     
    5755  public static JMenuItem ZOOM_MENU;
    5856  public static JMenuItem DOWNLOAD_VIEW_MENU;
     57  public static JMenuItem IMPORT_INTO_SEQUENCE_MENU;
    5958
    6059  public MapillaryPlugin(PluginInformation info) {
     
    6564    zoomAction = new MapillaryZoomAction();
    6665    downloadViewAction = new MapillaryDownloadViewAction();
     66    importIntoSequenceAction = new MapillaryImportIntoSequenceAction();
    6767
    6868    if (Main.main != null) { // important for headless mode
    69       DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, downloadAction,
    70           false);
    71       EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, false,
    72           14);
    73       IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false,
    74           14);
     69      DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false);
     70      EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
     71      IMPORT_INTO_SEQUENCE_MENU = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
     72      IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
    7573      ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
    76       DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu,
    77           downloadViewAction, false, 14);
     74      DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14);
    7875    }
    7976
     
    8178    DOWNLOAD_MENU.setEnabled(false);
    8279    IMPORT_MENU.setEnabled(false);
     80    IMPORT_INTO_SEQUENCE_MENU.setEnabled(false);
    8381    ZOOM_MENU.setEnabled(false);
    8482    DOWNLOAD_VIEW_MENU.setEnabled(false);
     
    8684    MapView.addEditLayerChangeListener(this);
    8785    try {
    88       CACHE = JCSCacheManager.getCache("mapillary", 10, 10000,
    89           this.getPluginDir() + "/cache/");
     86      CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, this.getPluginDir() + "/cache/");
    9087    } catch (IOException e) {
    9188      Main.error(e);
     
    106103        setMenuEnabled(DOWNLOAD_VIEW_MENU, true);
    107104      setMenuEnabled(IMPORT_MENU, true);
     105      setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, true);
    108106    }
    109107    if (oldFrame != null && newFrame == null) { // map frame destroyed
     
    114112      setMenuEnabled(DOWNLOAD_VIEW_MENU, false);
    115113      setMenuEnabled(IMPORT_MENU, false);
     114      setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, false);
    116115    }
    117116  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java

    r31350 r31355  
    1212 */
    1313public class MapillarySequence {
    14   private final List<MapillaryImage> images;
    15   private final String key;
    16   private final long created_at;
     14  private final List<MapillaryAbstractImage> images;
     15  private String key;
     16  private long created_at;
     17 
     18  public MapillarySequence() {
     19    this.images = new ArrayList<>();
     20  }
    1721
    1822  public MapillarySequence(String key, long created_at) {
     
    2731   * @return
    2832   */
    29   public List<MapillaryImage> getImages() {
     33  public List<MapillaryAbstractImage> getImages() {
    3034    return this.images;
    3135  }
     
    4044   * @param image
    4145   */
    42   public synchronized void add(MapillaryImage image) {
     46  public synchronized void add(MapillaryAbstractImage image) {
    4347    this.images.add(image);
    4448  }
     
    5357   * @param images
    5458   */
    55   public synchronized void add(List<MapillaryImage> images) {
    56     for (MapillaryImage image : images)
     59  public synchronized void add(List<MapillaryAbstractImage> images) {
     60    for (MapillaryAbstractImage image : images)
    5761      add(image);
    5862  }
     
    6367   * @param image
    6468   */
    65   public void remove(MapillaryImage image) {
     69  public void remove(MapillaryAbstractImage image) {
    6670    this.images.remove(image);
    6771  }
     
    7377   * @return
    7478   */
    75   public MapillaryImage next(MapillaryImage image) {
     79  public MapillaryAbstractImage next(MapillaryAbstractImage image) {
    7680    if (!images.contains(image))
    7781      throw new IllegalArgumentException();
     
    8488
    8589  /**
    86    * Returns the previous MapillaryImage in the sequence.
     90   * Returns the previous {@link MapillaryAbstractImage} in the sequence.
    8791   *
    8892   * @param image
    8993   * @return
    9094   */
    91   public MapillaryImage previous(MapillaryImage image) {
     95  public MapillaryAbstractImage previous(MapillaryAbstractImage image) {
    9296    if (!images.contains(image))
    9397      throw new IllegalArgumentException();
     
    100104
    101105  /**
    102    * Returns the difference of index between two MapillaryImage objects
    103    * belonging to the same MapillarySequence.
     106   * Returns the difference of index between two {@link MapillaryAbstractImage}
     107   * objects belonging to the same {@link MapillarySequence}.
    104108   *
    105109   * @param image1
     
    107111   * @return
    108112   */
    109   public int getDistance(MapillaryImage image1, MapillaryImage image2) {
     113  public int getDistance(MapillaryAbstractImage image1, MapillaryAbstractImage image2) {
    110114    if (!this.images.contains(image1) || !this.images.contains(image2))
    111115      throw new IllegalArgumentException();
    112116    return Math.abs(this.images.indexOf(image1) - this.images.indexOf(image2));
    113117  }
    114 
    115   @Override
    116   public boolean equals(Object obj) {
    117     if (obj instanceof MapillarySequence)
    118       return this.getKey().equals(((MapillarySequence) obj).getKey());
    119     return false;
    120   }
    121 
    122   @Override
    123   public int hashCode() {
    124     return this.key.hashCode();
    125   }
    126118}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31352 r31355  
    4444
    4545  public MapillaryImportAction() {
    46     super(tr("Import pictures"), new ImageProvider("icon24.png"),
    47         tr("Import local pictures"), Shortcut.registerShortcut("Import Mapillary",
    48             tr("Import pictures into Mapillary layer"), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE),
    49         false, "mapillaryImport", false);
     46    super(tr("Import pictures"), new ImageProvider("icon24.png"), tr("Import local pictures"), Shortcut
     47        .registerShortcut("Import Mapillary", tr("Import pictures into Mapillary layer"), KeyEvent.CHAR_UNDEFINED,
     48            Shortcut.NONE), false, "mapillaryImport", false);
    5049    this.setEnabled(false);
    5150  }
     
    6362      for (int i = 0; i < chooser.getSelectedFiles().length; i++) {
    6463        File file = chooser.getSelectedFiles()[i];
    65         if (!file.isDirectory()) {
    66           MapillaryLayer.getInstance();
     64        if (file.isDirectory()) {
     65          // TODO import directory
     66        } else {
    6767          if (file.getPath().substring(file.getPath().length() - 4).equals(".jpg")
    6868              || file.getPath().substring(file.getPath().length() - 5).equals(".jpeg")) {
     
    108108      double lonValue = 0;
    109109      double caValue = 0;
    110       if (lat.getValue() instanceof RationalNumber[])
    111         latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString());
    112       if (lon.getValue() instanceof RationalNumber[])
    113         lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString());
     110      if (lat != null && lat.getValue() instanceof RationalNumber[])
     111        latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString());
     112      if (lon != null && lon.getValue() instanceof RationalNumber[])
     113        lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString());
    114114      if (ca != null && ca.getValue() instanceof RationalNumber)
    115115        caValue = ((RationalNumber) ca.getValue()).doubleValue();
     116      if (lat_ref.getValue().toString().equals("S"))
     117        latValue = -latValue;
     118      if (lon_ref.getValue().toString().equals("W"))
     119        lonValue = -lonValue;
    116120      if (datetimeOriginal != null)
    117         MapillaryData.getInstance()
    118             .add(new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue()));
     121        MapillaryData.getInstance().add(
     122            new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue()));
    119123      else
    120124        MapillaryData.getInstance().add(new MapillaryImportedImage(latValue, lonValue, caValue, file));
     
    144148  }
    145149
    146   /**
    147    * Calculates the decimal degree-value from a degree value given in degrees-minutes-seconds-format
    148    *
    149    * @param degMinSec an array of length 3, the values in there are (in this order) degrees, minutes and seconds
    150    * @param ref the latitude or longitude reference determining if the given value is:
    151    *        <ul>
    152    *        <li>north ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or
    153    *        south ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of the equator</li>
    154    *        <li>east ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or
    155    *        west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST}) of the equator</li>
    156    *        </ul>
    157    * @return the decimal degree-value for the given input, negative when west of 0-meridian or south of equator,
    158    *         positive otherwise
    159    * @throws IllegalArgumentException if {@code degMinSec} doesn't have length 3 or if {@code ref} is not one of the
    160    *         values mentioned above
    161    */
    162   private static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) {
    163     if (degMinSec == null || degMinSec.length != 3) { throw new IllegalArgumentException(); }
    164     switch (ref) {
    165     case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH:
    166     case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH:
    167     case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST:
    168     case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST:
    169       break;
    170     default:
    171       throw new IllegalArgumentException();
    172     }
    173 
    174     double result = degMinSec[0].doubleValue(); // degrees
    175     result += degMinSec[1].doubleValue() / 60; // minutes
    176     result += degMinSec[2].doubleValue() / 3600; // seconds
    177 
    178     if (ref == GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH
    179         || ref == GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST) {
    180       result *= -1;
    181     }
    182 
    183     return result;
     150  public static double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) {
     151    RationalNumber deg = degMinSec[0];
     152    RationalNumber min = degMinSec[1];
     153    RationalNumber sec = degMinSec[2];
     154    return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue() / 3600;
    184155  }
    185156}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31350 r31355  
    145145        this.previousButton.setEnabled(false);
    146146        if (((MapillaryImage) image).getSequence() != null) {
    147           MapillaryImage tempImage = (MapillaryImage) image;
     147          MapillaryAbstractImage tempImage = image;
    148148          while (tempImage.next() != null) {
    149149            tempImage = tempImage.next();
     
    155155        }
    156156        if (((MapillaryImage) image).getSequence() != null) {
    157           MapillaryImage tempImage = (MapillaryImage) image;
     157          MapillaryAbstractImage tempImage = image;
    158158          while (tempImage.previous() != null) {
    159159            tempImage = tempImage.previous();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java

    r31352 r31355  
    3939    in.close();
    4040    System.out.println();
     41    in.close();
    4142  }
    4243
Note: See TracChangeset for help on using the changeset viewer.