Changeset 31176 in osm for applications
- Timestamp:
- 2015-06-02T11:30:58+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/.classpath
r31175 r31176 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 6 6 <classpathentry kind="lib" path="/home/nokutu/Dropbox/programacion/GSoC/josm/plugins/mapillary/lib/sanselan-0.97-incubator.jar"/> 7 7 <classpathentry kind="output" path="bin"/> -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31166 r31176 28 28 29 29 private final List<MapillaryImage> images; 30 private MapillaryImage selectedImage = null;31 private List<MapillaryImage> multiSelectedImages;30 private MapillaryImage selectedImage; 31 private final List<MapillaryImage> multiSelectedImages; 32 32 33 33 public MapillaryData() { 34 34 images = new CopyOnWriteArrayList<>(); 35 35 multiSelectedImages = new ArrayList<>(); 36 selectedImage = null; 36 37 } 37 38 … … 41 42 } 42 43 return INSTANCE; 43 }44 45 public static void deleteInstance() {46 INSTANCE = null;47 }48 49 public MapillaryData(List<MapillaryImage> images) {50 this.images = images;51 44 } 52 45 … … 154 147 /** 155 148 * Selects a new image and then starts a new MapillaryImageDownloadThread 156 * thread in order to download its surrounding thumbnails and images. If the149 * thread in order to download its surrounding thumbnails. If the 157 150 * user does ctrl+click, this isn't triggered. 158 151 * 159 152 * @param image 160 153 * The MapillaryImage which is going to be selected 161 * @param clearThumbnail162 * Whether if the old selected MapillaryImage's thumbnail should163 * be deleted or not.164 * @param clearImageWhether165 * if the old selected MapillaryImage's full resolution image166 * should be deleted or not.167 154 */ 168 155 public void setSelectedImage(MapillaryImage image) { … … 236 223 CacheEntryAttributes attributes, LoadResult result) { 237 224 // DO NOTHING 238 239 225 } 240 226 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java
r31173 r31176 39 39 dlg.setVisible(true); 40 40 41 // Checks if the inputs are correct and starts the export process. 41 42 if (pane.getValue() != null 42 43 && (int) pane.getValue() == JOptionPane.OK_OPTION … … 51 52 } 52 53 } 53 54 54 dlg.dispose(); 55 55 } 56 56 57 57 /** 58 * Exports the given images from the database 58 * Exports the given images from the database. 59 59 */ 60 60 public void export(List<MapillaryImage> images) { 61 new Thread(new MapillaryExportManager( tr("Downloading..."),images,61 new Thread(new MapillaryExportManager(images, 62 62 dialog.chooser.getSelectedFile().toString())).start(); 63 63 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportDialog.java
r31164 r31176 49 49 group.add(sequence); 50 50 group.add(selected); 51 // Some options are disabled depending on the circumstances 51 52 if (MapillaryData.getInstance().getSelectedImage() == null 52 53 || MapillaryData.getInstance().getSelectedImage().getSequence() == null) { … … 60 61 choose.addActionListener(this); 61 62 63 // All options belong to the same jpanel so the are in line. 62 64 JPanel jpanel = new JPanel(); 63 65 jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.PAGE_AXIS)); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31166 r31176 15 15 private Double ca; 16 16 private boolean isModified = false; 17 p ublicMapillarySequence sequence;17 private MapillarySequence sequence; 18 18 19 19 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImageDisplay.java
r31166 r31176 24 24 * 25 25 * @author Jorge 26 * 26 * @see ImageDisplay 27 * @see MapillaryToggleDialog 27 28 */ 28 29 public class MapillaryImageDisplay extends JComponent { … … 310 311 } 311 312 313 /** 314 * Sets a new picture to be displayed. 315 * 316 * @param image 317 */ 312 318 public void setImage(BufferedImage image) { 313 319 synchronized (this) { … … 320 326 repaint(); 321 327 } 322 328 329 /** 330 * Returns the picture that is being displayerd 331 * 332 * @return 333 */ 323 334 public BufferedImage getImage() { 324 335 return this.image; 325 336 } 326 337 338 /** 339 * Paints the visible part of the picture. 340 */ 327 341 public void paintComponent(Graphics g) { 328 342 Image image; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31173 r31176 75 75 CACHE = JCSCacheManager.getCache("Mapillary"); 76 76 } catch (IOException e) { 77 // TODO Auto-generated catch block 78 e.printStackTrace(); 77 Main.error(e); 79 78 } 80 79 if (Main.map != null && Main.map.mapView != null) { … … 95 94 } 96 95 97 public s tatic MapillaryLayer getInstance() {96 public synchronized static MapillaryLayer getInstance() { 98 97 if (MapillaryLayer.INSTANCE == null) 99 98 MapillaryLayer.INSTANCE = new MapillaryLayer(); … … 109 108 if (!this.bounds.contains(bounds)) { 110 109 this.bounds.add(bounds); 111 new MapillaryDownloader(mapillaryData).getImages( 112 bounds.getMin(), bounds.getMax()); 113 } 114 } 115 } 116 117 /** 118 * Returs the MapillaryData object, which acts as the database of the Layer. 110 new MapillaryDownloader().getImages(bounds.getMin(), 111 bounds.getMax()); 112 } 113 } 114 } 115 116 /** 117 * Returns the MapillaryData object, which acts as the database of the 118 * Layer. 119 119 * 120 120 * @return … … 125 125 126 126 /** 127 * Method invo qued when the layer is destroyed.127 * Method invoked when the layer is destroyed. 128 128 */ 129 129 @Override … … 134 134 MapillaryLayer.INSTANCE = null; 135 135 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false); 136 MapillaryData. deleteInstance();136 MapillaryData.INSTANCE = null; 137 137 Main.map.mapView.removeMouseListener(this); 138 138 MapView.removeEditLayerChangeListener(this); … … 147 147 @Override 148 148 public boolean isModified() { 149 for (MapillaryImage image : mapillaryData.getImages()) {150 if (image.isModified()) {149 for (MapillaryImage image : mapillaryData.getImages()) 150 if (image.isModified()) 151 151 return true; 152 }153 }154 152 return false; 155 153 } … … 208 206 int width = icon.getIconWidth(); 209 207 int height = icon.getIconHeight(); 210 208 211 209 // Rotate the image 212 210 double rotationRequired = Math.toRadians(image.getCa()); 213 211 double locationX = width / 2; 214 212 double locationY = height / 2; 215 AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); 216 AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); 217 218 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2), 219 Main.map.mapView); 220 213 AffineTransform tx = AffineTransform.getRotateInstance( 214 rotationRequired, locationX, locationY); 215 AffineTransformOp op = new AffineTransformOp(tx, 216 AffineTransformOp.TYPE_BILINEAR); 217 218 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y 219 - (height / 2), Main.map.mapView); 221 220 } 222 221 } … … 278 277 @Override 279 278 public void mouseClicked(MouseEvent e) { 280 if (e.getButton() != MouseEvent.BUTTON1) {279 if (e.getButton() != MouseEvent.BUTTON1) 281 280 return; 282 } 283 if (Main.map.mapView.getActiveLayer() != this) { 281 if (Main.map.mapView.getActiveLayer() != this) 284 282 return; 285 }286 283 Point clickPoint = e.getPoint(); 287 284 double snapDistance = 10; … … 290 287 for (MapillaryImage image : mapillaryData.getImages()) { 291 288 Point imagePoint = Main.map.mapView.getPoint(image.getLatLon()); 292 // move the note point to the center of the icon where users are293 // most likely to click when selecting294 289 imagePoint.setLocation(imagePoint.getX(), imagePoint.getY()); 295 290 double dist = clickPoint.distanceSq(imagePoint); … … 371 366 sleep(1000); 372 367 } catch (InterruptedException e) { 373 // TODO Auto-generated catch block 374 e.printStackTrace(); 368 Main.error(e); 375 369 } 376 370 MapillaryLayer.getInstance().download(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31173 r31176 29 29 public static final int ICON_SIZE = 24; 30 30 31 MapillaryDownloadAction downloadAction;32 MapillaryExportAction exportAction;31 private final MapillaryDownloadAction downloadAction; 32 private final MapillaryExportAction exportAction; 33 33 34 34 public static JMenuItem DOWNLOAD_MENU; 35 35 public static JMenuItem EXPORT_MENU; 36 36 37 public static String DIR;38 39 37 public MapillaryPlugin(PluginInformation info) { 40 38 super(info); 39 Main.logLevel = 1; 41 40 downloadAction = new MapillaryDownloadAction(); 42 41 exportAction = new MapillaryExportAction(); … … 47 46 false, 14); 48 47 EXPORT_MENU.setEnabled(false); 49 MapillaryPlugin.DIR = this.getPluginDir();50 51 48 } 52 49 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
r31159 r31176 6 6 7 7 import org.apache.commons.jcs.access.behavior.ICacheAccess; 8 import org.openstreetmap.josm.Main; 8 9 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 9 10 import org.openstreetmap.josm.data.cache.JCSCachedTileLoaderJob; … … 36 37 } 37 38 } catch (MalformedURLException e) { 38 // TODO Auto-generated catch block 39 e.printStackTrace(); 39 Main.error(e); 40 40 } 41 41 } … … 66 66 // @Override 67 67 protected boolean handleNotFound() { 68 // TODO Auto-generated method stub69 68 return false; 70 69 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31164 r31176 2 2 3 3 import org.openstreetmap.josm.Main; 4 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;5 4 import org.openstreetmap.josm.data.Bounds; 6 5 import org.openstreetmap.josm.data.coor.LatLon; … … 21 20 private String[] parameters = { "lat", "lon", "distance", "limit", 22 21 "min_lat", "min_lon", "max_lat", "max_lon" }; 23 private MapillaryData data;24 22 25 public MapillaryDownloader(MapillaryData data) { 26 this.data = data; 23 public MapillaryDownloader() { 27 24 } 28 25 … … 49 46 url2 += buildParameters(hash); 50 47 try { 51 Main.worker.submit(new MapillarySquareDownloadManagerThread(this.data, 52 url1, url2, new Bounds(minLatLon, maxLatLon))); 48 Main.worker.submit(new MapillarySquareDownloadManagerThread(url1, url2, new Bounds(minLatLon, maxLatLon))); 53 49 } catch (Exception e) { 50 Main.error(e); 54 51 } 55 52 } … … 57 54 private String buildParameters(ConcurrentHashMap<String, Double> hash) { 58 55 String ret = "?client_id=" + CLIENT_ID; 59 for (int i = 0; i < parameters.length; i++) {56 for (int i = 0; i < parameters.length; i++) 60 57 if (hash.get(parameters[i]) != null) 61 58 ret += "&" + parameters[i] + "=" + hash.get(parameters[i]); 62 }63 59 return ret; 64 60 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java
r31166 r31176 11 11 12 12 import org.apache.commons.jcs.access.CacheAccess; 13 import org.openstreetmap.josm.Main; 13 14 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 14 15 import org.openstreetmap.josm.data.cache.CacheEntry; … … 56 57 .submit(this, false); 57 58 } catch (MalformedURLException e) { 58 // TODO Auto-generated catch block 59 e.printStackTrace(); 59 Main.error(e); 60 60 } catch (IOException e) { 61 // TODO -generated catch block 62 e.printStackTrace(); 61 Main.error(e); 63 62 } 64 63 } … … 72 71 73 72 } catch (InterruptedException e) { 74 // TODO Auto-generated catch block 75 e.printStackTrace(); 73 Main.error(e); 76 74 } catch (IOException e) { 77 // TODO Auto-generated catch block 78 e.printStackTrace(); 75 Main.error(e); 79 76 } 80 77 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
r31166 r31176 1 1 package org.openstreetmap.josm.plugins.mapillary.downloads; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 3 4 import java.awt.image.BufferedImage; 4 5 import java.io.IOException; … … 8 9 import java.util.concurrent.TimeUnit; 9 10 11 import org.openstreetmap.josm.Main; 10 12 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 11 13 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 33 35 String path; 34 36 35 public MapillaryExportManager(String title, List<MapillaryImage> images, 36 String path) { 37 super(title, 38 new PleaseWaitProgressMonitor("Exporting Mapillary Images"), 39 true); 37 public MapillaryExportManager(List<MapillaryImage> images, String path) { 38 super(tr("Downloading") + "...", new PleaseWaitProgressMonitor( 39 "Exporting Mapillary Images"), true); 40 40 queue = new ArrayBlockingQueue<>(10); 41 41 queueImages = new ArrayBlockingQueue<>(10); … … 48 48 protected void cancel() { 49 49 // TODO Auto-generated method stub 50 51 50 } 52 51 … … 54 53 protected void realRun() throws SAXException, IOException, 55 54 OsmTransferException { 55 // Starts a writer thread in order to write the pictures on the disk. 56 56 Thread writer = new Thread(new MapillaryExportWriterThread(path, queue, 57 57 queueImages, images.size(), this.getProgressMonitor())); 58 writer.start();58 Main.worker.submit(writer); 59 59 ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25, 60 60 TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); … … 64 64 queueImages)); 65 65 } catch (Exception e) { 66 System.out.println("Exception");66 Main.error(e); 67 67 } 68 68 try { 69 // If the queue is full, waits for it to have more space 70 // available before executing anything else. 69 71 while (ex.getQueue().remainingCapacity() == 0) 70 72 Thread.sleep(100); 71 73 } catch (Exception e) { 72 System.out.println(e);74 Main.error(e); 73 75 } 74 76 } … … 76 78 writer.join(); 77 79 } catch (Exception e) { 80 Main.error(e); 78 81 } 79 82 … … 83 86 protected void finish() { 84 87 // TODO Auto-generated method stub 85 86 88 } 87 88 89 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
r31168 r31176 22 22 import org.apache.sanselan.formats.tiff.write.TiffOutputField; 23 23 import org.apache.sanselan.formats.tiff.write.TiffOutputSet; 24 import org.openstreetmap.josm.Main; 24 25 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 25 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 34 35 public class MapillaryExportWriterThread implements Runnable { 35 36 36 private String path;37 private ArrayBlockingQueue<BufferedImage> queue;38 private ArrayBlockingQueue<MapillaryImage> queueImages;39 private int amount;40 private ProgressMonitor monitor;37 private final String path; 38 private final ArrayBlockingQueue<BufferedImage> queue; 39 private final ArrayBlockingQueue<MapillaryImage> queueImages; 40 private final int amount; 41 private final ProgressMonitor monitor; 41 42 42 43 public MapillaryExportWriterThread(String path, … … 63 64 mimg = queueImages.take(); 64 65 finalPath = path + "/" + mimg.getKey(); 66 // Creates a temporal file that is going to be deleted after 67 // writing the EXIF tags. 65 68 tempFile = new File(finalPath + ".tmp"); 66 67 69 ImageIO.write(img, "jpg", tempFile); 68 70 … … 72 74 .getOrCreateGPSDirectory(); 73 75 FieldType fieldType = TiffFieldTypeConstants.FIELD_TYPE_RATIONAL; 74 TiffOutputField directionref = TiffOutputField.create(GPSTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF, outputSet.byteOrder, "T"); 76 TiffOutputField directionref = TiffOutputField.create( 77 GPSTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF, 78 outputSet.byteOrder, "T"); 75 79 exifDirectory.add(directionref); 76 TiffOutputField direction = TiffOutputField.create( 77 new TagInfo("GPS Img Direction", 17, fieldType , 1, TiffDirectoryConstants.EXIF_DIRECTORY_GPS), outputSet.byteOrder, mimg.getCa()); 80 TiffOutputField direction = TiffOutputField.create(new TagInfo( 81 "GPS Img Direction", 17, fieldType, 1, 82 TiffDirectoryConstants.EXIF_DIRECTORY_GPS), 83 outputSet.byteOrder, mimg.getCa()); 78 84 exifDirectory.add(direction); 79 85 try { … … 81 87 .getLatLon().lat()); 82 88 } catch (ImageWriteException e) { 83 // TODO Auto-generated catch block 84 e.printStackTrace(); 89 Main.error(e); 85 90 } 86 91 OutputStream os = new BufferedOutputStream( … … 90 95 tempFile.delete(); 91 96 os.close(); 92 93 } catch (InterruptedException e1) { 94 // TODO Auto-generated catch block 95 e1.printStackTrace(); 97 } catch (InterruptedException e) { 98 Main.error(e); 96 99 } catch (IOException e) { 97 // TODO Auto-generated catch block 98 e.printStackTrace(); 100 Main.error(e); 99 101 } catch (ImageReadException e) { 100 // TODO Auto-generated catch block 101 e.printStackTrace(); 102 Main.error(e); 102 103 } catch (ImageWriteException e) { 103 // TODO Auto-generated catch block 104 e.printStackTrace(); 104 Main.error(e); 105 105 } 106 106 107 // Increases the progress bar. 107 108 monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / amount); 108 109 monitor.setCustomText("Downloaded " + (i + 1) + "/" + amount); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31170 r31176 14 14 import java.util.concurrent.ExecutorService; 15 15 16 import org.openstreetmap.josm.Main; 16 17 import org.openstreetmap.josm.data.Bounds; 17 18 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; … … 29 30 public class MapillarySequenceDownloadThread implements Runnable { 30 31 31 private MapillaryData data;32 32 private String url; 33 33 private ExecutorService ex; 34 34 private Bounds bounds; 35 35 36 public MapillarySequenceDownloadThread(ExecutorService ex, 37 MapillaryData data, String url, Bounds bounds) { 38 this.data = data; 36 public MapillarySequenceDownloadThread(ExecutorService ex, String url, Bounds bounds) { 39 37 this.url = url; 40 38 this.ex = ex; … … 47 45 br = new BufferedReader(new InputStreamReader( 48 46 new URL(url).openStream())); 49 /*50 * String jsonLine = ""; while (br.ready()) { jsonLine +=51 * br.readLine(); }52 */53 47 JsonObject jsonall = Json.createReader(br).readObject(); 54 48 … … 71 65 .getJsonNumber(j).doubleValue())); 72 66 } catch (Exception e) { 73 // Mapillary service bug here74 // System.out.println(cas.length());75 // System.out.println(coords.length());76 // System.out.println(keys.length());77 67 System.out.println(e); 78 68 } 79 69 } 80 70 MapillarySequence sequence = new MapillarySequence(); 81 //sequence.setTimestamp(jsonobj.getString("created_at"));82 71 int first = -1; 83 72 int last = -1; … … 105 94 img.setSequence(sequence); 106 95 } 107 data.addWithoutUpdate(finalImages);96 MapillaryData.getInstance().addWithoutUpdate(finalImages); 108 97 sequence.add(finalImages); 109 98 } 110 99 } catch (IOException e) { 111 return;100 Main.error(e); 112 101 } 113 return;114 102 } 115 103 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31166 r31176 5 5 import java.util.concurrent.ArrayBlockingQueue; 6 6 7 import org.openstreetmap.josm.Main; 7 8 import org.openstreetmap.josm.data.Bounds; 8 9 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; … … 20 21 21 22 @SuppressWarnings("unused") 22 private String urlImages; 23 private String urlSequences; 24 private MapillaryData data; 25 private Bounds bounds; 23 private final String urlImages; 24 private final String urlSequences; 25 private final Bounds bounds; 26 26 27 public MapillarySquareDownloadManagerThread(MapillaryData data, 28 String urlImages, String urlSequences, Bounds bounds) { 29 this.data = data; 27 public MapillarySquareDownloadManagerThread(String urlImages, String urlSequences, Bounds bounds) { 30 28 this.urlImages = urlImages; 31 29 this.urlSequences = urlSequences; … … 34 32 35 33 public void run() { 36 fullfillSequences(); 37 return; 34 downloadSequences(); 38 35 } 39 36 40 public void fullfillSequences() {37 public void downloadSequences() { 41 38 ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25, 42 39 TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 43 ;44 40 int page = 0; 45 41 while (!ex.isShutdown()) { 46 ex.execute(new MapillarySequenceDownloadThread(ex, data,42 ex.execute(new MapillarySequenceDownloadThread(ex, 47 43 urlSequences + "&page=" + page + "&limit=1", bounds)); 48 44 try { … … 50 46 Thread.sleep(100); 51 47 } catch (Exception e) { 52 System.out.println(e);48 Main.error(e); 53 49 } 54 50 page++; … … 58 54 } 59 55 } catch (Exception e) { 60 System.out.println(e);56 Main.error(e); 61 57 } 62 data.dataUpdated();58 MapillaryData.getInstance().dataUpdated(); 63 59 } 64 60 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java
r31166 r31176 12 12 import java.util.concurrent.ExecutorService; 13 13 14 import org.openstreetmap.josm.Main; 14 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; 15 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; … … 22 23 */ 23 24 public class MapillarySquareDownloadThread implements Runnable { 24 String url; 25 MapillaryData data; 26 ExecutorService ex; 25 private final String url; 26 private final ExecutorService ex; 27 27 28 28 public MapillarySquareDownloadThread(ExecutorService ex, 29 29 MapillaryData data, String url) { 30 30 this.ex = ex; 31 this.data = data;32 31 this.url = url; 33 32 } … … 38 37 br = new BufferedReader(new InputStreamReader( 39 38 new URL(url).openStream())); 40 /*41 * String jsonLine = ""; while (br.ready()) { jsonLine +=42 * br.readLine(); }43 */44 39 JsonObject jsonobj = Json.createReader(br).readObject(); 45 40 if (!jsonobj.getBoolean("more")) { … … 57 52 .getJsonNumber("ca").doubleValue())); 58 53 } catch (Exception e) { 59 System.out.println(e);54 Main.error(e); 60 55 } 61 56 } 62 data.add(images); 63 return; 57 MapillaryData.getInstance().add(images); 64 58 } catch (Exception e) { 65 return;59 Main.error(e); 66 60 } 67 61 }
Note:
See TracChangeset
for help on using the changeset viewer.