Changeset 17429 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-12-30T11:52:34+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r17408 r17429 341 341 boolean changedMembers = rr.a != rr.b; 342 342 final Relation existingRelation = rr.a; 343 final Relation relation = changedMembers ? rr.b : new Relation(rr.a);343 final Relation relation = changedMembers ? rr.b : rr.a; 344 344 345 345 final List<Command> list = removeTagsFromWaysIfNeeded(relation); … … 349 349 commandName = getName(false); 350 350 } else { 351 boolean changedKeys = !relation.getKeys().equals(existingRelation.getKeys()); 352 if (changedKeys && changedMembers) 353 list.add(new ChangeCommand(existingRelation, relation)); 354 else if (changedMembers) { 355 list.add(new ChangeMembersCommand(existingRelation, new ArrayList<>(relation.getMembers()))); 356 } else if (changedKeys) { 357 list.add(ChangePropertyCommand.build(existingRelation, relation)); 351 if (changedMembers) { 352 if (!relation.getKeys().equals(existingRelation.getKeys())) { 353 list.add(new ChangeCommand(existingRelation, relation)); 354 } else { 355 list.add(new ChangeMembersCommand(existingRelation, new ArrayList<>(relation.getMembers()))); 356 } 358 357 } 359 358 if (list.isEmpty()) { 360 if (!changedMembers) { 361 MultipolygonTest mpTest = new MultipolygonTest(); 362 mpTest.visit(existingRelation); 363 if (!mpTest.getErrors().isEmpty()) { 364 showErrors(mpTest.getErrors()); 365 return null; 366 } 359 MultipolygonTest mpTest = new MultipolygonTest(); 360 mpTest.visit(existingRelation); 361 if (!mpTest.getErrors().isEmpty()) { 362 showErrors(mpTest.getErrors()); 363 return null; 367 364 } 368 365 … … 404 401 * This method removes tags/value pairs from inner and outer ways and put them on relation if necessary. 405 402 * Function was extended in reltoolbox plugin by Zverikk and copied back to the core 406 * @param relation the multipolygon style relation to process. If it is new, the tags might be403 * @param relation the multipolygon style relation to process. If it not linked to a dataset, the tags might be 407 404 * modified, else the list of commands will contain a command to modify its tags 408 405 * @return a list of commands to execute … … 488 485 if (moveTags && !values.isEmpty()) { 489 486 // add those tag values to the relation 490 boolean fixed = false;491 487 Map<String, String> tagsToAdd = new HashMap<>(); 492 488 for (Entry<String, String> entry : values.entrySet()) { 493 489 String key = entry.getKey(); 494 490 if (!relation.hasKey(key)) { 495 if (relation. isNew())491 if (relation.getDataSet() == null) 496 492 relation.put(key, entry.getValue()); 497 493 else 498 494 tagsToAdd.put(key, entry.getValue()); 499 fixed = true; 500 } 501 } 502 if (fixed && !relation.isNew()) { 503 DataSet ds = relation.getDataSet(); 504 if (ds == null) { 505 ds = MainApplication.getLayerManager().getEditDataSet(); 506 } 507 commands.add(new ChangePropertyCommand(ds, Collections.singleton(relation), tagsToAdd)); 495 } 496 } 497 if (!tagsToAdd.isEmpty()) { 498 commands.add(new ChangePropertyCommand(Collections.singleton(relation), tagsToAdd)); 508 499 } 509 500 }
Note:
See TracChangeset
for help on using the changeset viewer.