Package org.openstreetmap.josm.actions
Class CreateMultipolygonAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.CreateMultipolygonAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
Create multipolygon from selected ways automatically.
New relation with type=multipolygon is created.
If one or more of ways is already in relation with type=multipolygon or the
way is not closed, then error is reported and no relation is created.
The "inner" and "outer" roles are guessed automatically. First, bbox is
calculated for each way. then the largest area is assumed to be outside and
the rest inside. In cases with one "outside" area and several cut-ins, the
guess should be always good ... In more complex (multiple outer areas) or
buggy (inner and outer ways intersect) scenarios the result is likely to be
wrong.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classNested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final booleanFields inherited from class org.openstreetmap.josm.actions.JosmAction
scFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON -
Constructor Summary
ConstructorsConstructorDescriptionCreateMultipolygonAction(boolean update) Constructs a newCreateMultipolygonAction. -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic Pair<SequenceCommand,Relation> createMultipolygonCommand(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) createMultipolygonRelation(Collection<Way> selectedWays, boolean showNotif) private static StringgetName(boolean update) private static RelationgetSelectedMultipolygonRelation(Collection<Way> selectedWays, Collection<Relation> selectedRelations) mergeRelationsMembers(Relation old, Relation calculated) Merge members of multipolygon relation.removeTagsFromWaysIfNeeded(Relation relation) This method removes tags/value pairs from inner and outer ways and put them on relation if necessary.private static voidshowErrors(List<TestError> errors) protected voidEnable this action only if something is selectedprotected voidupdateEnabledState(Collection<? extends OsmPrimitive> selection) Enable this action only if something is selectedupdateMultipolygonRelation(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
update
-
MAX_MEMBERS_TO_DOWNLOAD
- See Also:
-
DEFAULT_LINEAR_TAGS
-
-
Constructor Details
-
CreateMultipolygonAction
Constructs a newCreateMultipolygonAction.- Parameters:
update-trueif the multipolygon must be updated,falseif it must be created
-
-
Method Details
-
getName
-
actionPerformed
-
getSelectedMultipolygonRelation
private static Relation getSelectedMultipolygonRelation(Collection<Way> selectedWays, Collection<Relation> selectedRelations) -
updateMultipolygonRelation
public static Pair<Relation,Relation> updateMultipolygonRelation(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) Returns aPairof the old multipolygonRelation(or null) and the newly created/modified multipolygonRelation.- Parameters:
selectedWays- selected waysselectedMultipolygonRelation- selected multipolygon relation- Returns:
- null if ways don't build a valid multipolygon, pair of old and new multipolygon relation if a difference was found, else the pair contains the old relation twice
-
mergeRelationsMembers
Merge members of multipolygon relation. Maintains the order of the old relation. May change roles, removes duplicate and non-way members and adds new members found incalculated.- Parameters:
old- old multipolygon relationcalculated- calculated multipolygon relation- Returns:
- pair of old and new multipolygon relation if a difference was found, else the pair contains the old relation twice
-
createMultipolygonRelation
public static Pair<Relation,Relation> createMultipolygonRelation(Collection<Way> selectedWays, boolean showNotif) - Parameters:
selectedWays- selected waysshowNotif- iftrue, shows a notification if an error occurs- Returns:
- pair of null and new multipolygon relation
-
showErrors
-
createMultipolygonCommand
public static Pair<SequenceCommand,Relation> createMultipolygonCommand(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) - Parameters:
selectedWays- selected waysselectedMultipolygonRelation- selected multipolygon relation- Returns:
- pair of command and multipolygon relation
-
updateEnabledState
Enable this action only if something is selected- Overrides:
updateEnabledStatein classJosmAction- See Also:
-
updateEnabledState
Enable this action only if something is selected- Overrides:
updateEnabledStatein classJosmAction- Parameters:
selection- the current selection, gets tested for emptiness- See Also:
-
removeTagsFromWaysIfNeeded
This method removes tags/value pairs from inner and outer ways and put them on relation if necessary. Function was extended in reltoolbox plugin by Zverikk and copied back to the core- Parameters:
relation- the multipolygon style relation to process. If it not linked to a dataset, the tags might be modified, else the list of commands will contain a command to modify its tags- Returns:
- a list of commands to execute
-