Modify

Opened 9 months ago

Closed 9 months ago

#23830 closed defect (fixed)

[PATCH] Slow selection when there is a lot of data

Reported by: taylor.smock Owned by: team
Priority: normal Milestone: 24.08
Component: Core Version:
Keywords: Cc:

Description

It turns out that SelectionManager iterates through all nodes and all ways when we are making a selection.

This is not ideal when working with large datasets.

  • src/org/openstreetmap/josm/gui/SelectionManager.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/SelectionManager.java b/src/org/openstreetmap/josm/gui/SelectionManager.java
    a b  
    1919
    2020import org.openstreetmap.josm.actions.SelectByInternalPointAction;
    2121import org.openstreetmap.josm.data.Bounds;
     22import org.openstreetmap.josm.data.osm.BBox;
    2223import org.openstreetmap.josm.data.osm.DataSet;
    2324import org.openstreetmap.josm.data.osm.Node;
    2425import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    382383                selection.add(osm);
    383384            }
    384385        } else if (ds != null) {
     386            final BBox bbox = nc.getLatLonBounds(bounding).toBBox();
    385387            // nodes
    386             for (Node n : ds.getNodes()) {
     388            for (Node n : ds.searchNodes(bbox)) {
    387389                if (n.isSelectable() && selectionResult.contains(nc.getPoint2D(n))) {
    388390                    selection.add(n);
    389391                }
    390392            }
    391393
    392394            // ways
    393             for (Way w : ds.getWays()) {
     395            for (Way w : ds.searchWays(bbox)) {
    394396                if (!w.isSelectable() || w.isEmpty()) {
    395397                    continue;
    396398                }

Attachments (0)

Change History (1)

comment:1 by taylor.smock, 9 months ago

Resolution: fixed
Status: newclosed

In 19167/josm:

Fix #23830: Slow selection when there is a lot of data

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.