Skip to content

Commit

Permalink
Fix #23830: Slow selection when there is a lot of data
Browse files Browse the repository at this point in the history
We were previously iterating through all nodes and ways when making a selection.
We don't have to do that since we have a way to efficiently find objects in a
bbox.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19167 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Aug 5, 2024
1 parent 8e373fc commit 873c9a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/org/openstreetmap/josm/gui/SelectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.openstreetmap.josm.actions.SelectByInternalPointAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.osm.BBox;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
Expand Down Expand Up @@ -382,15 +383,16 @@ public Collection<OsmPrimitive> getSelectedObjects(boolean alt) {
selection.add(osm);
}
} else if (ds != null) {
final BBox bbox = nc.getLatLonBounds(bounding).toBBox();
// nodes
for (Node n : ds.getNodes()) {
for (Node n : ds.searchNodes(bbox)) {
if (n.isSelectable() && selectionResult.contains(nc.getPoint2D(n))) {
selection.add(n);
}
}

// ways
for (Way w : ds.getWays()) {
for (Way w : ds.searchWays(bbox)) {
if (!w.isSelectable() || w.isEmpty()) {
continue;
}
Expand Down

0 comments on commit 873c9a2

Please sign in to comment.