Changeset 25693 in osm for applications/editors/josm
- Timestamp:
- 2011-03-24T20:56:47+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/relcontext
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/relcontext/TODO
r25692 r25693 1 - After creating multipolygon, move tags from outer to relation (setting "tags")2 1 - Solve width problem for narrows buttons when "fix" and "download" appear simultaneously 3 2 - Check all strings to be properly formulated, search for similar ones in josm core and plugins -
applications/editors/josm/plugins/relcontext/src/relcontext/RelContextDialog.java
r25692 r25693 1 1 package relcontext; 2 2 3 import org.openstreetmap.josm.command.SequenceCommand; 4 import org.openstreetmap.josm.command.Command; 3 5 import java.io.IOException; 4 6 import java.io.BufferedReader; … … 45 47 import org.openstreetmap.josm.tools.GBC; 46 48 import org.openstreetmap.josm.command.ChangeCommand; 49 import org.openstreetmap.josm.command.ChangeRelationMemberRoleCommand; 47 50 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 48 51 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; … … 514 517 Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected(); 515 518 Relation r = new Relation(chosenRelation.get()); 516 boolean fixed = false;519 List<Command> commands = new ArrayList<Command>(); 517 520 for( int i = 0; i < r.getMembersCount(); i++ ) { 518 521 RelationMember m = r.getMember(i); 519 522 if( selected.contains(m.getMember()) ) { 520 523 if( !role.equals(m.getRole()) ) { 521 r.setMember(i, new RelationMember(role, m.getMember())); 522 fixed = true; 524 commands.add(new ChangeRelationMemberRoleCommand(r, i, role)); 523 525 } 524 526 } 525 527 } 526 if( fixed)527 Main.main.undoRedo.add(new ChangeCommand(chosenRelation.get(), r));528 if( !commands.isEmpty() ) 529 Main.main.undoRedo.add(new SequenceCommand(tr("Change relation member roles to {0}", role), commands)); 528 530 } 529 531 } … … 591 593 addMenuItem("boundary", "Create administrative boundary relations"); 592 594 addMenuItem("boundaryways", "Add tags boundary and admin_level to boundary relation ways"); 593 addMenuItem("tags", "Move area tags from contour to relation") .setEnabled(false);595 addMenuItem("tags", "Move area tags from contour to relation"); 594 596 addMenuItem("single", "Create a single multipolygon for multiple outer contours").setEnabled(false); 595 597 } -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/CreateMultipolygonAction.java
r25692 r25693 178 178 } 179 179 180 static public final String[] DEFAULT_LINEAR_TAGS = {"barrier", "source"}; 181 180 182 /** 181 183 * This method removes tags/value pairs from inner ways that are present in relation or outer ways. … … 193 195 194 196 List<Way> innerWays = new ArrayList<Way>(); 197 List<Way> outerWays = new ArrayList<Way>(); 198 Set<String> conflictingKeys = new TreeSet<String>(); 195 199 196 200 for (RelationMember m: relation.getMembers()) { … … 202 206 if (m.hasRole() && m.getRole() == "outer" && m.isWay() && m.getWay().hasKeys()) { 203 207 Way way = m.getWay(); 208 outerWays.add(way); 204 209 for (String key: way.keySet()) { 205 210 if (!values.containsKey(key)) { //relation values take precedence 206 211 values.put(key, way.get(key)); 212 } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) { 213 conflictingKeys.add(key); 207 214 } 208 215 } … … 210 217 } 211 218 219 // filter out empty key conflicts - we need second iteration 220 for( RelationMember m: relation.getMembers() ) 221 if( m.hasRole() && m.getRole().equals("outer") && m.isWay() ) 222 for( String key : values.keySet() ) 223 if( !m.getWay().hasKey(key) && !relation.hasKey(key) ) 224 conflictingKeys.add(key); 225 226 for( String key : conflictingKeys ) 227 values.remove(key); 228 229 for( String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", Arrays.asList(DEFAULT_LINEAR_TAGS))) 230 values.remove(linearTag); 231 232 if( values.containsKey("natural") && values.get("natural").equals("coastline") ) 233 values.remove("natural"); 234 235 values.put("area", "yes"); 236 212 237 List<Command> commands = new ArrayList<Command>(); 238 boolean moveTags = getPref("tags"); 213 239 214 240 for(String key: values.keySet()) { … … 222 248 } 223 249 250 if( moveTags ) { 251 // remove duplicated tags from outer ways 252 for (Way way: outerWays) { 253 if (way.hasKey(key)) { 254 affectedWays.add(way); 255 } 256 } 257 } 258 224 259 if (affectedWays.size() > 0) { 225 260 commands.add(new ChangePropertyCommand(affectedWays, key, null)); 226 261 } 262 } 263 264 if( moveTags ) { 265 // add those tag values to the relation 266 boolean fixed = false; 267 Relation r2 = new Relation(relation); 268 for( String key : values.keySet() ) { 269 if( !r2.hasKey(key) && !key.equals("area") ) { 270 r2.put(key, values.get(key)); 271 fixed = true; 272 } 273 } 274 if( fixed ) 275 commands.add(new ChangeCommand(relation, r2)); 227 276 } 228 277
Note:
See TracChangeset
for help on using the changeset viewer.