Ticket #18701: 18701.patch

File 18701.patch, 4.7 KB (added by simon04, 2 months ago)
  • src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java

    diff --git a/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java b/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java
    index 8dc358470..6f163de4a 100644
    a b public DownloadPrimitivesTask(OsmDataLayer layer, List<PrimitiveId> ids, boolean 
    5555    protected void initMultiFetchReader(MultiFetchServerObjectReader reader) {
    5656        getProgressMonitor().indeterminateSubTask(tr("Initializing nodes to download ..."));
    5757        reader.setRecurseDownRelations(fullRelation);
    58         reader.appendIds(ids);
     58        if (ids != null) {
     59            ids.forEach(reader::append);
     60        }
    5961    }
    6062}
  • src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    diff --git a/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java b/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
    index 23ec25627..efc0e53d4 100644
    a b public static MultiFetchServerObjectReader create(final boolean fromMirror) { 
    131131     *
    132132     * @param id  the id
    133133     */
    134     protected void remember(PrimitiveId id) {
     134    public void append(PrimitiveId id) {
    135135        if (id.isNew()) return;
    136136        switch(id.getType()) {
    137137        case NODE: nodes.add(id.getUniqueId()); break;
    protected void remember(PrimitiveId id) { 
    152152     */
    153153    public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType type) {
    154154        OsmPrimitive p = ds.getPrimitiveById(id, type);
    155         switch(type) {
    156         case NODE:
    157             return appendNode((Node) p);
    158         case WAY:
    159             return appendWay((Way) p);
    160         case RELATION:
    161             return appendRelation((Relation) p);
    162         default:
    163             return this;
    164         }
     155        return append(p);
    165156    }
    166157
    167158    /**
    public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType 
    172163     */
    173164    public MultiFetchServerObjectReader appendNode(Node node) {
    174165        if (node == null || node.isNew()) return this;
    175         remember(node.getPrimitiveId());
     166        append(node.getPrimitiveId());
    176167        return this;
    177168    }
    178169
    public MultiFetchServerObjectReader appendNode(Node node) { 
    185176    public MultiFetchServerObjectReader appendWay(Way way) {
    186177        if (way == null || way.isNew()) return this;
    187178        if (recurseDownAppended) {
    188             for (Node node : way.getNodes()) {
    189                 if (!node.isNew()) {
    190                     remember(node.getPrimitiveId());
    191                 }
    192             }
     179            append(way.getNodes());
    193180        }
    194         remember(way.getPrimitiveId());
     181        append(way.getPrimitiveId());
    195182        return this;
    196183    }
    197184
    public MultiFetchServerObjectReader appendWay(Way way) { 
    203190     */
    204191    protected MultiFetchServerObjectReader appendRelation(Relation relation) {
    205192        if (relation == null || relation.isNew()) return this;
    206         remember(relation.getPrimitiveId());
     193        append(relation.getPrimitiveId());
    207194        if (recurseDownAppended) {
    208195            for (RelationMember member : relation.getMembers()) {
    209196                // avoid infinite recursion in case of cyclic dependencies in relations
    public MultiFetchServerObjectReader append(OsmPrimitive primitive) { 
    245232     */
    246233    public MultiFetchServerObjectReader append(Collection<? extends OsmPrimitive> primitives) {
    247234        if (primitives == null) return this;
    248         for (OsmPrimitive primitive : primitives) {
    249             append(primitive);
    250         }
    251         return this;
    252     }
    253 
    254     /**
    255      * appends a list of {@link PrimitiveId} to the list of ids which will be fetched from the server.
    256      *
    257      * @param ids the list of primitive Ids (ignored, if null)
    258      * @return this
    259      * @since 15811
    260      *
    261      */
    262     public MultiFetchServerObjectReader appendIds(Collection<PrimitiveId> ids) {
    263         if (ids == null)
    264             return this;
    265         for (PrimitiveId id : ids) {
    266             if (id.isNew()) continue;
    267             switch (id.getType()) {
    268             case NODE:
    269                 nodes.add(id.getUniqueId());
    270                 break;
    271             case WAY:
    272             case CLOSEDWAY:
    273                 ways.add(id.getUniqueId());
    274                 break;
    275             case MULTIPOLYGON:
    276             case RELATION:
    277                 relations.add(id.getUniqueId());
    278                 break;
    279             default:
    280                 throw new AssertionError();
    281             }
    282         }
     235        primitives.forEach(this::append);
    283236        return this;
    284237    }
    285238