Changeset 31165 in osm for applications/editors/josm/plugins
- Timestamp:
- 2015-05-31T17:30:53+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31158 r31165 6 6 import java.io.InputStreamReader; 7 7 8 import org.json.JSONException;9 import org.json.JSONObject;10 import org.json.JSONArray;8 import javax.json.JsonArray; 9 import javax.json.JsonObject; 10 import javax.json.Json; 11 11 12 12 import java.util.ArrayList; … … 46 46 br = new BufferedReader(new InputStreamReader( 47 47 new URL(url).openStream())); 48 String jsonLine = "";49 while (br.ready()) {50 jsonLine += br.readLine();51 }52 J SONObject jsonall = new JSONObject(jsonLine);48 /* 49 * String jsonLine = ""; while (br.ready()) { jsonLine += 50 * br.readLine(); } 51 */ 52 JsonObject jsonall = Json.createReader(br).readObject(); 53 53 54 54 if (!jsonall.getBoolean("more") && !ex.isShutdown()) { 55 55 ex.shutdownNow(); 56 56 } 57 J SONArray jsonseq = jsonall.getJSONArray("ss");58 for (int i = 0; i < jsonseq. length(); i++) {59 J SONObject jsonobj = jsonseq.getJSONObject(i);60 J SONArray cas = jsonobj.getJSONArray("cas");61 J SONArray coords = jsonobj.getJSONArray("coords");62 J SONArray keys = jsonobj.getJSONArray("keys");57 JsonArray jsonseq = jsonall.getJsonArray("ss"); 58 for (int i = 0; i < jsonseq.size(); i++) { 59 JsonObject jsonobj = jsonseq.getJsonObject(i); 60 JsonArray cas = jsonobj.getJsonArray("cas"); 61 JsonArray coords = jsonobj.getJsonArray("coords"); 62 JsonArray keys = jsonobj.getJsonArray("keys"); 63 63 ArrayList<MapillaryImage> images = new ArrayList<>(); 64 for (int j = 0; j < cas. length(); j++) {64 for (int j = 0; j < cas.size(); j++) { 65 65 try { 66 images.add(new MapillaryImage(keys.getString(j), coords 67 .getJSONArray(j).getDouble(1), coords 68 .getJSONArray(j).getDouble(0), cas.getDouble(j))); 66 images.add(new MapillaryImage(keys.getString(j), 67 coords.getJsonArray(j).getJsonNumber(1) 68 .doubleValue(), coords.getJsonArray(j) 69 .getJsonNumber(0).doubleValue(), cas 70 .getJsonNumber(j).doubleValue())); 69 71 } catch (Exception e) { 70 72 // Mapillary service bug here 71 // System.out.println(cas.length());72 // System.out.println(coords.length());73 // System.out.println(keys.length());73 // System.out.println(cas.length()); 74 // System.out.println(coords.length()); 75 // System.out.println(keys.length()); 74 76 System.out.println(e); 75 77 } … … 79 81 int last = -1; 80 82 int pos = 0; 81 83 82 84 // Here it gets only those images which are in the downloaded 83 85 // area. … … 104 106 sequence.add(finalImages); 105 107 } 106 } catch (IOException | JSONExceptione) {108 } catch (IOException e) { 107 109 return; 108 110 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31158 r31165 2 2 3 3 import java.util.concurrent.ThreadPoolExecutor; 4 import static org.openstreetmap.josm.tools.I18n.tr;5 4 import java.util.concurrent.TimeUnit; 6 5 import java.util.concurrent.ArrayBlockingQueue; … … 34 33 35 34 public void run() { 36 /*37 * ThreadPoolExecutor ex = new ThreadPoolExecutor(30, 35, 25,38 * TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20));39 * ArrayList<JSONArray> ret = new ArrayList<JSONArray>(); int page = 0;40 * while (!ex.isShutdown()) { ex.execute(new41 * MapillarySquareDownloadThread(ex, this.data, urlImages + "&page=" +42 * page + "&limit=25")); try { if (ex.getQueue().peek() != null)43 * Thread.sleep(1000); } catch(Exception e){ System.out.println(e); }44 * page++; }45 */46 System.out.println(tr("INFORMATION: GET") + urlSequences);47 35 fullfillSequences(); 48 36 return; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java
r31158 r31165 5 5 import java.io.InputStreamReader; 6 6 7 import org.json.JSONObject; 8 import org.json.JSONArray; 7 import javax.json.JsonArray; 8 import javax.json.JsonObject; 9 import javax.json.Json; 9 10 10 11 import java.util.ArrayList; … … 31 32 br = new BufferedReader(new InputStreamReader( 32 33 new URL(url).openStream())); 33 String jsonLine = "";34 /*String jsonLine = ""; 34 35 while (br.ready()) { 35 36 jsonLine += br.readLine(); 36 } 37 J SONObject jsonobj = new JSONObject(jsonLine);37 }*/ 38 JsonObject jsonobj = Json.createReader(br).readObject(); 38 39 if (!jsonobj.getBoolean("more")) { 39 40 ex.shutdownNow(); 40 41 } 41 J SONArray jsonarr = jsonobj.getJSONArray("ims");42 JsonArray jsonarr = jsonobj.getJsonArray("ims"); 42 43 ArrayList<MapillaryImage> images = new ArrayList<>(); 43 J SONObject image;44 for (int i = 0; i < jsonarr. length(); i++) {44 JsonObject image; 45 for (int i = 0; i < jsonarr.size(); i++) { 45 46 try { 46 image = jsonarr.getJ SONObject(i);47 image = jsonarr.getJsonObject(i); 47 48 images.add(new MapillaryImage(image.getString("key"), image 48 .getDouble("lat"), image.getDouble("lon"), image 49 .getDouble("ca"))); 49 .getJsonNumber("lat") 50 .doubleValue(), image.getJsonNumber("lon").doubleValue(), image 51 .getJsonNumber("ca").doubleValue())); 50 52 } catch (Exception e) { 51 53 System.out.println(e);
Note:
See TracChangeset
for help on using the changeset viewer.