Changeset 31422 in osm for applications/editors/josm
- Timestamp:
- 2015-07-31T11:36:18+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31416 r31422 107 107 */ 108 108 private void init() { 109 if (INSTANCE == null) 110 INSTANCE = this; 109 111 if (Main.map != null && Main.map.mapView != null) { 110 112 setMode(new SelectMode()); … … 114 116 if (Main.map.mapView.getEditLayer() != null) 115 117 Main.map.mapView.getEditLayer().data.addDataSetListener(this); 118 if (MapillaryDownloader.getMode() == MapillaryDownloader.AUTOMATIC) 119 MapillaryDownloader.automaticDownload(); 120 if (MapillaryDownloader.getMode() == MapillaryDownloader.SEMIAUTOMATIC) 121 mode.zoomChanged(); 116 122 } 117 123 if (MapillaryPlugin.EXPORT_MENU != null) { // Does not execute when in … … 154 160 public synchronized static MapillaryLayer getInstance() { 155 161 if (INSTANCE == null) 156 INSTANCE =new MapillaryLayer();162 return new MapillaryLayer(); 157 163 return MapillaryLayer.INSTANCE; 158 164 } … … 445 451 * Returns the 2 closest images belonging to a different sequence. 446 452 * 447 * @return An array of length 2 containing the two closest images belonging 448 * todifferent sequences.453 * @return An array of length 2 containing the two closest images belonging to 454 * different sequences. 449 455 */ 450 456 private MapillaryImage[] getClosestImagesFromDifferentSequences() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31418 r31422 148 148 Main.map.addToggleDialog(MapillaryFilterDialog.getInstance(), false); 149 149 setMenuEnabled(DOWNLOAD_MENU, true); 150 if (Main.pref.get("mapillary.download-mode").equals( 151 MapillaryDownloader.MODES[2])) 150 if (MapillaryDownloader.getMode() == MapillaryDownloader.MANUAL) 152 151 setMenuEnabled(DOWNLOAD_VIEW_MENU, true); 153 152 setMenuEnabled(IMPORT_MENU, true); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadViewAction.java
r31417 r31422 6 6 import java.awt.event.KeyEvent; 7 7 8 import javax.swing.JOptionPane;9 10 import org.openstreetmap.josm.Main;11 8 import org.openstreetmap.josm.actions.JosmAction; 12 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;13 9 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 14 10 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; … … 26 22 private static final long serialVersionUID = -6837073336175123503L; 27 23 28 /** Max area to be downloaded */29 public static final double MAX_AREA = Main.pref.getDouble(30 "mapillary.max-download-area", 0.015);31 32 24 /** 33 25 * Main constructor. … … 44 36 @Override 45 37 public void actionPerformed(ActionEvent arg0) { 46 MapillaryLayer.getInstance().bounds.add(Main.map.mapView.getRealBounds()); 47 if (Main.map.mapView.getRealBounds().getArea() <= MAX_AREA) { 48 MapillaryDownloader.getImages(Main.map.mapView.getRealBounds()); 49 } else { 50 JOptionPane.showMessageDialog(Main.parent, 51 tr("This area is too big to be downloaded")); 52 } 38 MapillaryDownloader.completeView(); 53 39 } 54 40 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31418 r31422 9 9 10 10 import javax.swing.JOptionPane; 11 import javax.swing.SwingUtilities; 11 12 12 13 import org.openstreetmap.josm.Main; … … 15 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 16 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 17 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryDownloadViewAction;18 18 19 19 /** … … 29 29 public static final String[] MODES = new String[] { "Automatic", 30 30 "Semiautomatic", "Manual" }; 31 /** Automatic mode. */ 32 public static final int AUTOMATIC = 0; 33 /** Semiautomatic mode. */ 34 public static final int SEMIAUTOMATIC = 1; 35 /** Manual mode. */ 36 public static final int MANUAL = 2; 37 38 /** Max area to be downloaded */ 39 public static final double MAX_AREA = Main.pref.getDouble( 40 "mapillary.max-download-area", 0.015); 31 41 32 42 /** Base URL of the Mapillary API. */ … … 66 76 */ 67 77 public static void completeView() { 78 if (getMode() != SEMIAUTOMATIC && getMode() != MANUAL) 79 throw new IllegalStateException("Must be in semiautomatic or manual mode"); 68 80 Bounds view = Main.map.mapView.getRealBounds(); 69 if (view.getArea() > M apillaryDownloadViewAction.MAX_AREA)81 if (view.getArea() > MAX_AREA) 70 82 return; 71 83 if (isViewDownloaded(view)) … … 81 93 for (int j = 0; j < n; j++) { 82 94 if (isInBounds(new LatLon(view.getMinLat() 83 + (view.getMaxLat() - view.getMinLat()) * ((double) i / n), view.getMinLon()84 + (view.getMaxLon() - view.getMinLon())95 + (view.getMaxLat() - view.getMinLat()) * ((double) i / n), 96 view.getMinLon() + (view.getMaxLon() - view.getMinLon()) 85 97 * ((double) j / n)))) { 86 98 inside[i][j] = true; … … 120 132 public static void automaticDownload() { 121 133 MapillaryLayer layer = MapillaryLayer.getInstance(); 122 checkAreaTooBig(); 123 if (!Main.pref.get("mapillary.download-mode").equals( 124 MapillaryDownloader.MODES[0]) 125 || layer.TEMP_SEMIAUTOMATIC) 134 if (isAreaTooBig()) { 135 tooBigErrorDialog(); 126 136 return; 137 } 138 139 if (getMode() != AUTOMATIC) 140 throw new IllegalStateException("Must be in automatic mode."); 127 141 for (Bounds bounds : Main.map.mapView.getEditLayer().data 128 142 .getDataSourceBounds()) { … … 140 154 * and you will have to download areas manually. 141 155 */ 142 private static void checkAreaTooBig() {156 private static boolean isAreaTooBig() { 143 157 double area = 0; 144 158 for (Bounds bounds : Main.map.mapView.getEditLayer().data … … 146 160 area += bounds.getArea(); 147 161 } 148 if (area > MapillaryDownloadViewAction.MAX_AREA) { 162 if (area > MAX_AREA) 163 return true; 164 return false; 165 } 166 167 /** 168 * Returns the current download mode. 169 * 170 * @return 0 - automatic; 1 - semiautomatic; 2 - manual. 171 */ 172 public static int getMode() { 173 if (Main.pref.get("mapillary.download-mode").equals(MODES[0]) 174 && !MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC) 175 return 0; 176 else if (Main.pref.get("mapillary.download-mode").equals(MODES[1]) 177 || MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC) 178 return 1; 179 else if (Main.pref.get("mapillary.download-mode").equals(MODES[2])) 180 return 2; 181 else 182 throw new IllegalStateException(); 183 } 184 185 private static void tooBigErrorDialog() { 186 if (!SwingUtilities.isEventDispatchThread()) { 187 SwingUtilities.invokeLater(new Runnable() { 188 @Override 189 public void run() { 190 tooBigErrorDialog(); 191 } 192 }); 193 } else { 149 194 MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC = true; 150 195 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true); … … 152 197 .showMessageDialog( 153 198 Main.parent, 154 tr("The downloaded OSM area is too big. Download mode has been changed to manualuntil the layer is restarted."));199 tr("The downloaded OSM area is too big. Download mode has been changed to semiautomatic until the layer is restarted.")); 155 200 } 156 201 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31409 r31422 64 64 @Override 65 65 public void zoomChanged() { 66 if (Main.pref.get("mapillary.download-mode").equals( 67 MapillaryDownloader.MODES[1]) 68 || MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC) { 66 if (MapillaryDownloader.getMode() == MapillaryDownloader.SEMIAUTOMATIC) { 69 67 if (!semiautomaticThread.isAlive()) 70 68 semiautomaticThread.start(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r31415 r31422 18 18 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage; 19 19 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord; 20 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;21 20 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 22 21 … … 42 41 public SelectMode() { 43 42 record = MapillaryRecord.getInstance(); 44 if (Main.pref.get("mapillary.download-mode").equals(45 MapillaryDownloader.MODES[1]))46 zoomChanged();47 43 } 48 44
Note:
See TracChangeset
for help on using the changeset viewer.