Changeset 15531 in josm for trunk


Ignore:
Timestamp:
2019-11-19T11:35:34+01:00 (4 years ago)
Author:
GerdP
Message:

see #18341: Improve performance when incomplete multipolygon is updated (Ctrl+Shift+B)
Only download a set of incomplete members if the number is not bigger than 100, else download the full relation.
This is expected to be much faster and less stressing for the server when the multipolygon is very complex (thousands of members).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r15161 r15531  
    3232import org.openstreetmap.josm.data.UndoRedoHandler;
    3333import org.openstreetmap.josm.data.osm.DataSet;
     34import org.openstreetmap.josm.data.osm.IPrimitive;
    3435import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3536import org.openstreetmap.josm.data.osm.OsmUtils;
     
    5051import org.openstreetmap.josm.tools.Pair;
    5152import org.openstreetmap.josm.tools.Shortcut;
     53import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    5254import org.openstreetmap.josm.tools.Utils;
    5355
     
    7072
    7173    private final boolean update;
     74    private static final int MAX_MEMBERS_TO_DOWNLOAD = 100;
    7275
    7376    /**
     
    170173        if (multipolygonRelation != null && editLayer != null && editLayer.isDownloadable()) {
    171174            if (!multipolygonRelation.isNew() && multipolygonRelation.isIncomplete()) {
    172                 MainApplication.worker.submit(
    173                         new DownloadRelationTask(Collections.singleton(multipolygonRelation), editLayer));
     175                MainApplication.worker
     176                        .submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), editLayer));
    174177            } else if (multipolygonRelation.hasIncompleteMembers()) {
    175                 MainApplication.worker.submit(new DownloadRelationMemberTask(multipolygonRelation,
    176                         Utils.filteredCollection(
    177                             DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(
    178                                     Collections.singleton(multipolygonRelation)), OsmPrimitive.class),
    179                         editLayer));
     178                // with complex relations the download of the full relation is much faster than download of almost all members, see #18341
     179                SubclassFilteredCollection<IPrimitive, OsmPrimitive> incompleteMembers = Utils
     180                        .filteredCollection(DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(
     181                                Collections.singleton(multipolygonRelation)), OsmPrimitive.class);
     182
     183                if (incompleteMembers.size() <= MAX_MEMBERS_TO_DOWNLOAD) {
     184                    MainApplication.worker
     185                            .submit(new DownloadRelationMemberTask(multipolygonRelation, incompleteMembers, editLayer));
     186                } else {
     187                    MainApplication.worker
     188                            .submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), editLayer));
     189
     190                }
    180191            }
    181192        }
Note: See TracChangeset for help on using the changeset viewer.