Changeset 31355 in osm for applications
- Timestamp:
- 2015-07-09T11:56:57+02:00 (9 years ago)
- 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 24 24 /** The time the image was captured, in Epoch format */ 25 25 private long capturedAt; 26 /** Sequence of pictures containing this object */ 27 private MapillarySequence sequence; 26 28 /** Position of the picture */ 27 29 public final LatLon latLon; … … 105 107 */ 106 108 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); 109 110 this.isModified = true; 110 111 } … … 203 204 SimpleDateFormat formatter = new SimpleDateFormat(format); 204 205 try { 205 Date dateTime = formatter.parse(date);206 Date dateTime = (Date) formatter.parse(date); 206 207 return dateTime.getTime(); 207 208 } catch (ParseException e) { … … 220 221 return cal.getTimeInMillis(); 221 222 } 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 } 222 270 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31350 r31355 170 170 if (selectedImage instanceof MapillaryImage 171 171 && ((MapillaryImage) selectedImage).getSequence() != null) { 172 Mapillary Image tempImage = (MapillaryImage)selectedImage;172 MapillaryAbstractImage tempImage = selectedImage; 173 173 while (tempImage.next() != null) { 174 174 tempImage = tempImage.next(); … … 196 196 if (selectedImage instanceof MapillaryImage 197 197 && ((MapillaryImage) selectedImage).getSequence() != null) { 198 Mapillary Image tempImage = (MapillaryImage)selectedImage;198 MapillaryAbstractImage tempImage = selectedImage; 199 199 while (tempImage.previous() != null) { 200 200 tempImage = tempImage.previous(); … … 242 242 // Donwloadins thumbnails of surrounding pictures. 243 243 if (mapillaryImage.next() != null) { 244 new MapillaryCache( mapillaryImage.next().getKey(),244 new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(), 245 245 MapillaryCache.Type.THUMBNAIL).submit(this, false); 246 246 if (mapillaryImage.next().next() != null) 247 new MapillaryCache( mapillaryImage.next().next().getKey(),247 new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(), 248 248 MapillaryCache.Type.THUMBNAIL).submit(this, false); 249 249 } 250 250 if (mapillaryImage.previous() != null) { 251 new MapillaryCache( mapillaryImage.previous().getKey(),251 new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(), 252 252 MapillaryCache.Type.THUMBNAIL).submit(this, false); 253 253 if (mapillaryImage.previous().previous() != null) 254 new MapillaryCache( mapillaryImage.previous().previous().getKey(),254 new MapillaryCache(((MapillaryImage) mapillaryImage.previous().previous()).getKey(), 255 255 MapillaryCache.Type.THUMBNAIL).submit(this, false); 256 256 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31352 r31355 14 14 /** Unique identifier of the object */ 15 15 private final String key; 16 /** Sequence of pictures containing this object */17 private MapillarySequence sequence;18 16 19 17 /** The user that made the image */ … … 91 89 } 92 90 93 /**94 * Sets the MapillarySequence object which contains the MapillaryImage.95 *96 * @param sequence97 * 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 @Override113 91 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 + "]"; 144 93 } 145 94 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31350 r31355 302 302 continue; 303 303 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 304 320 if (imageAbs instanceof MapillaryImage) { 305 321 MapillaryImage image = (MapillaryImage) imageAbs; 306 Point nextp = null;307 // Draw sequence line308 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 321 322 ImageIcon icon; 322 323 if (!data.getMultiSelectedImages().contains(image)) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java
r31350 r31355 43 43 return; 44 44 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) { 47 47 this.lastClicked = this.closest; 48 48 MapillaryData.getInstance().setSelectedImage(closestTemp); 49 49 return; 50 } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer 51 .getInstance()) 50 } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance()) 52 51 return; 53 52 if (closestTemp instanceof MapillaryImage || closestTemp == null) { 54 53 MapillaryImage closest = (MapillaryImage) closestTemp; 55 54 // Doube click 56 if (e.getClickCount() == 2 && mapillaryData.getSelectedImage() != null 57 && closest != null) { 55 if (e.getClickCount() == 2 && mapillaryData.getSelectedImage() != null && closest != null) { 58 56 for (MapillaryAbstractImage img : closest.getSequence().getImages()) { 59 57 mapillaryData.addMultiSelectedImage(img); … … 66 64 return; 67 65 // 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) 70 67 mapillaryData.addMultiSelectedImage(closest); 71 68 // shift + click 72 69 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); 83 75 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))); 88 78 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))); 93 81 } 94 82 // click … … 103 91 if (mapillaryData.getMultiSelectedImages().contains(closest)) 104 92 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) 107 94 mapillaryData.addMultiSelectedImage(closest); 108 95 else … … 119 106 imagePoint.setLocation(imagePoint.getX(), imagePoint.getY()); 120 107 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()) { 123 109 minDistance = dist; 124 110 closest = image; … … 134 120 135 121 if (!Main.pref.getBoolean("mapillary.developer")) 136 for (MapillaryAbstractImage img : MapillaryData.getInstance() 137 .getMultiSelectedImages()) { 122 for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) { 138 123 if (img instanceof MapillaryImage) 139 124 return; … … 143 128 LatLon to = Main.map.mapView.getLatLon(e.getX(), e.getY()); 144 129 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()) { 147 131 148 132 img.move(to.getX() - from.getX(), to.getY() - from.getY()); … … 150 134 Main.map.repaint(); 151 135 } 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()); 159 140 } 160 141 Main.map.repaint(); … … 167 148 if (mapillaryData.getSelectedImage() == null) 168 149 return; 169 if (mapillaryData.getSelectedImage().getTempCa() != mapillaryData 170 .getSelectedImage().getCa()) { 150 if (mapillaryData.getSelectedImage().getTempCa() != mapillaryData.getSelectedImage().getCa()) { 171 151 double from = mapillaryData.getSelectedImage().getTempCa(); 172 152 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()) { 177 155 LatLon from = mapillaryData.getSelectedImage().getTempLatLon(); 178 156 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() 181 158 - from.getY())); 182 159 } … … 193 170 public void mouseMoved(MouseEvent e) { 194 171 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) { 201 175 Main.map.mapMode.putValue("active", Boolean.FALSE); 202 176 imageHighlighted = true; 203 177 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) { 207 180 nothingHighlighted = false; 208 181 Main.map.mapMode.putValue("active", Boolean.TRUE); 209 182 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()) { 217 187 primivitive.setHighlighted(false); 218 188 } … … 221 191 } 222 192 223 if (MapillaryData.getInstance().getHoveredImage() != closestTemp 224 && closestTemp != null) { 193 if (MapillaryData.getInstance().getHoveredImage() != closestTemp && closestTemp != null) { 225 194 MapillaryData.getInstance().setHighlightedImage(closestTemp); 226 195 MapillaryMainDialog.getInstance().setImage(closestTemp); 227 196 MapillaryMainDialog.getInstance().updateImage(); 228 } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp 229 && closestTemp == null) { 197 } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp && closestTemp == null) { 230 198 MapillaryData.getInstance().setHighlightedImage(null); 231 MapillaryMainDialog.getInstance().setImage( 232 MapillaryData.getInstance().getSelectedImage()); 199 MapillaryMainDialog.getInstance().setImage(MapillaryData.getInstance().getSelectedImage()); 233 200 MapillaryMainDialog.getInstance().updateImage(); 234 201 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31350 r31355 35 35 public static final ImageIcon ICON24 = new ImageProvider("icon24.png").get(); 36 36 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(); 43 40 public static final ImageIcon MAP_SIGN = new ImageProvider("sign.png").get(); 44 41 public static final int ICON_SIZE = 24; … … 51 48 private final MapillaryZoomAction zoomAction; 52 49 private final MapillaryDownloadViewAction downloadViewAction; 50 private final MapillaryImportIntoSequenceAction importIntoSequenceAction; 53 51 54 52 public static JMenuItem DOWNLOAD_MENU; … … 57 55 public static JMenuItem ZOOM_MENU; 58 56 public static JMenuItem DOWNLOAD_VIEW_MENU; 57 public static JMenuItem IMPORT_INTO_SEQUENCE_MENU; 59 58 60 59 public MapillaryPlugin(PluginInformation info) { … … 65 64 zoomAction = new MapillaryZoomAction(); 66 65 downloadViewAction = new MapillaryDownloadViewAction(); 66 importIntoSequenceAction = new MapillaryImportIntoSequenceAction(); 67 67 68 68 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); 75 73 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); 78 75 } 79 76 … … 81 78 DOWNLOAD_MENU.setEnabled(false); 82 79 IMPORT_MENU.setEnabled(false); 80 IMPORT_INTO_SEQUENCE_MENU.setEnabled(false); 83 81 ZOOM_MENU.setEnabled(false); 84 82 DOWNLOAD_VIEW_MENU.setEnabled(false); … … 86 84 MapView.addEditLayerChangeListener(this); 87 85 try { 88 CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, 89 this.getPluginDir() + "/cache/"); 86 CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, this.getPluginDir() + "/cache/"); 90 87 } catch (IOException e) { 91 88 Main.error(e); … … 106 103 setMenuEnabled(DOWNLOAD_VIEW_MENU, true); 107 104 setMenuEnabled(IMPORT_MENU, true); 105 setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, true); 108 106 } 109 107 if (oldFrame != null && newFrame == null) { // map frame destroyed … … 114 112 setMenuEnabled(DOWNLOAD_VIEW_MENU, false); 115 113 setMenuEnabled(IMPORT_MENU, false); 114 setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, false); 116 115 } 117 116 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
r31350 r31355 12 12 */ 13 13 public 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 } 17 21 18 22 public MapillarySequence(String key, long created_at) { … … 27 31 * @return 28 32 */ 29 public List<Mapillary Image> getImages() {33 public List<MapillaryAbstractImage> getImages() { 30 34 return this.images; 31 35 } … … 40 44 * @param image 41 45 */ 42 public synchronized void add(Mapillary Image image) {46 public synchronized void add(MapillaryAbstractImage image) { 43 47 this.images.add(image); 44 48 } … … 53 57 * @param images 54 58 */ 55 public synchronized void add(List<Mapillary Image> images) {56 for (Mapillary Image image : images)59 public synchronized void add(List<MapillaryAbstractImage> images) { 60 for (MapillaryAbstractImage image : images) 57 61 add(image); 58 62 } … … 63 67 * @param image 64 68 */ 65 public void remove(Mapillary Image image) {69 public void remove(MapillaryAbstractImage image) { 66 70 this.images.remove(image); 67 71 } … … 73 77 * @return 74 78 */ 75 public Mapillary Image next(MapillaryImage image) {79 public MapillaryAbstractImage next(MapillaryAbstractImage image) { 76 80 if (!images.contains(image)) 77 81 throw new IllegalArgumentException(); … … 84 88 85 89 /** 86 * Returns the previous MapillaryImagein the sequence.90 * Returns the previous {@link MapillaryAbstractImage} in the sequence. 87 91 * 88 92 * @param image 89 93 * @return 90 94 */ 91 public Mapillary Image previous(MapillaryImage image) {95 public MapillaryAbstractImage previous(MapillaryAbstractImage image) { 92 96 if (!images.contains(image)) 93 97 throw new IllegalArgumentException(); … … 100 104 101 105 /** 102 * Returns the difference of index between two MapillaryImage objects103 * belonging to the same MapillarySequence.106 * Returns the difference of index between two {@link MapillaryAbstractImage} 107 * objects belonging to the same {@link MapillarySequence}. 104 108 * 105 109 * @param image1 … … 107 111 * @return 108 112 */ 109 public int getDistance(Mapillary Image image1, MapillaryImage image2) {113 public int getDistance(MapillaryAbstractImage image1, MapillaryAbstractImage image2) { 110 114 if (!this.images.contains(image1) || !this.images.contains(image2)) 111 115 throw new IllegalArgumentException(); 112 116 return Math.abs(this.images.indexOf(image1) - this.images.indexOf(image2)); 113 117 } 114 115 @Override116 public boolean equals(Object obj) {117 if (obj instanceof MapillarySequence)118 return this.getKey().equals(((MapillarySequence) obj).getKey());119 return false;120 }121 122 @Override123 public int hashCode() {124 return this.key.hashCode();125 }126 118 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31352 r31355 44 44 45 45 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); 50 49 this.setEnabled(false); 51 50 } … … 63 62 for (int i = 0; i < chooser.getSelectedFiles().length; i++) { 64 63 File file = chooser.getSelectedFiles()[i]; 65 if (!file.isDirectory()) { 66 MapillaryLayer.getInstance(); 64 if (file.isDirectory()) { 65 // TODO import directory 66 } else { 67 67 if (file.getPath().substring(file.getPath().length() - 4).equals(".jpg") 68 68 || file.getPath().substring(file.getPath().length() - 5).equals(".jpeg")) { … … 108 108 double lonValue = 0; 109 109 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()); 114 114 if (ca != null && ca.getValue() instanceof RationalNumber) 115 115 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; 116 120 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())); 119 123 else 120 124 MapillaryData.getInstance().add(new MapillaryImportedImage(latValue, lonValue, caValue, file)); … … 144 148 } 145 149 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; 184 155 } 185 156 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31350 r31355 145 145 this.previousButton.setEnabled(false); 146 146 if (((MapillaryImage) image).getSequence() != null) { 147 Mapillary Image tempImage = (MapillaryImage)image;147 MapillaryAbstractImage tempImage = image; 148 148 while (tempImage.next() != null) { 149 149 tempImage = tempImage.next(); … … 155 155 } 156 156 if (((MapillaryImage) image).getSequence() != null) { 157 Mapillary Image tempImage = (MapillaryImage)image;157 MapillaryAbstractImage tempImage = image; 158 158 while (tempImage.previous() != null) { 159 159 tempImage = tempImage.previous(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java
r31352 r31355 39 39 in.close(); 40 40 System.out.println(); 41 in.close(); 41 42 } 42 43
Note:
See TracChangeset
for help on using the changeset viewer.