Changeset 6780 in osm for applications/editors/josm
- Timestamp:
- 2008-02-06T16:45:02+01:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/DownloadWMSTask.java
r6777 r6780 35 35 @Override protected void finish() {} 36 36 37 public static void download(String name, String wmsurl, 38 Bounds b, double pixelPerDegree) { 39 WMSLayer wmsLayer = null; 40 41 // simply check if we already have a layer created. if not, create; if yes, reuse. 42 for (Layer l : Main.main.map.mapView.getAllLayers()) { 43 if (l instanceof WMSLayer && l.name.equals(name)) { 44 wmsLayer = (WMSLayer) l; 45 } 46 } 47 48 // FIXME: move this to WMSPlugin/WMSInfo/preferences. 49 if (wmsLayer == null) { 50 if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){ 51 wmsLayer = new WMSLayer(name, new OSGBGrabber(wmsurl)); 52 } else { 53 wmsLayer = new WMSLayer(name, new WMSGrabber(wmsurl)); 54 } 55 Main.main.addLayer(wmsLayer); 56 } 57 58 Main.worker.execute(new DownloadWMSTask(wmsLayer, b, pixelPerDegree)); 59 } 60 61 public static void download(String name, String wmsurl) { 37 public static void download(WMSLayer wmsLayer) { 62 38 MapView mv = Main.map.mapView; 63 39 … … 66 42 mv.getLatLon(mv.getWidth(), 0)); 67 43 68 download(name, wmsurl, b, mv.getWidth() / (b.max.lon() - b.min.lon())); 44 Main.worker.execute(new DownloadWMSTask(wmsLayer, b, 45 mv.getWidth() / (b.max.lon() - b.min.lon()))); 69 46 } 70 47 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java
r6777 r6780 6 6 import org.openstreetmap.josm.actions.JosmAction; 7 7 import org.openstreetmap.josm.gui.MapView; 8 import org.openstreetmap.josm.gui.layer.Layer; 8 9 9 10 public class WMSDownloadAction extends JosmAction { … … 19 20 System.out.println(info.url); 20 21 21 MapView mv = Main.map.mapView; 22 23 DownloadWMSTask.download(info.name, info.url); 22 DownloadWMSTask.download(getLayer(info)); 23 } 24 25 public static WMSLayer getLayer(WMSInfo info) { 26 // simply check if we already have a layer created. if not, create; if yes, reuse. 27 for (Layer l : Main.main.map.mapView.getAllLayers()) { 28 if (l instanceof WMSLayer && l.name.equals(info.name)) { 29 return (WMSLayer) l; 30 } 31 } 32 33 // FIXME: move this to WMSPlugin/WMSInfo/preferences. 34 WMSLayer wmsLayer = new WMSLayer(info.name, info.grabber); 35 Main.main.addLayer(wmsLayer); 36 return wmsLayer; 24 37 } 25 38 }; -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java
r6776 r6780 12 12 String name; 13 13 String url; 14 Grabber grabber; 14 15 int prefid; 15 16 17 public WMSInfo(String name, String url, Grabber grabber, int prefid) { 18 this.name=name; this.url=url; this.prefid=prefid; 19 this.grabber = grabber; 20 } 21 16 22 public WMSInfo(String name, String url, int prefid) { 17 this .name=name; this.url=url; this.prefid=prefid;23 this(name, url, WMSPlugin.getGrabber(url), prefid); 18 24 } 19 25 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
r6776 r6780 120 120 setEnabledAll(false); 121 121 } 122 123 public static Grabber getGrabber(String wmsurl) { 124 if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){ 125 return new OSGBGrabber(wmsurl); 126 } else { 127 return new WMSGrabber(wmsurl); 128 } 129 } 122 130 123 131 private static void setEnabledAll(boolean isEnabled) {
Note:
See TracChangeset
for help on using the changeset viewer.