Changeset 31401 in osm for applications
- Timestamp:
- 2015-07-24T17:12:23+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 30 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31400 r31401 58 58 * 59 59 * @param images 60 * The set of images to be added.60 * The set of images to be added. 61 61 */ 62 62 public synchronized void add(List<MapillaryAbstractImage> images) { … … 70 70 * 71 71 * @param image 72 * The image to be added.72 * The image to be added. 73 73 */ 74 74 public synchronized void add(MapillaryAbstractImage image) { … … 83 83 * Adds a new listener. 84 84 * 85 * @param lis Listener to be added. 85 * @param lis 86 * Listener to be added. 86 87 */ 87 88 public void addListener(MapillaryDataListener lis) { … … 92 93 * Removes a listener. 93 94 * 94 * @param lis Listener to be removed. 95 * @param lis 96 * Listener to be removed. 95 97 */ 96 98 public void removeListener(MapillaryDataListener lis) { … … 103 105 * 104 106 * @param images 105 * The set of images to be added.107 * The set of images to be added. 106 108 */ 107 109 public synchronized void addWithoutUpdate(List<MapillaryAbstractImage> images) { … … 115 117 * 116 118 * @param image 117 * The image under the cursor.119 * The image under the cursor. 118 120 */ 119 121 public void setHighlightedImage(MapillaryAbstractImage image) { … … 135 137 * 136 138 * @param image 137 * The image to be added.139 * The image to be added. 138 140 */ 139 141 public synchronized void addWithoutUpdate(MapillaryAbstractImage image) { … … 191 193 tempImage = tempImage.next(); 192 194 if (tempImage.isVisible()) { 193 setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true)); 195 setSelectedImage(tempImage, 196 Main.pref.getBoolean("mapillary.move-to-picture", true)); 194 197 break; 195 198 } … … 211 214 tempImage = tempImage.previous(); 212 215 if (tempImage.isVisible()) { 213 setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true)); 216 setSelectedImage(tempImage, 217 Main.pref.getBoolean("mapillary.move-to-picture", true)); 214 218 break; 215 219 } … … 221 225 * 222 226 * @param image 223 * The MapillaryImage which is going to be selected227 * The MapillaryImage which is going to be selected 224 228 */ 225 229 public void setSelectedImage(MapillaryAbstractImage image) { … … 228 232 229 233 /** 230 * Selects a new image.If the user does ctrl+click, this isn't triggered. 231 * Youcan choose whether to center the view on the new image or not.232 * 233 * @param image 234 * The {@link MapillaryImage} which is going to be selected.234 * Selects a new image.If the user does ctrl+click, this isn't triggered. You 235 * can choose whether to center the view on the new image or not. 236 * 237 * @param image 238 * The {@link MapillaryImage} which is going to be selected. 235 239 * @param zoom 236 * True if the view must be centered on the image; false otherwise.240 * True if the view must be centered on the image; false otherwise. 237 241 */ 238 242 public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) { … … 251 255 // Downloading thumbnails of surrounding pictures. 252 256 if (mapillaryImage.next() != null) { 253 Utils.downloadPicture( mapillaryImage.next());257 Utils.downloadPicture((MapillaryImage) mapillaryImage.next()); 254 258 if (mapillaryImage.next().next() != null) 255 Utils.downloadPicture(mapillaryImage.next().next()); 259 Utils 260 .downloadPicture((MapillaryImage) mapillaryImage.next().next()); 256 261 } 257 262 if (mapillaryImage.previous() != null) { 258 Utils.downloadPicture( mapillaryImage.previous());263 Utils.downloadPicture((MapillaryImage) mapillaryImage.previous()); 259 264 if (mapillaryImage.previous().previous() != null) 260 Utils.downloadPicture(mapillaryImage.previous().previous()); 265 Utils.downloadPicture((MapillaryImage) mapillaryImage.previous() 266 .previous()); 261 267 } 262 268 } 263 269 } 264 270 if (zoom) 265 Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage().getLatLon()); 271 Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage() 272 .getLatLon()); 266 273 if (Main.map != null) 267 274 Main.map.mapView.repaint(); … … 269 276 } 270 277 271 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) { 278 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, 279 MapillaryAbstractImage newImage) { 272 280 if (listeners.isEmpty()) 273 281 return; … … 281 289 * 282 290 * @param image 283 * The MapillaryImage object to be added.291 * The MapillaryImage object to be added. 284 292 */ 285 293 public void addMultiSelectedImage(MapillaryAbstractImage image) { … … 298 306 * 299 307 * @param images 300 * A List object containing the set of images to be added.308 * A List object containing the set of images to be added. 301 309 */ 302 310 public void addMultiSelectedImage(List<MapillaryAbstractImage> images) { … … 313 321 /** 314 322 * Returns a List containing all {@code MapillaryAbstractImage} objects 315 * selected with ctrl + click 323 * selected with ctrl + click. 316 324 * 317 325 * @return A List object containing all the images selected. -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDataListener.java
r31386 r31401 18 18 * manually clicking on the icon. 19 19 * 20 * @param oldImage Old selected {@link MapillaryAbstractImage} 21 * @param newImage New selected {@link MapillaryAbstractImage} 20 * @param oldImage 21 * Old selected {@link MapillaryAbstractImage} 22 * @param newImage 23 * New selected {@link MapillaryAbstractImage} 22 24 */ 23 25 public void selectedImageChanged(MapillaryAbstractImage oldImage, -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31386 r31401 98 98 * Returns the username of the person who took the picture. 99 99 * 100 * @return A String containing the username of the person who took the picture. 100 * @return A String containing the username of the person who took the 101 * picture. 101 102 */ 102 103 public String getUser() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31400 r31401 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 6 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryDownloadViewAction;7 6 import org.openstreetmap.josm.plugins.mapillary.cache.Utils; 8 7 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; … … 52 51 import javax.swing.Action; 53 52 import javax.swing.Icon; 54 import javax.swing.JOptionPane;55 53 56 54 import java.util.List; … … 71 69 "mapillary.sequence-max-jump-distance", 100); 72 70 73 /** If the download is in manual mode during the rest of the session*/71 /** If the download is in semiautomatic during this object lifetime. */ 74 72 public boolean TEMP_SEMIAUTOMATIC = false; 75 73 … … 82 80 83 81 /** {@link MapillaryData} object that stores the database */ 84 public final MapillaryData data = MapillaryData.getInstance();82 public final MapillaryData data; 85 83 86 84 /** The bounds of the areas for which the pictures have been downloaded */ … … 99 97 private MapillaryLayer() { 100 98 super(tr("Mapillary Images")); 99 data = MapillaryData.getInstance(); 101 100 bounds = new ArrayList<>(); 102 101 init(); … … 158 157 159 158 /** 160 * Downloads all images of the area covered by the OSM data. This is only just161 * for automatic download.162 */163 public void download() {164 checkAreaTooBig();165 if (!Main.pref.get("mapillary.download-mode").equals(166 MapillaryDownloader.MODES[0])167 || TEMP_SEMIAUTOMATIC)168 return;169 for (Bounds bounds : Main.map.mapView.getEditLayer().data170 .getDataSourceBounds()) {171 if (!this.bounds.contains(bounds)) {172 this.bounds.add(bounds);173 MapillaryDownloader.getImages(bounds.getMin(), bounds.getMax());174 }175 }176 }177 178 /**179 * Checks if the area of the OSM data is too big. This means that probably180 * lots of Mapillary images are going to be downloaded, slowing down the181 * program too much. To solve this the automatic is stopped, an alert is shown182 * and you will have to download areas manually.183 */184 private void checkAreaTooBig() {185 double area = 0;186 for (Bounds bounds : Main.map.mapView.getEditLayer().data187 .getDataSourceBounds()) {188 area += bounds.getArea();189 }190 if (area > MapillaryDownloadViewAction.MAX_AREA) {191 TEMP_SEMIAUTOMATIC = true;192 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true);193 JOptionPane194 .showMessageDialog(195 Main.parent,196 tr("The downloaded OSM area is too big. Download mode has been changed to manual until the layer is restarted."));197 }198 }199 200 /**201 159 * Returns the {@link MapillaryData} object, which acts as the database of the 202 160 * Layer. … … 208 166 } 209 167 210 /**211 * Method invoked when the layer is destroyed.212 */213 168 @Override 214 169 public void destroy() { … … 566 521 Main.error(e); 567 522 } 568 Mapillary Layer.getInstance().download();523 MapillaryDownloader.automaticDownload(); 569 524 } 570 525 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
r31384 r31401 33 33 /** 34 34 * Returns and when needed instantiates the Mapillary traffic sign layer. 35 * 35 36 * @return the only instance of the traffic sign layer 36 37 */ 37 38 public static MapillaryTrafficSignLayer getInstance() { 38 return instance == null ? (instance = new MapillaryTrafficSignLayer()) : instance; 39 return instance == null ? (instance = new MapillaryTrafficSignLayer()) 40 : instance; 39 41 } 40 42 … … 48 50 /* 49 51 * (non-Javadoc) 52 * 50 53 * @see org.openstreetmap.josm.gui.layer.AbstractModifiableLayer#isModified() 51 54 */ … … 57 60 /* 58 61 * (non-Javadoc) 59 * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics2D, org.openstreetmap.josm.gui.MapView, 60 * org.openstreetmap.josm.data.Bounds) 62 * 63 * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics2D, 64 * org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.Bounds) 61 65 */ 62 66 @Override 63 67 public void paint(Graphics2D g, MapView mv, Bounds box) { 64 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 68 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 69 RenderingHints.VALUE_ANTIALIAS_ON); 65 70 try { 66 g.setFont(Font.createFont(Font.TRUETYPE_FONT, new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f)); 71 g.setFont(Font.createFont(Font.TRUETYPE_FONT, 72 new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f)); 67 73 } catch (FontFormatException e) { 68 74 e.printStackTrace(); … … 76 82 points[2] = mv.getPoint(new LatLon(49.01038, 8.40636)); 77 83 78 TrafficoSignElement[][] signs = { TrafficoSign.getSign("europe", "mandatory_cycle_track"), TrafficoSign.getSign("de", "information_bus_stop"), TrafficoSign.getSign("europe", "information_pedestrian_crossing") }; 84 TrafficoSignElement[][] signs = { 85 TrafficoSign.getSign("europe", "mandatory_cycle_track"), 86 TrafficoSign.getSign("de", "information_bus_stop"), 87 TrafficoSign.getSign("europe", "information_pedestrian_crossing") }; 79 88 80 89 for (int i = 0; i < signs.length && i < points.length; i++) { … … 87 96 // Start iterating the images 88 97 g.setColor(Color.MAGENTA); 89 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getMapillaryData().getImages()) { 98 for (MapillaryAbstractImage img : MapillaryLayer.getInstance() 99 .getMapillaryData().getImages()) { 90 100 if (img instanceof MapillaryImage) { 91 g.fillOval(mv.getPoint(img.getLatLon()).x-3, mv.getPoint(img.getLatLon()).y-3, 6, 6); 101 g.fillOval(mv.getPoint(img.getLatLon()).x - 3, 102 mv.getPoint(img.getLatLon()).y - 3, 6, 6); 92 103 if (((MapillaryImage) img).getSigns().size() >= 1) { 93 104 Point imgLoc = mv.getPoint(img.getLatLon()); 94 for (TrafficoSignElement e : TrafficoSign.getSign("de", ((MapillaryImage) img).getSigns().get(0))) { 105 for (TrafficoSignElement e : TrafficoSign.getSign("de", 106 ((MapillaryImage) img).getSigns().get(0))) { 95 107 g.setColor(e.getColor()); 96 108 g.drawString("" + e.getGlyph(), imgLoc.x, imgLoc.y); … … 103 115 /* 104 116 * (non-Javadoc) 117 * 105 118 * @see org.openstreetmap.josm.gui.layer.Layer#getIcon() 106 119 */ … … 112 125 /* 113 126 * (non-Javadoc) 127 * 114 128 * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText() 115 129 */ … … 121 135 /* 122 136 * (non-Javadoc) 123 * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer) 137 * 138 * @see 139 * org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm 140 * .gui.layer.Layer) 124 141 */ 125 142 @Override 126 143 public void mergeFrom(Layer from) { 127 // Does nothing as this layer is not mergeable (see method isMergable(Layer)) 144 // Does nothing as this layer is not mergeable (see method 145 // isMergable(Layer)) 128 146 } 129 147 130 148 /* 131 149 * (non-Javadoc) 132 * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer) 150 * 151 * @see 152 * org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm 153 * .gui.layer.Layer) 133 154 */ 134 155 @Override … … 139 160 /* 140 161 * (non-Javadoc) 162 * 141 163 * @see 142 * org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor) 164 * org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap 165 * .josm.data.osm.visitor.BoundingXYVisitor) 143 166 */ 144 167 @Override … … 150 173 /* 151 174 * (non-Javadoc) 175 * 152 176 * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent() 153 177 */ … … 160 184 /* 161 185 * (non-Javadoc) 186 * 162 187 * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries() 163 188 */ -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java
r31386 r31401 12 12 import org.openstreetmap.josm.actions.JosmAction; 13 13 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 14 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 14 15 import org.openstreetmap.josm.tools.ImageProvider; 15 16 import org.openstreetmap.josm.tools.Shortcut; … … 41 42 if (MapillaryLayer.INSTANCE == null) { 42 43 if (Main.map.mapView.getEditLayer() != null) 43 Mapillary Layer.getInstance().download();44 MapillaryDownloader.automaticDownload(); 44 45 } else { 45 46 if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance()) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r31386 r31401 57 57 JButton cancel = new JButton(tr("Cancel")); 58 58 cancel.addActionListener(new CancelAction(pane)); 59 60 59 61 60 dialog = new MapillaryExportDialog(ok); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31387 r31401 153 153 if (datetimeOriginal != null) 154 154 MapillaryData.getInstance().add( 155 new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue())); 155 new MapillaryImportedImage(latValue, lonValue, caValue, file, 156 datetimeOriginal.getStringValue())); 156 157 else 157 158 MapillaryData.getInstance().add( 158 159 new MapillaryImportedImage(latValue, lonValue, caValue, file)); 159 160 } 160 161 161 162 MapillaryLayer.getInstance().showAllPictures(); 162 163 } … … 219 220 } 220 221 switch (ref) { 221 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH:222 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH:223 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST:224 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST:225 break;226 default:227 throw new IllegalArgumentException();222 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH: 223 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH: 224 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST: 225 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST: 226 break; 227 default: 228 throw new IllegalArgumentException(); 228 229 } 229 230 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31396 r31401 73 73 "jpeg")); 74 74 chooser.setMultiSelectionEnabled(true); 75 75 76 76 if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 77 77 for (int i = 0; i < chooser.getSelectedFiles().length; i++) { … … 112 112 joinImages(); 113 113 } 114 114 115 115 MapillaryLayer.getInstance().showAllPictures(); 116 116 } … … 140 140 final TiffField datetimeOriginal = jpegMetadata 141 141 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 142 if (lat_ref == null || lat == null || lon == null || lon_ref == null || datetimeOriginal == null) 143 throw new IllegalArgumentException("The picture has not correct EXIF tags"); 142 if (lat_ref == null || lat == null || lon == null || lon_ref == null 143 || datetimeOriginal == null) 144 throw new IllegalArgumentException( 145 "The picture has not correct EXIF tags"); 144 146 145 147 double latValue = 0; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
r31398 r31401 103 103 } 104 104 105 106 105 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkListener.java
r31398 r31401 1 1 package org.openstreetmap.josm.plugins.mapillary.actions; 2 3 2 4 3 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java
r31398 r31401 46 46 while (!end && data.getSelectedImage().next() != null) { 47 47 MapillaryAbstractImage image = data.getSelectedImage(); 48 for (int i = 0; i < 5; i++) { 49 if (image.next() == null) 50 break; 51 image = image.next(); 52 Utils.downloadPicture(image); 48 // Predownload next 5 pictures. 49 if (image instanceof MapillaryImage) { 50 for (int i = 0; i < 5; i++) { 51 if (image.next() == null) 52 break; 53 image = image.next(); 54 Utils.downloadPicture((MapillaryImage) image); 55 } 53 56 } 54 57 try { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
r31387 r31401 30 30 /** Full quality image */ 31 31 FULL_IMAGE, 32 32 33 33 /** Low quality image */ 34 34 THUMBNAIL -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/Utils.java
r31400 r31401 4 4 import org.openstreetmap.josm.data.cache.CacheEntryAttributes; 5 5 import org.openstreetmap.josm.data.cache.ICachedLoaderListener; 6 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;7 6 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 8 7 … … 18 17 19 18 /** 20 * Downloads the picture of the given image and does nothing when it is downloaded. 19 * Downloads the picture of the given image and does nothing when it is 20 * downloaded. 21 21 * 22 22 * @param img 23 23 */ 24 public static void downloadPicture(MapillaryAbstractImage img) { 25 if (!(img instanceof MapillaryImage)) 26 throw new IllegalArgumentException(); 27 new MapillaryCache(((MapillaryImage) img).getKey(), MapillaryCache.Type.THUMBNAIL).submit( 24 public static void downloadPicture(MapillaryImage img) { 25 new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL).submit( 28 26 IGNORE_DOWNLOAD, false); 29 new MapillaryCache( ((MapillaryImage) img).getKey(), MapillaryCache.Type.FULL_IMAGE).submit(27 new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE).submit( 30 28 IGNORE_DOWNLOAD, false); 31 29 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java
r31387 r31401 22 22 * Main constructor. 23 23 * 24 * @param images Set of images that are going to be moved. 25 * @param x How much the x coordinate increases. 26 * @param y How much the y coordinate increases. 24 * @param images 25 * Set of images that are going to be moved. 26 * @param x 27 * How much the x coordinate increases. 28 * @param y 29 * How much the y coordinate increases. 27 30 */ 28 public CommandMoveImage(List<MapillaryAbstractImage> images, double x, double y) { 31 public CommandMoveImage(List<MapillaryAbstractImage> images, double x, 32 double y) { 29 33 this.images = new ArrayList<>(images); 30 34 this.x = x; … … 54 58 @Override 55 59 public String toString() { 56 return trn("Moved {0} image", "Moved {0} images", images.size(), images.size()); 60 return trn("Moved {0} image", "Moved {0} images", images.size(), 61 images.size()); 57 62 } 58 63 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java
r31387 r31401 21 21 * Main constructor. 22 22 * 23 * @param images Set of images that is turned. 24 * @param ca How much the images turn. 23 * @param images 24 * Set of images that is turned. 25 * @param ca 26 * How much the images turn. 25 27 */ 26 28 public CommandTurnImage(List<MapillaryAbstractImage> images, double ca) { … … 51 53 @Override 52 54 public String toString() { 53 return trn("Turned {0} image", "Turned {0} images", this.images.size(), this.images.size()); 55 return trn("Turned {0} image", "Turned {0} images", this.images.size(), 56 this.images.size()); 54 57 } 55 58 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecord.java
r31387 r31401 72 72 if (!command.images.contains(img)) 73 73 equalSets = false; 74 if (equalSets && commandList.get(position).getClass() == command.getClass()) { 74 if (equalSets 75 && commandList.get(position).getClass() == command.getClass()) { 75 76 commandList.get(position).sum(command); 76 77 fireRecordChanged(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31399 r31401 1 1 package org.openstreetmap.josm.plugins.mapillary.downloads; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import java.util.concurrent.ConcurrentHashMap; … … 5 7 import java.util.concurrent.Executors; 6 8 9 import javax.swing.JOptionPane; 10 7 11 import org.openstreetmap.josm.Main; 8 12 import org.openstreetmap.josm.data.Bounds; 9 13 import org.openstreetmap.josm.data.coor.LatLon; 10 14 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 11 16 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryDownloadViewAction; 12 17 … … 20 25 public class MapillaryDownloader { 21 26 22 /** Possible download modes. */23 public static final String[] MODES = new String[] { "Automatic", "Semiautomatic",24 "Manual" };27 /** Possible download modes. */ 28 public static final String[] MODES = new String[] { "Automatic", 29 "Semiautomatic", "Manual" }; 25 30 26 31 /** Base URL of the Mapillary API. */ … … 83 88 getImages(bounds.getMin(), bounds.getMax()); 84 89 } 90 91 /** 92 * Downloads all images of the area covered by the OSM data. This is only just 93 * for automatic download. 94 */ 95 public static void automaticDownload() { 96 MapillaryLayer layer = MapillaryLayer.getInstance(); 97 checkAreaTooBig(); 98 if (!Main.pref.get("mapillary.download-mode").equals( 99 MapillaryDownloader.MODES[0]) 100 || layer.TEMP_SEMIAUTOMATIC) 101 return; 102 for (Bounds bounds : Main.map.mapView.getEditLayer().data 103 .getDataSourceBounds()) { 104 if (!layer.bounds.contains(bounds)) { 105 layer.bounds.add(bounds); 106 MapillaryDownloader.getImages(bounds.getMin(), bounds.getMax()); 107 } 108 } 109 } 110 111 /** 112 * Checks if the area of the OSM data is too big. This means that probably 113 * lots of Mapillary images are going to be downloaded, slowing down the 114 * program too much. To solve this the automatic is stopped, an alert is shown 115 * and you will have to download areas manually. 116 */ 117 private static void checkAreaTooBig() { 118 double area = 0; 119 for (Bounds bounds : Main.map.mapView.getEditLayer().data 120 .getDataSourceBounds()) { 121 area += bounds.getArea(); 122 } 123 if (area > MapillaryDownloadViewAction.MAX_AREA) { 124 MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC = true; 125 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true); 126 JOptionPane 127 .showMessageDialog( 128 Main.parent, 129 tr("The downloaded OSM area is too big. Download mode has been changed to manual until the layer is restarted.")); 130 } 131 } 85 132 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java
r31387 r31401 25 25 * @see MapillaryExportWriterThread 26 26 */ 27 public class MapillaryExportDownloadThread extends Thread implements ICachedLoaderListener { 27 public class MapillaryExportDownloadThread extends Thread implements 28 ICachedLoaderListener { 28 29 29 30 String url; … … 37 38 * Main constructor. 38 39 * 39 * @param image Image to be downloaded. 40 * @param queue Queue of {@link BufferedImage} objects for the {@link MapillaryExportWriterThread}. 41 * @param queueImages Queue of {@link MapillaryAbstractImage} objects for the {@link MapillaryExportWriterThread}. 40 * @param image 41 * Image to be downloaded. 42 * @param queue 43 * Queue of {@link BufferedImage} objects for the 44 * {@link MapillaryExportWriterThread}. 45 * @param queueImages 46 * Queue of {@link MapillaryAbstractImage} objects for the 47 * {@link MapillaryExportWriterThread}. 42 48 */ 43 public MapillaryExportDownloadThread(MapillaryImage image, ArrayBlockingQueue<BufferedImage> queue, 49 public MapillaryExportDownloadThread(MapillaryImage image, 50 ArrayBlockingQueue<BufferedImage> queue, 44 51 ArrayBlockingQueue<MapillaryAbstractImage> queueImages) { 45 url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey() + "/thumb-2048.jpg"; 52 url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey() 53 + "/thumb-2048.jpg"; 46 54 this.queue = queue; 47 55 this.image = image; … … 51 59 @Override 52 60 public void run() { 53 new MapillaryCache(image.getKey(), MapillaryCache.Type.FULL_IMAGE).submit(this, false); 61 new MapillaryCache(image.getKey(), MapillaryCache.Type.FULL_IMAGE).submit( 62 this, false); 54 63 } 55 64 56 65 @Override 57 public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result) { 66 public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, 67 LoadResult result) { 58 68 try { 59 69 queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent()))); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
r31387 r31401 20 20 21 21 /** 22 * Export main thread. Exportation works by creating a {@link MapillaryExportWriterThread} and several 22 * Export main thread. Exportation works by creating a 23 * {@link MapillaryExportWriterThread} and several 23 24 * {@link MapillaryExportDownloadThread}. The second ones download every single 24 * image that is going to be exported and stores them in an {@link ArrayBlockingQueue}. Then it is picked by the first25 * one and written on25 * image that is going to be exported and stores them in an 26 * {@link ArrayBlockingQueue}. Then it is picked by the first one and written on 26 27 * the selected folder. Each image will be named by its key. 27 28 * … … 44 45 * Main constructor. 45 46 * 46 * @param images Set of {@link MapillaryAbstractImage} objects to be exported. 47 * @param path Export path. 47 * @param images 48 * Set of {@link MapillaryAbstractImage} objects to be exported. 49 * @param path 50 * Export path. 48 51 */ 49 52 public MapillaryExportManager(List<MapillaryAbstractImage> images, String path) { 50 super(tr("Downloading") + "...", new PleaseWaitProgressMonitor("Exporting Mapillary Images"), true); 53 super(tr("Downloading") + "...", new PleaseWaitProgressMonitor( 54 "Exporting Mapillary Images"), true); 51 55 queue = new ArrayBlockingQueue<>(10); 52 56 queueImages = new ArrayBlockingQueue<>(10); … … 63 67 * @throws IOException 64 68 */ 65 public MapillaryExportManager(List<MapillaryImportedImage> images) throws IOException { 66 super(tr("Downloading") + "...", new PleaseWaitProgressMonitor("Exporting Mapillary Images"), true); 69 public MapillaryExportManager(List<MapillaryImportedImage> images) 70 throws IOException { 71 super(tr("Downloading") + "...", new PleaseWaitProgressMonitor( 72 "Exporting Mapillary Images"), true); 67 73 queue = new ArrayBlockingQueue<>(10); 68 74 queueImages = new ArrayBlockingQueue<>(10); … … 81 87 82 88 @Override 83 protected void realRun() throws SAXException, IOException, OsmTransferException { 89 protected void realRun() throws SAXException, IOException, 90 OsmTransferException { 84 91 // Starts a writer thread in order to write the pictures on the disk. 85 writer = new MapillaryExportWriterThread(path, queue, queueImages, amount, this.getProgressMonitor()); 92 writer = new MapillaryExportWriterThread(path, queue, queueImages, amount, 93 this.getProgressMonitor()); 86 94 writer.start(); 87 95 if (path == null) { … … 93 101 return; 94 102 } 95 ex = new ThreadPoolExecutor(20, 35, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); 103 ex = new ThreadPoolExecutor(20, 35, 25, TimeUnit.SECONDS, 104 new ArrayBlockingQueue<Runnable>(10)); 96 105 for (MapillaryAbstractImage image : images) { 97 106 if (image instanceof MapillaryImage) { 98 107 try { 99 ex.execute(new MapillaryExportDownloadThread((MapillaryImage) image, queue, queueImages)); 108 ex.execute(new MapillaryExportDownloadThread((MapillaryImage) image, 109 queue, queueImages)); 100 110 } catch (Exception e) { 101 111 Main.error(e); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
r31387 r31401 47 47 * Main constructor. 48 48 * 49 * @param path Path to write the pictures. 50 * @param queue Queue of {@link MapillaryAbstractImage} objects. 51 * @param queueImages Queue of {@link BufferedImage} objects. 52 * @param amount Amount of images that are going to be exported. 53 * @param monitor Progress monitor. 49 * @param path 50 * Path to write the pictures. 51 * @param queue 52 * Queue of {@link MapillaryAbstractImage} objects. 53 * @param queueImages 54 * Queue of {@link BufferedImage} objects. 55 * @param amount 56 * Amount of images that are going to be exported. 57 * @param monitor 58 * Progress monitor. 54 59 */ 55 60 public MapillaryExportWriterThread(String path, -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java
r31391 r31401 32 32 * Main constructor. 33 33 * 34 * @param ex {@link ExecutorService} object that is executing this thread. 35 * @param queryString 36 * @param layer 34 * @param ex 35 * {@link ExecutorService} object that is executing this thread. 36 * @param queryString 37 * @param layer 37 38 */ 38 public MapillaryImageInfoDownloaderThread(ExecutorService ex, String queryString, MapillaryLayer layer) { 39 public MapillaryImageInfoDownloaderThread(ExecutorService ex, 40 String queryString, MapillaryLayer layer) { 39 41 this.ex = ex; 40 42 this.queryString = queryString; … … 45 47 public void run() { 46 48 try { 47 BufferedReader br = new BufferedReader(new InputStreamReader( 48 new URL(URL+ queryString).openStream(), "UTF-8"));49 BufferedReader br = new BufferedReader(new InputStreamReader(new URL(URL 50 + queryString).openStream(), "UTF-8")); 49 51 JsonObject jsonobj = Json.createReader(br).readObject(); 50 52 if (!jsonobj.getBoolean("more")) … … 55 57 data = jsonarr.getJsonObject(i); 56 58 String key = data.getString("key"); 57 for (MapillaryAbstractImage image : layer.getMapillaryData().getImages()) { 59 for (MapillaryAbstractImage image : layer.getMapillaryData() 60 .getImages()) { 58 61 if (image instanceof MapillaryImage) { 59 62 if (((MapillaryImage) image).getKey().equals(key) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31399 r31401 79 79 completeImages(); 80 80 MapillaryMainDialog.getInstance().updateTitle(); 81 Main.map.statusLine.setHelpText(tr("Downloading signs"));81 Main.map.statusLine.setHelpText(tr("Downloading traffic signs")); 82 82 downloadSigns(); 83 83 } … … 125 125 int page = 0; 126 126 while (!ex.isShutdown()) { 127 ex.execute(new Mapillary SignDownloaderThread(ex, signQueryString127 ex.execute(new MapillaryTrafficSignDownloaderThread(ex, signQueryString 128 128 + "&page=" + page + "&limit=20", layer)); 129 129 while (ex.getQueue().remainingCapacity() == 0) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloaderThread.java
r31400 r31401 23 23 * 24 24 */ 25 public class Mapillary SignDownloaderThread extends Thread {25 public class MapillaryTrafficSignDownloaderThread extends Thread { 26 26 private static final String URL = MapillaryDownloader.BASE_URL 27 27 + "search/im/or/"; … … 38 38 * @param layer 39 39 */ 40 public Mapillary SignDownloaderThread(ExecutorService ex, String queryString,41 MapillaryLayer layer) {40 public MapillaryTrafficSignDownloaderThread(ExecutorService ex, 41 String queryString, MapillaryLayer layer) { 42 42 this.ex = ex; 43 43 this.queryString = queryString; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
r31391 r31401 34 34 /** Button to export all downloaded images. */ 35 35 public JRadioButton all; 36 /** Button to export all images in the sequence of the selected MapillaryImage. */ 36 /** 37 * Button to export all images in the sequence of the selected MapillaryImage. 38 */ 37 39 public JRadioButton sequence; 38 /** Button to export all images belonging to the selected {@link MapillaryImage} objects. */ 40 /** 41 * Button to export all images belonging to the selected 42 * {@link MapillaryImage} objects. 43 */ 39 44 public JRadioButton selected; 40 45 /** Button to rewrite all imported images. */ … … 51 56 /** 52 57 * Main constructor. 53 * @param ok 58 * 59 * @param ok 54 60 */ 55 61 public MapillaryExportDialog(JButton ok) { 56 62 this.ok = ok; 57 63 ok.setEnabled(false); 58 64 59 65 setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); 60 66 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r31398 r31401 114 114 downloaded.setSelected(true); 115 115 116 JPanel col1 = new JPanel(new GridLayout(2, 1));116 JPanel col1 = new JPanel(new GridLayout(2, 1)); 117 117 col1.add(downloaded); 118 118 col1.add(fromPanel); 119 119 panel.add(col1); 120 JPanel col2 = new JPanel(new GridLayout(2, 1));120 JPanel col2 = new JPanel(new GridLayout(2, 1)); 121 121 col2.add(imported); 122 122 col2.add(userSearchPanel); 123 123 panel.add(col2); 124 JPanel col3 = new JPanel(new GridLayout(2, 1));124 JPanel col3 = new JPanel(new GridLayout(2, 1)); 125 125 col3.add(onlySigns); 126 126 col3.add(signChooserPanel); … … 204 204 Long currentTime = currentTime(); 205 205 if (time.getSelectedItem() == TIME_LIST[1]) { 206 if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() 207 * 365 * 24 * 60 * 60 * 1000) { 206 if (img.getCapturedAt() < currentTime 207 - ((Integer) spinner.getValue()).longValue() * 365 * 24 * 60 * 60 208 * 1000) { 208 209 img.setVisible(false); 209 210 continue; … … 211 212 } 212 213 if (time.getSelectedItem() == TIME_LIST[2]) { 213 if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * 30 * 24 214 * 60 * 60 * 1000) { 214 if (img.getCapturedAt() < currentTime 215 - ((Integer) spinner.getValue()).longValue() * 30 * 24 * 60 * 60 216 * 1000) { 215 217 img.setVisible(false); 216 218 continue; … … 218 220 } 219 221 if (time.getSelectedItem() == TIME_LIST[3]) { 220 if (img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * 60221 * 60 * 1000) {222 if (img.getCapturedAt() < currentTime 223 - ((Integer) spinner.getValue()).longValue() * 60 * 60 * 1000) { 222 224 img.setVisible(false); 223 225 continue; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r31399 r31401 23 23 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 24 24 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 25 import org.openstreetmap.josm.plugins.mapillary.oauth. PortListener;25 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener; 26 26 27 27 /** … … 62 62 panel.add(reverseButtons); 63 63 64 // Sets the value of the ComboBox. 65 if (Main.pref.get("mapillary.download-mode").equals( 66 MapillaryDownloader.MODES[0])) 67 downloadMode.setSelectedItem(MapillaryDownloader.MODES[0]); 68 if (Main.pref.get("mapillary.download-mode").equals( 69 MapillaryDownloader.MODES[1])) 70 downloadMode.setSelectedItem(MapillaryDownloader.MODES[1]); 71 if (Main.pref.get("mapillary.download-mode").equals( 72 MapillaryDownloader.MODES[2])) 73 downloadMode.setSelectedItem(MapillaryDownloader.MODES[2]); 64 74 JPanel downloadModePanel = new JPanel(); 65 75 downloadModePanel.add(new JLabel(tr("Download mode: "))); … … 117 127 @Override 118 128 public void actionPerformed(ActionEvent arg0) { 119 PortListener portListener = newPortListener();129 OAuthPortListener portListener = new OAuthPortListener(); 120 130 portListener.start(); 121 131 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryWalkDialog.java
r31396 r31401 10 10 /** 11 11 * Dialog to set the walk mode options. 12 * 12 13 * @author nokutu 13 14 * 14 15 */ 15 16 public class MapillaryWalkDialog extends JPanel { 16 17 17 18 private static final long serialVersionUID = -6258767312211941358L; 18 19 19 20 /** Spin containing the interval value. */ 20 21 public SpinnerModel spin; … … 31 32 interval.add(new JSpinner(spin)); 32 33 add(interval); 33 34 34 35 waitForPicture = new JCheckBox("Wait for the picture to be downloaded"); 35 36 waitForPicture.setSelected(true); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31399 r31401 17 17 18 18 /** 19 * Superclass for all the mode of the {@link MapillaryLayer} 19 * Superclass for all the mode of the {@link MapillaryLayer}. 20 20 * 21 21 * @author nokutu … … 28 28 protected MapillaryData data = MapillaryData.getInstance(); 29 29 30 /** If in semiautomatic mode, the last Epoch time when there was a download */ 30 31 private long lastDownload; 31 32 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r31391 r31401 49 49 return; 50 50 MapillaryAbstractImage closest = getClosest(e.getPoint()); 51 if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closest != null52 && Main.map.mapMode == Main.map.mapModeSelect) {51 if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer 52 && closest != null && Main.map.mapMode == Main.map.mapModeSelect) { 53 53 this.lastClicked = this.closest; 54 54 data.setSelectedImage(closest); … … 113 113 Main.map.repaint(); 114 114 } else if (lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) { 115 this.closest 116 .turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa()); 115 this.closest.turn(Math.toDegrees(Math.atan2((e.getX() - start.x), 116 -(e.getY() - start.y))) 117 - closest.getTempCa()); 117 118 for (MapillaryAbstractImage img : data.getMultiSelectedImages()) { 118 img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa()); 119 img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x), 120 -(e.getY() - start.y))) - closest.getTempCa()); 119 121 } 120 122 Main.map.repaint(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java
r31400 r31401 12 12 13 13 /** 14 * Listens to the OAuth port in order to get the access token. 15 * 14 16 * @author nokutu 15 17 * 16 18 */ 17 public class PortListener extends Thread {19 public class OAuthPortListener extends Thread { 18 20 19 21 @Override … … 23 25 Socket clientSocket = serverSocket.accept(); 24 26 PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); 25 Scanner in = new Scanner(new InputStreamReader(clientSocket.getInputStream())); 27 Scanner in = new Scanner(new InputStreamReader( 28 clientSocket.getInputStream())); 26 29 String s; 27 30 String accessToken = null; … … 32 35 for (int i = 0; i < ss.length; i++) { 33 36 if (ss[i].contains("access_token=")) { 34 accessToken = ss[i].substring(ss[i].indexOf("access_token=") + 13, ss[i].length()); 37 accessToken = ss[i].substring( 38 ss[i].indexOf("access_token=") + 13, ss[i].length()); 35 39 break; 36 40 } … … 42 46 writeContent(out); 43 47 44 Main.info("Successful login with Mapillary, the access token is: " + accessToken); 48 Main.info("Successful login with Mapillary, the access token is: " 49 + accessToken); 45 50 Main.pref.put("mapillary.access-token", accessToken); 46 51 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
r31391 r31401 57 57 Color c; 58 58 switch (elements.getJsonObject(i).getString("color").toLowerCase()) { 59 case "black":60 c = Color.BLACK;61 break;62 case "red":63 c = Color.RED;64 break;65 case "blue":66 c = Color.BLUE;67 break;68 case "white":69 c = Color.WHITE;70 break;71 case "green":72 c = Color.GREEN;73 break;74 case "yellow":75 c = Color.YELLOW;76 break;77 default:78 c = Color.MAGENTA;59 case "black": 60 c = Color.BLACK; 61 break; 62 case "red": 63 c = Color.RED; 64 break; 65 case "blue": 66 c = Color.BLUE; 67 break; 68 case "white": 69 c = Color.WHITE; 70 break; 71 case "green": 72 c = Color.GREEN; 73 break; 74 case "yellow": 75 c = Color.YELLOW; 76 break; 77 default: 78 c = Color.MAGENTA; 79 79 } 80 80 layers.add(new TrafficoSignElement(glyph, c));
Note:
See TracChangeset
for help on using the changeset viewer.