Changeset 16585 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-06-09T15:29:05+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r16453 r16585 16 16 import java.util.Collections; 17 17 import java.util.EnumSet; 18 import java.util. HashSet;18 import java.util.LinkedHashSet; 19 19 import java.util.LinkedList; 20 20 import java.util.List; … … 36 36 37 37 import org.openstreetmap.josm.actions.AdaptableAction; 38 import org.openstreetmap.josm.actions.CreateMultipolygonAction; 38 39 import org.openstreetmap.josm.command.ChangePropertyCommand; 39 40 import org.openstreetmap.josm.command.Command; … … 48 49 import org.openstreetmap.josm.data.osm.RelationMember; 49 50 import org.openstreetmap.josm.data.osm.Tag; 51 import org.openstreetmap.josm.data.osm.Way; 50 52 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 51 53 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; … … 55 57 import org.openstreetmap.josm.gui.Notification; 56 58 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 59 import org.openstreetmap.josm.gui.dialogs.relation.sort.RelationSorter; 57 60 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 58 61 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; … … 70 73 import org.openstreetmap.josm.tools.ImageResource; 71 74 import org.openstreetmap.josm.tools.Logging; 75 import org.openstreetmap.josm.tools.Pair; 72 76 import org.openstreetmap.josm.tools.StreamUtils; 73 77 import org.openstreetmap.josm.tools.Utils; … … 401 405 } 402 406 } else if (answer == DIALOG_ANSWER_NEW_RELATION) { 403 final Relation r = new Relation(); 404 final Collection<RelationMember> members = new HashSet<>(); 407 Relation calculated = null; 408 if (getChangedTags().stream().anyMatch(t -> "boundary".equals(t.get("type")) || "multipolygon".equals(t.get("type")))) { 409 Pair<Relation, Relation> res = CreateMultipolygonAction.createMultipolygonRelation(ds.getSelectedWays(), true); 410 if (res != null) { 411 calculated = res.b; 412 } 413 } 414 final Relation r = calculated != null ? calculated : new Relation(); 415 final Collection<RelationMember> members = new LinkedHashSet<>(); 416 members.addAll(r.getMembers()); 405 417 for (Tag t : getChangedTags()) { 406 418 r.put(t.getKey(), t.getValue()); 407 419 } 408 420 for (OsmPrimitive osm : ds.getSelected()) { 421 if (r == calculated && osm instanceof Way) 422 continue; 409 423 String role = suggestRoleForOsmPrimitive(osm); 410 424 RelationMember rm = new RelationMember(role == null ? "" : role, osm); 411 425 r.addMember(rm); 412 426 members.add(rm); 427 } 428 if (r.isMultipolygon() && r != calculated) { 429 r.setMembers(RelationSorter.sortMembersByConnectivity(r.getMembers())); 413 430 } 414 431 SwingUtilities.invokeLater(() -> RelationEditor.getEditor(
Note:
See TracChangeset
for help on using the changeset viewer.