Changeset 2202 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-09-27T18:01:21+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2120 r2202 31 31 import org.openstreetmap.josm.data.osm.Tag; 32 32 import org.openstreetmap.josm.data.osm.TagCollection; 33 import org.openstreetmap.josm.data.osm.TigerUtils; 33 34 import org.openstreetmap.josm.data.osm.Way; 34 35 import org.openstreetmap.josm.gui.ExtendedDialog; … … 46 47 super(tr("Combine Way"), "combineway", tr("Combine several ways into one."), 47 48 Shortcut.registerShortcut("tools:combineway", tr("Tool: {0}", tr("Combine Way")), KeyEvent.VK_C, Shortcut.GROUP_EDIT), true); 48 }49 50 protected Set<OsmPrimitive> intersect(Set<? extends OsmPrimitive> s1, Set<? extends OsmPrimitive> s2) {51 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(s1);52 ret.retainAll(s2);53 return ret;54 }55 56 protected boolean confirmCombiningWithConflictsInRelationMemberships() {57 ExtendedDialog ed = new ExtendedDialog(Main.parent,58 tr("Combine ways with different memberships?"),59 new String[] {tr("Combine Anyway"), tr("Cancel")});60 ed.setButtonIcons(new String[] {"combineway.png", "cancel.png"});61 ed.setContent(tr("The selected ways have differing relation memberships. "62 + "Do you still want to combine them?"));63 ed.showDialog();64 65 return ed.getValue() == 1;66 49 } 67 50 … … 82 65 JOptionPane.showMessageDialog( 83 66 Main.parent, 84 msg, //FIXME: not sure whether this fits in a dialog67 msg, 85 68 tr("Information"), 86 69 JOptionPane.INFORMATION_MESSAGE … … 120 103 } 121 104 105 /** 106 * Combines tags from TIGER data 107 * 108 * @param tc the tag collection 109 */ 110 protected static void combineTigerTags(TagCollection tc) { 111 for (String key: tc.getKeys()) { 112 if (TigerUtils.isTigerTag(key)) { 113 tc.setUniqueForKey(key, TigerUtils.combineTags(key, tc.getValues(key))); 114 } 115 } 116 } 117 122 118 protected static void completeTagCollectionForEditing(TagCollection tc) { 123 119 for (String key: tc.getKeys()) { … … 148 144 149 145 150 // try to build a new way out of the combination of ways151 // w hich are combined146 // try to build a new way which includes all the combined 147 // ways 152 148 // 153 149 NodeGraph graph = NodeGraph.createDirectedGraphFromWays(ways); … … 172 168 173 169 TagCollection completeWayTags = new TagCollection(wayTags); 170 combineTigerTags(completeWayTags); 174 171 completeTagCollectionWithMissingTags(completeWayTags, ways); 175 172 TagCollection tagsToEdit = new TagCollection(completeWayTags); … … 216 213 } 217 214 } 218 219 215 220 216 public void actionPerformed(ActionEvent event) { -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r2181 r2202 25 25 import org.openstreetmap.josm.data.osm.Tag; 26 26 import org.openstreetmap.josm.data.osm.TagCollection; 27 import org.openstreetmap.josm.data.osm.TigerUtils; 27 28 import org.openstreetmap.josm.data.osm.Way; 28 29 import org.openstreetmap.josm.data.osm.BackreferencedDataSet.RelationToChildReference; … … 93 94 94 95 /** 96 * Combines tags from TIGER data 97 * 98 * @param tc the tag collection 99 */ 100 protected static void combineTigerTags(TagCollection tc) { 101 for (String key: tc.getKeys()) { 102 if (TigerUtils.isTigerTag(key)) { 103 tc.setUniqueForKey(key, TigerUtils.combineTags(key, tc.getValues(key))); 104 } 105 } 106 } 107 108 /** 95 109 * Selects a node out of a collection of candidate nodes. The selected 96 110 * node will become the target node the remaining nodes are merged to. … … 153 167 * Fixes the parent ways referring to one of the nodes. 154 168 * 155 * Replies null, if the ways could not be fixed, i.e. because a way would have to be del ted169 * Replies null, if the ways could not be fixed, i.e. because a way would have to be deleted 156 170 * which is referred to by a relation. 157 171 * … … 159 173 * @param nodesToDelete the collection of nodes to be deleted 160 174 * @param targetNode the target node the other nodes are merged to 161 * @return a list of command ; null,the ways could not be fixed175 * @return a list of commands; null, if the ways could not be fixed 162 176 */ 163 177 protected static List<Command> fixParentWays(BackreferencedDataSet backreferences, Collection<OsmPrimitive> nodesToDelete, Node targetNode) { … … 207 221 /** 208 222 * Merges the nodes in <code>node</code> onto one of the nodes. Uses the dataset 209 * managed by <code>layer</code> as reference. <code>backreferences</code> is precomputed223 * managed by <code>layer</code> as reference. <code>backreferences</code> is a precomputed 210 224 * collection of all parent/child references in the dataset. 211 225 * 212 226 * @param layer layer the reference data layer. Must not be null. 213 * @param backreferences if null, backrefer neces are first computed from layer.data; otherwise214 * backreferences.getSource() == layer.data must hold227 * @param backreferences if null, backreferences are first computed from layer.data; otherwise 228 * backreferences.getSource() == layer.data must be true 215 229 * @param nodes the collection of nodes. Ignored if null. 216 230 * @param targetNode the target node the collection of nodes is merged to. Must not be null. … … 235 249 // 236 250 TagCollection nodeTags = TagCollection.unionOfAllPrimitives(nodes); 251 combineTigerTags(nodeTags); 237 252 completeTagCollectionWithMissingTags(nodeTags, nodes); 238 253 TagCollection nodeTagsToEdit = new TagCollection(nodeTags); … … 258 273 nodesToDelete.remove(targetNode); 259 274 260 // change the ways referring to at least one of the mergenodes275 // fix the ways referring to at least one of the merged nodes 261 276 // 262 277 Collection<Way> waysToDelete= new HashSet<Way>(); … … 287 302 288 303 /** 289 * Enable the "Merge Nodes" menu option if more th en one node is selected304 * Enable the "Merge Nodes" menu option if more than one node is selected 290 305 */ 291 306 @Override
Note:
See TracChangeset
for help on using the changeset viewer.