| 1 | Index: src/org/openstreetmap/josm/gui/MapView.java
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- src/org/openstreetmap/josm/gui/MapView.java (Revision 1013)
|
|---|
| 4 | +++ src/org/openstreetmap/josm/gui/MapView.java (Arbeitskopie)
|
|---|
| 5 | @@ -31,6 +31,7 @@
|
|---|
| 6 | import org.openstreetmap.josm.data.coor.EastNorth;
|
|---|
| 7 | import org.openstreetmap.josm.data.coor.LatLon;
|
|---|
| 8 | import org.openstreetmap.josm.data.osm.DataSet;
|
|---|
| 9 | +import org.openstreetmap.josm.data.osm.DataSource;
|
|---|
| 10 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
|---|
| 11 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
|
|---|
| 12 | import org.openstreetmap.josm.data.projection.Projection;
|
|---|
| 13 | @@ -103,7 +104,8 @@
|
|---|
| 14 | @Override public void componentResized(ComponentEvent e) {
|
|---|
| 15 | removeComponentListener(this);
|
|---|
| 16 |
|
|---|
| 17 | - new AutoScaleAction("data").actionPerformed(null);
|
|---|
| 18 | + if (!zoomToEditLayerBoundingBox())
|
|---|
| 19 | + new AutoScaleAction("data").actionPerformed(null);
|
|---|
| 20 |
|
|---|
| 21 | new MapMover(MapView.this, Main.contentPane);
|
|---|
| 22 | Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, java.awt.event.InputEvent.SHIFT_MASK), "UP");
|
|---|
| 23 | @@ -403,6 +405,35 @@
|
|---|
| 24 | if (oldScale != scale)
|
|---|
| 25 | firePropertyChange("scale", oldScale, scale);
|
|---|
| 26 | }
|
|---|
| 27 | +
|
|---|
| 28 | + /**
|
|---|
| 29 | + * Tries to zoom to the download boundingbox[es] of the current edit layer
|
|---|
| 30 | + * (aka {@link OsmDataLayer}). If the edit layer has multiple download bounding
|
|---|
| 31 | + * boxes it zooms to a large virtual bounding box containing all smaller ones.
|
|---|
| 32 | + * This implementation can be used for resolving ticket #1461.
|
|---|
| 33 | + *
|
|---|
| 34 | + * @return <code>true</code> if a zoom operation has been performed
|
|---|
| 35 | + * @author Jan Peter Stotz
|
|---|
| 36 | + */
|
|---|
| 37 | + public boolean zoomToEditLayerBoundingBox() {
|
|---|
| 38 | + // workaround for #1461 (zoom to download bounding box instead of all data)
|
|---|
| 39 | + // In case we already have an existing data layer ...
|
|---|
| 40 | + Collection<DataSource> dataSources = Main.main.editLayer().data.dataSources;
|
|---|
| 41 | + // ... with bounding box[es] of data loaded from OSM or a file...
|
|---|
| 42 | + BoundingXYVisitor bbox = new BoundingXYVisitor();
|
|---|
| 43 | + for (DataSource ds : dataSources) {
|
|---|
| 44 | + if (ds.bounds != null) {
|
|---|
| 45 | + bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.max));
|
|---|
| 46 | + bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.min));
|
|---|
| 47 | + }
|
|---|
| 48 | + if (bbox.max != null && bbox.min != null && !bbox.max.equals(bbox.min)) {
|
|---|
| 49 | + // ... we zoom to it's bounding box
|
|---|
| 50 | + recalculateCenterScale(bbox);
|
|---|
| 51 | + return true;
|
|---|
| 52 | + }
|
|---|
| 53 | + }
|
|---|
| 54 | + return false;
|
|---|
| 55 | + }
|
|---|
| 56 |
|
|---|
| 57 | public boolean addTemporaryLayer(MapViewPaintable mvp) {
|
|---|
| 58 | if (temporaryLayers.contains(mvp)) return false;
|
|---|