Changeset 24997 in osm for applications/editors/josm/plugins/irsrectify/src
- Timestamp:
- 2011-01-08T13:33:31+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/irsrectify/src/irsrectify/IRSRectifyPlugin.java
r23070 r24997 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.event.ActionEvent; 5 6 import java.awt.event.KeyEvent; 6 7 import java.text.SimpleDateFormat; 7 8 import java.util.Date; 9 8 10 import javax.swing.JOptionPane; 11 9 12 import org.openstreetmap.josm.Main; 10 13 import org.openstreetmap.josm.actions.JosmAction; … … 14 17 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 15 18 import org.openstreetmap.josm.gui.MapFrame; 19 import org.openstreetmap.josm.gui.layer.ImageryLayer; 16 20 import org.openstreetmap.josm.gui.layer.Layer; 17 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 19 23 import org.openstreetmap.josm.plugins.PluginInformation; 20 24 import org.openstreetmap.josm.tools.Shortcut; 21 import wmsplugin.WMSLayer;22 25 23 26 public class IRSRectifyPlugin extends Plugin { … … 45 48 46 49 public void actionPerformed(ActionEvent e) { 47 WMSLayer wms= findWMSLayer();48 if( wms== null )50 ImageryLayer l = findImageryLayer(); 51 if( l == null ) 49 52 return; 50 53 51 54 // calculate offset from wms layer 52 double ppd = wms.getPPD(); 53 int dx = wms.getImageX(0); 54 int dy = wms.getImageY(0); 55 double dx = l.getDx(); 56 double dy = l.getDy(); 55 57 if( dx == 0 && dy == 0 ) { 56 58 JOptionPane.showMessageDialog(Main.parent, tr("This option creates IRS adjustment layer and a little way inside it. You need to adjust WMS layer placement first.\nResulting layer is to be saved as .osm and sent to Komzpa (me@komzpa.net) with [irs rectify] in subject.")); … … 59 61 // create an offset way and add to dataset 60 62 Node center = new Node(frame.mapView.getCenter()); 61 Node offset = new Node(center.getEastNorth().add(dx /ppd, dy/ppd));63 Node offset = new Node(center.getEastNorth().add(dx, dy)); 62 64 Way way = new Way(); 63 65 way.addNode(center); … … 67 69 if( userName != null ) 68 70 way.put("user", userName); 69 if( Math.abs(dx) < 10 && Math.abs(dy) < 10 )70 way.put("note", tr("Zoom level was not enough to record an offset precisely"));71 71 72 72 OsmDataLayer data = findOrCreateDataLayer(); … … 78 78 } 79 79 80 private WMSLayer findWMSLayer() {80 private ImageryLayer findImageryLayer() { 81 81 if( frame == null || frame.mapView == null ) 82 82 return null; 83 83 for( Layer l : frame.mapView.getAllLayers() ) 84 if( l instanceof WMSLayer )85 return ( WMSLayer)l;84 if( l instanceof ImageryLayer ) 85 return (ImageryLayer)l; 86 86 return null; 87 87 } … … 120 120 @Override 121 121 protected void updateEnabledState() { 122 setEnabled(find WMSLayer() != null);122 setEnabled(findImageryLayer() != null); 123 123 } 124 124 }
Note:
See TracChangeset
for help on using the changeset viewer.