Ignore:
Timestamp:
2011-10-20T04:45:57+02:00 (13 years ago)
Author:
Don-vip
Message:

see #6653 and #6960 - Allow JOSM to download osmChange files again

File:
1 edited

Legend:

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

    r4523 r4530  
    3333    protected DataSet downloadedData;
    3434    protected DownloadTask downloadTask;
     35   
     36    protected OsmDataLayer targetLayer;
    3537
    3638    protected void rememberDownloadedData(DataSet ds) {
     
    7981    }
    8082
    81      protected class DownloadTask extends PleaseWaitRunnable {
     83    protected class DownloadTask extends PleaseWaitRunnable {
    8284        protected OsmServerReader reader;
    8385        protected DataSet dataSet;
     
    8991            this.newLayer = newLayer;
    9092        }
     93       
     94        protected DataSet parseDataSet() throws OsmTransferException {
     95            return reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
     96        }
    9197
    9298        @Override public void realRun() throws IOException, SAXException, OsmTransferException {
     
    94100                if (isCanceled())
    95101                    return;
    96                 dataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
     102                dataSet = parseDataSet();
    97103            } catch(Exception e) {
    98104                if (isCanceled()) {
     
    161167                // or it is not clear which layer to merge to
    162168                //
    163                 OsmDataLayer layer = createNewLayer();
     169                targetLayer = createNewLayer();
    164170                final boolean isDisplayingMapView = Main.isDisplayingMapView();
    165171
    166                 Main.main.addLayer(layer);
     172                Main.main.addLayer(targetLayer);
    167173
    168174                // If the mapView is not there yet, we cannot calculate the bounds (see constructor of MapView).
    169175                // Otherwise jump to the current download.
    170176                if (isDisplayingMapView) {
    171                     BoundingXYVisitor v = new BoundingXYVisitor();
    172                     if (currentBounds != null) {
    173                         v.visit(currentBounds);
    174                     } else {
    175                         v.computeBoundingBox(dataSet.getNodes());
    176                     }
    177                     Main.map.mapView.recalculateCenterScale(v);
     177                    computeBboxAndCenterScale();
    178178                }
    179179            } else {
    180                 OsmDataLayer target;
    181                 target = getEditLayer();
    182                 if (target == null) {
    183                     target = getFirstDataLayer();
    184                 }
    185                 target.mergeFrom(dataSet);
    186                 BoundingXYVisitor v = new BoundingXYVisitor();
    187                 if (currentBounds != null) {
    188                     v.visit(currentBounds);
    189                 } else {
    190                     v.computeBoundingBox(dataSet.getNodes());
    191                 }
    192                 Main.map.mapView.recalculateCenterScale(v);
    193                 target.onPostDownloadFromServer();
    194             }
     180                targetLayer = getEditLayer();
     181                if (targetLayer == null) {
     182                    targetLayer = getFirstDataLayer();
     183                }
     184                targetLayer.mergeFrom(dataSet);
     185                computeBboxAndCenterScale();
     186                targetLayer.onPostDownloadFromServer();
     187            }
     188        }
     189       
     190        protected void computeBboxAndCenterScale() {
     191            BoundingXYVisitor v = new BoundingXYVisitor();
     192            if (currentBounds != null) {
     193                v.visit(currentBounds);
     194            } else {
     195                v.computeBoundingBox(dataSet.getNodes());
     196            }
     197            Main.map.mapView.recalculateCenterScale(v);
    195198        }
    196199
Note: See TracChangeset for help on using the changeset viewer.