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, directionalKeyPredicate, 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, wayPredicatechangesetId, 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)
Makes the given visitor visit this primitive.
|
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)
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.
|
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,
boolean testInterestingTagsOnly) |
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()
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, clearCachedStyle, clearOsmMetadata, equals, evaluateCondition, getDataSet, getDisabledType, getDiscardableKeys, getFilteredList, getFilteredSet, getFlagsAsString, getHiddenType, getInterestingTags, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, getUninterestingKeys, getWorkInProgressKeys, hasAreaTags, hasDirectionKeys, hasEqualSemanticAttributes, 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, setKeys, setModified, setOsmId, setTimestamp, setUser, setVisible, unsetDisabledState, updateFlags, visitReferrers, writeLock, writeUnlockcloneFrom, 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, setRawTimestamp, visitKeysclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetChangesetId, getId, getLocalName, getName, getPrimitiveId, getRawTimestamp, getTimestamp, getUser, getVersion, isDeleted, isIncomplete, isModified, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isVisible, setChangesetId, setModified, setOsmId, setRawTimestamp, setTimestamp, setUser, setVisibleget, getKeys, hasKeys, keySet, put, remove, removeAll, setKeysgetUniqueId, isNewprotected 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()
IWaygetNodesCount in interface IWaypublic int getRealNodesCount()
getNodesCount(),
isClosed()public Node getNode(int index)
index.index - the positionindexjava.lang.IndexOutOfBoundsException - if index < 0
or index >= getNodesCount()public long getNodeId(int idx)
IWaypublic 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(Visitor 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 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)
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()
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)
OsmPrimitiveformattergetDisplayName in class OsmPrimitiveformatter - formatter to usepublic OsmPrimitiveType getType()
PrimitiveIdgetType in interface PrimitiveIdNode,
Way,
Relationpublic OsmPrimitiveType getDisplayType()
getDisplayType in class AbstractPrimitiveprivate void checkNodes()
private void fireNodesChanged()
void setDataset(DataSet dataSet)
OsmPrimitivesetDataset in class OsmPrimitivedataSet - the parent datasetpublic BBox getBBox()
OsmPrimitivegetBBox in class OsmPrimitivepublic void updatePosition()
OsmPrimitiveupdatePosition in class OsmPrimitivepublic boolean hasIncompleteNodes()
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()
OsmPrimitiveisDrawable 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()