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 DataSetdataSetthe parent dataset(package private) static SearchCompiler.MatchdirectionKeysA tagged way that matches this pattern has a direction.private StyleCachemappaintStyleprivate java.lang.Objectreferrersprivate static SearchCompiler.MatchreversedDirectionKeysA tagged way that matches this pattern has a direction that is reversed.private static java.lang.StringSPECIAL_VALUE_IDprivate static java.lang.StringSPECIAL_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 protectedOsmPrimitive(long id, boolean allowNegativeId)Creates a new primitive for the given id.protectedOsmPrimitive(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 Modifier and Type Method Description abstract voidaccept(OsmPrimitiveVisitor visitor)Implementation of the visitor scheme.protected voidaddReferrer(OsmPrimitive referrer)Add new referrer.protected abstract voidaddToBBox(BBox box, java.util.Set<PrimitiveId> visited)If necessary, extend the bbox to contain this primitivevoidcheckDataset()Throws exception if primitive is not part of the datasetprotected voidcheckDatasetNotReadOnly()Throws exception if primitive is in a read-only datasetvoidclearOsmMetadata()Clears the metadata, including id and version known to the OSM API.voidcloneFrom(OsmPrimitive other)Get and write all attributes from the parameter.protected voidcloneFrom(OsmPrimitive other, boolean copyChildren)Get and write all attributes from the parameter.private static SearchCompiler.MatchcompileDirectionKeys(java.lang.String prefName, java.lang.String defaultValue)abstract booleanconcernsArea()Determines if this primitive semantically concerns an area.voiddeclareCachedStyleUpToDate()Declare that the cached style for this primitive is up to date.private voiddoVisitReferrers(java.util.function.Consumer<OsmPrimitive> visitor)booleanequals(java.lang.Object obj)Equal if the id (and class) are equal.booleanevaluateCondition(SearchCompiler.Match condition)Check if a condition holds for the object represented by thisTemplateEngineDataProvider.StyleCachegetCachedStyle()Returns the cached style.DataSetgetDataSet()Returns the parent data set of this primitive.protected java.lang.StringgetFlagsAsString()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.ObjectgetTemplateValue(java.lang.String name, boolean special)Map a key to a value given the properties of the object.booleanhasAreaTags()Determines if this primitive has tags denoting an area.booleanhasEqualSemanticAttributes(OsmPrimitive other)Replies true if this primitive and other are equal with respect to their semantic attributes.(package private) booleanhasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly)(package private) booleanhasEqualSemanticFlags(OsmPrimitive other)booleanhasEqualTechnicalAttributes(OsmPrimitive other)Replies true if this primitive and other are equal with respect to their technical attributes.inthashCode()Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.booleanisCachedStyleUpToDate()Check if the cached style for this primitive is up to date.booleanisMemberOfSelected()Determines if this primitive is a member of a selected relation.protected booleanisNodeReferredByWays(int n)Return true, if this primitive is a node referred by at least n waysprivate booleanisOuterMemberOfMultipolygon(OsmPrimitive ref)booleanisOuterMemberOfSelected()Determines if this primitive is an outer member of a selected multipolygon relation.abstract booleanisOutsideDownloadArea()Tests if this primitive lies outside of the downloaded area of itsDataSet.booleanisSelectable()Determines if this object is selectable.booleanisSelected()Determines whether the primitive is selectedprotected voidkeysChangedImpl(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.voidload(PrimitiveData data)Loads (clone) this primitive from provided PrimitiveDatavoidmergeFrom(OsmPrimitive other)Merges the technical and semantic attributes fromotheronto this.voidput(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.voidremove(java.lang.String key)Remove the given key from the listvoidremoveAll()Removes all keys from this primitive.protected voidremoveReferrer(OsmPrimitive referrer)Remove referrer.abstract PrimitiveDatasave()Save parameters of this primitive to the transport objectprotected voidsaveCommonAttributes(PrimitiveData data)Save common parameters of primitives to the transport objectvoidsetCachedStyle(StyleCache mappaintStyle)Sets the cached style.voidsetChangesetId(int changesetId)Sets the changeset id of this primitive.(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.booleansetDisabledState(boolean hidden)Make the primitive disabled (e.g. if a filter applies).voidsetHighlighted(boolean highlighted)Updates the highlight flag for this primitive.protected voidsetIncomplete(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)voidsetKeys(java.util.Map<java.lang.String,java.lang.String> keys)Sets the keys of this primitives to the key/value pairs inkeys.voidsetKeys(TagMap keys)Copy the keys from a TagMap.voidsetModified(boolean modified)Marks this primitive as being modified.voidsetOsmId(long id, int version)Sets the id and the version of this primitive if it is known to the OSM API.voidsetPreserved(boolean isPreserved)Set binary property used internally by the filter mechanism.voidsetUser(User user)Sets the user who has last touched this object.voidsetVisible(boolean visible)Sets whether this primitive is visible, i.e.booleanunsetDisabledState()Remove the disabled flag from the primitive.private voidupdateAnnotated()protected voidupdateDirectionFlags()protected voidupdateFlags(short flag, boolean value)private voidupdateFlagsNoLock(short flag, boolean value)abstract voidupdatePosition()Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)private voidupdateTagged()voidvisitReferrers(OsmPrimitiveVisitor visitor)Visitsvisitorfor all referrers.voidvisitReferrers(PrimitiveVisitor visitor)Visitsvisitorfor all referrers.protected booleanwriteLock()protected voidwriteUnlock(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, 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-trueto 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-trueto 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:StylableReturns the cached style.- Specified by:
getCachedStylein interfaceStylable- Returns:
- the cached style
-
setCachedStyle
public final void setCachedStyle(StyleCache mappaintStyle)
Description copied from interface:StylableSets the cached style.- Specified by:
setCachedStylein interfaceStylable- Parameters:
mappaintStyle- the cached style
-
isCachedStyleUpToDate
public final boolean isCachedStyleUpToDate()
Description copied from interface:StylableCheck if the cached style for this primitive is up to date.- Specified by:
isCachedStyleUpToDatein interfaceStylable- Returns:
- true if the cached style for this primitive is up to date
-
declareCachedStyleUpToDate
public final void declareCachedStyleUpToDate()
Description copied from interface:StylableDeclare that the cached style for this primitive is up to date.- Specified by:
declareCachedStyleUpToDatein 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:IPrimitiveReturns the parent data set of this primitive.- Specified by:
getDataSetin 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:
setOsmIdin interfaceIPrimitive- Overrides:
setOsmIdin 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:
clearOsmMetadatain classAbstractPrimitive- Throws:
DataIntegrityProblemException- If primitive was already added to the dataset- Since:
- 6140
-
setUser
public void setUser(User user)
Description copied from interface:IPrimitiveSets the user who has last touched this object.- Specified by:
setUserin interfaceIPrimitive- Overrides:
setUserin classAbstractPrimitive- Parameters:
user- the user
-
setChangesetId
public void setChangesetId(int changesetId)
Description copied from interface:IPrimitiveSets the changeset id of this primitive. Can't be set on a new primitive.- Specified by:
setChangesetIdin interfaceIPrimitive- Overrides:
setChangesetIdin classAbstractPrimitive- Parameters:
changesetId- the id. >= 0 required.
-
updateFlagsNoLock
private void updateFlagsNoLock(short flag, boolean value)
-
updateFlags
protected final void updateFlags(short flag, boolean value)
- Overrides:
updateFlagsin classAbstractPrimitive
-
setDisabledState
public boolean setDisabledState(boolean hidden)
Description copied from interface:IFilterablePrimitiveMake the primitive disabled (e.g. if a filter applies). To enable the primitive again, use unsetDisabledState.- Specified by:
setDisabledStatein interfaceIFilterablePrimitive- Overrides:
setDisabledStatein 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:
unsetDisabledStatein interfaceIFilterablePrimitive- Overrides:
unsetDisabledStatein classAbstractPrimitive- Returns:
trueif 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:IPrimitiveDetermines 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:
isSelectablein interfaceIPrimitive- Returns:
trueif this object is selectable
-
setModified
public void setModified(boolean modified)
Description copied from interface:IPrimitiveMarks this primitive as being modified.- Specified by:
setModifiedin interfaceIPrimitive- Overrides:
setModifiedin classAbstractPrimitive- Parameters:
modified- true, if this primitive is to be modified
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:IPrimitiveSets whether this primitive is visible, i.e. whether it is known on the server and not deleted on the server.- Specified by:
setVisiblein interfaceIPrimitive- Overrides:
setVisiblein classAbstractPrimitive- Parameters:
visible-trueif this primitive is visible- See Also:
IPrimitive.isVisible()
-
setDeleted
public void setDeleted(boolean deleted)
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 classAbstractPrimitive- Parameters:
deleted- true, if this primitive is deleted; false, otherwise
-
setIncomplete
protected final void setIncomplete(boolean incomplete)
Description copied from class:AbstractPrimitiveIf set to true, this object is incomplete, which means only the id and type is known (type is the objects instance class)- Overrides:
setIncompletein classAbstractPrimitive- Parameters:
incomplete- incomplete flag value
-
isSelected
public boolean isSelected()
Description copied from interface:IPrimitiveDetermines whether the primitive is selected- Specified by:
isSelectedin interfaceIPrimitive- Returns:
- whether the primitive is selected
-
isMemberOfSelected
public boolean isMemberOfSelected()
Description copied from interface:IPrimitiveDetermines if this primitive is a member of a selected relation.- Specified by:
isMemberOfSelectedin interfaceIPrimitive- Returns:
trueif this primitive is a member of a selected relation,falseotherwise
-
isOuterMemberOfSelected
public boolean isOuterMemberOfSelected()
Description copied from interface:IPrimitiveDetermines if this primitive is an outer member of a selected multipolygon relation.- Specified by:
isOuterMemberOfSelectedin interfaceIPrimitive- Returns:
trueif this primitive is an outer member of a selected multipolygon relation,falseotherwise
-
isOuterMemberOfMultipolygon
private boolean isOuterMemberOfMultipolygon(OsmPrimitive ref)
-
setHighlighted
public void setHighlighted(boolean highlighted)
Description copied from interface:IPrimitiveUpdates the highlight flag for this primitive.- Specified by:
setHighlightedin 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:AbstractPrimitiveCopy the keys from a TagMap.- Overrides:
setKeysin 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:AbstractPrimitiveSets the keys of this primitives to the key/value pairs inkeys. Old key/value pairs are removed. Ifkeysis 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:
setKeysin interfaceTagged- Overrides:
setKeysin 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:AbstractPrimitiveSet 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:
putin interfaceTagged- Overrides:
putin 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:AbstractPrimitiveRemove 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:
removein interfaceTagged- Overrides:
removein classAbstractPrimitive- Parameters:
key- the key to be removed. Ignored, if key is null.
-
removeAll
public final void removeAll()
Description copied from class:AbstractPrimitiveRemoves 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:
removeAllin interfaceTagged- Overrides:
removeAllin classAbstractPrimitive
-
keysChangedImpl
protected void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
Description copied from class:AbstractPrimitiveWhat to do, when the tags have changed by one of the tag-changing methods.- Specified by:
keysChangedImplin 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:IPrimitiveFind 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:
getReferrersin 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:IPrimitiveGets a list of all primitives in the current dataset that reference this primitive.- Specified by:
getReferrersin interfaceIPrimitive- Returns:
- The referrers
-
visitReferrers
public void visitReferrers(OsmPrimitiveVisitor visitor)
Visits
visitorfor all referrers.- Parameters:
visitor- the visitor. Ignored, if null.- Since:
- 12809
-
visitReferrers
public void visitReferrers(PrimitiveVisitor visitor)
Description copied from interface:IPrimitiveVisits
visitorfor all referrers.- Specified by:
visitReferrersin 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:
trueif 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 fromotheronto this.Both this and other must be new, or both must be assigned an OSM ID. If both this and
otherhave 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:
getFlagsAsStringin 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:
equalsin 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:
hashCodein classjava.lang.Object
-
getTemplateKeys
public java.util.Collection<java.lang.String> getTemplateKeys()
Description copied from interface:TemplateEngineDataProviderGet the collection of all keys that can be mapped to values.- Specified by:
getTemplateKeysin 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:TemplateEngineDataProviderMap a key to a value given the properties of the object.- Specified by:
getTemplateValuein 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
specialis true
-
evaluateCondition
public boolean evaluateCondition(SearchCompiler.Match condition)
Description copied from interface:TemplateEngineDataProviderCheck if a condition holds for the object represented by thisTemplateEngineDataProvider.- Specified by:
evaluateConditionin 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:
trueif this primitive has tags denoting an area,falseotherwise.- Since:
- 6491
-
concernsArea
public abstract boolean concernsArea()
Determines if this primitive semantically concerns an area.- Returns:
trueif this primitive semantically concerns an area, according to its type, geometry and tags,falseotherwise.- Since:
- 6491
-
isOutsideDownloadArea
public abstract boolean isOutsideDownloadArea()
Tests if this primitive lies outside of the downloaded area of itsDataSet.- Returns:
trueif 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
-
-