Changeset 26489 in osm for applications/editors/josm/plugins/piclayer/src/org/openstreetmap
- Timestamp:
- 2011-08-08T17:37:37+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java
r26487 r26489 25 25 import java.awt.Color; 26 26 import java.awt.Component; 27 import java.awt.Graphics;28 27 import java.awt.Graphics2D; 29 28 import java.awt.Image; 30 29 import java.awt.Toolkit; 31 30 import java.awt.event.ActionEvent; 32 import java.awt.image.BufferedImage;33 31 import java.io.File; 34 32 import java.io.FileInputStream; 35 import java.io.FileNotFoundException;36 import java.io.FileOutputStream;37 33 import java.io.IOException; 38 34 import java.util.List; … … 49 45 import org.openstreetmap.josm.data.Bounds; 50 46 import org.openstreetmap.josm.data.coor.EastNorth; 47 import org.openstreetmap.josm.data.coor.LatLon; 51 48 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 52 49 import org.openstreetmap.josm.gui.MapView; … … 202 199 EastNorth center = Main.map.mapView.getCenter(); 203 200 EastNorth leftop = Main.map.mapView.getEastNorth( 0, 0 ); 201 // Number of pixels for one unit in east north space. 202 // This is the same in x- and y- direction. 204 203 double pixel_per_en = ( Main.map.mapView.getWidth() / 2.0 ) / ( center.east() - leftop.east() ); 205 204 … … 208 207 double pic_offset_y = (( leftop.north() - m_position.north() ) * pixel_per_en); 209 208 210 // Let's use Graphics 2D211 209 Graphics2D g = (Graphics2D)g2.create(); 212 210 // Move … … 215 213 g.rotate( m_angle * Math.PI / 180.0 ); 216 214 // Scale 217 double scalex = m_scalex * m_initial_scale / Main.map.mapView.getDist100Pixel();218 double scaley = m_scaley * m_initial_scale / Main.map.mapView.getDist100Pixel();215 double scalex = m_scalex * m_initial_scale * pixel_per_en / getMetersPerEasting(m_position) / 100; 216 double scaley = m_scaley * m_initial_scale * pixel_per_en / getMetersPerNorthing(m_position) / 100; 219 217 g.scale( scalex, scaley ); 220 218 // Shear … … 239 237 } 240 238 } 241 239 240 /** 241 * Returns the distance in meter, that corresponds to one unit in east north 242 * space. For normal projections, it is about 1 (but usually changing with 243 * latitude). 244 * For EPSG:4326, it is the distance from one meridian of full degree to the 245 * next (a couple of kilometers). 246 */ 247 private double getMetersPerEasting(EastNorth en) { 248 /* Natural scale in east/north units per pixel. 249 * This means, the projection should be able to handle 250 * a shift of that size in east north space without 251 * going out of bounds. 252 * 253 * Also, this should get us somewhere in the range of meters, 254 * so we get the result at the point 'en' and not some average. 255 */ 256 double naturalScale = Main.getProjection().getDefaultZoomInPPD(); 257 naturalScale *= 0.01; // make a little smaller 258 259 LatLon ll1 = Main.getProjection().eastNorth2latlon( 260 new EastNorth(en.east() - naturalScale, en.north())); 261 LatLon ll2 = Main.getProjection().eastNorth2latlon( 262 new EastNorth(en.east() + naturalScale, en.north())); 263 264 double dist = ll1.greatCircleDistance(ll2) / naturalScale / 2; 265 return dist; 266 } 267 268 /* see getMetersPerEasting */ 269 private double getMetersPerNorthing(EastNorth en) { 270 double naturalScale = Main.getProjection().getDefaultZoomInPPD(); 271 naturalScale *= 0.01; 272 273 LatLon ll1 = Main.getProjection().eastNorth2latlon( 274 new EastNorth(en.east(), en.north()- naturalScale)); 275 LatLon ll2 = Main.getProjection().eastNorth2latlon( 276 new EastNorth(en.east(), en.north() + naturalScale)); 277 278 double dist = ll1.greatCircleDistance(ll2) / naturalScale / 2; 279 return dist; 280 } 281 242 282 /** 243 283 * Moves the picture. Scaled in EastNorth... -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
r26487 r26489 62 62 super(info); 63 63 64 System.err.println("hi there!");65 64 // Create menu entry 66 65 if ( Main.main.menu != null ) {
Note:
See TracChangeset
for help on using the changeset viewer.