Changeset 31459 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-08-06T16:55:05+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31457 r31459 2 2 3 3 import org.openstreetmap.josm.Main; 4 import org.openstreetmap.josm.data.Bounds; 4 5 import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils; 5 6 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; … … 26 27 27 28 private CopyOnWriteArrayList<MapillaryDataListener> listeners = new CopyOnWriteArrayList<>(); 29 30 /** The bounds of the areas for which the pictures have been downloaded. */ 31 public CopyOnWriteArrayList<Bounds> bounds; 28 32 29 33 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31457 r31459 74 74 public boolean TEMP_SEMIAUTOMATIC = false; 75 75 76 /** Unique instance of the class */ 76 /** Unique instance of the class. */ 77 77 public static MapillaryLayer INSTANCE; 78 /** The image pointed by the blue line */ 78 /** The image pointed by the blue line. */ 79 79 public static MapillaryImage BLUE; 80 /** The image pointed by the red line */ 80 /** The image pointed by the red line. */ 81 81 public static MapillaryImage RED; 82 82 83 /** {@link MapillaryData} object that stores the database */ 83 /** {@link MapillaryData} object that stores the database. */ 84 84 private final MapillaryData data; 85 85 86 /** The bounds of the areas for which the pictures have been downloaded */ 87 public CopyOnWriteArrayList<Bounds> bounds; 88 89 /** Mode of the layer */ 86 /** Mode of the layer. */ 90 87 public AbstractMode mode; 91 88 … … 100 97 super(tr("Mapillary Images")); 101 98 this.data = new MapillaryData(); 102 this.bounds = new CopyOnWriteArrayList<>(); 99 this.data.bounds = new CopyOnWriteArrayList<>(); 103 100 init(); 104 101 } … … 243 240 * Replies background color for downloaded areas. 244 241 * 245 * @return background color for downloaded areas. Black by default 242 * @return background color for downloaded areas. Black by default. 246 243 */ 247 244 private static Color getBackgroundColor() { … … 252 249 * Replies background color for non-downloaded areas. 253 250 * 254 * @return background color for non-downloaded areas. Yellow by default 251 * @return background color for non-downloaded areas. Yellow by default. 255 252 */ 256 253 private static Color getOutsideColor() { … … 259 256 260 257 /** 261 * Initialize the hatch pattern used to paint the non-downloaded area 258 * Initialize the hatch pattern used to paint the non-downloaded area. 262 259 */ 263 260 private void createHatchTexture() { … … 283 280 Area a = new Area(b); 284 281 // now successively subtract downloaded areas 285 for (Bounds bounds : this.bounds) { 282 for (Bounds bounds : this.data.bounds) { 286 283 Point p1 = mv.getPoint(bounds.getMin()); 287 284 Point p2 = mv.getPoint(bounds.getMax()); … … 508 505 } 509 506 510 // EditDataLayerChanged511 507 @Override 512 508 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31455 r31459 82 82 if (isViewDownloaded(view)) 83 83 return; 84 MapillaryLayer.getInstance().bounds.add(view); 84 MapillaryLayer.getInstance().getData().bounds.add(view); 85 85 getImages(view); 86 86 } … … 108 108 } 109 109 110 /** 111 * Checks if the given {@LatLon} object lies inside the bounds of the 112 * image. 113 * 114 * @param latlon 115 * @return true if it lies inside the bounds; false otherwise; 116 */ 110 117 private static boolean isInBounds(LatLon latlon) { 111 for (Bounds bounds : MapillaryLayer.getInstance().bounds) { 118 for (Bounds bounds : MapillaryLayer.getInstance().getData().bounds) { 112 119 if (bounds.contains(latlon)) 113 120 return true; … … 141 148 for (Bounds bounds : Main.map.mapView.getEditLayer().data 142 149 .getDataSourceBounds()) { 143 if (!layer.bounds.contains(bounds)) { 144 layer.bounds.add(bounds); 150 if (!layer.getData().bounds.contains(bounds)) { 151 layer.getData().bounds.add(bounds); 145 152 MapillaryDownloader.getImages(bounds.getMin(), bounds.getMax()); 146 153 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31451 r31459 132 132 133 133 private boolean isInside(MapillaryAbstractImage image) { 134 for (int i = 0; i < this.layer.bounds.size(); i++) 135 if (this.layer.bounds.get(i).contains(image.getLatLon())) 134 for (int i = 0; i < this.layer.getData().bounds.size(); i++) 135 if (this.layer.getData().bounds.get(i).contains(image.getLatLon())) 136 136 return true; 137 137 return false; -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceDownloadThreadTest.java
r31454 r31459 21 21 public class MapillarySequenceDownloadThreadTest extends AbstractTest { 22 22 23 /** 24 * Test method for {@link org.openstreetmap.josm.plugins.mapillary.downloads.MapillarySequenceDownloadThread#run()}. 25 * 26 * This downloads a small area of mapillary-sequences where we know that images already exist. 27 * When the download-thread finishes, we check if the Mapillary-layer now contains one or more images. 28 * 29 * @throws InterruptedException 30 */ 31 @Test 32 public void testRun() throws InterruptedException { 33 System.out.println("[JUnit] MapillarySequenceDownloadThreadTest.testRun()"); 34 //Area around image UjEbeXZYIoyAKOsE-remlg (59.32125452° N 18.06166856° E) 35 LatLon minLatLon = new LatLon(59.3212545, 18.0616685); 36 LatLon maxLatLon = new LatLon(59.3212546, 18.0616686); 23 /** 24 * Test method for 25 * {@link org.openstreetmap.josm.plugins.mapillary.downloads.MapillarySequenceDownloadThread#run()} 26 * . 27 * 28 * This downloads a small area of mapillary-sequences where we know that 29 * images already exist. When the download-thread finishes, we check if the 30 * Mapillary-layer now contains one or more images. 31 * 32 * @throws InterruptedException 33 */ 34 @Test 35 public void testRun() throws InterruptedException { 36 System.out.println("[JUnit] MapillarySequenceDownloadThreadTest.testRun()"); 37 // Area around image UjEbeXZYIoyAKOsE-remlg (59.32125452° N 18.06166856° E) 38 LatLon minLatLon = new LatLon(59.3212545, 18.0616685); 39 LatLon maxLatLon = new LatLon(59.3212546, 18.0616686); 37 40 38 ExecutorService ex = Executors.newSingleThreadExecutor(); 39 String queryString = String.format( 41 ExecutorService ex = Executors.newSingleThreadExecutor(); 42 String queryString = String 43 .format( 40 44 Locale.UK, 41 45 "?max_lat=%.8f&max_lon=%.8f&min_lat=%.8f&min_lon=%.8f&limit=10&client_id=%s", 42 maxLatLon.lat(), 43 maxLatLon.lon(), 44 minLatLon.lat(), 45 minLatLon.lon(), 46 MapillaryDownloader.CLIENT_ID 47 ); 48 MapillaryLayer.getInstance().bounds.add(new Bounds(minLatLon, maxLatLon)); 46 maxLatLon.lat(), maxLatLon.lon(), minLatLon.lat(), minLatLon.lon(), 47 MapillaryDownloader.CLIENT_ID); 48 MapillaryLayer.getInstance().getData().bounds.add(new Bounds(minLatLon, 49 maxLatLon)); 49 50 50 int page = 1; 51 while (!ex.isShutdown() && MapillaryLayer.getInstance().getData().getImages().size() <= 0 && page < 50) { 52 System.out.println("Sending sequence-request "+page+" to Mapillary-servers…"); 53 Thread downloadThread = new MapillarySequenceDownloadThread(ex, queryString+"&page="+page); 54 downloadThread.start(); 55 downloadThread.join(); 56 page++; 57 Thread.sleep(500); 58 } 59 assertTrue(MapillaryLayer.getInstance().getData().getImages().size() >= 1); 60 System.out.println("One or more images were added to the MapillaryLayer within the given bounds."); 51 int page = 1; 52 while (!ex.isShutdown() 53 && MapillaryLayer.getInstance().getData().getImages().size() <= 0 54 && page < 50) { 55 System.out.println("Sending sequence-request " + page 56 + " to Mapillary-servers…"); 57 Thread downloadThread = new MapillarySequenceDownloadThread(ex, 58 queryString + "&page=" + page); 59 downloadThread.start(); 60 downloadThread.join(); 61 page++; 62 Thread.sleep(500); 61 63 } 64 assertTrue(MapillaryLayer.getInstance().getData().getImages().size() >= 1); 65 System.out 66 .println("One or more images were added to the MapillaryLayer within the given bounds."); 67 } 62 68 63 69 }
Note:
See TracChangeset
for help on using the changeset viewer.