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 double
east
private java.lang.Object
eastNorthCacheKey
(package private) static UniqueIdGenerator
idGenerator
private double
lat
private double
lon
private double
north
-
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 localNode
with id 0.Node(long id)
Constructs an incompleteNode
object with the given id.Node(long id, boolean allowNegative)
Node(long id, int version)
Constructs a newNode
with the given id and version.Node(EastNorth eastNorth)
Constructs a newNode
with the given east/north with id 0.Node(LatLon latlon)
Constructs a newNode
with 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 void
accept(OsmPrimitiveVisitor visitor)
Implementation of the visitor scheme.void
accept(PrimitiveVisitor visitor)
Makes the given visitor visit this primitive.protected void
addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
If necessary, extend the bbox to contain this primitivevoid
cloneFrom(OsmPrimitive osm, boolean copyChildren)
Get and write all attributes from the parameter.boolean
concernsArea()
Determines if this primitive semantically concerns an area.BBox
getBBox()
Fetches the bounding box of the primitive.LatLon
getCoor()
Returns lat/lon coordinates of this node, ornull
unlessILatLon.isLatLonKnown()
EastNorth
getEastNorth(Projecting projection)
Replies the projected east/north coordinates.UniqueIdGenerator
getIdGenerator()
Returns the unique identifier generator.java.util.List<Way>
getParentWays()
Replies the list of referring ways.OsmPrimitiveType
getType()
Gets the type of object represented by this object.private boolean
hasEqualCoordinates(Node other)
boolean
hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
void
invalidateEastNorthCache()
Invoke to invalidate the internal cache of projected east/north coordinates.boolean
isDrawable()
Determines if this object is drawable.boolean
isOutsideDownloadArea()
Tests if this primitive lies outside of the downloaded area of itsDataSet
.boolean
isOutSideWorld()
Determines if this node is outside of the world.boolean
isReferredByWays(int n)
Return true, if this primitive is referred by at least n waysdouble
lat()
Returns the latitude, i.e., the north-south position in degrees.void
load(PrimitiveData data)
Loads (clone) this primitive from provided PrimitiveDatadouble
lon()
Returns the longitude, i.e., the east-west position in degrees.void
mergeFrom(OsmPrimitive other)
Merges the technical and semantical attributes fromother
onto this.NodeData
save()
Save parameters of this primitive to the transport objectvoid
setCoor(LatLon coor)
Sets lat/lon coordinates of this node.(package private) void
setCoorInternal(LatLon coor, EastNorth eastNorth)
To be used only by Dataset.reindexNode(package private) void
setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methodsvoid
setEastNorth(EastNorth eastNorth)
Sets east/north coordinates of this node.java.lang.String
toString()
private void
updateCoor(LatLon coor, EastNorth eastNorth)
protected void
updateDirectionFlags()
void
updatePosition()
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 localNode
with id 0.
-
Node
public Node(long id)
Constructs an incompleteNode
object 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 newNode
with 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 newNode
with the given lat/lon with id 0.- Parameters:
latlon
- TheLatLon
coordinates
-
-
Method Detail
-
setCoor
public void setCoor(LatLon coor)
Description copied from interface:INode
Sets lat/lon coordinates of this node.
-
setEastNorth
public void setEastNorth(EastNorth eastNorth)
Description copied from interface:INode
Sets east/north coordinates of this node.- Specified by:
setEastNorth
in 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, ornull
unlessILatLon.isLatLonKnown()
- Specified by:
getCoor
in interfaceINode
- Returns:
- lat/lon coordinates of this node, or
null
unlessILatLon.isLatLonKnown()
-
lat
public double lat()
Description copied from interface:ILatLon
Returns the latitude, i.e., the north-south position in degrees.- Specified by:
lat
in interfaceILatLon
- Returns:
- the latitude or NaN if
ILatLon.isLatLonKnown()
returns false
-
lon
public double lon()
Description copied from interface:ILatLon
Returns the longitude, i.e., the east-west position in degrees.- Specified by:
lon
in interfaceILatLon
- Returns:
- the longitude or NaN if
ILatLon.isLatLonKnown()
returns false
-
getEastNorth
public EastNorth getEastNorth(Projecting projection)
Description copied from interface:ILatLon
Replies 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:
getEastNorth
in 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:OsmPrimitive
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods- Overrides:
setDataset
in classOsmPrimitive
- Parameters:
dataSet
- the parent dataset
-
accept
public void accept(OsmPrimitiveVisitor visitor)
Description copied from class:OsmPrimitive
Implementation of the visitor scheme. Subclasses have to call the correct visitor function.- Specified by:
accept
in classOsmPrimitive
- Parameters:
visitor
- The visitor from which the visit() function must be called.
-
accept
public void accept(PrimitiveVisitor visitor)
Description copied from interface:IPrimitive
Makes the given visitor visit this primitive.- Specified by:
accept
in interfaceIPrimitive
- Parameters:
visitor
- visitor
-
cloneFrom
public void cloneFrom(OsmPrimitive osm, boolean copyChildren)
Description copied from class:OsmPrimitive
Get and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Overrides:
cloneFrom
in classOsmPrimitive
- Parameters:
osm
- other primitivecopyChildren
- whether to copy child primitives too
-
mergeFrom
public void mergeFrom(OsmPrimitive other)
Merges the technical and semantical attributes fromother
onto this. Both this and other must be new, or both must be assigned an OSM ID. If both this andother
have an assigend OSM id, the IDs have to be the same.- Overrides:
mergeFrom
in 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:OsmPrimitive
Loads (clone) this primitive from provided PrimitiveData- Overrides:
load
in classOsmPrimitive
- Parameters:
data
- The object which should be cloned
-
save
public NodeData save()
Description copied from class:OsmPrimitive
Save parameters of this primitive to the transport object- Specified by:
save
in classOsmPrimitive
- Returns:
- The saved object data
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hasEqualSemanticAttributes
public boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
- Overrides:
hasEqualSemanticAttributes
in classOsmPrimitive
-
hasEqualCoordinates
private boolean hasEqualCoordinates(Node other)
-
getType
public OsmPrimitiveType getType()
Description copied from interface:PrimitiveId
Gets 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:
getType
in interfacePrimitiveId
- Returns:
- the object type
- See Also:
Node
,Way
,Relation
-
getBBox
public BBox getBBox()
Description copied from interface:IPrimitive
Fetches the bounding box of the primitive. Since 17752, the returned bounding box might be immutable, i.e., modifying calls throw anUnsupportedOperationException
.- Specified by:
getBBox
in interfaceIPrimitive
- Specified by:
getBBox
in interfaceIQuadBucketType
- Returns:
- Bounding box of the object
-
addToBBox
protected void addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
Description copied from class:OsmPrimitive
If necessary, extend the bbox to contain this primitive- Specified by:
addToBBox
in classOsmPrimitive
- Parameters:
box
- a bbox instancevisited
- a set of visited members or null
-
updatePosition
public void updatePosition()
Description copied from class:OsmPrimitive
Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)- Specified by:
updatePosition
in classOsmPrimitive
-
isDrawable
public boolean isDrawable()
Description copied from interface:IPrimitive
Determines 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:
isDrawable
in interfaceIPrimitive
- Overrides:
isDrawable
in classAbstractPrimitive
- Returns:
true
if this object is drawable
-
isReferredByWays
public boolean isReferredByWays(int n)
Description copied from interface:INode
Return true, if this primitive is referred by at least n ways- Specified by:
isReferredByWays
in interfaceINode
- Parameters:
n
- Minimal number of ways to return true. Must be positive- Returns:
true
if 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:OsmPrimitive
Determines if this primitive semantically concerns an area.- Specified by:
concernsArea
in classOsmPrimitive
- Returns:
true
if this primitive semantically concerns an area, according to its type, geometry and tags,false
otherwise.
-
isOutsideDownloadArea
public boolean isOutsideDownloadArea()
Description copied from class:OsmPrimitive
Tests if this primitive lies outside of the downloaded area of itsDataSet
.- Specified by:
isOutsideDownloadArea
in classOsmPrimitive
- Returns:
true
if 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:AbstractPrimitive
Returns the unique identifier generator.- Specified by:
getIdGenerator
in classAbstractPrimitive
- Returns:
- the unique identifier generator
-
updateDirectionFlags
protected void updateDirectionFlags()
- Overrides:
updateDirectionFlags
in classOsmPrimitive
-
-