Changeset 2950 in josm


Ignore:
Timestamp:
2010-02-08T07:05:59+01:00 (12 years ago)
Author:
mjulius
Message:

when downloading referrers also download way nodes for referring ways
see #4467

File:
1 edited

Legend:

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

    r2923 r2950  
    2121import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2222import org.openstreetmap.josm.data.osm.PrimitiveId;
     23import org.openstreetmap.josm.data.osm.Way;
    2324import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    2425import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2526import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     27import org.openstreetmap.josm.io.MultiFetchServerObjectReader;
    2628import org.openstreetmap.josm.io.OsmServerBackreferenceReader;
     29import org.openstreetmap.josm.io.OsmServerReader;
    2730import org.openstreetmap.josm.io.OsmTransferException;
    2831import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    3740    private boolean cancelled;
    3841    private Exception lastException;
    39     private OsmServerBackreferenceReader reader;
     42    private OsmServerReader reader;
    4043    /** the target layer */
    4144    private OsmDataLayer targetLayer;
     
    184187    protected void downloadParents(long id, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException{
    185188        reader = new OsmServerBackreferenceReader(id, type);
    186         DataSet ds = reader.parseOsm(progressMonitor);
     189        DataSet ds = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
    187190        synchronized(this) { // avoid race condition in cancel()
    188191            reader = null;
    189192        }
    190         DataSetMerger visitor = new DataSetMerger(parents, ds);
    191         visitor.merge();
     193        Collection<Way> ways = ds.getWays();
     194        DataSetMerger merger;
     195        if (!ways.isEmpty()) {
     196            reader = new MultiFetchServerObjectReader();
     197            for (Way w: ways) {
     198                ((MultiFetchServerObjectReader)reader).append(w.getNodes());
     199            }
     200            DataSet wayNodes = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
     201            synchronized(this) { // avoid race condition in cancel()
     202                reader = null;
     203            }
     204            merger = new DataSetMerger(ds, wayNodes);
     205            merger.merge();
     206        }
     207        merger = new DataSetMerger(parents, ds);
     208        merger.merge();
    192209    }
    193210
     
    207224                }
    208225                progressMonitor.subTask(msg);
    209                 downloadParents(entry.getKey(), entry.getValue(), progressMonitor.createSubTaskMonitor(1, false));
     226                downloadParents(entry.getKey(), entry.getValue(), progressMonitor);
    210227                i++;
    211228            }
Note: See TracChangeset for help on using the changeset viewer.