Ignore:
Timestamp:
2011-01-08T13:33:31+01:00 (14 years ago)
Author:
upliner
Message:

make irsrectify compatible with recent JOSM

Location:
applications/editors/josm/plugins/irsrectify
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/irsrectify/build.xml

    r23188 r24997  
    3333    <property name="commit.message" value="New plugin - irsrectify" />
    3434    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    35     <property name="plugin.main.version" value="3000" />
     35    <property name="plugin.main.version" value="3715" />
    3636
    3737
     
    6565    <target name="compile" depends="init">
    6666        <echo message="compiling sources for  ${plugin.jar} ... "/>
    67         <javac srcdir="src" classpath="${josm};../../dist/wmsplugin.jar" debug="true" destdir="${plugin.build.dir}">
     67        <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
    6868            <compilerarg value="-Xlint:deprecation"/>
    6969            <compilerarg value="-Xlint:unchecked"/>
     
    106106                <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
    107107                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    108                 <attribute name="Plugin-Requires" value="wmsplugin"/>
    109108            </manifest>
    110109        </jar>
  • applications/editors/josm/plugins/irsrectify/src/irsrectify/IRSRectifyPlugin.java

    r23070 r24997  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     4
    45import java.awt.event.ActionEvent;
    56import java.awt.event.KeyEvent;
    67import java.text.SimpleDateFormat;
    78import java.util.Date;
     9
    810import javax.swing.JOptionPane;
     11
    912import org.openstreetmap.josm.Main;
    1013import org.openstreetmap.josm.actions.JosmAction;
     
    1417import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    1518import org.openstreetmap.josm.gui.MapFrame;
     19import org.openstreetmap.josm.gui.layer.ImageryLayer;
    1620import org.openstreetmap.josm.gui.layer.Layer;
    1721import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1923import org.openstreetmap.josm.plugins.PluginInformation;
    2024import org.openstreetmap.josm.tools.Shortcut;
    21 import wmsplugin.WMSLayer;
    2225
    2326public class IRSRectifyPlugin extends Plugin {
     
    4548
    4649        public void actionPerformed(ActionEvent e) {
    47             WMSLayer wms = findWMSLayer();
    48             if( wms == null )
     50            ImageryLayer l = findImageryLayer();
     51            if( l == null )
    4952                return;
    5053
    5154            // 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();
    5557            if( dx == 0 && dy == 0 ) {
    5658                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."));
     
    5961            // create an offset way and add to dataset
    6062            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));
    6264            Way way = new Way();
    6365            way.addNode(center);
     
    6769            if( userName != null )
    6870                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"));
    7171
    7272            OsmDataLayer data = findOrCreateDataLayer();
     
    7878        }
    7979
    80         private WMSLayer findWMSLayer() {
     80        private ImageryLayer findImageryLayer() {
    8181            if( frame == null || frame.mapView == null )
    8282                return null;
    8383            for( Layer l : frame.mapView.getAllLayers() )
    84                 if( l instanceof WMSLayer )
    85                     return (WMSLayer)l;
     84                if( l instanceof ImageryLayer )
     85                    return (ImageryLayer)l;
    8686            return null;
    8787        }
     
    120120        @Override
    121121        protected void updateEnabledState() {
    122             setEnabled(findWMSLayer() != null);
     122            setEnabled(findImageryLayer() != null);
    123123        }
    124124    }
Note: See TracChangeset for help on using the changeset viewer.