Ticket #18122: 18122-quick-and-dirty.patch

File 18122-quick-and-dirty.patch, 4.0 KB (added by GerdP, 6 years ago)
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

     
    467467                if (remark != null && !remark.isEmpty()) {
    468468                    rememberErrorMessage(remark);
    469469                }
    470                 // need to synthesize a download bounds lest the visual indication of downloaded area doesn't work
    471                 dataSet.addDataSource(new DataSource(currentBounds != null ? currentBounds :
    472                     new Bounds(LatLon.ZERO), "OpenStreetMap server"));
     470                if (!(reader instanceof OverpassDownloadReader)) {
     471                    // need to synthesize a download bounds lest the visual indication of downloaded area doesn't work
     472                    dataSet.addDataSource(new DataSource(currentBounds != null ? currentBounds :
     473                        new Bounds(LatLon.ZERO), "OpenStreetMap server"));
     474                }
    473475            }
    474476
    475477            rememberDownloadedData(dataSet);
  • src/org/openstreetmap/josm/io/OverpassDownloadReader.java

     
    3030import org.openstreetmap.josm.data.coor.LatLon;
    3131import org.openstreetmap.josm.data.osm.BBox;
    3232import org.openstreetmap.josm.data.osm.DataSet;
     33import org.openstreetmap.josm.data.osm.DataSetMerger;
    3334import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    3435import org.openstreetmap.josm.data.osm.PrimitiveId;
    3536import org.openstreetmap.josm.data.preferences.BooleanProperty;
     
    384385    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
    385386
    386387        DataSet ds = super.parseOsm(progressMonitor);
     388        boolean ignoreBounds = !overpassQuery.contains("node({{bbox}})"); // quick & dirty solution
     389        if (ignoreBounds) {
     390            DataSet noBounds = new DataSet();
     391            DataSetMerger dsm = new DataSetMerger(noBounds, ds);
     392            dsm.merge(null, false);
     393            return dsm.getTargetDataSet();
     394        } else {
     395            // add bounds if necessary (note that Overpass API does not return bounds in the response XML)
     396            if (ds != null && ds.getDataSources().isEmpty() && overpassQuery.contains("{{bbox}}")) {
     397                if (crosses180th) {
     398                    Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
     399                    DataSource src = new DataSource(bounds, getBaseUrl());
     400                    ds.addDataSource(src);
    387401
    388         // add bounds if necessary (note that Overpass API does not return bounds in the response XML)
    389         if (ds != null && ds.getDataSources().isEmpty() && overpassQuery.contains("{{bbox}}")) {
    390             if (crosses180th) {
    391                 Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
    392                 DataSource src = new DataSource(bounds, getBaseUrl());
    393                 ds.addDataSource(src);
    394 
    395                 bounds = new Bounds(lat1, -180.0, lat2, lon2);
    396                 src = new DataSource(bounds, getBaseUrl());
    397                 ds.addDataSource(src);
    398             } else {
    399                 Bounds bounds = new Bounds(lat1, lon1, lat2, lon2);
    400                 DataSource src = new DataSource(bounds, getBaseUrl());
    401                 ds.addDataSource(src);
     402                    bounds = new Bounds(lat1, -180.0, lat2, lon2);
     403                    src = new DataSource(bounds, getBaseUrl());
     404                    ds.addDataSource(src);
     405                } else {
     406                    Bounds bounds = new Bounds(lat1, lon1, lat2, lon2);
     407                    DataSource src = new DataSource(bounds, getBaseUrl());
     408                    ds.addDataSource(src);
     409                }
    402410            }
     411            return ds;
    403412        }
    404 
    405         return ds;
    406413    }
    407414
    408415    /**