public class JoinAreasAction extends JosmAction
Modifier and Type | Class and Description |
---|---|
static class |
JoinAreasAction.AssembledMultipolygon |
static class |
JoinAreasAction.AssembledPolygon
This helper class describes a polygon, assembled from several ways.
|
static class |
JoinAreasAction.JoinAreasResult
This helper class describes join areas action result.
|
static class |
JoinAreasAction.Multipolygon |
(package private) static class |
JoinAreasAction.PolygonLevel
Helper storage class for finding findOuterWays
|
private static class |
JoinAreasAction.RelationRole |
static class |
JoinAreasAction.WayInPolygon
HelperClass - saves a way and the "inside" side.
|
private static class |
JoinAreasAction.WayTraverser
This hepler class implements algorithm traversing trough connected ways.
|
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
private java.util.List<Relation> |
addedRelations |
private java.util.LinkedList<Command> |
cmds |
private int |
cmdsCount |
sc
Constructor and Description |
---|
JoinAreasAction()
Constructs a new
JoinAreasAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Gets called whenever the shortcut is pressed or the menu entry is selected.
|
private JoinAreasAction.RelationRole |
addOwnMultipolygonRelation(java.util.Collection<Way> inner)
Will add own multipolygon relation to the "previously existing" relations.
|
private static java.util.List<java.util.List<Node>> |
buildNodeChunks(Way way,
java.util.Collection<Node> splitNodes)
Simple chunking version.
|
static java.util.List<JoinAreasAction.Multipolygon> |
collectMultipolygons(java.util.Collection<Way> selectedWays)
This method analyzes multipolygon relationships of given ways and collects addition inner ways to consider.
|
private static void |
commitCommand(Command c) |
private void |
commitCommands(java.lang.String description)
Commits the command list with a description
|
static java.util.List<JoinAreasAction.AssembledPolygon> |
findBoundaryPolygons(java.util.Collection<JoinAreasAction.WayInPolygon> multigonWays,
java.util.List<Way> discardedResult)
Finds all ways that form inner or outer boundaries.
|
private static java.util.List<JoinAreasAction.PolygonLevel> |
findOuterWaysImpl(int level,
java.util.Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
Collects outer way and corresponding inner ways from all boundaries.
|
private static java.util.List<JoinAreasAction.AssembledMultipolygon> |
findPolygons(java.util.Collection<JoinAreasAction.AssembledPolygon> boundaries)
This method finds which ways are outer and which are inner.
|
private void |
fixRelations(java.util.List<JoinAreasAction.RelationRole> rels,
Way outer,
JoinAreasAction.RelationRole ownMultipol,
java.util.Set<Relation> relationsToDelete)
Adds the previously removed relations again to the outer way.
|
static java.util.List<JoinAreasAction.AssembledPolygon> |
fixTouchingPolygons(java.util.List<JoinAreasAction.AssembledPolygon> polygons)
This method checks if polygons have several touching parts and splits them in several polygons.
|
void |
join(java.util.Collection<Way> ways)
Joins the given ways.
|
JoinAreasAction.JoinAreasResult |
joinAreas(java.util.List<JoinAreasAction.Multipolygon> areas)
Will join two or more overlapping areas
|
private Way |
joinOrientedWays(java.util.List<JoinAreasAction.WayInPolygon> ways)
Joins a list of ways (using CombineWayAction and ReverseWayAction as specified in WayInPath)
|
private JoinAreasAction.Multipolygon |
joinPolygon(JoinAreasAction.AssembledMultipolygon polygon)
Joins the lists of ways.
|
private Way |
joinWays(java.util.List<JoinAreasAction.WayInPolygon> ways)
Joins the outer ways and deletes all short ways that can't be part of a multipolygon anyway.
|
private void |
makeCommitsOneAction(java.lang.String message)
Takes the last cmdsCount actions back and combines them into a single action
(for when the user wants to undo the join action)
|
private static java.util.List<JoinAreasAction.WayInPolygon> |
markWayInsideSide(java.util.List<Way> parts,
boolean isInner)
This method analyzes the way and assigns each part what direction polygon "inside" is.
|
private boolean |
removeDuplicateNodes(java.util.List<Way> ways)
This method removes duplicate points (if any) from the input way.
|
private java.util.List<JoinAreasAction.RelationRole> |
removeFromAllRelations(OsmPrimitive osm)
Removes a given OsmPrimitive from all relations.
|
private boolean |
resolveTagConflicts(java.util.List<JoinAreasAction.Multipolygon> polygons)
Checks if tags of two given ways differ, and presents the user a dialog to solve conflicts
|
private java.util.List<Way> |
splitWayOnNodes(Way way,
java.util.Set<Node> nodes)
This is a method that splits way into smaller parts, using the prepared nodes list as split points.
|
private void |
stripTags(java.util.Collection<Way> ways)
Remove all tags from the all the way
|
private boolean |
testJoin(java.util.List<JoinAreasAction.Multipolygon> areas)
Tests if the areas have some intersections to join.
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when
something in the JOSM state changes, i.e.
|
protected void |
updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the
collection of selected primitives changes.
|
static boolean |
wayInsideWay(JoinAreasAction.AssembledPolygon inside,
JoinAreasAction.AssembledPolygon outside)
Tests if way is inside other way
|
destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setTooltip, updateEnabledStateOnCurrentSelection, waitFuture
private int cmdsCount
private final transient java.util.List<Relation> addedRelations
public JoinAreasAction()
JoinAreasAction
.public void actionPerformed(java.awt.event.ActionEvent e)
public void join(java.util.Collection<Way> ways)
ways
- Ways to joinprivate boolean testJoin(java.util.List<JoinAreasAction.Multipolygon> areas)
areas
- Areas to testtrue
if areas are joinablepublic JoinAreasAction.JoinAreasResult joinAreas(java.util.List<JoinAreasAction.Multipolygon> areas) throws UserCancelException
areas
- list of areas to joinUserCancelException
- if user cancels the operationprivate boolean resolveTagConflicts(java.util.List<JoinAreasAction.Multipolygon> polygons)
polygons
- ways to checktrue
if all conflicts are resolved, false
if conflicts remain.private boolean removeDuplicateNodes(java.util.List<Way> ways)
ways
- the ways to processtrue
if any changes where madeprivate void commitCommands(java.lang.String description)
description
- The description of what the commands doprivate static void commitCommand(Command c)
private static java.util.List<JoinAreasAction.WayInPolygon> markWayInsideSide(java.util.List<Way> parts, boolean isInner)
parts
- the split parts of the wayisInner
- - if true, reverts the direction (for multipolygon islands)java.lang.IllegalArgumentException
- if parts is empty or not circularprivate java.util.List<Way> splitWayOnNodes(Way way, java.util.Set<Node> nodes)
SplitWayAction.splitWay(org.openstreetmap.josm.gui.layer.OsmDataLayer, org.openstreetmap.josm.data.osm.Way, java.util.List<java.util.List<org.openstreetmap.josm.data.osm.Node>>, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>)
for the heavy lifting.way
- way to splitnodes
- split pointsprivate static java.util.List<java.util.List<Node>> buildNodeChunks(Way way, java.util.Collection<Node> splitNodes)
way
- the way to chunksplitNodes
- the places where to cut.private static java.util.List<JoinAreasAction.AssembledMultipolygon> findPolygons(java.util.Collection<JoinAreasAction.AssembledPolygon> boundaries)
boundaries
- list of joined boundaries to search inprivate static java.util.List<JoinAreasAction.PolygonLevel> findOuterWaysImpl(int level, java.util.Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
level
- depth levelboundaryWays
- list of joined boundaries to search inpublic static java.util.List<JoinAreasAction.AssembledPolygon> findBoundaryPolygons(java.util.Collection<JoinAreasAction.WayInPolygon> multigonWays, java.util.List<Way> discardedResult)
multigonWays
- A list of (splitted) ways that form a multigon and share common end nodes on intersections.discardedResult
- this list is filled with ways that are to be discardedpublic static java.util.List<JoinAreasAction.AssembledPolygon> fixTouchingPolygons(java.util.List<JoinAreasAction.AssembledPolygon> polygons)
polygons
- the polygons to process.public static boolean wayInsideWay(JoinAreasAction.AssembledPolygon inside, JoinAreasAction.AssembledPolygon outside)
outside
- outer polygon descriptioninside
- inner polygon descriptiontrue
if inner is inside outerprivate JoinAreasAction.Multipolygon joinPolygon(JoinAreasAction.AssembledMultipolygon polygon) throws UserCancelException
polygon
- The list of outer ways that belong to that multipolygon.UserCancelException
- if user cancels the operationprivate Way joinWays(java.util.List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways
- The list of outer ways that belong to that multigon.UserCancelException
- if user cancels the operationprivate Way joinOrientedWays(java.util.List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways
- The list of ways to join and reverseUserCancelException
- if user cancels the operationpublic static java.util.List<JoinAreasAction.Multipolygon> collectMultipolygons(java.util.Collection<Way> selectedWays)
selectedWays
- the selected waysprivate JoinAreasAction.RelationRole addOwnMultipolygonRelation(java.util.Collection<Way> inner)
inner
- List of already closed inner waysprivate java.util.List<JoinAreasAction.RelationRole> removeFromAllRelations(OsmPrimitive osm)
osm
- Element to remove from all relationsprivate void fixRelations(java.util.List<JoinAreasAction.RelationRole> rels, Way outer, JoinAreasAction.RelationRole ownMultipol, java.util.Set<Relation> relationsToDelete)
rels
- List of relations with roles the (original) ways were part ofouter
- The newly created outer area/wayownMultipol
- elements to directly add as outerrelationsToDelete
- set of relations to delete.private void stripTags(java.util.Collection<Way> ways)
ways
- The List of Ways to remove all tags fromprivate void makeCommitsOneAction(java.lang.String message)
message
- The commit message to displayprotected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
,
JosmAction.listenToLayerChange()
protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
JosmAction
updateEnabledState
in class JosmAction
selection
- the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState()
,
JosmAction.initEnabledState()
,
JosmAction.listenToSelectionChange()