public final class Way extends OsmPrimitive implements IWay<Node>
nodes.| Modifier and Type | Field and Description |
|---|---|
private BBox |
bbox |
private Node[] |
nodes
All way nodes in this way
|
directionKeyschangesetId, 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, versionMAX_TAG_LENGTH| Modifier | Constructor and Description |
|---|---|
|
Way()
Constructs a new
Way with id 0. |
|
Way(long id)
Constructs a new
Way for the given id. |
protected |
Way(long id,
boolean allowNegative) |
|
Way(long id,
int version)
Constructs a new
Way with given id and version. |
|
Way(Way original)
Constructs a new
Way from an existing Way (including its id). |
|
Way(Way original,
boolean clearMetadata)
Constructs 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.
|
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.
|
java.util.List<Pair<java.lang.Double,Node>> |
getAngles()
Returns angles of vertices.
|
BBox |
getBBox()
Fetches 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<java.lang.Long> |
getNodeIds()
Returns the list of node ids in this way.
|
java.util.List<Pair<Node,Node>> |
getNodePairs(boolean sort)
Replies the ordered
List of chunks of this way. |
java.util.List<Node> |
getNodes()
Returns the list of nodes in this 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(INode n)
Replies true if the given node is the first or the last one of this way, false otherwise.
|
boolean |
isInnerNode(INode 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, clearOsmMetadata, declareCachedStyleUpToDate, equals, evaluateCondition, getCachedStyle, getDataSet, getDisabledType, getFlagsAsString, getHiddenType, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, hasAreaTags, hasDirectionKeys, hasEqualSemanticAttributes, hasEqualSemanticFlags, hasEqualTechnicalAttributes, hashCode, isAnnotated, isCachedStyleUpToDate, isDisabled, isDisabledAndHidden, isHighlighted, isMemberOfSelected, isNodeReferredByWays, isOuterMemberOfSelected, isPreserved, isSelectable, isSelected, isTagged, mergeFrom, put, referrers, remove, removeAll, removeReferrer, reversedDirection, saveCommonAttributes, setCachedStyle, setChangesetId, setDisabledState, setDisabledType, setHiddenType, setHighlighted, setIncomplete, setKeys, setKeys, setModified, setOsmId, setPreserved, setTimestamp, setUser, setVisible, unsetDisabledState, updateFlags, visitReferrers, visitReferrers, writeLock, writeUnlockadvanceUniqueId, cloneFrom, currentUniqueId, doGet, generateUniqueId, get, getChangesetId, getDiscardableKeys, getId, getIgnoreCase, getInterestingTags, getKeys, getNumKeys, getRawTimestamp, getTimestamp, getUninterestingKeys, getUniqueId, getUser, getVersion, getWorkInProgressKeys, hasKey, hasKey, hasKeys, isDeleted, isIncomplete, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isUninterestingKey, isVisible, keySet, setRawTimestamp, visitKeysclone, finalize, getClass, notify, notifyAll, wait, wait, waitcompareTo, getDisplayName, getRealNodesCountgetChangesetId, getDataSet, getId, getInterestingTags, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getRawTimestamp, getReferrers, getReferrers, getTimestamp, getUser, getVersion, hasDirectionKeys, hasSameInterestingTags, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isHighlighted, isIncomplete, isMemberOfSelected, isModified, isMultipolygon, isNewOrUndeleted, isOuterMemberOfSelected, isPreserved, isSelectable, isSelected, isTagged, isTimestampEmpty, isUndeleted, isVisible, reversedDirection, setChangesetId, setHighlighted, setModified, setOsmId, setRawTimestamp, setTimestamp, setUser, setVisible, visitReferrersget, getKeys, getNumKeys, hasKey, hasKeys, hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, keySet, put, put, remove, removeAll, setKeys, visitKeysgetUniqueId, isNewclearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyleprotected 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()
IWaypublic void setNodes(java.util.List<Node> nodes)
IWayprivate static java.util.List<Node> removeDouble(java.util.List<Node> nodes)
nodes - list of nodesnodes with consecutive identical nodes removedpublic int getNodesCount()
IWaygetNodesCount in interface IWay<Node>public Node getNode(int index)
IWayindex.public long getNodeId(int idx)
IWaypublic java.util.List<java.lang.Long> getNodeIds()
IWaygetNodeIds in interface IWay<Node>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)
nodenode - the node. May be null.nodepublic 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)
OsmPrimitiveaccept in class OsmPrimitivevisitor - The visitor from which the visit() function must be called.public void accept(PrimitiveVisitor visitor)
IPrimitiveaccept in interface IPrimitivevisitor - visitorpublic void load(PrimitiveData data)
OsmPrimitiveload in class OsmPrimitivedata - The object which should be clonedpublic WayData save()
OsmPrimitivesave in class OsmPrimitivepublic void cloneFrom(OsmPrimitive osm)
OsmPrimitivecloneFrom in class OsmPrimitiveosm - other primitivepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
hasEqualSemanticAttributes in class OsmPrimitivepublic 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)
IPrimitivesetDeleted in interface IPrimitivesetDeleted in class OsmPrimitivedeleted - true, if this primitive is deleted; false, otherwisepublic boolean isClosed()
IWaypublic boolean isArea()
true if this way is closed and contains at least three distinct nodesisClosed()public Node lastNode()
IWaygetNode(getNodesCount - 1).public Node firstNode()
IWaygetNode(0).public boolean isFirstLastNode(INode n)
IWayisFirstLastNode in interface IWay<Node>n - The node to testn is the first or the last node, false otherwise.public boolean isInnerNode(INode n)
IWayisInnerNode in interface IWay<Node>n - The node to testn is an inner node, false otherwise.public OsmPrimitiveType getType()
PrimitiveIdgetType in interface PrimitiveIdNode,
Way,
Relationpublic OsmPrimitiveType getDisplayType()
IPrimitivegetDisplayType in interface IPrimitiveOsmPrimitiveTypeprivate void checkNodes()
private void fireNodesChanged()
void setDataset(DataSet dataSet)
OsmPrimitivesetDataset in class OsmPrimitivedataSet - the parent datasetpublic BBox getBBox()
IPrimitivegetBBox in interface IPrimitiveprotected void addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
OsmPrimitiveaddToBBox in class OsmPrimitivebox - a bbox instancevisited - a set of visited members or nullpublic void updatePosition()
OsmPrimitiveupdatePosition in class OsmPrimitivepublic boolean hasIncompleteNodes()
public boolean hasOnlyLocatableNodes()
public boolean isUsable()
IPrimitivetrue, if the object is usable
(i.e. complete and not deleted).isUsable in interface IPrimitiveisUsable in class AbstractPrimitivetrue, if the object is usable.IPrimitive.setDeleted(boolean)public boolean isDrawable()
IPrimitiveA primitive is drawable if all conditions are met:
isDrawable in interface IPrimitiveisDrawable in class OsmPrimitivetrue 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()
OsmPrimitiveconcernsArea in class OsmPrimitivetrue if this primitive semantically concerns an area, according to its type, geometry and tags, false otherwise.public boolean isOutsideDownloadArea()
OsmPrimitiveDataSet.isOutsideDownloadArea in class OsmPrimitivetrue if this primitive lies outside of the downloaded areaprotected void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
AbstractPrimitivekeysChangedImpl in class OsmPrimitiveoriginalKeys - original tagspublic void clearCachedNodeStyles()
Stylable.clearCachedStyle()