Changeset 31473 in osm for applications/editors
- Timestamp:
- 2015-08-10T12:42:05+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31456 r31473 145 145 if (lat_ref == null || lat == null || lon == null || lon_ref == null 146 146 || datetimeOriginal == null) 147 throw new IllegalArgumentException( 148 "The picture has not correct EXIF tags"); 147 return; 149 148 150 149 double latValue = 0; … … 182 181 183 182 /** 184 * Comparator that comp eres two {@link MapillaryAbstractImage} objects183 * Comparator that compares two {@link MapillaryAbstractImage} objects 185 184 * depending on the time they were taken. 186 185 * -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31472 r31473 49 49 public final static String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"; 50 50 /** Executor that will run the petitions. */ 51 private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5, 52 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(50));51 private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, 52 new ArrayBlockingQueue<Runnable>(100));; 53 53 54 54 /** … … 229 229 EXECUTOR.awaitTermination(30, TimeUnit.SECONDS); 230 230 } catch (InterruptedException e) { 231 // TODO Auto-generated catch block 232 e.printStackTrace(); 231 Main.error(e); 233 232 } 234 233 EXECUTOR = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, 235 new ArrayBlockingQueue<Runnable>( 50));234 new ArrayBlockingQueue<Runnable>(100)); 236 235 } 237 236 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
r31454 r31473 11 11 import java.awt.event.ActionListener; 12 12 import java.awt.event.MouseEvent; 13 import java.io.IOException;14 13 import java.net.MalformedURLException; 15 import java.net.URISyntaxException;16 14 import java.net.URL; 17 15 … … 23 21 import org.openstreetmap.josm.Main; 24 22 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 25 26 import java.awt.Desktop; 23 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 27 24 28 25 /** … … 176 173 if (this.url == null) 177 174 return; 178 Desktop desktop = Desktop.getDesktop(); 179 if (desktop.isSupported(Desktop.Action.BROWSE)) { 180 try { 181 desktop.browse(this.url.toURI()); 182 } catch (IOException | URISyntaxException e1) { 183 Main.error(e1); 184 } 185 } else { 186 Runtime runtime = Runtime.getRuntime(); 187 try { 188 runtime.exec("xdg-open " + this.url); 189 } catch (IOException exc) { 190 exc.printStackTrace(); 191 } 192 } 175 MapillaryUtils.browse(this.url); 193 176 } 194 177 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r31465 r31473 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.Desktop;6 5 import java.awt.FlowLayout; 7 6 import java.awt.event.ActionEvent; 8 import java.io.IOException; 9 import java.net.URI; 10 import java.net.URISyntaxException; 7 import java.net.MalformedURLException; 8 import java.net.URL; 11 9 12 10 import javax.swing.AbstractAction; … … 25 23 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser; 26 24 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener; 25 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 27 26 28 27 /** … … 146 145 147 146 String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&response_type=token&scope=user:read%20public:upload%20public:write"; 148 Desktop desktop = Desktop.getDesktop(); 149 if (desktop.isSupported(Desktop.Action.BROWSE)) { 150 try { 151 desktop.browse(new URI(url)); 152 } catch (IOException | URISyntaxException e1) { 153 Main.error(e1); 154 } 155 } else { 156 Runtime runtime = Runtime.getRuntime(); 157 try { 158 runtime.exec("xdg-open " + url); 159 } catch (IOException exc) { 160 exc.printStackTrace(); 161 } 147 try { 148 MapillaryUtils.browse(new URL(url)); 149 } catch (MalformedURLException e) { 150 Main.error(e); 162 151 } 163 152 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31457 r31473 125 125 HttpEntity entity = entityBuilder.build(); 126 126 httpPost.setEntity(entity); 127 128 127 HttpResponse response = httpClient.execute(httpPost); 129 128 if (response.getStatusLine().toString().contains("204")) { 130 129 PluginState.imageUploaded(); 131 } 130 Main.info(PluginState.getUploadString() + " (Mapillary)"); 131 } else 132 Main.info("Upload error"); 132 133 file.delete(); 133 134 MapillaryUtils.updateHelpText(); … … 153 154 this.images = images; 154 155 this.uuid = UUID.randomUUID(); 155 this.ex = new ThreadPoolExecutor( 3, 5, 25, TimeUnit.SECONDS,156 new ArrayBlockingQueue<Runnable>( 5));156 this.ex = new ThreadPoolExecutor(1, 1, 25, TimeUnit.SECONDS, 157 new ArrayBlockingQueue<Runnable>(100)); 157 158 } 158 159 159 160 @Override 160 161 public void run() { 161 PluginState.startUpload();162 162 PluginState.imagesToUpload(this.images.size()); 163 163 MapillaryUtils.updateHelpText(); … … 168 168 this.ex.execute(new SingleUploadThread((MapillaryImportedImage) img, 169 169 this.uuid)); 170 while (this.ex.getQueue().remainingCapacity() == 0) 171 try { 172 Thread.sleep(100); 173 } catch (InterruptedException e) { 174 Main.error(e); 175 } 170 176 } 171 177 this.ex.shutdown(); 172 PluginState.finishUpload();173 178 } 174 179 } … … 187 192 public void run() { 188 193 upload(this.image, this.uuid); 189 190 194 } 191 195 } … … 212 216 TiffOutputDirectory gpsDirectory = null; 213 217 // If the image is imported, loads the rest of the EXIF data. 214 ImageMetadata metadata = Imaging.getMetadata(image.getFile()); 215 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 218 JpegImageMetadata jpegMetadata = null; 219 try { 220 ImageMetadata metadata = Imaging.getMetadata(image.getFile()); 221 jpegMetadata = (JpegImageMetadata) metadata; 222 } catch (Exception e) { 223 } 216 224 if (null != jpegMetadata) { 217 225 final TiffImageMetadata exif = jpegMetadata.getExif(); … … 239 247 240 248 outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat()); 241 File tempFile = new File(c +".tmp");249 File tempFile = File.createTempFile("imagetoupload_" + c, ".tmp"); 242 250 c++; 243 251 OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31457 r31473 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.Desktop; 6 import java.io.IOException; 7 import java.net.URISyntaxException; 8 import java.net.URL; 4 9 5 10 import org.apache.commons.imaging.common.RationalNumber; … … 91 96 return result; 92 97 } 98 99 /** 100 * @param url 101 */ 102 public static void browse(URL url) { 103 Desktop desktop = Desktop.getDesktop(); 104 if (desktop.isSupported(Desktop.Action.BROWSE)) { 105 try { 106 desktop.browse(url.toURI()); 107 } catch (IOException | URISyntaxException e1) { 108 Main.error(e1); 109 } 110 } else { 111 Runtime runtime = Runtime.getRuntime(); 112 try { 113 runtime.exec("xdg-open " + url); 114 } catch (IOException exc) { 115 exc.printStackTrace(); 116 } 117 } 118 } 93 119 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/PluginState.java
r31449 r31473 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.Dimension; 6 7 import javax.swing.JDialog; 8 import javax.swing.JOptionPane; 9 import javax.swing.SwingUtilities; 10 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.plugins.mapillary.gui.FinishedUploadDialog; 4 13 5 14 /** … … 10 19 11 20 private static int runningDownloads = 0; 12 private static int runningUploads = 0; 13 private static int imagesToUpload = 0; 14 private static int imagesUploaded = 0; 21 /** Images that have to be uploaded. */ 22 public static int imagesToUpload = 0; 23 /** Images that have been uploaded. */ 24 public static int imagesUploaded = 0; 15 25 16 26 /** … … 38 48 39 49 /** 40 * Called when an upload is starting.41 */42 public static void startUpload() {43 runningUploads++;44 }45 46 /**47 50 * Called when an upload is finished. 48 51 */ 49 52 public static void finishUpload() { 50 runningUploads--;51 53 if (imagesUploaded >= imagesToUpload) { 52 54 imagesUploaded = 0; … … 61 63 */ 62 64 public static boolean isUploading() { 63 return runningUploads > 0;65 return imagesToUpload > imagesUploaded; 64 66 } 65 67 … … 79 81 public static void imageUploaded() { 80 82 imagesUploaded++; 83 if (imagesToUpload == imagesUploaded) { 84 finishedUploadDialog(); 85 } 86 } 87 88 private static void finishedUploadDialog() { 89 if (!SwingUtilities.isEventDispatchThread()) { 90 SwingUtilities.invokeLater(new Runnable() { 91 @Override 92 public void run() { 93 finishedUploadDialog(); 94 } 95 }); 96 } else { 97 JOptionPane pane = new JOptionPane(); 98 pane.setMessage(new FinishedUploadDialog()); 99 JDialog dlg = pane.createDialog(Main.parent, tr("Finished upload")); 100 dlg.setVisible(true); 101 } 81 102 } 82 103 … … 87 108 */ 88 109 public static String getUploadString() { 89 return tr(" Downloading: {0}", "(" + imagesUploaded + "/" + imagesToUpload110 return tr("Uploading: {0}", "(" + imagesUploaded + "/" + imagesToUpload 90 111 + ")"); 91 112 }
Note:
See TracChangeset
for help on using the changeset viewer.