Changeset 4530 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
- Timestamp:
- 2011-10-20T04:45:57+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r4523 r4530 33 33 protected DataSet downloadedData; 34 34 protected DownloadTask downloadTask; 35 36 protected OsmDataLayer targetLayer; 35 37 36 38 protected void rememberDownloadedData(DataSet ds) { … … 79 81 } 80 82 81 protectedclass DownloadTask extends PleaseWaitRunnable {83 protected class DownloadTask extends PleaseWaitRunnable { 82 84 protected OsmServerReader reader; 83 85 protected DataSet dataSet; … … 89 91 this.newLayer = newLayer; 90 92 } 93 94 protected DataSet parseDataSet() throws OsmTransferException { 95 return reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 96 } 91 97 92 98 @Override public void realRun() throws IOException, SAXException, OsmTransferException { … … 94 100 if (isCanceled()) 95 101 return; 96 dataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));102 dataSet = parseDataSet(); 97 103 } catch(Exception e) { 98 104 if (isCanceled()) { … … 161 167 // or it is not clear which layer to merge to 162 168 // 163 OsmDataLayer layer = createNewLayer();169 targetLayer = createNewLayer(); 164 170 final boolean isDisplayingMapView = Main.isDisplayingMapView(); 165 171 166 Main.main.addLayer( layer);172 Main.main.addLayer(targetLayer); 167 173 168 174 // If the mapView is not there yet, we cannot calculate the bounds (see constructor of MapView). 169 175 // Otherwise jump to the current download. 170 176 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(); 178 178 } 179 179 } 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); 195 198 } 196 199
Note:
See TracChangeset
for help on using the changeset viewer.