Changeset 7909 in josm for trunk


Ignore:
Timestamp:
2014-12-29T22:16:57+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #10899 - robustness to nodes without coordinates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r7817 r7909  
    4040import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    4141import org.openstreetmap.josm.data.SelectionChangedListener;
     42import org.openstreetmap.josm.data.coor.LatLon;
    4243import org.openstreetmap.josm.data.osm.Node;
    4344import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    611612                        if (selection.size() == 2) {
    612613                            Iterator<? extends OsmPrimitive> it = selection.iterator();
    613                             OsmPrimitive n1 = it.next(), n2=it.next();
    614                             // show distance between two selected nodes
     614                            OsmPrimitive n1 = it.next();
     615                            OsmPrimitive n2 = it.next();
     616                            // show distance between two selected nodes with coordinates
    615617                            if (n1 instanceof Node && n2 instanceof Node) {
    616                                 double d = ((Node) n1).getCoor().greatCircleDistance(((Node) n2).getCoor());
    617                                 Main.map.statusLine.setDist(d);
    618                                 return;
     618                                LatLon c1 = ((Node) n1).getCoor();
     619                                LatLon c2 = ((Node) n2).getCoor();
     620                                if (c1 != null && c2 != null) {
     621                                    Main.map.statusLine.setDist(c1.greatCircleDistance(c2));
     622                                    return;
     623                                }
    619624                            }
    620625                        }
    621                         Main.map.statusLine.setDist(new SubclassFilteredCollection<OsmPrimitive, Way>(selection, OsmPrimitive.wayPredicate));
     626                        Main.map.statusLine.setDist(
     627                                new SubclassFilteredCollection<OsmPrimitive, Way>(selection, OsmPrimitive.wayPredicate));
    622628                    }
    623629                }
Note: See TracChangeset for help on using the changeset viewer.