Changeset 34982 in osm for applications/editors
- Timestamp:
- 2019-04-20T10:11:28+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/MergeAddrPointsAction.java
r34850 r34982 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 import java.util.AbstractMap;10 9 import java.util.Collection; 11 10 import java.util.Collections; 12 11 import java.util.HashMap; 12 import java.util.HashSet; 13 13 import java.util.LinkedList; 14 14 import java.util.List; 15 import java.util.Map; 15 16 import java.util.Map.Entry; 17 import java.util.Set; 16 18 17 19 import javax.swing.JOptionPane; … … 56 58 List<Node> addrNodes = new LinkedList<>(); 57 59 List<Way> buildings = new LinkedList<>(); 58 scanSelection:59 60 for (OsmPrimitive p : selection) { 60 61 if (p.getType() == OsmPrimitiveType.NODE) { 62 boolean refsOK = true; 61 63 for (OsmPrimitive r : p.getReferrers()) { 62 if (r.getType() == OsmPrimitiveType.WAY) 63 continue scanSelection; // Don't use nodes if they're referenced by ways 64 if (r.getType() == OsmPrimitiveType.WAY) { 65 // Don't use nodes if they're referenced by ways 66 refsOK = false; 67 break; 68 } 64 69 } 70 if (!refsOK) 71 continue; 65 72 for (String key : p.getKeys().keySet()) { 66 73 if (key.startsWith("addr:")) { … … 82 89 return; 83 90 } 91 92 // find nodes covered by more than one building, see #17625 93 Map<Node, Way> nodeToWayMap = new HashMap<>(); 94 Set<Way> overlappingWays = new HashSet<>(); 95 for (Way w : buildings) { 96 for (Node n : addrNodes) { 97 if (Geometry.nodeInsidePolygon(n, w.getNodes())) { 98 Way old = nodeToWayMap.put(n, w); 99 if (old != null) { 100 overlappingWays.add(w); 101 overlappingWays.add(old); 102 } 103 } 104 } 105 } 106 buildings.removeAll(overlappingWays); 107 84 108 List<Command> cmds = new LinkedList<>(); 85 109 int multi = 0; 86 110 int conflicts = 0; 87 buildingsLoop: for (Way w : buildings) { 111 112 for (Way w : buildings) { 88 113 Node mergeNode = null; 114 int oldMulti = multi; 89 115 for (Node n : addrNodes) { 90 116 if (Geometry.nodeInsidePolygon(n, w.getNodes())) … … 93 119 // Multiple address nodes inside one building -- 94 120 // skipping 95 continue buildingsLoop;121 break; 96 122 } else 97 123 mergeNode = n; 98 124 } 125 if (oldMulti != multi) 126 continue; 99 127 if (mergeNode != null) { 100 128 boolean hasConflicts = false; 101 AbstractMap<String, String> tags = new HashMap<>();129 Map<String, String> tags = new HashMap<>(); 102 130 for (Entry<String, String> entry : mergeNode.getKeys().entrySet()) { 103 131 String newValue = entry.getValue(); … … 141 169 "There are {0} buildings with address conflicts", conflicts, conflicts)) 142 170 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 143 if (cmds.isEmpty() && multi == 0 && conflicts == 0) 171 if (!overlappingWays.isEmpty()) 172 new Notification(tr("There are {0} buildings covering the same address node", overlappingWays.size())) 173 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 174 if (cmds.isEmpty() && multi == 0 && conflicts == 0 && overlappingWays.isEmpty()) 144 175 new Notification(tr("No address nodes inside buildings found")) 145 176 .setIcon(JOptionPane.INFORMATION_MESSAGE).show();
Note:
See TracChangeset
for help on using the changeset viewer.