Changeset 32978 in osm for applications/editors/josm
- Timestamp:
- 2016-09-11T13:47:54+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r32974 r32978 92 92 } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) { 93 93 ArrayList<MapillaryImportedImage> images = new ArrayList<>(); 94 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) { 95 if (image instanceof MapillaryImportedImage) { 96 images.add((MapillaryImportedImage) image); 97 } 98 } 94 MapillaryLayer.getInstance().getData().getImages().stream().filter(img -> img instanceof MapillaryImportedImage).forEach(img -> images.add((MapillaryImportedImage) img)); 99 95 try { 100 96 Main.worker.submit(new MapillaryExportManager(images)); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
r32976 r32978 7 7 import java.util.concurrent.ThreadPoolExecutor; 8 8 import java.util.concurrent.TimeUnit; 9 import java.util.stream.IntStream; 9 10 10 11 import javax.swing.JOptionPane; … … 23 24 * 24 25 * @author nokutu 25 *26 26 */ 27 27 public final class MapillaryDownloader { … … 80 80 } 81 81 82 /** All the Threads that have been run. Used to interrupt them properly. */83 //private static List<Thread> threads = new ArrayList<>();84 85 82 /** Max area to be downloaded */ 86 p ublicstatic final double MAX_AREA = Main.pref.getDouble("mapillary.max-download-area", 0.015);83 private static final double MAX_AREA = Main.pref.getDouble("mapillary.max-download-area", 0.015); 87 84 88 85 /** Executor that will run the petitions. */ 89 private static ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue< Runnable>(100));86 private static ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100)); 90 87 91 88 private MapillaryDownloader() { … … 97 94 * sequences that pass through the given rectangle. 98 95 * 99 * @param minLatLon 100 * The minimum latitude and longitude of the rectangle. 101 * @param maxLatLon 102 * The maximum latitude and longitude of the rectangle 96 * @param minLatLon The minimum latitude and longitude of the rectangle. 97 * @param maxLatLon The maximum latitude and longitude of the rectangle 103 98 */ 104 99 public static void getImages(LatLon minLatLon, LatLon maxLatLon) { … … 112 107 * Gets the images within the given bounds. 113 108 * 114 * @param bounds 115 * A {@link Bounds} object containing the area to be downloaded. 109 * @param bounds A {@link Bounds} object containing the area to be downloaded. 116 110 */ 117 111 public static void getImages(Bounds bounds) { … … 125 119 */ 126 120 public static MapillaryDownloader.DOWNLOAD_MODE getMode() { 127 return MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic128 ? DOWNLOAD_MODE.VISIBLE_AREA129 : DOWNLOAD_MODE.fromPrefId(Main.pref.get("mapillary.download-mode"));121 return MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic 122 ? DOWNLOAD_MODE.VISIBLE_AREA 123 : DOWNLOAD_MODE.fromPrefId(Main.pref.get("mapillary.download-mode")); 130 124 } 131 125 … … 159 153 for (int j = 0; j < n; j++) { 160 154 if (isInBounds(new LatLon(view.getMinLat() 161 162 163 155 + (view.getMaxLat() - view.getMinLat()) * ((double) i / n), 156 view.getMinLon() + (view.getMaxLon() - view.getMinLon()) 157 * ((double) j / n)))) { 164 158 inside[i][j] = true; 165 159 } … … 179 173 * image. 180 174 * 181 * @param latlon 182 * The coordinates to check.175 * @param latlon The coordinates to check. 176 * 183 177 * @return true if it lies inside the bounds; false otherwise; 184 178 */ 185 179 private static boolean isInBounds(LatLon latlon) { 186 for (Bounds bounds : MapillaryLayer.getInstance().getData().getBounds()) { 187 if (bounds.contains(latlon)) 188 return true; 189 } 190 return false; 180 return MapillaryLayer.getInstance().getData().getBounds().parallelStream().anyMatch(b -> b.contains(latlon)); 191 181 } 192 182 … … 206 196 throw new IllegalStateException("Must be in automatic mode."); 207 197 } 208 for (Bounds bounds : Main.getLayerManager().getEditLayer().data.getDataSourceBounds()) { 209 if (!MapillaryLayer.getInstance().getData().getBounds().contains(bounds)) { 210 MapillaryLayer.getInstance().getData().getBounds().add(bounds); 211 MapillaryDownloader.getImages(bounds.getMin(), bounds.getMax()); 212 } 213 } 198 Main.getLayerManager().getEditLayer().data.getDataSourceBounds().stream().filter(bounds -> !MapillaryLayer.getInstance().getData().getBounds().contains(bounds)).forEach(bounds -> { 199 MapillaryLayer.getInstance().getData().getBounds().add(bounds); 200 MapillaryDownloader.getImages(bounds.getMin(), bounds.getMax()); 201 }); 214 202 } 215 203 … … 221 209 */ 222 210 private static boolean isAreaTooBig() { 223 double area = 0; 224 for (Bounds bounds : Main.getLayerManager().getEditLayer().data.getDataSourceBounds()) { 225 area += bounds.getArea(); 226 } 211 double area = Main.getLayerManager().getEditLayer().data.getDataSourceBounds().parallelStream().map(Bounds::getArea).reduce(0.0, Double::sum); 227 212 return area > MAX_AREA; 228 213 } … … 233 218 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true); 234 219 JOptionPane 235 236 237 220 .showMessageDialog( 221 Main.parent, 222 I18n.tr("The downloaded OSM area is too big. Download mode has been changed to semiautomatic until the layer is restarted.")); 238 223 } else { 239 SwingUtilities.invokeLater( () -> tooBigErrorDialog());224 SwingUtilities.invokeLater(MapillaryDownloader::tooBigErrorDialog); 240 225 } 241 226 } … … 245 230 */ 246 231 public static void stopAll() { 247 /*for (Thread t : threads) {248 if (t.isAlive())249 Main.info(t+" is still alive!");250 t.interrupt();251 }252 threads.clear();*/253 232 executor.shutdownNow(); 254 233 try { … … 258 237 } 259 238 executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, 260 new ArrayBlockingQueue<Runnable>(100));239 new ArrayBlockingQueue<>(100)); 261 240 } 262 241 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r32658 r32978 100 100 synchronized (this) { 101 101 try { 102 wait(100);102 Thread.sleep(100); 103 103 } catch (InterruptedException e) { 104 return; 104 105 } 105 106 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
r32659 r32978 57 57 || this.lastClick.previous() == this.data.getHighlightedImage()) { 58 58 MapillaryRecord.getInstance().addCommand( 59 new CommandUnjoin(Arrays.asList(new MapillaryAbstractImage[] { 60 this.lastClick, this.data.getHighlightedImage() }))); 59 new CommandUnjoin(Arrays.asList(this.lastClick, this.data.getHighlightedImage()))); 61 60 } 62 61 this.lastClick = null;
Note:
See TracChangeset
for help on using the changeset viewer.