Changeset 6776 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2008-02-04T15:50:57+01:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/DownloadWMSTask.java
r6775 r6776 8 8 import org.openstreetmap.josm.actions.DownloadAction; 9 9 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 10 11 10 import org.openstreetmap.josm.data.Bounds; 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.gui.layer.Layer; 12 13 13 14 public class DownloadWMSTask extends PleaseWaitRunnable { 14 15 15 16 private WMSLayer wmsLayer; 16 private double minlat, minlon, maxlat, maxlon;17 private Bounds bounds; 17 18 18 /* whether our layer was already added. */ 19 private boolean layerAdded = false; 20 21 22 public DownloadWMSTask(String name, String wmsurl) { 23 super(tr("Downloading " + name)); 19 public DownloadWMSTask(WMSLayer wmsLayer, Bounds bounds) { 20 super(tr("Downloading " + wmsLayer.name)); 24 21 25 // simply check if we already have a layer created. if not, create; if yes, reuse. 26 if (wmsLayer == null) { 27 if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){ 28 //then we use the OSGBLayer 29 this.wmsLayer= new OSGBLayer(name, wmsurl); 30 } else { 31 this.wmsLayer = new WMSLayer(name, wmsurl); 32 } 33 } 34 22 this.wmsLayer = wmsLayer; 23 this.bounds = bounds; 35 24 } 36 25 37 26 @Override public void realRun() throws IOException { 38 27 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting WMS Server...")); 39 wmsLayer.grab(minlat,minlon,maxlat,maxlon); 28 wmsLayer.grab( 29 bounds.min.lat(), bounds.min.lon(), 30 bounds.max.lat(), bounds.max.lon()); 40 31 } 41 32 42 @Override protected void finish() { 33 @Override protected void cancel() {} 34 @Override protected void finish() {} 43 35 44 // BUG if layer is deleted, wmsLayer is not null and layerAdded remains true! 45 // FIXED, see below 46 47 layerAdded = false; 48 for (Iterator it = Main.map.mapView.getAllLayers().iterator(); it.hasNext(); ) { 49 Object element = it.next(); 50 if (element.equals(wmsLayer)) layerAdded = true; 36 public static void download(String name, String wmsurl, 37 double minlat, double minlon, double maxlat, double maxlon) { 38 WMSLayer wmsLayer = null; 39 40 // simply check if we already have a layer created. if not, create; if yes, reuse. 41 for (Layer l : Main.main.map.mapView.getAllLayers()) { 42 if (l instanceof WMSLayer && l.name.equals(name)) { 43 wmsLayer = (WMSLayer) l; 44 } 51 45 } 52 53 if ((wmsLayer != null) && (!layerAdded)) 54 { 46 47 if (wmsLayer == null) { 48 if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){ 49 //then we use the OSGBLayer 50 wmsLayer= new OSGBLayer(name, wmsurl); 51 } else { 52 wmsLayer = new WMSLayer(name, wmsurl); 53 } 55 54 Main.main.addLayer(wmsLayer); 56 layerAdded = true; 57 } 58 } 55 } 59 56 60 @Override protected void cancel() { 61 } 62 63 public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) { 64 this.minlat=minlat; 65 this.minlon=minlon; 66 this.maxlat=maxlat; 67 this.maxlon=maxlon; 68 Main.worker.execute(this); 57 Main.worker.execute(new DownloadWMSTask(wmsLayer, 58 new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon)))); 69 59 } 70 60 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Map_Rectifier_WMSmenuAction.java
r6775 r6776 21 21 22 22 } 23 DownloadWMSTask downloadTask;24 23 25 24 public void actionPerformed(ActionEvent e) { … … 42 41 //System.out.println(newURL); 43 42 44 // if (downloadTask == null){45 //System.out.println("new download task!");46 downloadTask = new DownloadWMSTask("rectifier id="+newid, newURL);47 // }48 43 MapView mv = Main.map.mapView; 49 44 50 downloadTask.download(null,45 DownloadWMSTask.download("rectifier id="+newid, newURL, 51 46 mv.getLatLon(0, mv.getHeight()).lat(), 52 47 mv.getLatLon(0, mv.getHeight()).lon(), -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java
r6775 r6776 17 17 18 18 public void actionPerformed(ActionEvent e) { 19 20 // store the download task with the "info" object. if we create a new21 // download task here every time, then different layers are displayed even22 // for images from the same server, and we don't want that.23 19 System.out.println(info.url); 24 if (info.downloadTask == null)25 info.downloadTask = new DownloadWMSTask(info.name, info.url);26 20 27 21 MapView mv = Main.map.mapView; 28 22 29 info.downloadTask.download(null,23 DownloadWMSTask.download(info.name, info.url, 30 24 mv.getLatLon(0, mv.getHeight()).lat(), 31 25 mv.getLatLon(0, mv.getHeight()).lon(), -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java
r6775 r6776 13 13 String url; 14 14 int prefid; 15 DownloadWMSTask downloadTask;16 15 17 16 public WMSInfo(String name, String url, int prefid) { 18 17 this.name=name; this.url=url; this.prefid=prefid; 19 downloadTask = null;20 18 } 21 19 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
r6775 r6776 30 30 static String VERSION = "2.4"; 31 31 32 DownloadWMSTask task;33 32 WMSLayer wmsLayer; 34 33 static JMenu wmsJMenu;
Note:
See TracChangeset
for help on using the changeset viewer.