Changeset 27491 in osm
- Timestamp:
- 2012-01-19T18:48:10+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r27483 r27491 4 4 5 5 import java.awt.Image; 6 import java.io.BufferedReader;7 import java.io.ByteArrayInputStream;8 6 import java.io.IOException; 9 import java.io. InputStreamReader;7 import java.io.StringReader; 10 8 import java.net.URL; 11 9 import java.util.ArrayList; 12 10 import java.util.List; 13 11 import java.util.Locale; 12 import java.util.Scanner; 14 13 import java.util.concurrent.Callable; 15 14 import java.util.concurrent.Executors; … … 63 62 URL u = new URL("http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?include=ImageryProviders&output=xml&key=" 64 63 + API_KEY); 65 BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream())); 66 StringBuilder content = new StringBuilder(1<<15 /* represents 32k */); 67 String line; 68 while ((line = in.readLine()) != null) { 69 content.append(line); 70 } 71 in.close(); 64 UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8"); 65 String r = new Scanner(in).useDelimiter("\\A").next(); 72 66 System.out.println("Successfully loaded Bing attribution data."); 73 return content.toString().getBytes();67 return r.getBytes("utf-8"); 74 68 } 75 69 } … … 99 93 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 100 94 DocumentBuilder builder = factory.newDocumentBuilder(); 101 Document document = builder.parse(new InputSource( 102 UTFInputStreamReader.create(new ByteArrayInputStream(xml.getBytes()), "UTF-8"))); 95 Document document = builder.parse(new InputSource(new StringReader(xml))); 103 96 104 97 XPathFactory xPathFactory = XPathFactory.newInstance(); … … 228 221 Thread.sleep(waitTimeSec * 1000L); 229 222 waitTimeSec *= 2; 223 ex.printStackTrace(); 230 224 } 231 225 } … … 236 230 final List<Attribution> data; 237 231 try { 238 data = attributions.get(100, TimeUnit.MILLISECONDS); 232 data = attributions.get(1000, TimeUnit.MILLISECONDS); 239 233 } catch (TimeoutException ex) { 240 234 return "Loading Bing attribution data...";
Note:
See TracChangeset
for help on using the changeset viewer.