Changeset 31446 in osm
- Timestamp:
- 2015-08-04T11:35:27+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/.gitignore
r31392 r31446 4 4 /build/ 5 5 /.gradle/ 6 6 /.settings 7 7 /test/data/preferences/ -
applications/editors/josm/plugins/mapillary/build.gradle
r31426 r31446 33 33 34 34 packIntoJar 'com.amazonaws:aws-java-sdk-s3:1.10.8' 35 packIntoJar 'org.apache.httpcomponents:httpmime:4.5' 35 36 36 37 testCompile 'junit:junit:4.12' -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31445 r31446 56 56 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 57 57 if (dialog.sequence.isSelected()) { 58 try { 59 OAuthUtils.uploadSequence(MapillaryData.getInstance().getSelectedImage().getSequence()); 60 } catch (InvalidKeyException e) { 61 Main.error(e); 62 } catch (UnsupportedEncodingException e) { 63 Main.error(e); 64 } catch (NoSuchAlgorithmException e) { 65 Main.error(e); 66 } 58 OAuthUtils.uploadSequence(MapillaryData.getInstance() 59 .getSelectedImage().getSequence()); 67 60 } 68 61 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java
r31445 r31446 15 15 import java.security.NoSuchAlgorithmException; 16 16 import java.util.HashMap; 17 import java.util.List; 17 18 import java.util.UUID; 19 import java.util.concurrent.ArrayBlockingQueue; 20 import java.util.concurrent.ThreadPoolExecutor; 21 import java.util.concurrent.TimeUnit; 18 22 19 23 import javax.imageio.ImageIO; … … 155 159 entityBuilder.addPart(key, new StringBody(hash.get(key), 156 160 ContentType.TEXT_PLAIN)); 157 System.out.println(key + " => " + hash.get(key));158 161 } 159 162 entityBuilder.addPart("file", new FileBody(file)); … … 162 165 httpPost.setEntity(entity); 163 166 164 System.out.println(httpPost);165 167 HttpResponse response = httpClient.execute(httpPost); 166 System.out.println(response.toString()); 168 if (response.getStatusLine().toString().contains("204")) 169 System.out.println("Succesfully uploaded image"); 170 file.delete(); 167 171 } 168 172 … … 177 181 * @throws InvalidKeyException 178 182 */ 179 public static void uploadSequence(MapillarySequence sequence) 180 throws InvalidKeyException, UnsupportedEncodingException, 181 NoSuchAlgorithmException { 182 UUID uuid = UUID.randomUUID(); 183 184 for (MapillaryAbstractImage img : sequence.getImages()) { 185 if (!(img instanceof MapillaryImportedImage)) 186 throw new IllegalArgumentException( 187 "The sequence contains downloaded images."); 183 public static void uploadSequence(MapillarySequence sequence) { 184 new SequenceUploadThread(sequence.getImages()).start(); 185 } 186 187 private static class SequenceUploadThread extends Thread { 188 private List<MapillaryAbstractImage> images; 189 private UUID uuid; 190 ThreadPoolExecutor ex; 191 192 private SequenceUploadThread(List<MapillaryAbstractImage> images) { 193 this.images = images; 194 this.uuid = UUID.randomUUID(); 195 this.ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 196 new ArrayBlockingQueue<Runnable>(5)); 197 } 198 199 @Override 200 public void run() { 201 for (MapillaryAbstractImage img : this.images) { 202 if (!(img instanceof MapillaryImportedImage)) 203 throw new IllegalArgumentException( 204 "The sequence contains downloaded images."); 205 this.ex.execute(new SingleUploadThread((MapillaryImportedImage) img, 206 this.uuid)); 207 } 208 } 209 } 210 211 private static class SingleUploadThread extends Thread { 212 213 private MapillaryImportedImage image; 214 private UUID uuid; 215 216 private SingleUploadThread(MapillaryImportedImage image, UUID uuid) { 217 this.image = image; 218 this.uuid = uuid; 219 } 220 221 @Override 222 public void run() { 188 223 try { 189 upload((MapillaryImportedImage) img,uuid);190 } catch (I OException e) {224 OAuthUtils.upload(this.image, this.uuid); 225 } catch (InvalidKeyException | NoSuchAlgorithmException | IOException e) { 191 226 Main.error(e); 192 227 } … … 226 261 outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat()); 227 262 File tempFile = new File(c + ".tmp"); 263 c++; 228 264 OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); 229 265
Note:
See TracChangeset
for help on using the changeset viewer.