- Timestamp:
- 2008-10-05T16:39:49+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r999 r1022 32 32 import org.openstreetmap.josm.data.coor.LatLon; 33 33 import org.openstreetmap.josm.data.osm.DataSet; 34 import org.openstreetmap.josm.data.osm.DataSource; 34 35 import org.openstreetmap.josm.data.osm.OsmPrimitive; 35 36 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 104 105 removeComponentListener(this); 105 106 106 new AutoScaleAction("data").actionPerformed(null); 107 if (!zoomToEditLayerBoundingBox()) 108 new AutoScaleAction("data").actionPerformed(null); 107 109 108 110 new MapMover(MapView.this, Main.contentPane); … … 404 406 firePropertyChange("scale", oldScale, scale); 405 407 } 408 409 /** 410 * Tries to zoom to the download boundingbox[es] of the current edit layer 411 * (aka {@link OsmDataLayer}). If the edit layer has multiple download bounding 412 * boxes it zooms to a large virtual bounding box containing all smaller ones. 413 * This implementation can be used for resolving ticket #1461. 414 * 415 * @return <code>true</code> if a zoom operation has been performed 416 * @author Jan Peter Stotz 417 */ 418 public boolean zoomToEditLayerBoundingBox() { 419 // workaround for #1461 (zoom to download bounding box instead of all data) 420 // In case we already have an existing data layer ... 421 Collection<DataSource> dataSources = Main.main.editLayer().data.dataSources; 422 // ... with bounding box[es] of data loaded from OSM or a file... 423 BoundingXYVisitor bbox = new BoundingXYVisitor(); 424 for (DataSource ds : dataSources) { 425 if (ds.bounds != null) { 426 bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.max)); 427 bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.min)); 428 } 429 if (bbox.max != null && bbox.min != null && !bbox.max.equals(bbox.min)) { 430 // ... we zoom to it's bounding box 431 recalculateCenterScale(bbox); 432 return true; 433 } 434 } 435 return false; 436 } 406 437 407 438 public boolean addTemporaryLayer(MapViewPaintable mvp) {
Note:
See TracChangeset
for help on using the changeset viewer.