Changeset 29629 in osm for applications


Ignore:
Timestamp:
2013-06-06T13:01:27+02:00 (11 years ago)
Author:
donvip
Message:

[josm_routing] fix #josm8768 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java

    r28138 r29629  
    3838import org.jgrapht.graph.DirectedWeightedMultigraph;
    3939import org.openstreetmap.josm.Main;
     40import org.openstreetmap.josm.data.coor.LatLon;
    4041import org.openstreetmap.josm.data.osm.DataSet;
    4142import org.openstreetmap.josm.data.osm.Node;
     
    241242         */
    242243        private void addEdge(Way way,Node from, Node to) {
    243                 double length = from.getCoor().greatCircleDistance(to.getCoor());
     244            LatLon fromLL = from.getCoor();
     245            LatLon toLL = from.getCoor();
     246            if (fromLL == null || toLL == null) {
     247                return;
     248            }
     249                double length = fromLL.greatCircleDistance(toLL);
    244250
    245251                OsmEdge edge = new OsmEdge(way, from, to);
     
    252258                                + "(from node " + from.getId() + " to node "
    253259                                + to.getId() + ") has weight: " + weight);
    254                 //((GraphDelegator<Node,OsmEdge>) graph).setEdgeWeight(edge, weight);
    255260                ((DirectedWeightedMultigraph<Node,OsmEdge>)graph).setEdgeWeight(edge, weight);
    256261        }
Note: See TracChangeset for help on using the changeset viewer.