Ticket #4115: JoinAreasOutsideBoundary.patch
| File JoinAreasOutsideBoundary.patch, 4.7 KB (added by , 16 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/JoinAreasAction.java
8 8 import java.awt.Polygon; 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 import java.awt.geom.Area; 11 12 import java.awt.geom.Line2D; 12 13 import java.util.ArrayList; 13 14 import java.util.Collection; … … 33 34 import org.openstreetmap.josm.command.Command; 34 35 import org.openstreetmap.josm.command.DeleteCommand; 35 36 import org.openstreetmap.josm.command.SequenceCommand; 36 import org.openstreetmap.josm.data.Bounds;37 37 import org.openstreetmap.josm.data.UndoRedoHandler; 38 38 import org.openstreetmap.josm.data.coor.EastNorth; 39 39 import org.openstreetmap.josm.data.coor.LatLon; 40 40 import org.openstreetmap.josm.data.osm.DataSet; 41 import org.openstreetmap.josm.data.osm.DataSource;42 41 import org.openstreetmap.josm.data.osm.Node; 43 42 import org.openstreetmap.josm.data.osm.OsmPrimitive; 44 43 import org.openstreetmap.josm.data.osm.Relation; … … 46 45 import org.openstreetmap.josm.data.osm.TigerUtils; 47 46 import org.openstreetmap.josm.data.osm.Way; 48 47 import org.openstreetmap.josm.gui.ExtendedDialog; 49 import org.openstreetmap.josm.gui.layer.OsmDataLayer;50 48 import org.openstreetmap.josm.tools.GBC; 51 49 import org.openstreetmap.josm.tools.Shortcut; 52 50 … … 113 111 int ways = 0; 114 112 Way[] selWays = new Way[2]; 115 113 116 LinkedList<Bounds> bounds = new LinkedList<Bounds>(); 117 OsmDataLayer dataLayer = Main.map.mapView.getEditLayer(); 118 for (DataSource ds : dataLayer.data.dataSources) { 119 if (ds.bounds != null) { 120 bounds.add(ds.bounds); 121 } 122 } 114 Area dataSourceArea = Main.main.getCurrentDataSet().getDataSourceArea(); 123 115 124 116 boolean askedAlready = false; 125 117 for (OsmPrimitive prim : selection) { … … 136 128 return; 137 129 } 138 130 139 // This is copied from SimplifyAction and should be probably ported to tools 140 for (Node node : way.getNodes()) { 141 if(askedAlready) { 142 break; 143 } 144 boolean isInsideOneBoundingBox = false; 145 for (Bounds b : bounds) { 146 if (b.contains(node.getCoor())) { 147 isInsideOneBoundingBox = true; 131 // TODO: Only display this warning when nodes outside dataSourceArea are deleted 132 if (dataSourceArea != null) { 133 for (Node node : way.getNodes()) { 134 if(askedAlready) { 148 135 break; 149 136 } 150 } 137 if (!dataSourceArea.contains(node.getCoor())) { 138 int option = JOptionPane.showConfirmDialog(Main.parent, 139 tr("The selected way(s) have nodes outside of the downloaded data region.\n" 140 + "This can lead to nodes being deleted accidentally.\n" 141 + "Are you really sure to continue?"), 142 tr("Please abort if you are not sure"), JOptionPane.YES_NO_OPTION, 143 JOptionPane.WARNING_MESSAGE); 151 144 152 if (!isInsideOneBoundingBox) { 153 int option = JOptionPane.showConfirmDialog(Main.parent, 154 tr("The selected way(s) have nodes outside of the downloaded data region.\n" 155 + "This can lead to nodes being deleted accidentally.\n" 156 + "Are you really sure to continue?"), 157 tr("Please abort if you are not sure"), JOptionPane.YES_NO_OPTION, 158 JOptionPane.WARNING_MESSAGE); 159 160 if (option != JOptionPane.YES_OPTION) return; 161 askedAlready = true; 162 break; 145 if (option != JOptionPane.YES_OPTION) return; 146 askedAlready = true; 147 break; 148 } 163 149 } 164 150 } 165 151 … … 458 444 private ArrayList<RelationRole> removeFromRelations(OsmPrimitive osm) { 459 445 ArrayList<RelationRole> result = new ArrayList<RelationRole>(); 460 446 for (Relation r : Main.main.getCurrentDataSet().getRelations()) { 461 if (r.isDeleted()) 447 if (r.isDeleted()) { 462 448 continue; 449 } 463 450 for (RelationMember rm : r.getMembers()) { 464 451 if (rm.getMember() != osm) { 465 452 continue;
