public final class Way extends OsmPrimitive implements IWay
nodes
.Modifier and Type | Field and Description |
---|---|
private BBox |
bbox |
private Node[] |
nodes
All way nodes in this way
|
directionKeys, mappaintStyle
changesetId, FLAG_ANNOTATED, FLAG_DELETED, FLAG_DIRECTION_REVERSED, FLAG_DISABLED, FLAG_DISABLED_TYPE, FLAG_HAS_DIRECTIONS, FLAG_HIDDEN_TYPE, FLAG_HIDE_IF_DISABLED, FLAG_HIGHLIGHTED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_PRESERVED, FLAG_TAGGED, FLAG_VISIBLE, flags, id, keys, timestamp, user, version
MAX_TAG_LENGTH
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(OsmPrimitiveVisitor visitor)
Implementation of the visitor scheme.
|
void |
accept(PrimitiveVisitor visitor)
Makes the given visitor visit this primitive.
|
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.
|
protected void |
addToBBox(BBox box,
java.util.Set<PrimitiveId> visited)
If necessary, extend the bbox to contain this primitive
|
private void |
checkNodes() |
void |
clearCachedNodeStyles()
Clears all cached styles for all nodes of this way.
|
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
|
OsmPrimitiveType |
getDisplayType()
Gets the type this primitive is displayed at
|
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)
Returns id of the node at given index.
|
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.
|
OsmPrimitiveType |
getType()
Gets the type of object represented by this object.
|
boolean |
hasEqualSemanticAttributes(OsmPrimitive other,
boolean testInterestingTagsOnly) |
boolean |
hasIncompleteNodes()
Replies true if this way has incomplete nodes, false otherwise.
|
boolean |
hasOnlyLocatableNodes()
Replies true if all nodes of the way have known lat/lon, false otherwise.
|
boolean |
isArea()
Determines if this way denotes an area (closed way with at least three distinct nodes).
|
boolean |
isClosed()
Determines if this way is closed.
|
boolean |
isDrawable()
Determines if this object is drawable.
|
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, checkDatasetNotReadOnly, clearCachedStyle, clearOsmMetadata, declareCachedStyleUpToDate, equals, evaluateCondition, getDataSet, getDisabledType, getDiscardableKeys, getFilteredList, getFilteredSet, getFlagsAsString, getHiddenType, getInterestingTags, getMappaintCacheIdx, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, getUninterestingKeys, getWorkInProgressKeys, hasAreaTags, hasDirectionKeys, hasEqualSemanticAttributes, hasEqualSemanticFlags, hasEqualTechnicalAttributes, hashCode, hasSameInterestingTags, isAnnotated, isCachedStyleUpToDate, isDisabled, isDisabledAndHidden, isHighlighted, isMemberOfSelected, isMultipolygon, isOuterMemberOfSelected, isPreserved, isReferredByWays, isSelectable, isSelected, isTagged, isUninterestingKey, mergeFrom, put, remove, removeAll, removeReferrer, reversedDirection, saveCommonAttributes, setChangesetId, setDisabledState, setDisabledType, setHiddenType, setHighlighted, setIncomplete, setKeys, setKeys, setMappaintCacheIdx, setModified, setOsmId, setPreserved, setTimestamp, setUser, setVisible, unsetDisabledState, updateFlags, visitReferrers, writeLock, writeUnlock
advanceUniqueId, cloneFrom, currentUniqueId, generateUniqueId, get, getChangesetId, getId, getIgnoreCase, getKeys, getLocalName, getName, getNumKeys, getPrimitiveId, getRawTimestamp, getTimestamp, getUniqueId, getUser, getVersion, hasKey, hasKey, hasKeys, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isDeleted, isIncomplete, isKeyFalse, isKeyTrue, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isVisible, keySet, setRawTimestamp, visitKeys
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getDisplayName, getRealNodesCount
getChangesetId, getId, getLocalName, getName, getPrimitiveId, getRawTimestamp, getTimestamp, getUser, getVersion, isDeleted, isIncomplete, isModified, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isVisible, setChangesetId, setModified, setOsmId, setRawTimestamp, setTimestamp, setUser, setVisible
get, getKeys, hasKey, hasKeys, hasTag, keySet, put, 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)
nodes
- list of nodesnodes
with consecutive identical nodes removedpublic int getNodesCount()
IWay
getNodesCount
in interface IWay
public Node getNode(int index)
index
.index
- the positionindex
java.lang.ArrayIndexOutOfBoundsException
- if index
< 0
or index
>= getNodesCount()
public long getNodeId(int idx)
IWay
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(OsmPrimitiveVisitor visitor)
OsmPrimitive
accept
in class OsmPrimitive
visitor
- The visitor from which the visit() function must be called.public void accept(PrimitiveVisitor visitor)
IPrimitive
accept
in interface IPrimitive
visitor
- visitorpublic 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
osm
- other primitivepublic java.lang.String toString()
toString
in class java.lang.Object
public boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
hasEqualSemanticAttributes
in class OsmPrimitive
public 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)
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)
IPrimitive
setDeleted
in interface IPrimitive
setDeleted
in class OsmPrimitive
deleted
- true, if this primitive is deleted; false, otherwisepublic boolean isClosed()
IWay
public 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 OsmPrimitiveType getType()
PrimitiveId
getType
in interface PrimitiveId
Node
,
Way
,
Relation
public OsmPrimitiveType getDisplayType()
IPrimitive
getDisplayType
in interface IPrimitive
OsmPrimitiveType
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
protected void addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
OsmPrimitive
addToBBox
in class OsmPrimitive
box
- a bbox instancevisited
- a set of visited members or nullpublic void updatePosition()
OsmPrimitive
updatePosition
in class OsmPrimitive
public boolean hasIncompleteNodes()
public boolean hasOnlyLocatableNodes()
public boolean isUsable()
IPrimitive
true
, if the object is usable
(i.e. complete and not deleted).isUsable
in interface IPrimitive
isUsable
in class AbstractPrimitive
true
, if the object is usable.IPrimitive.setDeleted(boolean)
public boolean isDrawable()
OsmPrimitive
A primitive is complete if all conditions are met:
isDrawable
in class OsmPrimitive
true
if this object is drawablepublic 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
originalKeys
- original tagspublic void clearCachedNodeStyles()
OsmPrimitive.clearCachedStyle()