public final class Way extends OsmPrimitive implements IWay
nodes
.AbstractPrimitive.KeyValueVisitor
Modifier and Type | Field and Description |
---|---|
private BBox |
bbox |
private Node[] |
nodes
All way nodes in this way
|
allPredicate, FLAG_ANNOTATED, FLAG_DIRECTION_REVERSED, FLAG_DISABLED, FLAG_DISABLED_TYPE, FLAG_HAS_DIRECTIONS, FLAG_HIDDEN_TYPE, FLAG_HIDE_IF_DISABLED, FLAG_HIGHLIGHTED, FLAG_TAGGED, isSelectablePredicate, isUsablePredicate, mappaintCacheIdx, mappaintStyle, modifiedPredicate, multipolygonPredicate, nodePredicate, nonDeletedCompletePredicate, nonDeletedPhysicalPredicate, nonDeletedPredicate, relationPredicate, wayPredicate
changesetId, FLAG_DELETED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_VISIBLE, flags, id, keys, timestamp, user, version
Modifier | Constructor and Description |
---|---|
|
Way()
Contructs a new
Way with id 0. |
|
Way(long id)
Contructs a new
Way for the given id. |
protected |
Way(long id,
boolean allowNegative) |
|
Way(long id,
int version)
Contructs a new
Way with given id and version. |
|
Way(Way original)
Contructs a new
Way from an existing Way (including its id). |
|
Way(Way original,
boolean clearMetadata)
Contructs a new
Way from an existing Way . |
Modifier and Type | Method and Description |
---|---|
void |
accept(PrimitiveVisitor visitor) |
void |
accept(Visitor visitor)
Implementation of the visitor scheme.
|
void |
addNode(int offs,
Node n)
Adds a node at position offs.
|
void |
addNode(Node n)
Adds a node to the end of the list of nodes.
|
private void |
checkNodes() |
void |
clearCachedNodeStyles() |
void |
cloneFrom(OsmPrimitive osm)
Get and write all attributes from the parameter.
|
int |
compareTo(OsmPrimitive o) |
boolean |
concernsArea()
Determines if this primitive semantically concerns an area.
|
boolean |
containsNode(Node node)
Replies true if this way contains the node
node , false
otherwise. |
private void |
fireNodesChanged() |
Node |
firstNode()
Returns the first node of this way.
|
Node |
firstNode(boolean respectOneway)
Replies the first node of this way, respecting or not its oneway state.
|
BBox |
getBBox()
Fetch the bounding box of the primitive
|
java.lang.String |
getDisplayName(NameFormatter formatter)
Replies the display name of a primitive formatted by
formatter |
OsmPrimitiveType |
getDisplayType() |
double |
getLength()
Replies the length of the way, in metres, as computed by
LatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.LatLon) . |
double |
getLongestSegmentLength()
Replies the length of the longest segment of the way, in metres, as computed by
LatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.LatLon) . |
java.util.Set<Node> |
getNeighbours(Node node)
Return nodes adjacent to
node |
Node |
getNode(int index)
Replies the node at position
index . |
long |
getNodeId(int idx) |
java.util.List<Pair<Node,Node>> |
getNodePairs(boolean sort)
Replies the ordered
List of chunks of this way. |
java.util.List<Node> |
getNodes()
You can modify returned list but changes will not be propagated back
to the Way.
|
int |
getNodesCount()
Replies the number of nodes in this way.
|
int |
getRealNodesCount()
Replies the real number of nodes in this way (full number of nodes minus one if this way is closed)
|
OsmPrimitiveType |
getType()
Gets the type of object represented by this object.
|
boolean |
hasEqualSemanticAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their semantic attributes.
|
boolean |
hasIncompleteNodes()
Replies true if this way has incomplete nodes, false otherwise.
|
boolean |
isArea()
Determines if this way denotes an area (closed way with at least three distinct nodes).
|
boolean |
isClosed() |
boolean |
isDrawable() |
boolean |
isFirstLastNode(Node n)
Replies true if the given node is the first or the last one of this way, false otherwise.
|
boolean |
isInnerNode(Node n)
Replies true if the given node is an inner node of this way, false otherwise.
|
int |
isOneway()
Tests if this way is a oneway.
|
boolean |
isOutsideDownloadArea()
Tests if this primitive lies outside of the downloaded area of its
DataSet . |
boolean |
isUsable()
Replies
true , if the object is usable
(i.e. |
protected void |
keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
What to do, when the tags have changed by one of the tag-changing methods.
|
Node |
lastNode()
Returns the last node of this way.
|
Node |
lastNode(boolean respectOneway)
Replies the last node of this way, respecting or not its oneway state.
|
void |
load(PrimitiveData data)
Loads (clone) this primitive from provided PrimitiveData
|
private static java.util.List<Node> |
removeDouble(java.util.List<Node> nodes)
Prevent directly following identical nodes in ways.
|
void |
removeNode(Node n)
Removes the given
Node from this way. |
void |
removeNodes(java.util.Set<? extends Node> selection)
Removes the given set of
nodes from this way. |
WayData |
save()
Save parameters of this primitive to the transport object
|
(package private) void |
setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods
|
void |
setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.
|
void |
setNodes(java.util.List<Node> nodes)
Set new list of nodes to way.
|
java.lang.String |
toString() |
void |
updatePosition()
Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)
|
addReferrer, checkDataset, clearCachedStyle, clearOsmMetadata, equals, evaluateCondition, getDataSet, getDisabledType, getDiscardableKeys, getFilteredList, getFilteredSet, getFlagsAsString, getHiddenType, getInterestingTags, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, getUninterestingKeys, getWorkInProgressKeys, hasAreaTags, hasDirectionKeys, hasEqualTechnicalAttributes, hashCode, hasSameInterestingTags, isAnnotated, isDisabled, isDisabledAndHidden, isHighlighted, isMemberOfSelected, isOuterMemberOfSelected, isReferredByWays, isSelectable, isSelected, isTagged, isUninterestingKey, mergeFrom, put, remove, removeAll, removeReferrer, reversedDirection, saveCommonAttributes, setChangesetId, setDisabledState, setDisabledType, setHiddenType, setHighlighted, setIncomplete, setKeys, setOsmId, setTimestamp, setUser, setVisible, unsetDisabledState, updateFlags, visitReferrers, writeLock, writeUnlock
cloneFrom, generateUniqueId, get, getChangesetId, getId, getIgnoreCase, getKeys, getLocalName, getName, getNumKeys, getPrimitiveId, getRawTimestamp, getTimestamp, getUniqueId, getUser, getVersion, hasKey, hasKeys, hasTag, hasTag, hasTag, isDeleted, isIncomplete, isKeyFalse, isKeyTrue, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isVisible, keySet, setModified, setRawTimestamp, visitKeys
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getChangesetId, getId, getLocalName, getName, getPrimitiveId, getRawTimestamp, getTimestamp, getUser, getVersion, isDeleted, isIncomplete, isModified, isNewOrUndeleted, isTimestampEmpty, isVisible, setChangesetId, setModified, setOsmId, setRawTimestamp, setTimestamp, setUser, setVisible
get, getKeys, hasKeys, keySet, put, remove, removeAll, setKeys
getUniqueId, isNew
protected Way(long id, boolean allowNegative)
public Way()
Way
with id 0.public Way(Way original, boolean clearMetadata)
Way
from an existing Way
.original
- The original Way
to be identically cloned. Must not be nullclearMetadata
- If true
, clears the OSM id and other metadata as defined by OsmPrimitive.clearOsmMetadata()
.
If false
, does nothingpublic Way(Way original)
Way
from an existing Way
(including its id).original
- The original Way
to be identically cloned. Must not be nullpublic Way(long id)
Way
for the given id. If the id > 0, the way is marked
as incomplete. If id == 0 then way is marked as newid
- the id. >= 0 requiredjava.lang.IllegalArgumentException
- if id < 0public Way(long id, int version)
Way
with given id and version.id
- the id. >= 0 requiredversion
- the versionjava.lang.IllegalArgumentException
- if id < 0public java.util.List<Node> getNodes()
setNodes(List)
to update this waypublic void setNodes(java.util.List<Node> nodes)
nodes
- New way nodes. Can be null, in that case all way nodes are removedprivate static java.util.List<Node> removeDouble(java.util.List<Node> nodes)
public int getNodesCount()
getNodesCount
in interface IWay
public int getRealNodesCount()
getNodesCount()
,
isClosed()
public Node getNode(int index)
index
.index
- the positionindex
java.lang.IndexOutOfBoundsException
- if index
< 0
or index
>= getNodesCount()
public boolean containsNode(Node node)
node
, false
otherwise. Replies false if node
is null.node
- the node. May be null.node
, false
otherwisepublic java.util.Set<Node> getNeighbours(Node node)
node
node
- the node. May be null.node
public java.util.List<Pair<Node,Node>> getNodePairs(boolean sort)
sort
- If true, the nodes of each pair are sorted as defined by Pair.sort(org.openstreetmap.josm.tools.Pair<T, T>)
.
If false, Pair.a and Pair.b are in the way order
(i.e for a given Pair(n), Pair(n-1).b == Pair(n).a, Pair(n).b == Pair(n+1).a, etc.)public void accept(Visitor visitor)
OsmPrimitive
accept
in class OsmPrimitive
visitor
- The visitor from which the visit() function must be called.public void accept(PrimitiveVisitor visitor)
accept
in interface IPrimitive
public void load(PrimitiveData data)
OsmPrimitive
load
in class OsmPrimitive
data
- The object which should be clonedpublic WayData save()
OsmPrimitive
save
in class OsmPrimitive
public void cloneFrom(OsmPrimitive osm)
OsmPrimitive
cloneFrom
in class OsmPrimitive
public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasEqualSemanticAttributes(OsmPrimitive other)
OsmPrimitive
hasEqualSemanticAttributes
in class OsmPrimitive
other
- other primitive to comparepublic int compareTo(OsmPrimitive o)
compareTo
in interface java.lang.Comparable<OsmPrimitive>
public void removeNode(Node n)
Node
from this way. Ignored, if n is null.n
- The node to remove. Ignored, if nullpublic void removeNodes(java.util.Set<? extends Node> selection)
nodes
from this way. Ignored, if selection is null.selection
- The selection of nodes to remove. Ignored, if nullpublic void addNode(Node n)
n
- the node. Ignored, if nulljava.lang.IllegalStateException
- if this way is marked as incomplete. We can't add a node
to an incomplete waypublic void addNode(int offs, Node n) throws java.lang.IndexOutOfBoundsException
offs
- the offsetn
- the node. Ignored, if null.java.lang.IllegalStateException
- if this way is marked as incomplete. We can't add a node
to an incomplete wayjava.lang.IndexOutOfBoundsException
- if offs is out of boundspublic void setDeleted(boolean deleted)
AbstractPrimitive
setDeleted
in interface IPrimitive
setDeleted
in class OsmPrimitive
deleted
- true, if this primitive is deleted; false, otherwisepublic boolean isArea()
true
if this way is closed and contains at least three distinct nodesisClosed()
public Node lastNode()
getNode
(getNodesCount
- 1).public Node firstNode()
getNode
(0)
.public boolean isFirstLastNode(Node n)
n
- The node to testn
is the first or the last node, false otherwise.public boolean isInnerNode(Node n)
n
- The node to testn
is an inner node, false otherwise.public java.lang.String getDisplayName(NameFormatter formatter)
OsmPrimitive
formatter
getDisplayName
in class OsmPrimitive
public OsmPrimitiveType getType()
PrimitiveId
getType
in interface PrimitiveId
Node
,
Way
,
Relation
public OsmPrimitiveType getDisplayType()
getDisplayType
in class AbstractPrimitive
private void checkNodes()
private void fireNodesChanged()
void setDataset(DataSet dataSet)
OsmPrimitive
setDataset
in class OsmPrimitive
dataSet
- the parent datasetpublic BBox getBBox()
OsmPrimitive
getBBox
in class OsmPrimitive
public void updatePosition()
OsmPrimitive
updatePosition
in class OsmPrimitive
public boolean hasIncompleteNodes()
public boolean isUsable()
AbstractPrimitive
true
, if the object is usable
(i.e. complete and not deleted).isUsable
in class AbstractPrimitive
true
, if the object is usable.AbstractPrimitive.setDeleted(boolean)
public boolean isDrawable()
isDrawable
in class OsmPrimitive
public double getLength()
LatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.LatLon)
.public double getLongestSegmentLength()
LatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.LatLon)
.public int isOneway()
1
if the way is a oneway,
-1
if the way is a reversed oneway,
0
otherwise.public Node firstNode(boolean respectOneway)
respectOneway
- If true and if this way is a reversed oneway, replies the last node. Otherwise, replies the first node.respectOneway
and its oneway state.public Node lastNode(boolean respectOneway)
respectOneway
- If true and if this way is a reversed oneway, replies the first node. Otherwise, replies the last node.respectOneway
and its oneway state.public boolean concernsArea()
OsmPrimitive
concernsArea
in class OsmPrimitive
true
if this primitive semantically concerns an area, according to its type, geometry and tags, false
otherwise.public boolean isOutsideDownloadArea()
OsmPrimitive
DataSet
.isOutsideDownloadArea
in class OsmPrimitive
true
if this primitive lies outside of the downloaded areaprotected void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
AbstractPrimitive
keysChangedImpl
in class OsmPrimitive
public void clearCachedNodeStyles()