Changeset 31451 in osm
- Timestamp:
- 2015-08-05T11:45:56+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31450 r31451 82 82 83 83 /** {@link MapillaryData} object that stores the database */ 84 p ublicfinal MapillaryData data;84 private final MapillaryData data; 85 85 86 86 /** The bounds of the areas for which the pictures have been downloaded */ … … 172 172 * @return The {@link MapillaryData} object that stores the database. 173 173 */ 174 public MapillaryData get MapillaryData() {174 public MapillaryData getData() { 175 175 return this.data; 176 176 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
r31401 r31451 97 97 g.setColor(Color.MAGENTA); 98 98 for (MapillaryAbstractImage img : MapillaryLayer.getInstance() 99 .get MapillaryData().getImages()) {99 .getData().getImages()) { 100 100 if (img instanceof MapillaryImage) { 101 101 g.fillOval(mv.getPoint(img.getLatLon()).x - 3, -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r31450 r31451 71 71 && this.dialog.chooser != null) { 72 72 if (this.dialog.group.isSelected(this.dialog.all.getModel())) { 73 export(MapillaryLayer.getInstance(). data.getImages());73 export(MapillaryLayer.getInstance().getData().getImages()); 74 74 } else if (this.dialog.group.isSelected(this.dialog.sequence.getModel())) { 75 75 ArrayList<MapillaryAbstractImage> images = new ArrayList<>(); 76 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() .data77 .getMultiSelectedImages()) 76 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() 77 .getData().getMultiSelectedImages()) 78 78 if (image instanceof MapillaryImage) { 79 79 if (!images.contains(image)) … … 83 83 export(images); 84 84 } else if (this.dialog.group.isSelected(this.dialog.selected.getModel())) { 85 export(MapillaryLayer.getInstance(). data.getMultiSelectedImages());85 export(MapillaryLayer.getInstance().getData().getMultiSelectedImages()); 86 86 } 87 87 // This option ignores the selected directory. 88 88 } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) { 89 89 ArrayList<MapillaryImportedImage> images = new ArrayList<>(); 90 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() .data91 .getImages()) 90 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() 91 .getData().getImages()) 92 92 if (image instanceof MapillaryImportedImage) { 93 93 images.add(((MapillaryImportedImage) image)); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31450 r31451 84 84 try { 85 85 if (extension.equals("jpg") || extension.equals("jpeg")) 86 MapillaryLayer.getInstance().data.add(readJPG(file.listFiles()[j])); 86 MapillaryLayer.getInstance().getData() 87 .add(readJPG(file.listFiles()[j])); 87 88 88 89 else if (extension.equals("png")) 89 MapillaryLayer.getInstance().data.add(readPNG(file.listFiles()[j])); 90 MapillaryLayer.getInstance().getData() 91 .add(readPNG(file.listFiles()[j])); 90 92 } catch (ImageReadException | IOException | NullPointerException e1) { 91 93 Main.error(e1); … … 98 100 .equals(".jpeg")) { 99 101 try { 100 MapillaryLayer.getInstance(). data.add(readJPG(file));102 MapillaryLayer.getInstance().getData().add(readJPG(file)); 101 103 } catch (ImageReadException ex) { 102 104 Main.error(ex); … … 106 108 } else if (file.getPath().substring(file.getPath().length() - 4) 107 109 .equals(".png")) { 108 MapillaryLayer.getInstance(). data.add(readPNG(file));110 MapillaryLayer.getInstance().getData().add(readPNG(file)); 109 111 } 110 112 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31450 r31451 161 161 MapillaryImportedImage image = new MapillaryImportedImage(latValue, 162 162 lonValue, caValue, file, datetimeOriginal.getStringValue()); 163 MapillaryLayer.getInstance(). data.add(image);163 MapillaryLayer.getInstance().getData().add(image); 164 164 image.getCapturedAt(); 165 165 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31450 r31451 38 38 Shortcut.NONE), false, "mapillaryUpload", false); 39 39 this.setEnabled(false); 40 MapillaryLayer.getInstance(). data.addListener(this);40 MapillaryLayer.getInstance().getData().addListener(this); 41 41 } 42 42 … … 53 53 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 54 54 if (dialog.sequence.isSelected()) { 55 OAuthUtils.uploadSequence(MapillaryLayer.getInstance(). data55 OAuthUtils.uploadSequence(MapillaryLayer.getInstance().getData() 56 56 .getSelectedImage().getSequence()); 57 57 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
r31450 r31451 35 35 KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryZoom", 36 36 false); 37 MapillaryLayer.getInstance(). data.addListener(this);37 MapillaryLayer.getInstance().getData().addListener(this); 38 38 this.setEnabled(false); 39 39 } … … 41 41 @Override 42 42 public void actionPerformed(ActionEvent arg0) { 43 if (MapillaryLayer.getInstance(). data.getSelectedImage() == null)43 if (MapillaryLayer.getInstance().getData().getSelectedImage() == null) 44 44 throw new IllegalStateException(); 45 Main.map.mapView.zoomTo(MapillaryLayer.getInstance(). data45 Main.map.mapView.zoomTo(MapillaryLayer.getInstance().getData() 46 46 .getSelectedImage().getLatLon()); 47 47 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java
r31445 r31451 51 51 this.followSelected = followSelected; 52 52 this.goForward = goForward; 53 this.data = MapillaryLayer.getInstance().get MapillaryData();53 this.data = MapillaryLayer.getInstance().getData(); 54 54 this.data.addListener(this); 55 55 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31445 r31451 64 64 queryStringParts.put("max_lat", maxLatLon.lat()); 65 65 queryStringParts.put("max_lon", maxLatLon.lon()); 66 run(new MapillarySquareDownloadManagerThread(queryStringParts, 67 MapillaryLayer.getInstance())); 66 run(new MapillarySquareDownloadManagerThread(queryStringParts)); 68 67 } 69 68 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java
r31445 r31451 27 27 private final String queryString; 28 28 private final ExecutorService ex; 29 private final MapillaryLayer layer;30 29 31 30 /** … … 36 35 * @param queryString 37 36 * A String containing the parameters for the download. 38 * @param layer39 * The layer to store the data.40 37 */ 41 38 public MapillaryImageInfoDownloaderThread(ExecutorService ex, 42 String queryString , MapillaryLayer layer) {39 String queryString) { 43 40 this.ex = ex; 44 41 this.queryString = queryString; 45 this.layer = layer;46 42 } 47 43 … … 59 55 data = jsonarr.getJsonObject(i); 60 56 String key = data.getString("key"); 61 for (MapillaryAbstractImage image : this.layer.getMapillaryData()57 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData() 62 58 .getImages()) { 63 59 if (image instanceof MapillaryImage) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31445 r31451 101 101 try { 102 102 for (MapillaryImage img : finalImages) { 103 if (this.layer.get MapillaryData().getImages().contains(img)) {103 if (this.layer.getData().getImages().contains(img)) { 104 104 // The image in finalImages is substituted by the one in the 105 105 // database, as they represent the same picture. 106 img = (MapillaryImage) this.layer.get MapillaryData().getImages()107 .get(this.layer.get MapillaryData().getImages().indexOf(img));106 img = (MapillaryImage) this.layer.getData().getImages() 107 .get(this.layer.getData().getImages().indexOf(img)); 108 108 sequence.add(img); 109 ((MapillaryImage) this.layer.get MapillaryData().getImages()110 .get(this.layer.get MapillaryData().getImages().indexOf(img)))109 ((MapillaryImage) this.layer.getData().getImages() 110 .get(this.layer.getData().getImages().indexOf(img))) 111 111 .setSequence(sequence); 112 112 finalImages.set(finalImages.indexOf(img), img); … … 121 121 } 122 122 123 this.layer.get MapillaryData().add(123 this.layer.getData().add( 124 124 new ArrayList<MapillaryAbstractImage>(finalImages), false); 125 125 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31449 r31451 30 30 private final String sequenceQueryString; 31 31 private final String signQueryString; 32 private final MapillaryLayer layer;33 32 34 33 /** … … 37 36 * @param queryStringParts 38 37 * The query data. 39 * @param layer40 * The layer to store the images.41 38 * 42 39 */ 43 40 public MapillarySquareDownloadManagerThread( 44 ConcurrentHashMap<String, Double> queryStringParts , MapillaryLayer layer) {41 ConcurrentHashMap<String, Double> queryStringParts) { 45 42 this.imageQueryString = buildQueryString(queryStringParts); 46 43 this.sequenceQueryString = buildQueryString(queryStringParts); … … 49 46 // TODO: Move this line to the appropriate place, here's no GET-request 50 47 Main.info("GET " + this.sequenceQueryString + " (Mapillary plugin)"); 51 52 this.layer = layer;53 48 } 54 49 … … 85 80 MapillaryLayer.getInstance().updateHelpText(); 86 81 } 87 this.layer.updateHelpText();82 MapillaryLayer.getInstance().updateHelpText(); 88 83 MapillaryData.dataUpdated(); 89 84 MapillaryFilterDialog.getInstance().refresh(); … … 112 107 while (!ex.isShutdown()) { 113 108 ex.execute(new MapillaryImageInfoDownloaderThread(ex, 114 this.imageQueryString + "&page=" + page + "&limit=20" , this.layer));109 this.imageQueryString + "&page=" + page + "&limit=20")); 115 110 while (ex.getQueue().remainingCapacity() == 0) 116 111 Thread.sleep(100); … … 126 121 while (!ex.isShutdown()) { 127 122 ex.execute(new MapillaryTrafficSignDownloaderThread(ex, 128 this.signQueryString + "&page=" + page + "&limit=20" , this.layer));123 this.signQueryString + "&page=" + page + "&limit=20")); 129 124 while (ex.getQueue().remainingCapacity() == 0) 130 125 Thread.sleep(100); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloaderThread.java
r31445 r31451 28 28 private final String queryString; 29 29 private final ExecutorService ex; 30 private final MapillaryLayer layer;31 30 32 31 /** … … 37 36 * @param queryString 38 37 * A String containing the parameter for the download. 39 * @param layer40 * The layer to store the data.41 38 */ 42 39 public MapillaryTrafficSignDownloaderThread(ExecutorService ex, 43 String queryString , MapillaryLayer layer) {40 String queryString) { 44 41 this.ex = ex; 45 42 this.queryString = queryString; 46 this.layer = layer;47 43 } 48 44 … … 51 47 BufferedReader br; 52 48 try { 53 br = new BufferedReader(new InputStreamReader( 54 new URL(URL+ this.queryString).openStream(), "UTF-8"));49 br = new BufferedReader(new InputStreamReader(new URL(URL 50 + this.queryString).openStream(), "UTF-8")); 55 51 JsonObject jsonobj = Json.createReader(br).readObject(); 56 52 if (!jsonobj.getBoolean("more")) { … … 68 64 for (int k = 0; k < rects.size(); k++) { 69 65 JsonObject data = rects.getJsonObject(k); 70 for (MapillaryAbstractImage image : this.layer.getMapillaryData()71 .getImages()) 66 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() 67 .getData().getImages()) 72 68 if (image instanceof MapillaryImage 73 69 && ((MapillaryImage) image).getKey().equals(key)) … … 81 77 for (int j = 0; j < rects.size(); j++) { 82 78 JsonObject data = rects.getJsonObject(j); 83 for (MapillaryAbstractImage image : this.layer.getMapillaryData()84 .getImages()) 79 for (MapillaryAbstractImage image : MapillaryLayer.getInstance() 80 .getData().getImages()) 85 81 if (image instanceof MapillaryImage 86 82 && ((MapillaryImage) image).getKey().equals(key)) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
r31450 r31451 81 81 this.group.add(this.rewrite); 82 82 // Some options are disabled depending on the circumstances 83 if (MapillaryLayer.getInstance(). data.getSelectedImage() == null84 || !(MapillaryLayer.getInstance(). data.getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryLayer85 .getInstance(). data.getSelectedImage()).getSequence() != null)) {83 if (MapillaryLayer.getInstance().getData().getSelectedImage() == null 84 || !(MapillaryLayer.getInstance().getData().getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryLayer 85 .getInstance().getData().getSelectedImage()).getSequence() != null)) { 86 86 this.sequence.setEnabled(false); 87 87 } 88 if (MapillaryLayer.getInstance().data.getMultiSelectedImages().isEmpty()) { 88 if (MapillaryLayer.getInstance().getData().getMultiSelectedImages() 89 .isEmpty()) { 89 90 this.selected.setEnabled(false); 90 91 } 91 92 this.rewrite.setEnabled(false); 92 for (MapillaryAbstractImage img : MapillaryLayer.getInstance(). data93 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData() 93 94 .getImages()) 94 95 if (img instanceof MapillaryImportedImage) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r31450 r31451 176 176 boolean onlySigns = this.onlySigns.isSelected(); 177 177 178 for (MapillaryAbstractImage img : MapillaryLayer.getInstance(). data178 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData() 179 179 .getImages()) { 180 180 img.setVisible(true); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31450 r31451 96 96 tr("Open Mapillary main dialog"), KeyEvent.VK_M, Shortcut.NONE), 97 97 200, false, MapillaryPreferenceSetting.class); 98 MapillaryLayer.getInstance(). data.addListener(this);98 MapillaryLayer.getInstance().getData().addListener(this); 99 99 addShortcuts(); 100 100 this.mapillaryImageDisplay = new MapillaryImageDisplay(); … … 344 344 @Override 345 345 public void actionPerformed(ActionEvent e) { 346 MapillaryLayer.getInstance(). data.selectNext();346 MapillaryLayer.getInstance().getData().selectNext(); 347 347 } 348 348 } … … 366 366 @Override 367 367 public void actionPerformed(ActionEvent e) { 368 MapillaryLayer.getInstance(). data.selectPrevious();368 MapillaryLayer.getInstance().getData().selectPrevious(); 369 369 } 370 370 } … … 389 389 public void actionPerformed(ActionEvent e) { 390 390 if (MapillaryMainDialog.getInstance().getImage() != null) { 391 MapillaryLayer.getInstance(). data.setSelectedImage(MapillaryLayer.RED,392 true); 391 MapillaryLayer.getInstance().getData() 392 .setSelectedImage(MapillaryLayer.RED, true); 393 393 } 394 394 } … … 414 414 public void actionPerformed(ActionEvent e) { 415 415 if (MapillaryMainDialog.getInstance().getImage() != null) { 416 MapillaryLayer.getInstance(). data.setSelectedImage(MapillaryLayer.BLUE,417 true); 416 MapillaryLayer.getInstance().getData() 417 .setSelectedImage(MapillaryLayer.BLUE, true); 418 418 } 419 419 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java
r31450 r31451 28 28 29 29 this.sequence = new JRadioButton("Upload selected sequence."); 30 if (MapillaryLayer.getInstance(). data.getSelectedImage() == null31 || !(MapillaryLayer.getInstance(). data.getSelectedImage() instanceof MapillaryImportedImage))30 if (MapillaryLayer.getInstance().getData().getSelectedImage() == null 31 || !(MapillaryLayer.getInstance().getData().getSelectedImage() instanceof MapillaryImportedImage)) 32 32 this.sequence.setEnabled(false); 33 33 this.group.add(this.sequence); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31450 r31451 28 28 private final static int DOWNLOAD_COOLDOWN = 2000; 29 29 30 protected MapillaryData data = MapillaryLayer.getInstance(). data;30 protected MapillaryData data = MapillaryLayer.getInstance().getData(); 31 31 private static SemiautomaticThread semiautomaticThread = new SemiautomaticThread(); 32 32 … … 55 55 /** 56 56 * Paint the dataset using the engine set. 57 * 57 58 * @param g 58 * @param mv The object that can translate GeoPoints to screen coordinates. 59 * @param mv 60 * The object that can translate GeoPoints to screen coordinates. 59 61 * @param box 60 62 */ -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceDownloadThreadTest.java
r31445 r31451 59 59 60 60 int page = 1; 61 while (!ex.isShutdown() && MapillaryLayer.getInstance().get MapillaryData().getImages().size() <= 0 && page < 50) {61 while (!ex.isShutdown() && MapillaryLayer.getInstance().getData().getImages().size() <= 0 && page < 50) { 62 62 System.out.println("Sending sequence-request "+page+" to Mapillary-servers…"); 63 63 Thread downloadThread = new MapillarySequenceDownloadThread(ex, queryString+"&page="+page); … … 67 67 Thread.sleep(500); 68 68 } 69 assertTrue(MapillaryLayer.getInstance().get MapillaryData().getImages().size() >= 1);69 assertTrue(MapillaryLayer.getInstance().getData().getImages().size() >= 1); 70 70 System.out.println("One or more images were added to the MapillaryLayer within the given bounds."); 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.