Changeset 31833 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-12-15T21:47:02+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31826 r31833 31 31 private final CopyOnWriteArrayList<MapillaryDataListener> listeners = new CopyOnWriteArrayList<>(); 32 32 /** The bounds of the areas for which the pictures have been downloaded. */ 33 public CopyOnWriteArrayList<Bounds> bounds;33 public List<Bounds> bounds; 34 34 35 35 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
r31828 r31833 8 8 import java.awt.event.ActionListener; 9 9 import java.io.IOException; 10 import java.net.URL;11 10 12 11 import javax.swing.BoxLayout; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31828 r31833 2 2 package org.openstreetmap.josm.plugins.mapillary.gui; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 6 7 7 import java.awt.BorderLayout; … … 15 15 import java.io.ByteArrayInputStream; 16 16 import java.io.IOException; 17 import java.net.MalformedURLException;18 17 import java.util.Arrays; 19 18 import java.util.List; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r31828 r31833 3 3 4 4 import java.awt.FlowLayout; 5 import java.awt.GridBagConstraints; 5 6 import java.awt.GridBagLayout; 6 7 import java.awt.event.ActionEvent; 7 8 import java.io.IOException; 8 import java.net.URL;9 9 10 10 import javax.swing.AbstractAction; … … 92 92 onLogout(); 93 93 panel.add(loginPanel, GBC.eol()); 94 panel.add(Box.createVerticalGlue(), GBC.eol().fill(G BC.BOTH));94 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.BOTH)); 95 95 96 96 gui.getDisplayPreference().addSubTab(this, "Mapillary", new JScrollPane(panel)); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
r31828 r31833 6 6 import java.util.ArrayList; 7 7 import java.util.concurrent.ArrayBlockingQueue; 8 import java.util.concurrent.ConcurrentHashMap;9 8 import java.util.concurrent.ThreadPoolExecutor; 10 9 import java.util.concurrent.TimeUnit; … … 39 38 40 39 /** Executor that will run the petitions. */ 41 private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5, 42 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));; 40 private static ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100)); 43 41 44 42 /** … … 52 50 */ 53 51 public static void getImages(LatLon minLatLon, LatLon maxLatLon) { 54 if (m axLatLon == null || maxLatLon == null) {52 if (minLatLon == null || maxLatLon == null) { 55 53 throw new IllegalArgumentException(); 56 54 } … … 90 88 private static void run(Thread t) { 91 89 threads.add(t); 92 EXECUTOR.execute(t);90 executor.execute(t); 93 91 } 94 92 … … 214 212 } 215 213 threads.clear(); 216 EXECUTOR.shutdownNow();214 executor.shutdownNow(); 217 215 try { 218 EXECUTOR.awaitTermination(30, TimeUnit.SECONDS);216 executor.awaitTermination(30, TimeUnit.SECONDS); 219 217 } catch (InterruptedException e) { 220 218 Main.error(e); 221 219 } 222 EXECUTOR= new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS,220 executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, 223 221 new ArrayBlockingQueue<Runnable>(100)); 224 222 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java
r31827 r31833 37 37 @Override 38 38 public void run() { 39 try { 40 ServerSocket serverSocket = new ServerSocket(PORT); 41 Socket clientSocket = serverSocket.accept(); 42 PrintWriter out = new PrintWriter(new OutputStreamWriter( 43 clientSocket.getOutputStream(), "UTF-8"), true); 44 Scanner in = new Scanner(new InputStreamReader( 45 clientSocket.getInputStream(), "UTF-8")); 39 try ( 40 ServerSocket serverSocket = new ServerSocket(PORT); 41 Socket clientSocket = serverSocket.accept(); 42 PrintWriter out = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8"), true); 43 Scanner in = new Scanner(new InputStreamReader(clientSocket.getInputStream(), "UTF-8")); 44 ) { 46 45 String s; 47 46 String accessToken = null; -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java
r31828 r31833 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.util.Locale;9 8 import java.util.concurrent.ExecutorService; 10 9 import java.util.concurrent.Executors; … … 15 14 import org.openstreetmap.josm.plugins.mapillary.AbstractTest; 16 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;18 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;19 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillarySequenceDownloadThread;20 16 21 17 /** -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryURLTest.java
r31831 r31833 3 3 import static org.junit.Assert.assertEquals; 4 4 import static org.junit.Assert.assertNull; 5 import static org.junit.Assert.assertTrue; 5 6 import static org.junit.Assert.fail; 6 7 … … 61 62 @Test 62 63 public void testConnectURL() throws MalformedURLException { 63 assertEquals( 64 new URL("https://www.mapillary.com/connect/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&scope=user%3Aread+public%3Aupload+public%3Awrite&response_type=token&redirect_uri=http%3A%2F%2Fredirect-host%2F%C3%A4"), 65 MapillaryURL.connectURL("http://redirect-host/ä") 66 ); 67 assertEquals( 68 new URL("https://www.mapillary.com/connect/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&scope=user%3Aread+public%3Aupload+public%3Awrite&response_type=token"), 69 MapillaryURL.connectURL(null) 70 ); 71 assertEquals( 72 new URL("https://www.mapillary.com/connect/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&scope=user%3Aread+public%3Aupload+public%3Awrite&response_type=token"), 73 MapillaryURL.connectURL("") 64 assertUrlEquals( 65 MapillaryURL.connectURL("http://redirect-host/ä"), 66 "https://www.mapillary.com/connect/", 67 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 68 "scope=user%3Aread+public%3Aupload+public%3Awrite", 69 "response_type=token", 70 "redirect_uri=http%3A%2F%2Fredirect-host%2F%C3%A4" 71 ); 72 73 assertUrlEquals( 74 MapillaryURL.connectURL(null), 75 "https://www.mapillary.com/connect/", 76 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 77 "scope=user%3Aread+public%3Aupload+public%3Awrite", 78 "response_type=token" 79 ); 80 81 assertUrlEquals( 82 MapillaryURL.connectURL(""), 83 "https://www.mapillary.com/connect/", 84 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 85 "scope=user%3Aread+public%3Aupload+public%3Awrite", 86 "response_type=token" 74 87 ); 75 88 } … … 77 90 @Test 78 91 public void testSearchImageURL() throws MalformedURLException { 79 assertEquals( 80 new URL("https://a.mapillary.com/v2/search/im/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&min_lon=2.220000&max_lat=3.333000&max_lon=4.444400&limit=20&page=42&min_lat=1.100000"), 81 MapillaryURL.searchImageURL(new Bounds(1.1, 2.22, 3.333, 4.4444), 42) 82 ); 83 assertEquals( 84 new URL("https://a.mapillary.com/v2/search/im/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&limit=20&page=-73"), 85 MapillaryURL.searchImageURL(null, -73) 92 assertUrlEquals( 93 MapillaryURL.searchImageURL(new Bounds(1.1, 2.22, 3.333, 4.4444), 42), 94 "https://a.mapillary.com/v2/search/im/", 95 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 96 "min_lon=2.220000", 97 "max_lon=4.444400", 98 "min_lat=1.100000", 99 "max_lat=3.333000", 100 "limit=20", 101 "page=42" 102 ); 103 assertUrlEquals( 104 MapillaryURL.searchImageURL(null, -73), 105 "https://a.mapillary.com/v2/search/im/", 106 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 107 "limit=20", 108 "page=-73" 86 109 ); 87 110 } … … 89 112 @Test 90 113 public void testSearchSequenceURL() throws MalformedURLException { 91 assertEquals( 92 new URL("https://a.mapillary.com/v2/search/s/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&min_lon=-66.666666&max_lat=77.777778&max_lon=88.888889&limit=10&page=42&min_lat=-55.555550"), 93 MapillaryURL.searchSequenceURL(new Bounds(-55.55555, -66.666666, 77.7777777, 88.88888888, false), 42) 94 ); 95 assertEquals( 96 new URL("https://a.mapillary.com/v2/search/s/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&limit=10&page=-73"), 97 MapillaryURL.searchSequenceURL(null, -73) 114 assertUrlEquals( 115 MapillaryURL.searchSequenceURL(new Bounds(-55.55555, -66.666666, 77.7777777, 88.88888888, false), 42), 116 "https://a.mapillary.com/v2/search/s/", 117 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 118 "min_lon=-66.666666", 119 "max_lon=88.888889", 120 "min_lat=-55.555550", 121 "max_lat=77.777778", 122 "limit=10", 123 "page=42" 124 ); 125 assertUrlEquals( 126 MapillaryURL.searchSequenceURL(null, -73), 127 "https://a.mapillary.com/v2/search/s/", 128 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 129 "limit=10", 130 "page=-73" 98 131 ); 99 132 } … … 101 134 @Test 102 135 public void testSearchTrafficSignURL() throws MalformedURLException { 103 assertEquals( 104 new URL("https://a.mapillary.com/v2/search/im/or/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&min_lon=2.220000&max_lat=3.333000&max_lon=4.444400&limit=20&page=-42&min_lat=1.100000"), 105 MapillaryURL.searchTrafficSignURL(new Bounds(1.1, 2.22, 3.333, 4.4444), -42) 106 ); 107 assertEquals( 108 new URL("https://a.mapillary.com/v2/search/im/or/?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&limit=20&page=73"), 109 MapillaryURL.searchTrafficSignURL(null, 73) 136 assertUrlEquals( 137 MapillaryURL.searchTrafficSignURL(new Bounds(1.1, 2.22, 3.333, 4.4444), -42), 138 "https://a.mapillary.com/v2/search/im/or/", 139 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 140 "min_lon=2.220000", 141 "max_lon=4.444400", 142 "min_lat=1.100000", 143 "max_lat=3.333000", 144 "limit=20", 145 "page=-42" 146 ); 147 assertUrlEquals( 148 MapillaryURL.searchTrafficSignURL(null, 73), 149 "https://a.mapillary.com/v2/search/im/or/", 150 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz", 151 "limit=20", 152 "page=73" 110 153 ); 111 154 } … … 128 171 129 172 @Test 130 public void testString2URL() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 173 public void testString2MalformedURL() 174 throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 131 175 Method method = MapillaryURL.class.getDeclaredMethod("string2URL", String.class); 132 176 method.setAccessible(true); … … 138 182 TestUtil.testUtilityClass(MapillaryURL.class); 139 183 } 184 185 private void assertUrlEquals(URL actualUrl, String expectedBaseUrl, String... expectedParams) { 186 assertEquals(expectedBaseUrl, actualUrl.toString().substring(0, actualUrl.toString().indexOf('?'))); 187 String[] actualParams = actualUrl.getQuery().split("&"); 188 assertEquals(expectedParams.length, actualParams.length); 189 for (int exIndex = 0; exIndex < expectedParams.length; exIndex++) { 190 boolean parameterIsPresent = false; 191 for (int acIndex = 0; !parameterIsPresent && acIndex < actualParams.length; acIndex++) { 192 parameterIsPresent |= actualParams[acIndex].equals(expectedParams[exIndex]); 193 } 194 assertTrue( 195 expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there." , 196 parameterIsPresent 197 ); 198 } 199 } 140 200 }
Note:
See TracChangeset
for help on using the changeset viewer.