Changeset 3747 in josm for trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
- Timestamp:
- 2010-12-27T19:40:35+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
r3720 r3747 27 27 import org.openstreetmap.josm.data.coor.EastNorth; 28 28 import org.openstreetmap.josm.data.coor.LatLon; 29 import org.openstreetmap.josm.data.imagery.GeorefImage.State; 29 30 import org.openstreetmap.josm.data.imagery.ImageryInfo; 30 import org.openstreetmap.josm.data.imagery.GeorefImage.State;31 31 import org.openstreetmap.josm.data.projection.Mercator; 32 32 import org.openstreetmap.josm.gui.MapView; 33 33 import org.openstreetmap.josm.gui.layer.WMSLayer; 34 import org.openstreetmap.josm.io.CacheFiles;35 34 import org.openstreetmap.josm.io.OsmTransferException; 36 35 import org.openstreetmap.josm.io.ProgressInputStream; … … 42 41 private final boolean urlWithPatterns; 43 42 44 public WMSGrabber(MapView mv, WMSLayer layer , CacheFiles cache) {45 super(mv, layer , cache);43 public WMSGrabber(MapView mv, WMSLayer layer) { 44 super(mv, layer); 46 45 this.baseURL = layer.getInfo().getURL(); 47 46 /* URL containing placeholders? */ … … 50 49 51 50 @Override 52 void fetch(WMSRequest request ) throws Exception{51 void fetch(WMSRequest request, int attempt) throws Exception{ 53 52 URL url = null; 54 53 try { … … 57 56 b.max.east(), b.max.north(), 58 57 width(), height()); 59 request.finish(State.IMAGE, grab(url ));58 request.finish(State.IMAGE, grab(url, attempt)); 60 59 61 60 } catch(Exception e) { … … 165 164 } 166 165 167 protected BufferedImage grab(URL url ) throws IOException, OsmTransferException {168 System.out.println("Grabbing WMS " + url);166 protected BufferedImage grab(URL url, int attempt) throws IOException, OsmTransferException { 167 System.out.println("Grabbing WMS " + (attempt > 1? "(attempt " + attempt + ") ":"") + url); 169 168 170 169 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); … … 193 192 InputStream in = conn.getInputStream(); 194 193 BufferedReader br = new BufferedReader(new InputStreamReader(in)); 195 196 String line = null; 197 while( (line = br.readLine()) != null) { 198 // filter non-ASCII characters and control characters 199 exception.append(line.replaceAll("[^\\p{Print}]", "")); 200 exception.append('\n'); 201 } 202 return exception.toString(); 194 try { 195 String line = null; 196 while( (line = br.readLine()) != null) { 197 // filter non-ASCII characters and control characters 198 exception.append(line.replaceAll("[^\\p{Print}]", "")); 199 exception.append('\n'); 200 } 201 return exception.toString(); 202 } finally { 203 br.close(); 204 } 203 205 } 204 206 }
Note:
See TracChangeset
for help on using the changeset viewer.