Ignore:
Timestamp:
2009-08-10T12:58:28+02:00 (15 years ago)
Author:
stoecker
Message:

fixed josm 3045 - patch by dmuecke - NPE - removed deprecated stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/waydownloader/src/WayDownloaderPlugin.java

    r16631 r16962  
    179179        for (Node onNode:Main.main.getCurrentDataSet().nodes) {
    180180            if (!onNode.equals(this.selectedNode)
     181                        && !onNode.incomplete
    181182                    && onNode.getCoor().lat()==selectedNode.getCoor().lat()
    182183                    && onNode.getCoor().lon()==selectedNode.getCoor().lon()) {
     
    189190    /** Given the the node on one end of the way, return the node on the other end */
    190191    private Node findOtherEnd(Way way, Node firstEnd) {
    191         Node otherEnd = way.nodes.get(0);
    192         if (otherEnd.equals(firstEnd)) otherEnd = way.nodes.get(way.nodes.size()-1);
     192        Node otherEnd = way.firstNode();
     193        if (otherEnd.equals(firstEnd)) otherEnd = way.lastNode();
    193194        return otherEnd;
    194195    }
     
    200201        //loop through every way
    201202        for (Way onWay:Main.main.getCurrentDataSet().ways) {
    202             Object[] nodes = onWay.nodes.toArray();
    203             if (nodes.length<2) {
    204                 //Should never happen should it? TODO: investigate. For the moment ignore these
    205                 System.err.println("WayDownloader plugin encountered a way with " + nodes.length + " nodes :" + onWay.toString());
    206             } else {
    207                 Node firstNode = (Node) nodes[0];
    208                 Node lastNode = (Node) nodes[nodes.length-1];
    209 
    210                 if (firstNode.equals(selectedNode) || lastNode.equals(selectedNode)) {
     203            if (onWay.getNodesCount() >= 2) {
     204                if (onWay.isFirstLastNode(selectedNode)) {
    211205                    //Found it
    212206                    connectedWays.add(onWay);
     
    228222        } else {
    229223            Way selectedWay = (Way) selection.toArray()[0];
    230             selectedNode = selectedWay.nodes.get(0);
     224            selectedNode = selectedWay.firstNode();
    231225
    232226            if (isDownloaded(selectedNode)) {
Note: See TracChangeset for help on using the changeset viewer.