source: osm/applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSTask.java@ 13497

Last change on this file since 13497 was 13497, checked in by skela, 16 years ago

applications/editors/josm: Set svn:eol-style native on all *.java files
in plugins. Normalize the eol-style in
plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java.

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1package cadastre_fr;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.io.IOException;
6import org.openstreetmap.josm.Main;
7import org.openstreetmap.josm.gui.PleaseWaitRunnable;
8import org.openstreetmap.josm.gui.MapView;
9import org.openstreetmap.josm.data.Bounds;
10
11public class DownloadWMSTask extends PleaseWaitRunnable {
12
13 private WMSLayer wmsLayer;
14
15 private Bounds bounds;
16
17 private CadastreGrabber grabber = CadastrePlugin.cadastreGrabber;
18
19 public DownloadWMSTask(WMSLayer wmsLayer, Bounds bounds) {
20 super(tr("Downloading {0}", wmsLayer.name));
21
22 this.wmsLayer = wmsLayer;
23 this.bounds = bounds;
24 }
25
26 @Override
27 public void realRun() throws IOException {
28 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting WMS Server..."));
29 try {
30 if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
31 if (wmsLayer.images.isEmpty()) {
32 // first time we grab an image for this layer
33 if (CacheControl.cacheEnabled) {
34 if (wmsLayer.getCacheControl().loadCacheIfExist()) {
35 Main.map.mapView.repaint();
36 return;
37 }
38 }
39 if (wmsLayer.isRaster())
40 // set raster image commune bounding box based on current view (before adjustment)
41 wmsLayer.setRasterBounds(bounds);
42 else
43 // set vectorized commune bounding box by opening the standard web window
44 wmsLayer.setCommuneBBox( grabber.getWmsInterface().retrieveCommuneBBox());
45 }
46 // grab new images from wms server into active layer
47 wmsLayer.grab(grabber, bounds);
48 }
49 } catch (DuplicateLayerException e) {
50 // we tried to grab onto a duplicated layer (removed)
51 System.err.println("removed a duplicated layer");
52 }
53 }
54
55 @Override
56 protected void cancel() {
57 grabber.getWmsInterface().cancel();
58 }
59
60 @Override
61 protected void finish() {
62 //wmsLayer.saveToCache();
63 }
64
65 public static void download(WMSLayer wmsLayer) {
66 MapView mv = Main.map.mapView;
67 Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0));
68
69 Main.worker.execute(new DownloadWMSTask(wmsLayer, bounds));
70
71 }
72}
Note: See TracBrowser for help on using the repository browser.