public class SimplifyWayAction extends JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
sc
Constructor and Description |
---|
SimplifyWayAction()
Constructs a new
SimplifyWayAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
protected void |
alertSelectAtLeastOneWay() |
static double |
askSimplifyWays(java.lang.String text,
boolean auto)
Asks the user for max-err value used to simplify ways, if not remembered before
|
protected static void |
buildSimplifiedNodeList(java.util.List<Node> wnew,
int from,
int to,
double threshold,
java.util.List<Node> simplifiedNodes)
Builds the simplified list of nodes for a way segment given by a lower index
from
and an upper index to |
protected boolean |
confirmSimplifyManyWays(int numWays) |
protected boolean |
confirmWayWithNodesOutsideBoundingBox(java.util.List<? extends OsmPrimitive> primitives) |
private static double |
course(double lat1,
double lon1,
double lat2,
double lon2) |
static SequenceCommand |
createSimplifyCommand(Way w)
Creates the SequenceCommand to simplify a way with default threshold.
|
static SequenceCommand |
createSimplifyCommand(Way w,
double threshold)
Creates the SequenceCommand to simplify a way with a given threshold.
|
private static double |
dist(double lat1,
double lon1,
double lat2,
double lon2) |
private static java.util.Set<Node> |
getMultiUseNodes(Way w)
Calculate a set of nodes which occurs more than once in the way
|
protected static boolean |
isRequiredNode(Way way,
Node node,
java.util.Set<Node> multipleUseNodes)
Replies true if
node is a required node which can't be removed
in order to simplify the way. |
SequenceCommand |
simplifyWay(Way w)
Deprecated.
Replaced by
createSimplifyCommand(Way) . You can also use simplifyWays(List, double) directly. |
static SequenceCommand |
simplifyWay(Way w,
double threshold)
Deprecated.
Replaced by
createSimplifyCommand(Way, double) . You can also use simplifyWays(List, double) directly. |
static void |
simplifyWays(java.util.List<Way> ways,
double threshold)
Runs the commands to simplify the ways with the given threshold
|
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.
|
private static double |
xtd(double lat1,
double lon1,
double lat2,
double lon2,
double lat3,
double lon3) |
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setTooltip, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
public SimplifyWayAction()
SimplifyWayAction
.protected boolean confirmWayWithNodesOutsideBoundingBox(java.util.List<? extends OsmPrimitive> primitives)
protected void alertSelectAtLeastOneWay()
protected boolean confirmSimplifyManyWays(int numWays)
public static double askSimplifyWays(java.lang.String text, boolean auto)
text
- the text being shownauto
- whether it's called automatically (conversion) or by the userpublic void actionPerformed(java.awt.event.ActionEvent e)
protected static boolean isRequiredNode(Way way, Node node, java.util.Set<Node> multipleUseNodes)
node
is a required node which can't be removed
in order to simplify the way.way
- the way to be simplifiednode
- the node to checkmultipleUseNodes
- set of nodes which is used more than once in the waynode
is a required node which can't be removed
in order to simplify the way.private static java.util.Set<Node> getMultiUseNodes(Way w)
w
- the waypublic static void simplifyWays(java.util.List<Way> ways, double threshold)
ways
- the ways to simplifythreshold
- the max error threshold@Deprecated public final SequenceCommand simplifyWay(Way w)
createSimplifyCommand(Way)
. You can also use simplifyWays(List, double)
directly.w
- the way to simplify@Deprecated public static SequenceCommand simplifyWay(Way w, double threshold)
createSimplifyCommand(Way, double)
. You can also use simplifyWays(List, double)
directly.w
- the way to simplifythreshold
- the max error thresholdpublic static SequenceCommand createSimplifyCommand(Way w)
w
- the way to simplifypublic static SequenceCommand createSimplifyCommand(Way w, double threshold)
w
- the way to simplifythreshold
- the max error thresholdprotected static void buildSimplifiedNodeList(java.util.List<Node> wnew, int from, int to, double threshold, java.util.List<Node> simplifiedNodes)
from
and an upper index to
wnew
- the way to simplifyfrom
- the lower indexto
- the upper indexthreshold
- the max error thresholdsimplifiedNodes
- list that will contain resulting nodesprivate static double dist(double lat1, double lon1, double lat2, double lon2)
private static double course(double lat1, double lon1, double lat2, double lon2)
private static double xtd(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3)
protected 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()