Changeset 5713 in josm for trunk


Ignore:
Timestamp:
2013-02-12T23:31:18+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #8403 - Show combined length of selected ways in status bar (up to 250 ways to prevent potential performance issue)

File:
1 edited

Legend:

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

    r5360 r5713  
    7474import org.openstreetmap.josm.tools.InputMapUtils;
    7575import org.openstreetmap.josm.tools.Shortcut;
     76import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    7677
    7778/**
     
    590591            remember(selection);
    591592            double dist = -1;
    592             if(this.selection.size() == 1) {
    593                 OsmPrimitive o = this.selection.get(0);
    594                 if(o instanceof Way)
    595                    dist = ((Way)o).getLength();
     593            SubclassFilteredCollection<OsmPrimitive, Way> ways = new SubclassFilteredCollection<OsmPrimitive, Way>(selection, OsmPrimitive.wayPredicate);
     594            // Compute total length of selected way(s) until an arbitrary limit set to 250 ways
     595            // in order to prevent performance issue if a large number of ways are selected (old behaviour kept in that case, see #8403)
     596            if (!ways.isEmpty() && ways.size() < 250) {
     597                for (Way w : ways) {
     598                    dist += w.getLength();
     599                }
    596600            }
    597601            Main.map.statusLine.setDist(dist);
Note: See TracChangeset for help on using the changeset viewer.