Package org.openstreetmap.josm.data.osm
Class Node
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.AbstractPrimitive
-
- org.openstreetmap.josm.data.osm.OsmPrimitive
-
- org.openstreetmap.josm.data.osm.Node
-
- All Implemented Interfaces:
java.lang.Comparable<IPrimitive>,ILatLon,IQuadBucketType,IFilterablePrimitive,INode,IPrimitive,PrimitiveId,Stylable,Tagged,TemplateEngineDataProvider
public final class Node extends OsmPrimitive implements INode
One node data, consisting of one world coordinate waypoint.
-
-
Field Summary
Fields Modifier and Type Field Description private doubleeastprivate java.lang.ObjecteastNorthCacheKey(package private) static UniqueIdGeneratoridGeneratorprivate doublelatprivate doublelonprivate doublenorth-
Fields inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive
directionKeys
-
Fields 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, version
-
Fields inherited from interface org.openstreetmap.josm.data.coor.ILatLon
MAX_SERVER_PRECISION
-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Constructor Description Node()Constructs a new localNodewith id 0.Node(long id)Constructs an incompleteNodeobject with the given id.Node(long id, boolean allowNegative)Node(long id, int version)Constructs a newNodewith the given id and version.Node(EastNorth eastNorth)Constructs a newNodewith the given east/north with id 0.Node(LatLon latlon)Constructs a newNodewith the given lat/lon with id 0.Node(Node clone)Constructs an identical clone of the argument (including the id).Node(Node clone, boolean clearMetadata)Constructs an identical clone of the argument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(OsmPrimitiveVisitor visitor)Implementation of the visitor scheme.voidaccept(PrimitiveVisitor visitor)Makes the given visitor visit this primitive.protected voidaddToBBox(BBox box, java.util.Set<PrimitiveId> visited)If necessary, extend the bbox to contain this primitivevoidcloneFrom(OsmPrimitive osm, boolean copyChildren)Get and write all attributes from the parameter.booleanconcernsArea()Determines if this primitive semantically concerns an area.BBoxgetBBox()Fetches the bounding box of the primitive.LatLongetCoor()Returns lat/lon coordinates of this node, ornullunlessILatLon.isLatLonKnown()EastNorthgetEastNorth(Projecting projection)Replies the projected east/north coordinates.UniqueIdGeneratorgetIdGenerator()Returns the unique identifier generator.java.util.List<Way>getParentWays()Replies the list of referring ways.OsmPrimitiveTypegetType()Gets the type of object represented by this object.private booleanhasEqualCoordinates(Node other)booleanhasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)voidinvalidateEastNorthCache()Invoke to invalidate the internal cache of projected east/north coordinates.booleanisDrawable()Determines if this object is drawable.booleanisOutsideDownloadArea()Tests if this primitive lies outside of the downloaded area of itsDataSet.booleanisOutSideWorld()Determines if this node is outside of the world.booleanisReferredByWays(int n)Return true, if this primitive is referred by at least n waysdoublelat()Returns the latitude, i.e., the north-south position in degrees.voidload(PrimitiveData data)Loads (clone) this primitive from provided PrimitiveDatadoublelon()Returns the longitude, i.e., the east-west position in degrees.voidmergeFrom(OsmPrimitive other)Merges the technical and semantical attributes fromotheronto this.NodeDatasave()Save parameters of this primitive to the transport objectvoidsetCoor(LatLon coor)Sets lat/lon coordinates of this node.(package private) voidsetCoorInternal(LatLon coor, EastNorth eastNorth)To be used only by Dataset.reindexNode(package private) voidsetDataset(DataSet dataSet)This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methodsvoidsetEastNorth(EastNorth eastNorth)Sets east/north coordinates of this node.java.lang.StringtoString()private voidupdateCoor(LatLon coor, EastNorth eastNorth)protected voidupdateDirectionFlags()voidupdatePosition()Called 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, 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, keysChangedImpl, put, referrers, remove, removeAll, removeReferrer, saveCommonAttributes, setCachedStyle, setChangesetId, setDeleted, setDisabledState, setHighlighted, setIncomplete, setKeys, setKeys, setModified, setOsmId, setPreserved, setUser, setVisible, unsetDisabledState, updateFlags, visitReferrers, visitReferrers, writeLock, writeUnlock
-
Methods 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, isUsable, isVisible, keys, keySet, putAll, reversedDirection, setDisabledType, setHiddenType, setInstant, setRawTimestamp, setReferrersDownloaded, updateFlagsChanged, visitKeys
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.coor.ILatLon
bearing, distanceSq, distanceSq, equalsEpsilon, equalsEpsilon, greatCircleDistance, interpolate, isLatLonKnown
-
Methods inherited from interface org.openstreetmap.josm.data.osm.INode
compareTo, getDisplayName, getEastNorth, isConnectionNode
-
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
getChangesetId, getChildren, getDataSet, getDisplayType, 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, isUsable, isVisible, reversedDirection, setChangesetId, setDeleted, setHighlighted, setInstant, setModified, setOsmId, setRawTimestamp, setReferrersDownloaded, setUser, setVisible, visitReferrers
-
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getUniqueId, isNew
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyle
-
Methods 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 Detail
-
idGenerator
static final UniqueIdGenerator idGenerator
-
lat
private double lat
-
lon
private double lon
-
east
private double east
-
north
private double north
-
eastNorthCacheKey
private java.lang.Object eastNorthCacheKey
-
-
Constructor Detail
-
Node
Node(long id, boolean allowNegative)
-
Node
public Node()
Constructs a new localNodewith id 0.
-
Node
public Node(long id)
Constructs an incompleteNodeobject with the given id.- Parameters:
id- The id. Must be >= 0- Throws:
java.lang.IllegalArgumentException- if id < 0
-
Node
public Node(long id, int version)
Constructs a newNodewith the given id and version.- Parameters:
id- The id. Must be >= 0version- The version- Throws:
java.lang.IllegalArgumentException- if id < 0
-
Node
public Node(Node clone, boolean clearMetadata)
Constructs an identical clone of the argument.- Parameters:
clone- The node to cloneclearMetadata- Iftrue, clears the OSM id and other metadata as defined byOsmPrimitive.clearOsmMetadata(). Iffalse, does nothing
-
Node
public Node(Node clone)
Constructs an identical clone of the argument (including the id).- Parameters:
clone- The node to clone, including its id
-
Node
public Node(LatLon latlon)
Constructs a newNodewith the given lat/lon with id 0.- Parameters:
latlon- TheLatLoncoordinates
-
-
Method Detail
-
setCoor
public void setCoor(LatLon coor)
Description copied from interface:INodeSets lat/lon coordinates of this node.
-
setEastNorth
public void setEastNorth(EastNorth eastNorth)
Description copied from interface:INodeSets east/north coordinates of this node.- Specified by:
setEastNorthin interfaceINode- Parameters:
eastNorth- east/north coordinates of this node
-
updateCoor
private void updateCoor(LatLon coor, EastNorth eastNorth)
-
getCoor
public LatLon getCoor()
Returns lat/lon coordinates of this node, ornullunlessILatLon.isLatLonKnown()- Specified by:
getCoorin interfaceINode- Returns:
- lat/lon coordinates of this node, or
nullunlessILatLon.isLatLonKnown()
-
lat
public double lat()
Description copied from interface:ILatLonReturns the latitude, i.e., the north-south position in degrees.- Specified by:
latin interfaceILatLon- Returns:
- the latitude or NaN if
ILatLon.isLatLonKnown()returns false
-
lon
public double lon()
Description copied from interface:ILatLonReturns the longitude, i.e., the east-west position in degrees.- Specified by:
lonin interfaceILatLon- Returns:
- the longitude or NaN if
ILatLon.isLatLonKnown()returns false
-
getEastNorth
public EastNorth getEastNorth(Projecting projection)
Description copied from interface:ILatLonReplies the projected east/north coordinates.The result of the last conversion may be cached. Null is returned in case this object is invalid.
- Specified by:
getEastNorthin interfaceILatLon- Parameters:
projection- The projection to use.- Returns:
- The projected east/north coordinates
-
setCoorInternal
void setCoorInternal(LatLon coor, EastNorth eastNorth)
To be used only by Dataset.reindexNode- Parameters:
coor- lat/loneastNorth- east/north
-
setDataset
void setDataset(DataSet dataSet)
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
-
accept
public void accept(OsmPrimitiveVisitor visitor)
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
public void accept(PrimitiveVisitor visitor)
Description copied from interface:IPrimitiveMakes the given visitor visit this primitive.- Specified by:
acceptin interfaceIPrimitive- Parameters:
visitor- visitor
-
cloneFrom
public void cloneFrom(OsmPrimitive osm, boolean copyChildren)
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 primitivecopyChildren- whether to copy child primitives too
-
mergeFrom
public void mergeFrom(OsmPrimitive other)
Merges the technical and semantical attributes fromotheronto this. Both this and other must be new, or both must be assigned an OSM ID. If both this andotherhave an assigend OSM id, the IDs have to be the same.- Overrides:
mergeFromin classOsmPrimitive- Parameters:
other- the other primitive. Must not be null.- Throws:
java.lang.IllegalArgumentException- if other is null.DataIntegrityProblemException- if either this is new and other is not, or other is new and this is notDataIntegrityProblemException- if other is new and other.getId() != this.getId()
-
load
public void load(PrimitiveData data)
Description copied from class:OsmPrimitiveLoads (clone) this primitive from provided PrimitiveData- Overrides:
loadin classOsmPrimitive- Parameters:
data- The object which should be cloned
-
save
public NodeData save()
Description copied from class:OsmPrimitiveSave parameters of this primitive to the transport object- Specified by:
savein classOsmPrimitive- Returns:
- The saved object data
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hasEqualSemanticAttributes
public boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
- Overrides:
hasEqualSemanticAttributesin classOsmPrimitive
-
hasEqualCoordinates
private boolean hasEqualCoordinates(Node other)
-
getType
public OsmPrimitiveType 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:
Node,Way,Relation
-
getBBox
public BBox 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
protected void addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
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
-
updatePosition
public void updatePosition()
Description copied from class:OsmPrimitiveCalled by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)- Specified by:
updatePositionin classOsmPrimitive
-
isDrawable
public boolean 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
-
isReferredByWays
public boolean isReferredByWays(int n)
Description copied from interface:INodeReturn true, if this primitive is referred by at least n ways- Specified by:
isReferredByWaysin interfaceINode- Parameters:
n- Minimal number of ways to return true. Must be positive- Returns:
trueif this primitive is referred by at least n ways
-
invalidateEastNorthCache
public void invalidateEastNorthCache()
Invoke to invalidate the internal cache of projected east/north coordinates. Coordinates are reprojected on demand when theINode.getEastNorth()is invoked next time.
-
concernsArea
public boolean 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
public boolean 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
-
getParentWays
public java.util.List<Way> getParentWays()
Replies the list of referring ways.- Returns:
- the list of referring ways
- Since:
- 12031
-
isOutSideWorld
public boolean isOutSideWorld()
Determines if this node is outside of the world. See also #13538.- Returns:
true, if the coordinate is outside the world, compared by using lat/lon and east/north- Since:
- 14960
-
getIdGenerator
public UniqueIdGenerator getIdGenerator()
Description copied from class:AbstractPrimitiveReturns the unique identifier generator.- Specified by:
getIdGeneratorin classAbstractPrimitive- Returns:
- the unique identifier generator
-
updateDirectionFlags
protected void updateDirectionFlags()
- Overrides:
updateDirectionFlagsin classOsmPrimitive
-
-