Changeset 1602 in osm
- Timestamp:
- 2006-11-19T12:04:49+01:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/josm/plugins/landsat/src/landsat/OSGBImage.java
r1567 r1602 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.data.coor.EastNorth; 12 13 import org.openstreetmap.josm.gui.NavigatableComponent; 14 15 import java.awt.Graphics2D; 16 import java.awt.BasicStroke; 17 import java.awt.Point; 18 import java.awt.Graphics; 19 import java.awt.Color; 13 20 14 21 public class OSGBImage extends WMSImage … … 23 30 { 24 31 // To deal with the fact that grid refs and lat/lon don't align 25 OSRef bottomLeftGR = 26 new LatLng(minlat,minlon).toOSRef(), 27 topRightGR = 28 new LatLng(maxlat,maxlon).toOSRef(), 29 topLeftGR = 30 new LatLng(maxlat,minlon).toOSRef(), 31 bottomRightGR = 32 new LatLng(minlat,maxlon).toOSRef(); 32 LatLng ll1 = new LatLng(minlat,minlon), 33 ll2 = new LatLng(maxlat,maxlon), 34 ll3 = new LatLng(maxlat,minlon), 35 ll4 = new LatLng(minlat,maxlon); 36 37 ll1.toOSGB36(); 38 ll2.toOSGB36(); 39 ll3.toOSGB36(); 40 ll4.toOSGB36(); 41 42 OSRef bottomLeftGR = ll1.toOSRef(), 43 topRightGR = ll2.toOSRef(), 44 topLeftGR = ll3.toOSRef(), 45 bottomRightGR = ll4.toOSRef(); 33 46 34 47 double w = Math.min(bottomLeftGR.getEasting(), … … 45 58 LatLng tl2 = new OSRef(w,n).toLatLng(); 46 59 LatLng br2 = new OSRef(e,s).toLatLng(); 60 tl2.toWGS84(); 61 br2.toWGS84(); 47 62 48 63 topLeft = Main.proj.latlon2eastNorth … … 60 75 { 61 76 URL url = doGetURL(w,s,e,n,widthPx,heightPx); 62 System.out.println("OSGB URL=" + url);63 77 doGrab(url); 64 78 } … … 68 82 } 69 83 } 84 85 public void paint(Graphics g,NavigatableComponent nc) 86 { 87 if(theImage!=null) 88 { 89 super.paint(g,nc); 90 Graphics2D g2d = (Graphics2D)g; 91 g2d.setStroke(new BasicStroke(2)); 92 93 // Display markers at the OSGB intersections. 94 // The code is very convoluted - projections really are fun 95 // things to deal with :-) 96 // Oh well, at least I can let someone else do the maths :-) 97 98 double zoomInFactor = grabbedScale / nc.getScale(); 99 100 EastNorth topLeftDisplaced = 101 new EastNorth(topLeft.east()+dEast, topLeft.north()+dNorth); 102 EastNorth bottomRightDisplaced = 103 new EastNorth(bottomRight.east()+dEast, 104 bottomRight.north()+dNorth); 105 106 LatLon ll5 = Main.proj.eastNorth2latlon(topLeftDisplaced), 107 ll6 = Main.proj.eastNorth2latlon(bottomRightDisplaced); 108 109 LatLng ll7 = new LatLng(ll5.lat(),ll5.lon()); 110 LatLng ll8 = new LatLng(ll6.lat(),ll6.lon()); 111 ll7.toOSGB36(); 112 ll8.toOSGB36(); 113 114 LatLng curLatLng; 115 EastNorth curEN; 116 117 118 OSRef osgb1 = ll7.toOSRef(), 119 osgb2 = ll8.toOSRef(); 120 121 for(int easting=(int)(osgb1.getEasting()/1000) + 1; 122 easting<=(int)(osgb2.getEasting()/1000); 123 easting++) 124 { 125 for (int northing=(int)(osgb1.getNorthing()/1000) ; 126 northing>(int)(osgb2.getNorthing()/1000); 127 northing--) 128 { 129 // Now we have to convert the OSGB eastings and northings 130 // *back* to EastNorth units so we can draw the 131 // intersections.... 132 // Not to mention converting between JOSM LatLon and 133 // JCoord LatLng.... 134 135 136 curLatLng = new OSRef(easting*1000,northing*1000). 137 toLatLng(); 138 curLatLng.toWGS84(); 139 curEN = Main.proj.latlon2eastNorth 140 (new LatLon(curLatLng.getLat(), 141 curLatLng.getLng() ) ); 142 143 // draw a cross at the intersection 144 Point p = Main.map.mapView.getPoint(curEN); 145 g.setColor(Color.BLUE); 146 g.drawLine(p.x-5,p.y,p.x+5,p.y); 147 g.drawLine(p.x,p.y-5,p.x,p.y+5); 148 } 149 } 150 g2d.setStroke(new BasicStroke(1)); 151 } 152 } 70 153 }
Note:
See TracChangeset
for help on using the changeset viewer.