Package org.openstreetmap.josm.data.osm
Class Way
java.lang.Object
org.openstreetmap.josm.data.osm.AbstractPrimitive
org.openstreetmap.josm.data.osm.OsmPrimitive
org.openstreetmap.josm.data.osm.Way
- All Implemented Interfaces:
Comparable<IPrimitive>,IQuadBucketType,IFilterablePrimitive,IPrimitive,IWay<Node>,PrimitiveId,Stylable,Tagged,TemplateEngineDataProvider
One full way, consisting of a list of way
nodes.- Since:
- 64
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BBoxprivate static final Node[](package private) static final UniqueIdGeneratorprivate Node[]All way nodes in this wayFields inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive
directionKeysFields inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
changesetId, FLAG_ALL_REFERRERS_DOWNLOADED, 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, mappaintCacheIdx, timestamp, user, versionFields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionWay()Constructs a newWaywith id 0.Way(long id) Constructs a newWayfor the given id.Way(long id, boolean allowNegative) Way(long id, int version) Constructs a newWaywith given id and version.Constructs a newWayfrom an existingWay(including its id).Constructs a newWayfrom an existingWay.Constructs a newWayfrom an existingWay. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(OsmPrimitiveVisitor visitor) Implementation of the visitor scheme.voidaccept(PrimitiveVisitor visitor) Makes the given visitor visit this primitive.voidAdds a node at position offs.voidAdds a node to the end of the list of nodes.protected voidaddToBBox(BBox box, Set<PrimitiveId> visited) If necessary, extend the bbox to contain this primitivecalculateRemoveNodes(Set<? extends Node> selection) Calculate the remaining nodes after a removal of the given set ofnodesfrom this way.private voidvoidClears all cached styles for all nodes of this way.voidcloneFrom(OsmPrimitive osm, boolean copyNodes) Get and write all attributes from the parameter.booleanDetermines if this primitive semantically concerns an area.booleancontainsNode(Node node) Replies true if this way contains the nodenode, false otherwise.private voidReturns the first node of this way.firstNode(boolean respectOneway) Replies the first node of this way, respecting or not its oneway state.Returns angles of vertices.getBBox()Fetches the bounding box of the primitive.Gets the type this primitive is displayed atReturns the unique identifier generator.doubleReplies the length of the way, in metres, as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).doubleReplies the length of the longest segment of the way, in metres, as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).getNeighbours(Node node) Return nodes adjacent tonodegetNode(int index) Replies the node at positionindex.longgetNodeId(int idx) Returns id of the node at given index.Returns the list of node ids in this way.getNodePairs(boolean sort) Replies the orderedListof chunks of this way.getNodes()Returns the list of nodes in this way.intReplies the number of nodes in this way.double[]Replies the segment lengths of the way as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).getType()Gets the type of object represented by this object.booleanhasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly) booleanReplies true if this way has incomplete nodes, false otherwise.booleanReplies true if all nodes of the way have known lat/lon, false otherwise.booleanisArea()Determines if this way denotes an area (closed way with at least three distinct nodes).booleanisClosed()Determines if this way is closed.booleanDetermines if this object is drawable.booleanReplies true if the given node is the first or the last one of this way, false otherwise.booleanisInnerNode(INode n) Replies true if the given node is an inner node of this way, false otherwise.intisOneway()Tests if this way is a oneway.booleanTests if this primitive lies outside of the downloaded area of itsDataSet.booleanisUsable()Repliestrue, if the object is usable (i.e.protected voidkeysChangedImpl(Map<String, String> originalKeys) What to do, when the tags have changed by one of the tag-changing methods.lastNode()Returns the last node of this way.lastNode(boolean respectOneway) Replies the last node of this way, respecting or not its oneway state.voidload(PrimitiveData data) Loads (clone) this primitive from provided PrimitiveDataremoveDouble(List<Node> nodes) Prevent directly following identical nodes in ways.voidremoveNode(Node n) Removes the givenNodefrom this way.voidremoveNodes(Set<? extends Node> selection) Removes the given set ofnodesfrom this way.save()Save parameters of this primitive to the transport objectprivate DoubleStreamGet the segment lengths as a streamprivate void(package private) voidsetDataset(DataSet dataSet) This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methodsvoidsetDeleted(boolean deleted) Sets whether this primitive is deleted or not.voidSet new list of nodes to way.toString()voidCalled by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)Methods inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive
addReferrer, checkDataset, checkDatasetNotReadOnly, clearCachedStyle, clearOsmMetadata, cloneFrom, declareCachedStyleUpToDate, equals, evaluateCondition, getCachedStyle, getDataSet, getFlagsAsString, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, hasAreaTags, hasEqualSemanticAttributes, hasEqualSemanticFlags, hasEqualTechnicalAttributes, hashCode, isCachedStyleUpToDate, isMemberOfSelected, isNodeReferredByWays, isOuterMemberOfSelected, isSelectable, isSelected, mergeFrom, put, referrers, remove, removeAll, removeReferrer, saveCommonAttributes, setCachedStyle, setChangesetId, setDisabledState, setHighlighted, setIncomplete, setKeys, setKeys, setModified, setOsmId, setPreserved, setUser, setVisible, unsetDisabledState, updateDirectionFlags, updateFlags, visitReferrers, visitReferrers, writeLock, writeUnlockMethods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
cloneFrom, doGet, get, getChangesetId, getDisabledType, getDiscardableKeys, getHiddenType, getId, getIgnoreCase, getInstant, getInterestingTags, getKeys, getNumKeys, getRawTimestamp, getUninterestingKeys, getUniqueId, getUser, getVersion, getWorkInProgressKeys, hasDirectionKeys, hasKey, hasKey, hasKeys, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isHighlighted, isIncomplete, isModified, isNew, isNewOrUndeleted, isPreserved, isReferrersDownloaded, isTagged, isTimestampEmpty, isUndeleted, isUninterestingKey, isVisible, keys, keySet, putAll, reversedDirection, setDisabledType, setHiddenType, setInstant, setRawTimestamp, setReferrersDownloaded, updateFlagsChanged, visitKeysMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
getChangesetId, getDataSet, getId, getInstant, getInterestingTags, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getRawTimestamp, getReferrers, getReferrers, getStyleCacheSyncObject, getUser, getVersion, hasDirectionKeys, hasSameInterestingTags, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isHighlighted, isIncomplete, isMemberOfSelected, isModified, isMultipolygon, isNewOrUndeleted, isOuterMemberOfSelected, isPreserved, isReferrersDownloaded, isSelectable, isSelected, isTagged, isTimestampEmpty, isUndeleted, isVisible, reversedDirection, setChangesetId, setHighlighted, setInstant, setModified, setOsmId, setRawTimestamp, setReferrersDownloaded, setUser, setVisible, visitReferrersMethods inherited from interface org.openstreetmap.josm.data.osm.IWay
compareTo, getChildren, getDisplayName, getRealNodesCount, isEmptyMethods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getUniqueId, isNewMethods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyleMethods inherited from interface org.openstreetmap.josm.data.osm.Tagged
get, getKeys, getNumKeys, hasKey, hasKeys, hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, keys, keySet, put, put, putAll, remove, removeAll, setKeys, visitKeys
-
Field Details
-
idGenerator
-
EMPTY_NODES
-
nodes
All way nodes in this way -
bbox
-
-
Constructor Details
-
Way
Way(long id, boolean allowNegative) -
Way
public Way()Constructs a newWaywith id 0.- Since:
- 86
-
Way
Constructs a newWayfrom an existingWay. This adds links from all way nodes to the clone. See #19885 for possible memory leaks.- Parameters:
original- The originalWayto be identically cloned. Must not be nullclearMetadata- Iftrue, clears the OSM id and other metadata as defined byOsmPrimitive.clearOsmMetadata(). Iffalse, does nothingcopyNodes- whether to copy nodes too- Since:
- 16212
-
Way
Constructs a newWayfrom an existingWay. This adds links from all way nodes to the clone. See #19885 for possible memory leaks.- Parameters:
original- The originalWayto be identically cloned. Must not be nullclearMetadata- Iftrue, clears the OSM id and other metadata as defined byOsmPrimitive.clearOsmMetadata(). Iffalse, does nothing- Since:
- 2410
-
Way
Constructs a newWayfrom an existingWay(including its id). This adds links from all way nodes to the clone. See #19885 for possible memory leaks.- Parameters:
original- The originalWayto be identically cloned. Must not be null- Since:
- 86
-
Way
Constructs a newWayfor the given id. If the id > 0, the way is marked as incomplete. If id == 0 then way is marked as new- Parameters:
id- the id. >= 0 required- Throws:
IllegalArgumentException- if id < 0- Since:
- 343
-
Way
Constructs a newWaywith given id and version.- Parameters:
id- the id. >= 0 requiredversion- the version- Throws:
IllegalArgumentException- if id < 0- Since:
- 2620
-
-
Method Details
-
getNodes
Description copied from interface:IWayReturns the list of nodes in this way. -
setNodes
Description copied from interface:IWaySet new list of nodes to way. This method is preferred to multiple calls to addNode/removeNode and similar methods because nodes are internally saved as array which means lower memory overhead but also slower modifying operations. -
removeDouble
Prevent directly following identical nodes in ways.- Parameters:
nodes- list of nodes- Returns:
nodeswith consecutive identical nodes removed
-
getNodesCount
Description copied from interface:IWayReplies the number of nodes in this way.- Specified by:
getNodesCountin interfaceIWay<Node>- Returns:
- the number of nodes in this way.
-
getNode
Description copied from interface:IWayReplies the node at positionindex. -
getNodeId
Description copied from interface:IWayReturns id of the node at given index. -
getNodeIds
Description copied from interface:IWayReturns the list of node ids in this way.- Specified by:
getNodeIdsin interfaceIWay<Node>- Returns:
- the list of node ids in this way
-
containsNode
Replies true if this way contains the nodenode, false otherwise. Replies false ifnodeis null.- Parameters:
node- the node. May be null.- Returns:
- true if this way contains the node
node, false otherwise - Since:
- 1911
-
getNeighbours
Return nodes adjacent tonode- Parameters:
node- the node. May be null.- Returns:
- Set of nodes adjacent to
node - Since:
- 4671
-
getNodePairs
- Parameters:
sort- If true, the nodes of each pair are sorted as defined byPair.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.)- Returns:
- The ordered list of chunks of this way.
- Since:
- 3348
-
accept
Description copied from class:OsmPrimitiveImplementation of the visitor scheme. Subclasses have to call the correct visitor function.- Specified by:
acceptin classOsmPrimitive- Parameters:
visitor- The visitor from which the visit() function must be called.
-
accept
Description copied from interface:IPrimitiveMakes the given visitor visit this primitive.- Specified by:
acceptin interfaceIPrimitive- Parameters:
visitor- visitor
-
load
Description copied from class:OsmPrimitiveLoads (clone) this primitive from provided PrimitiveData- Overrides:
loadin classOsmPrimitive- Parameters:
data- The object which should be cloned
-
save
Description copied from class:OsmPrimitiveSave parameters of this primitive to the transport object- Specified by:
savein classOsmPrimitive- Returns:
- The saved object data
-
cloneFrom
Description copied from class:OsmPrimitiveGet and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Overrides:
cloneFromin classOsmPrimitive- Parameters:
osm- other primitivecopyNodes- whether to copy child primitives too
-
toString
-
hasEqualSemanticAttributes
- Overrides:
hasEqualSemanticAttributesin classOsmPrimitive
-
removeNode
Removes the givenNodefrom this way. Ignored, if n is null.- Parameters:
n- The node to remove. Ignored, if null- Since:
- 1463
-
removeNodes
Removes the given set ofnodesfrom this way. Ignored, if selection is null.- Parameters:
selection- The selection of nodes to remove. Ignored, if null- Since:
- 5408
-
calculateRemoveNodes
Calculate the remaining nodes after a removal of the given set ofnodesfrom this way.- Parameters:
selection- The selection of nodes to remove. Ignored, if null- Returns:
- result of the removal, can be empty
- Since:
- 17102
-
addNode
Adds a node to the end of the list of nodes. Ignored, if n is null.- Parameters:
n- the node. Ignored, if null- Throws:
IllegalStateException- if this way is marked as incomplete. We can't add a node to an incomplete way- Since:
- 1313
-
addNode
Adds a node at position offs.- Parameters:
offs- the offsetn- the node. Ignored, if null.- Throws:
IllegalStateException- if this way is marked as incomplete. We can't add a node to an incomplete wayIndexOutOfBoundsException- if offs is out of bounds- Since:
- 1313
-
setDeleted
Description copied from interface:IPrimitiveSets whether this primitive is deleted or not.Also marks this primitive as modified if deleted is true.
- Specified by:
setDeletedin interfaceIPrimitive- Overrides:
setDeletedin classOsmPrimitive- Parameters:
deleted- true, if this primitive is deleted; false, otherwise
-
isClosed
Description copied from interface:IWayDetermines if this way is closed. -
isArea
Determines if this way denotes an area (closed way with at least three distinct nodes).- Returns:
trueif this way is closed and contains at least three distinct nodes- Since:
- 5490
- See Also:
-
lastNode
Description copied from interface:IWayReturns the last node of this way. The result equals.getNode(getNodesCount- 1) -
firstNode
Description copied from interface:IWayReturns the first node of this way. The result equalsgetNode(0). -
isFirstLastNode
Description copied from interface:IWayReplies true if the given node is the first or the last one of this way, false otherwise.- Specified by:
isFirstLastNodein interfaceIWay<Node>- Parameters:
n- The node to test- Returns:
- true if the
nis the first or the last node, false otherwise.
-
isInnerNode
Description copied from interface:IWayReplies true if the given node is an inner node of this way, false otherwise.- Specified by:
isInnerNodein interfaceIWay<Node>- Parameters:
n- The node to test- Returns:
- true if the
nis an inner node, false otherwise.
-
getType
Description copied from interface:PrimitiveIdGets the type of object represented by this object. Note that this should return the base primitive type (OsmPrimitiveType.NODE,OsmPrimitiveType.WAY, andOsmPrimitiveType.RELATION).- Specified by:
getTypein interfacePrimitiveId- Returns:
- the object type
- See Also:
-
getDisplayType
Description copied from interface:IPrimitiveGets the type this primitive is displayed at- Specified by:
getDisplayTypein interfaceIPrimitive- Returns:
- A
OsmPrimitiveType
-
checkNodes
-
fireNodesChanged
-
setDataset
Description copied from class:OsmPrimitiveThis method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods- Overrides:
setDatasetin classOsmPrimitive- Parameters:
dataSet- the parent dataset
-
getBBox
Description copied from interface:IPrimitiveFetches the bounding box of the primitive. Since 17752, the returned bounding box might be immutable, i.e., modifying calls throw anUnsupportedOperationException.- Specified by:
getBBoxin interfaceIPrimitive- Specified by:
getBBoxin interfaceIQuadBucketType- Returns:
- Bounding box of the object
-
addToBBox
Description copied from class:OsmPrimitiveIf necessary, extend the bbox to contain this primitive- Specified by:
addToBBoxin classOsmPrimitive- Parameters:
box- a bbox instancevisited- a set of visited members or null
-
setBBox
-
updatePosition
Description copied from class:OsmPrimitiveCalled by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)- Specified by:
updatePositionin classOsmPrimitive
-
hasIncompleteNodes
Description copied from interface:IWayReplies true if this way has incomplete nodes, false otherwise.- Specified by:
hasIncompleteNodesin interfaceIWay<Node>- Returns:
- true if this way has incomplete nodes, false otherwise.
-
hasOnlyLocatableNodes
Replies true if all nodes of the way have known lat/lon, false otherwise.- Returns:
- true if all nodes of the way have known lat/lon, false otherwise
- Since:
- 13033
-
isUsable
Description copied from interface:IPrimitiveRepliestrue, if the object is usable (i.e. complete and not deleted).- Specified by:
isUsablein interfaceIPrimitive- Overrides:
isUsablein classAbstractPrimitive- Returns:
true, if the object is usable.- See Also:
-
isDrawable
Description copied from interface:IPrimitiveDetermines if this object is drawable.A primitive is drawable if all conditions are met:
- type and id is known
- tags are known
- it is not deleted
- it is not hidden by a filter
- for nodes: lat/lon are known
- for ways: all nodes are known and complete
- for relations: all members are known and complete
- Specified by:
isDrawablein interfaceIPrimitive- Overrides:
isDrawablein classAbstractPrimitive- Returns:
trueif this object is drawable
-
getLength
Replies the length of the way, in metres, as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).- Returns:
- The length of the way, in metres
- Since:
- 4138
-
getSegmentLengths
Replies the segment lengths of the way as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).- Returns:
- The segment lengths of a way in metres, following way direction
- Since:
- 18553
-
getLongestSegmentLength
Replies the length of the longest segment of the way, in metres, as computed byILatLon.greatCircleDistance(org.openstreetmap.josm.data.coor.ILatLon).- Returns:
- The length of the segment, in metres
- Since:
- 8320
-
segmentLengths
Get the segment lengths as a stream- Returns:
- The stream of segment lengths (ordered)
-
isOneway
Tests if this way is a oneway.- Returns:
1if the way is a oneway,-1if the way is a reversed oneway,0otherwise.- Since:
- 5199
-
firstNode
Replies the first node of this way, respecting or not its oneway state.- Parameters:
respectOneway- If true and if this way is a reversed oneway, replies the last node. Otherwise, replies the first node.- Returns:
- the first node of this way, according to
respectOnewayand its oneway state. - Since:
- 5199
-
lastNode
Replies the last node of this way, respecting or not its oneway state.- Parameters:
respectOneway- If true and if this way is a reversed oneway, replies the first node. Otherwise, replies the last node.- Returns:
- the last node of this way, according to
respectOnewayand its oneway state. - Since:
- 5199
-
concernsArea
Description copied from class:OsmPrimitiveDetermines if this primitive semantically concerns an area.- Specified by:
concernsAreain classOsmPrimitive- Returns:
trueif this primitive semantically concerns an area, according to its type, geometry and tags,falseotherwise.
-
isOutsideDownloadArea
Description copied from class:OsmPrimitiveTests if this primitive lies outside of the downloaded area of itsDataSet.- Specified by:
isOutsideDownloadAreain classOsmPrimitive- Returns:
trueif this primitive lies outside of the downloaded area
-
keysChangedImpl
Description copied from class:AbstractPrimitiveWhat to do, when the tags have changed by one of the tag-changing methods.- Overrides:
keysChangedImplin classOsmPrimitive- Parameters:
originalKeys- original tags
-
clearCachedNodeStyles
Clears all cached styles for all nodes of this way. This should not be called from outside.- See Also:
-
getAngles
Returns angles of vertices.- Returns:
- angles of the way
- Since:
- 13670
-
getIdGenerator
Description copied from class:AbstractPrimitiveReturns the unique identifier generator.- Specified by:
getIdGeneratorin classAbstractPrimitive- Returns:
- the unique identifier generator
-