Class OsmPrimitive
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.AbstractPrimitive
-
- org.openstreetmap.josm.data.osm.OsmPrimitive
-
- All Implemented Interfaces:
java.lang.Comparable<IPrimitive>
,IQuadBucketType
,IFilterablePrimitive
,IPrimitive
,PrimitiveId
,Stylable
,Tagged
,TemplateEngineDataProvider
public abstract class OsmPrimitive extends AbstractPrimitive implements TemplateEngineDataProvider
The base class for OSM objects (Node
,Way
,Relation
).It can be created, deleted and uploaded to the OSM-Server.
Although OsmPrimitive is designed as a base class, it is not to be meant to subclass it by any other than from the package
org.openstreetmap.josm.data.osm
. The available primitives are a fixed set that are given by the server environment and not an extendable data stuff.
-
-
Field Summary
Fields Modifier and Type Field Description private DataSet
dataSet
the parent dataset(package private) static SearchCompiler.Match
directionKeys
A tagged way that matches this pattern has a direction.private StyleCache
mappaintStyle
private java.lang.Object
referrers
private static SearchCompiler.Match
reversedDirectionKeys
A tagged way that matches this pattern has a direction that is reversed.private static java.lang.String
SPECIAL_VALUE_ID
private static java.lang.String
SPECIAL_VALUE_LOCAL_NAME
-
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.osm.Tagged
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OsmPrimitive(long id, boolean allowNegativeId)
Creates a new primitive for the given id.protected
OsmPrimitive(long id, int version, boolean allowNegativeId)
Creates a new primitive for the given id and version.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
accept(OsmPrimitiveVisitor visitor)
Implementation of the visitor scheme.protected void
addReferrer(OsmPrimitive referrer)
Add new referrer.protected abstract void
addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
If necessary, extend the bbox to contain this primitivevoid
checkDataset()
Throws exception if primitive is not part of the datasetprotected void
checkDatasetNotReadOnly()
Throws exception if primitive is in a read-only datasetvoid
clearOsmMetadata()
Clears the metadata, including id and version known to the OSM API.void
cloneFrom(OsmPrimitive other)
Get and write all attributes from the parameter.protected void
cloneFrom(OsmPrimitive other, boolean copyChildren)
Get and write all attributes from the parameter.private static SearchCompiler.Match
compileDirectionKeys(java.lang.String prefName, java.lang.String defaultValue)
abstract boolean
concernsArea()
Determines if this primitive semantically concerns an area.void
declareCachedStyleUpToDate()
Declare that the cached style for this primitive is up to date.private void
doVisitReferrers(java.util.function.Consumer<OsmPrimitive> visitor)
boolean
equals(java.lang.Object obj)
Equal if the id (and class) are equal.boolean
evaluateCondition(SearchCompiler.Match condition)
Check if a condition holds for the object represented by thisTemplateEngineDataProvider
.StyleCache
getCachedStyle()
Returns the cached style.DataSet
getDataSet()
Returns the parent data set of this primitive.protected java.lang.String
getFlagsAsString()
static java.util.Set<Relation>
getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the set of referring relationsstatic java.util.Set<OsmPrimitive>
getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the collection of referring primitives for the primitives inprimitives
.java.util.List<OsmPrimitive>
getReferrers()
Gets a list of all primitives in the current dataset that reference this primitive.java.util.List<OsmPrimitive>
getReferrers(boolean allowWithoutDataset)
Find primitives that reference this primitive.java.util.Collection<java.lang.String>
getTemplateKeys()
Get the collection of all keys that can be mapped to values.java.lang.Object
getTemplateValue(java.lang.String name, boolean special)
Map a key to a value given the properties of the object.boolean
hasAreaTags()
Determines if this primitive has tags denoting an area.boolean
hasEqualSemanticAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their semantic attributes.(package private) boolean
hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
(package private) boolean
hasEqualSemanticFlags(OsmPrimitive other)
boolean
hasEqualTechnicalAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their technical attributes.int
hashCode()
Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.boolean
isCachedStyleUpToDate()
Check if the cached style for this primitive is up to date.boolean
isMemberOfSelected()
Determines if this primitive is a member of a selected relation.protected boolean
isNodeReferredByWays(int n)
Return true, if this primitive is a node referred by at least n waysprivate boolean
isOuterMemberOfMultipolygon(OsmPrimitive ref)
boolean
isOuterMemberOfSelected()
Determines if this primitive is an outer member of a selected multipolygon relation.abstract boolean
isOutsideDownloadArea()
Tests if this primitive lies outside of the downloaded area of itsDataSet
.boolean
isSelectable()
Determines if this object is selectable.boolean
isSelected()
Determines whether the primitive is selectedprotected 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.void
load(PrimitiveData data)
Loads (clone) this primitive from provided PrimitiveDatavoid
mergeFrom(OsmPrimitive other)
Merges the technical and semantic attributes fromother
onto this.void
put(java.lang.String key, java.lang.String value)
Set the given value to the given key.private <T extends OsmPrimitive>
java.util.stream.Stream<T>referrers(boolean allowWithoutDataset, java.lang.Class<T> filter)
<T extends OsmPrimitive>
java.util.stream.Stream<T>referrers(java.lang.Class<T> filter)
Gets all primitives in the current dataset that reference this primitive.void
remove(java.lang.String key)
Remove the given key from the listvoid
removeAll()
Removes all keys from this primitive.protected void
removeReferrer(OsmPrimitive referrer)
Remove referrer.abstract PrimitiveData
save()
Save parameters of this primitive to the transport objectprotected void
saveCommonAttributes(PrimitiveData data)
Save common parameters of primitives to the transport objectvoid
setCachedStyle(StyleCache mappaintStyle)
Sets the cached style.void
setChangesetId(int changesetId)
Sets the changeset id of this primitive.(package private) void
setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methodsvoid
setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.boolean
setDisabledState(boolean hidden)
Make the primitive disabled (e.g. if a filter applies).void
setHighlighted(boolean highlighted)
Updates the highlight flag for this primitive.protected void
setIncomplete(boolean incomplete)
If set to true, this object is incomplete, which means only the id and type is known (type is the objects instance class)void
setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the keys of this primitives to the key/value pairs inkeys
.void
setKeys(TagMap keys)
Copy the keys from a TagMap.void
setModified(boolean modified)
Marks this primitive as being modified.void
setOsmId(long id, int version)
Sets the id and the version of this primitive if it is known to the OSM API.void
setPreserved(boolean isPreserved)
Set binary property used internally by the filter mechanism.void
setTimestamp(java.util.Date timestamp)
Deprecated, for removal: This API element is subject to removal in a future version.void
setUser(User user)
Sets the user who has last touched this object.void
setVisible(boolean visible)
Sets whether this primitive is visible, i.e.boolean
unsetDisabledState()
Remove the disabled flag from the primitive.private void
updateAnnotated()
protected void
updateDirectionFlags()
protected void
updateFlags(short flag, boolean value)
private void
updateFlagsNoLock(short flag, boolean value)
abstract void
updatePosition()
Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)private void
updateTagged()
void
visitReferrers(OsmPrimitiveVisitor visitor)
Visitsvisitor
for all referrers.void
visitReferrers(PrimitiveVisitor visitor)
Visitsvisitor
for all referrers.protected boolean
writeLock()
protected void
writeUnlock(boolean locked)
-
Methods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
cloneFrom, doGet, get, getChangesetId, getDisabledType, getDiscardableKeys, getHiddenType, getId, getIdGenerator, getIgnoreCase, getInstant, getInterestingTags, getKeys, getNumKeys, getRawTimestamp, getTimestamp, getUninterestingKeys, getUniqueId, getUser, getVersion, getWorkInProgressKeys, hasDirectionKeys, hasKey, hasKey, hasKeys, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isDrawable, 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, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
accept, getBBox, getChildren, getDisplayName, getDisplayType, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getStyleCacheSyncObject, hasSameInterestingTags, isMultipolygon
-
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged
hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, put
-
-
-
-
Field Detail
-
SPECIAL_VALUE_ID
private static final java.lang.String SPECIAL_VALUE_ID
- See Also:
- Constant Field Values
-
SPECIAL_VALUE_LOCAL_NAME
private static final java.lang.String SPECIAL_VALUE_LOCAL_NAME
- See Also:
- Constant Field Values
-
directionKeys
static volatile SearchCompiler.Match directionKeys
A tagged way that matches this pattern has a direction.- See Also:
AbstractPrimitive.FLAG_HAS_DIRECTIONS
-
reversedDirectionKeys
private static final SearchCompiler.Match reversedDirectionKeys
A tagged way that matches this pattern has a direction that is reversed.This pattern should be a subset of
directionKeys
-
mappaintStyle
private StyleCache mappaintStyle
-
referrers
private java.lang.Object referrers
-
-
Constructor Detail
-
OsmPrimitive
protected OsmPrimitive(long id, boolean allowNegativeId)
Creates a new primitive for the given id.If allowNegativeId is set, provided id can be < 0 and will be set to primitive without any processing. If allowNegativeId is not set, then id will have to be 0 (in that case new unique id will be generated) or positive number.
- Parameters:
id
- the idallowNegativeId
-true
to allow negative id- Throws:
java.lang.IllegalArgumentException
- if id < 0 and allowNegativeId is false
-
OsmPrimitive
protected OsmPrimitive(long id, int version, boolean allowNegativeId)
Creates a new primitive for the given id and version.If allowNegativeId is set, provided id can be < 0 and will be set to primitive without any processing. If allowNegativeId is not set, then id will have to be 0 (in that case new unique id will be generated) or positive number.
If id is not > 0 version is ignored and set to 0.
- Parameters:
id
- the idversion
- the version (positive integer)allowNegativeId
-true
to allow negative id- Throws:
java.lang.IllegalArgumentException
- if id < 0 and allowNegativeId is false
-
-
Method Detail
-
getReferrer
public static java.util.Set<OsmPrimitive> getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the collection of referring primitives for the primitives inprimitives
.- Parameters:
primitives
- the collection of primitives.- Returns:
- the collection of referring primitives for the primitives in
primitives
; empty set if primitives is null or if there are no referring primitives
-
getCachedStyle
public final StyleCache getCachedStyle()
Description copied from interface:Stylable
Returns the cached style.- Specified by:
getCachedStyle
in interfaceStylable
- Returns:
- the cached style
-
setCachedStyle
public final void setCachedStyle(StyleCache mappaintStyle)
Description copied from interface:Stylable
Sets the cached style.- Specified by:
setCachedStyle
in interfaceStylable
- Parameters:
mappaintStyle
- the cached style
-
isCachedStyleUpToDate
public final boolean isCachedStyleUpToDate()
Description copied from interface:Stylable
Check if the cached style for this primitive is up to date.- Specified by:
isCachedStyleUpToDate
in interfaceStylable
- Returns:
- true if the cached style for this primitive is up to date
-
declareCachedStyleUpToDate
public final void declareCachedStyleUpToDate()
Description copied from interface:Stylable
Declare that the cached style for this primitive is up to date.- Specified by:
declareCachedStyleUpToDate
in interfaceStylable
-
setDataset
void setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods- Parameters:
dataSet
- the parent dataset
-
getDataSet
public DataSet getDataSet()
Description copied from interface:IPrimitive
Returns the parent data set of this primitive.- Specified by:
getDataSet
in interfaceIPrimitive
- Returns:
- OsmData this primitive is part of.
-
checkDataset
public void checkDataset()
Throws exception if primitive is not part of the dataset
-
checkDatasetNotReadOnly
protected final void checkDatasetNotReadOnly()
Throws exception if primitive is in a read-only dataset
-
writeLock
protected boolean writeLock()
-
writeUnlock
protected void writeUnlock(boolean locked)
-
setOsmId
public void setOsmId(long id, int version)
Sets the id and the version of this primitive if it is known to the OSM API.Since we know the id and its version it can't be incomplete anymore. incomplete is set to false.
- Specified by:
setOsmId
in interfaceIPrimitive
- Overrides:
setOsmId
in classAbstractPrimitive
- Parameters:
id
- the id. > 0 requiredversion
- the version > 0 required- Throws:
java.lang.IllegalArgumentException
- if id <= 0java.lang.IllegalArgumentException
- if version <= 0DataIntegrityProblemException
- if id is changed and primitive was already added to the dataset
-
clearOsmMetadata
public void clearOsmMetadata()
Clears the metadata, including id and version known to the OSM API. The id is a new unique id. The version, changeset and timestamp are set to 0. incomplete and deleted are set to false. It's preferred to use copy constructor with clearMetadata set to true insteadCaution: Do not use this method on primitives which are already added to a
DataSet
.- Overrides:
clearOsmMetadata
in classAbstractPrimitive
- Throws:
DataIntegrityProblemException
- If primitive was already added to the dataset- Since:
- 6140
-
setUser
public void setUser(User user)
Description copied from interface:IPrimitive
Sets the user who has last touched this object.- Specified by:
setUser
in interfaceIPrimitive
- Overrides:
setUser
in classAbstractPrimitive
- Parameters:
user
- the user
-
setChangesetId
public void setChangesetId(int changesetId)
Description copied from interface:IPrimitive
Sets the changeset id of this primitive. Can't be set on a new primitive.- Specified by:
setChangesetId
in interfaceIPrimitive
- Overrides:
setChangesetId
in classAbstractPrimitive
- Parameters:
changesetId
- the id. >= 0 required.
-
setTimestamp
@Deprecated(since="17749", forRemoval=true) public void setTimestamp(java.util.Date timestamp)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IPrimitive
Sets time of last modification to this object- Specified by:
setTimestamp
in interfaceIPrimitive
- Overrides:
setTimestamp
in classAbstractPrimitive
- Parameters:
timestamp
- date of last modification- See Also:
IPrimitive.getTimestamp()
-
updateFlagsNoLock
private void updateFlagsNoLock(short flag, boolean value)
-
updateFlags
protected final void updateFlags(short flag, boolean value)
- Overrides:
updateFlags
in classAbstractPrimitive
-
setDisabledState
public boolean setDisabledState(boolean hidden)
Description copied from interface:IFilterablePrimitive
Make the primitive disabled (e.g. if a filter applies). To enable the primitive again, use unsetDisabledState.- Specified by:
setDisabledState
in interfaceIFilterablePrimitive
- Overrides:
setDisabledState
in classAbstractPrimitive
- Parameters:
hidden
- if the primitive should be completely hidden from view or just shown in gray color.- Returns:
- true, any flag has changed; false if you try to set the disabled state to the value that is already preset
-
unsetDisabledState
public boolean unsetDisabledState()
Remove the disabled flag from the primitive. Afterwards, the primitive is displayed normally and can be selected again.- Specified by:
unsetDisabledState
in interfaceIFilterablePrimitive
- Overrides:
unsetDisabledState
in classAbstractPrimitive
- Returns:
true
if a change occurred
-
setPreserved
public void setPreserved(boolean isPreserved)
Set binary property used internally by the filter mechanism.- Parameters:
isPreserved
- new "preserved" flag value- Since:
- 13309
-
isSelectable
public boolean isSelectable()
Description copied from interface:IPrimitive
Determines if this object is selectable.A primitive can be selected if all conditions are met:
- it is drawable
- it is not disabled (greyed out) by a filter.
- Specified by:
isSelectable
in interfaceIPrimitive
- Returns:
true
if this object is selectable
-
setModified
public void setModified(boolean modified)
Description copied from interface:IPrimitive
Marks this primitive as being modified.- Specified by:
setModified
in interfaceIPrimitive
- Overrides:
setModified
in classAbstractPrimitive
- Parameters:
modified
- true, if this primitive is to be modified
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:IPrimitive
Sets whether this primitive is visible, i.e. whether it is known on the server and not deleted on the server.- Specified by:
setVisible
in interfaceIPrimitive
- Overrides:
setVisible
in classAbstractPrimitive
- Parameters:
visible
-true
if this primitive is visible- See Also:
IPrimitive.isVisible()
-
setDeleted
public void setDeleted(boolean deleted)
Description copied from interface:IPrimitive
Sets whether this primitive is deleted or not.Also marks this primitive as modified if deleted is true.
- Specified by:
setDeleted
in interfaceIPrimitive
- Overrides:
setDeleted
in classAbstractPrimitive
- Parameters:
deleted
- true, if this primitive is deleted; false, otherwise
-
setIncomplete
protected final void setIncomplete(boolean incomplete)
Description copied from class:AbstractPrimitive
If set to true, this object is incomplete, which means only the id and type is known (type is the objects instance class)- Overrides:
setIncomplete
in classAbstractPrimitive
- Parameters:
incomplete
- incomplete flag value
-
isSelected
public boolean isSelected()
Description copied from interface:IPrimitive
Determines whether the primitive is selected- Specified by:
isSelected
in interfaceIPrimitive
- Returns:
- whether the primitive is selected
-
isMemberOfSelected
public boolean isMemberOfSelected()
Description copied from interface:IPrimitive
Determines if this primitive is a member of a selected relation.- Specified by:
isMemberOfSelected
in interfaceIPrimitive
- Returns:
true
if this primitive is a member of a selected relation,false
otherwise
-
isOuterMemberOfSelected
public boolean isOuterMemberOfSelected()
Description copied from interface:IPrimitive
Determines if this primitive is an outer member of a selected multipolygon relation.- Specified by:
isOuterMemberOfSelected
in interfaceIPrimitive
- Returns:
true
if this primitive is an outer member of a selected multipolygon relation,false
otherwise
-
isOuterMemberOfMultipolygon
private boolean isOuterMemberOfMultipolygon(OsmPrimitive ref)
-
setHighlighted
public void setHighlighted(boolean highlighted)
Description copied from interface:IPrimitive
Updates the highlight flag for this primitive.- Specified by:
setHighlighted
in interfaceIPrimitive
- Parameters:
highlighted
- The new highlight flag.
-
compileDirectionKeys
private static SearchCompiler.Match compileDirectionKeys(java.lang.String prefName, java.lang.String defaultValue) throws java.lang.AssertionError
- Throws:
java.lang.AssertionError
-
updateTagged
private void updateTagged()
-
updateAnnotated
private void updateAnnotated()
-
updateDirectionFlags
protected void updateDirectionFlags()
-
setKeys
public final void setKeys(TagMap keys)
Description copied from class:AbstractPrimitive
Copy the keys from a TagMap.- Overrides:
setKeys
in classAbstractPrimitive
- Parameters:
keys
- The new key map.
-
setKeys
public final void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Description copied from class:AbstractPrimitive
Sets the keys of this primitives to the key/value pairs inkeys
. Old key/value pairs are removed. Ifkeys
is null, clears existing key/value pairs.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
- Specified by:
setKeys
in interfaceTagged
- Overrides:
setKeys
in classAbstractPrimitive
- Parameters:
keys
- the key/value pairs to set. If null, removes all existing key/value pairs.
-
put
public final void put(java.lang.String key, java.lang.String value)
Description copied from class:AbstractPrimitive
Set the given value to the given key. If key is null, does nothing. If value is null, removes the key and behaves likeAbstractPrimitive.remove(String)
.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
- Specified by:
put
in interfaceTagged
- Overrides:
put
in classAbstractPrimitive
- Parameters:
key
- The key, for which the value is to be set. Can be null or empty, does nothing in this case.value
- The value for the key. If null, removes the respective key/value pair.- See Also:
AbstractPrimitive.remove(String)
-
remove
public final void remove(java.lang.String key)
Description copied from class:AbstractPrimitive
Remove the given key from the listNote that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
- Specified by:
remove
in interfaceTagged
- Overrides:
remove
in classAbstractPrimitive
- Parameters:
key
- the key to be removed. Ignored, if key is null.
-
removeAll
public final void removeAll()
Description copied from class:AbstractPrimitive
Removes all keys from this primitive.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
- Specified by:
removeAll
in interfaceTagged
- Overrides:
removeAll
in classAbstractPrimitive
-
keysChangedImpl
protected void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
Description copied from class:AbstractPrimitive
What to do, when the tags have changed by one of the tag-changing methods.- Specified by:
keysChangedImpl
in classAbstractPrimitive
- Parameters:
originalKeys
- original tags
-
addReferrer
protected void addReferrer(OsmPrimitive referrer)
Add new referrer. If referrer is already included then no action is taken- Parameters:
referrer
- The referrer to add
-
removeReferrer
protected void removeReferrer(OsmPrimitive referrer)
Remove referrer. No action is taken if referrer is not registered- Parameters:
referrer
- The referrer to remove
-
referrers
private <T extends OsmPrimitive> java.util.stream.Stream<T> referrers(boolean allowWithoutDataset, java.lang.Class<T> filter)
-
referrers
public final <T extends OsmPrimitive> java.util.stream.Stream<T> referrers(java.lang.Class<T> filter)
Gets all primitives in the current dataset that reference this primitive.- Type Parameters:
T
- type of primitives- Parameters:
filter
- restrict primitives to subclasses- Returns:
- the referrers as Stream
- Since:
- 14654
-
getReferrers
public final java.util.List<OsmPrimitive> getReferrers(boolean allowWithoutDataset)
Description copied from interface:IPrimitive
Find primitives that reference this primitive. Returns only primitives that are included in the same dataset as this primitive.
For example following code will add wnew as referer to all nodes of existingWay, but this method will not return wnew because it's not part of the dataset
Way wnew = new Way(existingWay)
- Specified by:
getReferrers
in interfaceIPrimitive
- Parameters:
allowWithoutDataset
- If true, method will return empty list if primitive is not part of the dataset. If false, exception will be thrown in this case- Returns:
- a collection of all primitives that reference this primitive.
-
getReferrers
public final java.util.List<OsmPrimitive> getReferrers()
Description copied from interface:IPrimitive
Gets a list of all primitives in the current dataset that reference this primitive.- Specified by:
getReferrers
in interfaceIPrimitive
- Returns:
- The referrers
-
visitReferrers
public void visitReferrers(OsmPrimitiveVisitor visitor)
Visits
visitor
for all referrers.- Parameters:
visitor
- the visitor. Ignored, if null.- Since:
- 12809
-
visitReferrers
public void visitReferrers(PrimitiveVisitor visitor)
Description copied from interface:IPrimitive
Visits
visitor
for all referrers.- Specified by:
visitReferrers
in interfaceIPrimitive
- Parameters:
visitor
- the visitor. Ignored, if null.
-
doVisitReferrers
private void doVisitReferrers(java.util.function.Consumer<OsmPrimitive> visitor)
-
isNodeReferredByWays
protected final boolean isNodeReferredByWays(int n)
Return true, if this primitive is a node referred by at least n ways- Parameters:
n
- Minimal number of ways to return true. Must be positive- Returns:
true
if this primitive is referred by at least n ways
-
accept
public abstract void accept(OsmPrimitiveVisitor visitor)
Implementation of the visitor scheme. Subclasses have to call the correct visitor function.- Parameters:
visitor
- The visitor from which the visit() function must be called.- Since:
- 12809
-
cloneFrom
public final void cloneFrom(OsmPrimitive other)
Get and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Parameters:
other
- other primitive
-
cloneFrom
protected void cloneFrom(OsmPrimitive other, boolean copyChildren)
Get and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Parameters:
other
- other primitivecopyChildren
- whether to copy child primitives too- Since:
- 16212
-
mergeFrom
public void mergeFrom(OsmPrimitive other)
Merges the technical and semantic attributes fromother
onto this.Both this and other must be new, or both must be assigned an OSM ID. If both this and
other
have an assigned OSM id, the IDs have to be the same.- 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 isn't new and other.getId() != this.getId()
-
hasEqualSemanticAttributes
public final boolean hasEqualSemanticAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their semantic attributes.- equal id
- both are complete or both are incomplete
- both have the same tags
- Parameters:
other
- other primitive to compare- Returns:
- true if this primitive and other are equal with respect to their semantic attributes.
-
hasEqualSemanticFlags
boolean hasEqualSemanticFlags(OsmPrimitive other)
-
hasEqualSemanticAttributes
boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)
-
hasEqualTechnicalAttributes
public boolean hasEqualTechnicalAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their technical attributes. The attributes:- deleted
- modified
- timestamp
- version
- visible
- user
- Parameters:
other
- the other primitive- Returns:
- true if this primitive and other are equal with respect to their technical attributes
-
load
public void load(PrimitiveData data)
Loads (clone) this primitive from provided PrimitiveData- Parameters:
data
- The object which should be cloned
-
save
public abstract PrimitiveData save()
Save parameters of this primitive to the transport object- Returns:
- The saved object data
-
saveCommonAttributes
protected void saveCommonAttributes(PrimitiveData data)
Save common parameters of primitives to the transport object- Parameters:
data
- The object to save the data into
-
updatePosition
public abstract void updatePosition()
Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)
-
getFlagsAsString
protected java.lang.String getFlagsAsString()
- Overrides:
getFlagsAsString
in classAbstractPrimitive
-
equals
public boolean equals(java.lang.Object obj)
Equal if the id (and class) are equal.A primitive is equal to its incomplete counterpart.
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.A primitive has the same hashcode as its incomplete counterpart.
- Overrides:
hashCode
in classjava.lang.Object
-
getTemplateKeys
public java.util.Collection<java.lang.String> getTemplateKeys()
Description copied from interface:TemplateEngineDataProvider
Get the collection of all keys that can be mapped to values.- Specified by:
getTemplateKeys
in interfaceTemplateEngineDataProvider
- Returns:
- all keys that can be mapped to values
-
getTemplateValue
public java.lang.Object getTemplateValue(java.lang.String name, boolean special)
Description copied from interface:TemplateEngineDataProvider
Map a key to a value given the properties of the object.- Specified by:
getTemplateValue
in interfaceTemplateEngineDataProvider
- Parameters:
name
- the key to mapspecial
- if the key is a "special:*" keyword that is used to get certain information or automated behavior- Returns:
- a value that the key is mapped to or "special" information in case
special
is true
-
evaluateCondition
public boolean evaluateCondition(SearchCompiler.Match condition)
Description copied from interface:TemplateEngineDataProvider
Check if a condition holds for the object represented by thisTemplateEngineDataProvider
.- Specified by:
evaluateCondition
in interfaceTemplateEngineDataProvider
- Parameters:
condition
- the condition to check (which is a search expression)- Returns:
- true if the condition holds
-
getParentRelations
public static java.util.Set<Relation> getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the set of referring relations- Parameters:
primitives
- primitives to fetch relations from- Returns:
- the set of referring relations
-
hasAreaTags
public final boolean hasAreaTags()
Determines if this primitive has tags denoting an area.- Returns:
true
if this primitive has tags denoting an area,false
otherwise.- Since:
- 6491
-
concernsArea
public abstract boolean concernsArea()
Determines if this primitive semantically concerns an area.- Returns:
true
if this primitive semantically concerns an area, according to its type, geometry and tags,false
otherwise.- Since:
- 6491
-
isOutsideDownloadArea
public abstract boolean isOutsideDownloadArea()
Tests if this primitive lies outside of the downloaded area of itsDataSet
.- Returns:
true
if this primitive lies outside of the downloaded area
-
addToBBox
protected abstract void addToBBox(BBox box, java.util.Set<PrimitiveId> visited)
If necessary, extend the bbox to contain this primitive- Parameters:
box
- a bbox instancevisited
- a set of visited members or null- Since:
- 11269
-
-