Changeset 1553 in osm for utils/josm/plugins/landsat
- Timestamp:
- 2006-11-07T23:33:22+01:00 (18 years ago)
- Location:
- utils/josm/plugins/landsat
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/josm/plugins/landsat/src/landsat/DownloadLandsatTask.java
r1477 r1553 18 18 private JCheckBox checkBox = new JCheckBox(tr("Landsat background images")); 19 19 20 public DownloadLandsatTask() { 20 public DownloadLandsatTask(LandsatLayer landsatLayer) { 21 21 super(tr("Downloading data")); 22 landsatLayer = new LandsatLayer 23 ("http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+ 24 "layers=global_mosaic&styles=&srs=EPSG:4326&"+ 25 "format=image/jpeg"); 22 this.landsatLayer = landsatLayer; 26 23 } 27 24 -
utils/josm/plugins/landsat/src/landsat/LandsatImage.java
r1436 r1553 21 21 Image theImage; 22 22 double grabbedScale; 23 EastNorth topLeft; 23 EastNorth topLeft, bottomRight; 24 double dEast, dNorth; 25 double minLat,minLon,maxLat,maxLon; 24 26 25 27 public LandsatImage(String constURL) … … 56 58 57 59 topLeft = Main.proj.latlon2eastNorth(new LatLon(maxlat,minlon)); 58 EastNorthbottomRight = Main.proj.latlon2eastNorth60 bottomRight = Main.proj.latlon2eastNorth 59 61 (new LatLon(minlat,maxlon)); 60 62 … … 67 69 URL url = doGetURL(p,p2,widthPx,heightPx); 68 70 doGrab(url); 71 this.minLat=minlat; 72 this.minLon=minlon; 73 this.maxLat=maxlat; 74 this.maxLon=maxlon; 69 75 } 70 76 catch(MalformedURLException e) … … 72 78 System.out.println("Illegal url. Error="+e); 73 79 } 74 80 } 75 81 76 82 private URL getURL(NavigatableComponent nc) throws MalformedURLException … … 103 109 } 104 110 105 public void paint(Graphics g,NavigatableComponent nc) /*,EastNorth bottomLeft, 106 int x1, int y1, int x2, int y2) */ 111 public void displace (double dEast, double dNorth) 112 { 113 this.dEast += dEast; 114 this.dNorth += dNorth; 115 } 116 117 public boolean contains(EastNorth eastNorth) 118 { 119 double e1 = topLeft.east()+dEast, 120 e2 = bottomRight.east()+dEast, 121 n1 = bottomRight.north()+dNorth, 122 n2 = topLeft.north()+dNorth; 123 124 boolean b = eastNorth.east()>=e1 && eastNorth.east()<=e2 && 125 eastNorth.north()>=n1 && eastNorth.north()<=n2; 126 return b; 127 } 128 129 public void paint(Graphics g,NavigatableComponent nc) 107 130 { 108 131 if(theImage!=null) 109 132 { 110 /*111 System.out.println("x1="+x1+" y1="+y1+" x2="+x2+" y2="+y2+112 " img w="+theImage.getWidth(null) +113 " img h="+theImage.getHeight(null)) ;114 */115 133 double zoomInFactor = grabbedScale / nc.getScale(); 116 134 … … 119 137 // grabbed scale in EastNorth/pixel. 120 138 121 /*122 double ix = (bottomLeft.east()-this.bottomLeft.east())/grabbedScale,123 iy = theImage.getHeight(null) -124 ((bottomLeft.north() - this.bottomLeft.north())/grabbedScale);125 126 g.drawImage(theImage,x1,y1,x2,y2,(int)ix,(int)iy,127 (int)(ix+((x2-x1)/zoomInFactor)),128 (int)(iy+((y2-y1)/zoomInFactor)), null);129 */130 139 int w = theImage.getWidth(null), h=theImage.getHeight(null); 131 Point p = nc.getPoint(topLeft); 132 /* 133 System.out.println("topleft: e=" + topLeft.east() + " n="+ 134 topLeft.north()); 135 System.out.println("Drawing at "+p.x+","+p.y); 136 */ 137 g.drawImage(theImage,p.x,p.y, 138 (int)(p.x+w*zoomInFactor), 139 (int)(p.y+h*zoomInFactor), 140 EastNorth topLeftDisplaced = 141 new EastNorth(topLeft.east()+dEast, topLeft.north()+dNorth); 142 Point displacement = Main.map.mapView.getPoint(topLeftDisplaced); 143 g.drawImage(theImage,displacement.x,displacement.y, 144 (int)(displacement.x+w*zoomInFactor), 145 (int)(displacement.y+h*zoomInFactor), 140 146 0,0,w,h,null); 141 147 } 142 148 } 149 143 150 } -
utils/josm/plugins/landsat/src/landsat/LandsatLayer.java
r1443 r1553 7 7 import java.awt.Toolkit; 8 8 import java.io.IOException; 9 import java.util.ArrayList; 9 10 10 11 import javax.swing.Icon; … … 20 21 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 21 22 import org.openstreetmap.josm.gui.layer.Layer; 23 import org.openstreetmap.josm.data.coor.EastNorth; 22 24 23 25 /** … … 29 31 private static Icon icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(LandsatPlugin.class.getResource("/images/wms.png"))); 30 32 31 private final LandsatImage landsatImage; 33 private final ArrayList<LandsatImage> landsatImages; 32 34 33 35 private final String url; … … 47 49 48 50 this.url = url; 49 landsatImage = new LandsatImage(url); 51 //landsatImage = new LandsatImage(url); 52 landsatImages = new ArrayList<LandsatImage>(); 50 53 } 51 54 … … 53 56 { 54 57 MapView mv = Main.map.mapView; 58 LandsatImage landsatImage = new LandsatImage(url); 55 59 landsatImage.grab(mv); 60 landsatImages.add(landsatImage); 56 61 } 57 62 … … 60 65 { 61 66 MapView mv = Main.map.mapView; 67 LandsatImage landsatImage = new LandsatImage(url); 62 68 landsatImage.grab(mv,minlat,minlon,maxlat,maxlon); 69 landsatImages.add(landsatImage); 63 70 } 64 71 … … 79 86 80 87 @Override public void paint(Graphics g, final MapView mv) { 81 landsatImage.paint(g,mv); 88 for(LandsatImage landsatImage : landsatImages) { 89 landsatImage.paint(g,mv); 90 } 82 91 } 83 92 … … 97 106 new JMenuItem(new LayerListPopup.InfoAction(this))}; 98 107 } 108 109 public LandsatImage findImage(EastNorth eastNorth) 110 { 111 for(LandsatImage landsatImage : landsatImages) { 112 if (landsatImage.contains(eastNorth)) { 113 return landsatImage; 114 } 115 } 116 return null; 117 } 99 118 } -
utils/josm/plugins/landsat/src/landsat/LandsatPlugin.java
r1477 r1553 4 4 import org.openstreetmap.josm.plugins.Plugin; 5 5 import org.openstreetmap.josm.gui.MapFrame; 6 import org.openstreetmap.josm.gui.IconToggleButton; 6 7 7 8 // NW 151006 only add the landsat task when the map frame is initialised with … … 11 12 12 13 DownloadLandsatTask task; 14 LandsatLayer landsatLayer; 15 boolean addedAction; 13 16 14 17 public LandsatPlugin() { 15 task = new DownloadLandsatTask(); 18 landsatLayer = new LandsatLayer 19 ("http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+ 20 "layers=global_mosaic&styles=&srs=EPSG:4326&"+ 21 "format=image/jpeg"); 22 task = new DownloadLandsatTask(landsatLayer); 16 23 task.setEnabled(false); 17 24 Main.main.menu.download.downloadTasks.add(task); 25 18 26 } 19 27 20 28 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 29 if(!addedAction) { 30 Main.map.toolBarActions.addSeparator(); 31 Main.map.toolBarActions.add(new IconToggleButton 32 (new LandsatAdjustAction(Main.map))); 33 addedAction=true; 34 } 21 35 if(oldFrame==null && newFrame!=null) { 22 36 task.setEnabled(true);
Note:
See TracChangeset
for help on using the changeset viewer.