|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.data.osm.AbstractPrimitive
org.openstreetmap.josm.data.osm.OsmPrimitive
org.openstreetmap.josm.data.osm.Way
public final class Way
One full way, consisting of a list of way nodes
.
Field Summary | |
---|---|
private BBox |
bbox
|
private Node[] |
nodes
All way nodes in this way |
Fields inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive |
---|
allPredicate, 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 |
Fields inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive |
---|
changesetId, FLAG_DELETED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_VISIBLE, flags, id, keys, timestamp, user, version |
Constructor Summary | |
---|---|
|
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 clearId)
Contructs a new Way from an existing Way . |
Method Summary | |
---|---|
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 |
cloneFrom(OsmPrimitive osm)
Get and write all attributes from the parameter. |
int |
compareTo(OsmPrimitive o)
|
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()
|
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) . |
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 ways. |
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 |
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 |
isUsable()
Replies true , if the object is usable
(i.e. |
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 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 |
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, ...) |
void |
visit(PrimitiveVisitor visitor)
|
void |
visit(Visitor visitor)
|
Methods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive |
---|
cloneFrom, generateUniqueId, get, getChangesetId, getId, getIgnoreCase, getKeys, getLocalName, getName, getPrimitiveId, getTimestamp, getUniqueId, getUser, getVersion, hasKey, hasKeys, hasSameTags, hasTag, hasTag, isDeleted, isIncomplete, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isVisible, keySet, setModified |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive |
---|
getChangesetId, getId, getLocalName, getName, getPrimitiveId, getTimestamp, getUser, getVersion, isDeleted, isIncomplete, isModified, isNewOrUndeleted, isTimestampEmpty, isVisible, setChangesetId, setModified, setOsmId, setTimestamp, setUser, setVisible |
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged |
---|
get, getKeys, hasKeys, keySet, put, remove, removeAll, setKeys |
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId |
---|
getUniqueId, isNew |
Field Detail |
---|
private Node[] nodes
private BBox bbox
Constructor Detail |
---|
protected Way(long id, boolean allowNegative)
public Way()
Way
with id 0.
public Way(Way original, boolean clearId)
Way
from an existing Way
.
original
- The original Way
to be identically cloned. Must not be nullclearId
- If true, clears the OSM id as defined by OsmPrimitive.clearOsmId()
. 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) throws java.lang.IllegalArgumentException
Way
for the given id. If the id > 0, the way is marked
as incomplete. If id == 0 then way is marked as new
id
- the id. >= 0 required
java.lang.IllegalArgumentException
- if id < 0public Way(long id, int version) throws java.lang.IllegalArgumentException
Way
with given id and version.
id
- the id. >= 0 requiredversion
- the version
java.lang.IllegalArgumentException
- if id < 0Method Detail |
---|
public java.util.List<Node> getNodes()
setNodes(List)
to update this way
public void setNodes(java.util.List<Node> nodes)
nodes
- New way nodes. Can be null, in that case all way nodes are removedprivate java.util.List<Node> removeDouble(java.util.List<Node> nodes)
public int getNodesCount()
getNodesCount
in interface IWay
public Node getNode(int index)
index
.
index
- the position
index
java.lang.IndexOutOfBoundsException
- thrown if index
< 0
or index
>= getNodesCount()
public long getNodeId(int idx)
getNodeId
in interface 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)
List
of chunks of this way. Each chunk is replied as a Pair
of nodes
.
sort
- If true, the nodes of each pair are sorted as defined by Pair.sort(org.openstreetmap.josm.tools.Pair)
.
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 visit(Visitor visitor)
visit
in class OsmPrimitive
public void visit(PrimitiveVisitor visitor)
visit
in interface IPrimitive
public void load(PrimitiveData data)
OsmPrimitive
load
in class OsmPrimitive
public 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
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) throws java.lang.IllegalStateException
n
- the node. Ignored, if null
java.lang.IllegalStateException
- thrown, 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.IllegalStateException, java.lang.IndexOutOfBoundsException
offs
- the offsetn
- the node. Ignored, if null.
java.lang.IllegalStateException
- thrown, if this way is marked as incomplete. We can't add a node
to an incomplete way
java.lang.IndexOutOfBoundsException
- thrown 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 isClosed()
isClosed
in interface IWay
public Node lastNode()
getNode
(getNodesCount
- 1).
public Node firstNode()
getNode
(0)
.
public boolean isFirstLastNode(Node n)
n
- The node to test
n
is the first or the last node, false otherwise.public boolean isInnerNode(Node n)
n
- The node to test
n
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()
public void setDataset(DataSet dataSet)
OsmPrimitive
setDataset
in class OsmPrimitive
public BBox getBBox()
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 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 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 oneway, replies the first node. Otherwise, replies the last node.
respectOneway
and its oneway state.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |