Changeset 3010 in josm


Ignore:
Timestamp:
2010-02-18T08:46:30+01:00 (15 years ago)
Author:
bastiK
Message:

fixed #3921 - Autojump to downloaded area

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r2842 r3010  
    155155                OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
    156156                Main.main.addLayer(layer);
     157                BoundingXYVisitor v = new BoundingXYVisitor();
     158                v.visit(currentBounds);
     159                Main.map.mapView.recalculateCenterScale(v);
    157160            } else {
    158161                OsmDataLayer target;
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r2860 r3010  
    179179                scaler.setLocation(10,30);
    180180
    181                 if (!zoomToEditLayerBoundingBox()) {
    182                     new AutoScaleAction("data").actionPerformed(null);
     181                OsmDataLayer layer = getEditLayer();
     182                if (layer != null) {
     183                    if (!zoomToDataSetBoundingBox(layer.data)) {
     184                        // no bounding box defined
     185                        new AutoScaleAction("data").actionPerformed(null);
     186                    }
     187                } else {
     188                    new AutoScaleAction("layer").actionPerformed(null);
    183189                }
    184190
     
    682688     * (aka {@link OsmDataLayer}). If the edit layer has multiple download bounding
    683689     * boxes it zooms to a large virtual bounding box containing all smaller ones.
    684      * This implementation can be used for resolving ticket #1461.
    685690     *
    686691     * @return <code>true</code> if a zoom operation has been performed
    687692     */
    688     public boolean zoomToEditLayerBoundingBox() {
    689         // workaround for #1461 (zoom to download bounding box instead of all data)
     693    public boolean zoomToDataSetBoundingBox(DataSet ds) {
    690694        // In case we already have an existing data layer ...
    691695        OsmDataLayer layer= getEditLayer();
    692696        if (layer == null)
    693697            return false;
    694         Collection<DataSource> dataSources = layer.data.dataSources;
     698        Collection<DataSource> dataSources = ds.dataSources;
    695699        // ... with bounding box[es] of data loaded from OSM or a file...
    696700        BoundingXYVisitor bbox = new BoundingXYVisitor();
    697         for (DataSource ds : dataSources) {
    698             bbox.visit(ds.bounds);
    699             if (bbox.hasExtend()) {
    700                 // ... we zoom to it's bounding box
    701                 recalculateCenterScale(bbox);
    702                 return true;
    703             }
     701        for (DataSource source : dataSources) {
     702            bbox.visit(source.bounds);
     703        }
     704        if (bbox.hasExtend()) {
     705            // ... we zoom to it's bounding box
     706            recalculateCenterScale(bbox);
     707            return true;
    704708        }
    705709        return false;
Note: See TracChangeset for help on using the changeset viewer.