org.openstreetmap.josm.data.osm
Class OsmPrimitive

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.AbstractPrimitive
      extended by org.openstreetmap.josm.data.osm.OsmPrimitive
All Implemented Interfaces:
java.lang.Comparable<OsmPrimitive>, IPrimitive, PrimitiveId, Tagged, TemplateEngineDataProvider
Direct Known Subclasses:
Node, Relation, Way

public abstract class OsmPrimitive
extends AbstractPrimitive
implements java.lang.Comparable<OsmPrimitive>, TemplateEngineDataProvider

An OSM primitive can be associated with a key/value pair. It can be created, deleted and updated within 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 extendible data stuff.


Field Summary
static Predicate<OsmPrimitive> allPredicate
           
private  DataSet dataSet
          the parent dataset
private static SearchCompiler.Match directionKeys
           
protected static int FLAG_DIRECTION_REVERSED
          This flag is only relevant if FLAG_HAS_DIRECTIONS is set.
protected static int FLAG_DISABLED
          An object can be disabled by the filter mechanism.
protected static int FLAG_DISABLED_TYPE
          Flag used internally by the filter mechanism.
protected static int FLAG_HAS_DIRECTIONS
          This flag is set if the primitive is a way and according to the tags, the direction of the way is important.
protected static int FLAG_HIDDEN_TYPE
          Flag used internally by the filter mechanism.
protected static int FLAG_HIDE_IF_DISABLED
          This flag is only relevant if an object is disabled by the filter mechanism (i.e. FLAG_DISABLED is set).
protected static int FLAG_HIGHLIGHTED
          When hovering over ways and nodes in add mode, the "target" objects are visually highlighted.
protected static int FLAG_TAGGED
          If the primitive is tagged.
static Predicate<OsmPrimitive> isSelectablePredicate
           
static Predicate<OsmPrimitive> isUsablePredicate
          Some predicates, that describe conditions on primitives.
 int mappaintCacheIdx
           
 StyleCache mappaintStyle
           
static Predicate<OsmPrimitive> modifiedPredicate
           
static Predicate<OsmPrimitive> multipolygonPredicate
           
static Predicate<OsmPrimitive> nodePredicate
           
static Predicate<OsmPrimitive> nonDeletedCompletePredicate
           
static Predicate<OsmPrimitive> nonDeletedPhysicalPredicate
           
static Predicate<OsmPrimitive> nonDeletedPredicate
           
private  java.lang.Object referrers
           
static Predicate<OsmPrimitive> relationPredicate
           
private static SearchCompiler.Match reversedDirectionKeys
           
private static java.lang.String SPECIAL_VALUE_ID
           
private static java.lang.String SPECIAL_VALUE_LOCAL_NAME
           
private static java.util.Collection<java.lang.String> uninteresting
           
static Predicate<OsmPrimitive> wayPredicate
           
 
Fields inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
changesetId, FLAG_DELETED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_VISIBLE, flags, id, keys, timestamp, user, version
 
Constructor Summary
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
protected  void addReferrer(OsmPrimitive referrer)
          Add new referrer.
 void checkDataset()
          Throws exception if primitive is not part of the dataset
 void clearCachedStyle()
           
 void clearOsmId()
          Clears the id and version known to the OSM API.
 void cloneFrom(OsmPrimitive other)
          Get and write all attributes from the parameter.
 boolean equals(java.lang.Object obj)
          Equal, if the id (and class) is equal.
 boolean evaluateCondition(SearchCompiler.Match condition)
           
abstract  BBox getBBox()
           
 DataSet getDataSet()
           
 boolean getDisabledType()
          Get binary property used internally by the filter mechanism.
abstract  java.lang.String getDisplayName(NameFormatter formatter)
          Replies the display name of a primitive formatted by formatter
static
<T extends OsmPrimitive>
java.util.List<T>
getFilteredList(java.util.Collection<OsmPrimitive> list, java.lang.Class<T> type)
          Replies the sub-collection of OsmPrimitives of type type present in another collection of OsmPrimitives.
static
<T extends OsmPrimitive>
java.util.LinkedHashSet<T>
getFilteredSet(java.util.Collection<OsmPrimitive> set, java.lang.Class<T> type)
          Replies the sub-collection of OsmPrimitives of type type present in another collection of OsmPrimitives.
protected  java.lang.String getFlagsAsString()
           
 boolean getHiddenType()
          Get binary property used internally by the filter mechanism.
static java.util.Set<Relation> getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
          Replies the set of referring relations
static java.util.Set<OsmPrimitive> getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
          Replies the collection of referring primitives for the primitives in primitives.
 java.util.List<OsmPrimitive> getReferrers()
           
 java.util.List<OsmPrimitive> getReferrers(boolean allowWithoutDataset)
          Find primitives that reference this primitive.
 java.util.Collection<java.lang.String> getTemplateKeys()
           
 java.lang.Object getTemplateValue(java.lang.String name, boolean special)
           
static java.util.Collection<java.lang.String> getUninterestingKeys()
          Contains a list of "uninteresting" keys that do not make an object "tagged".
 boolean hasDirectionKeys()
          true if this object has direction dependent tags (e.g.
 boolean hasEqualSemanticAttributes(OsmPrimitive other)
          Replies true if this primitive and other are equal with respect to their semantic attributes.
 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 isDisabled()
          Replies true, if this primitive is disabled.
 boolean isDisabledAndHidden()
          Replies true, if this primitive is disabled and marked as completely hidden on the map.
 boolean isDrawable()
           
 boolean isHighlighted()
           
 boolean isMemberOfSelected()
           
 boolean isReferredByWays(int n)
          Return true, if this primitive is referred by at least n ways
 boolean isSelectable()
           
 boolean isSelected()
           
 boolean isTagged()
          true if this object is considered "tagged".
static boolean isUninterestingKey(java.lang.String key)
          Returns true if key is considered "uninteresting".
protected  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 PrimitiveData
 void mergeFrom(OsmPrimitive other)
          Merges the technical and semantical attributes from other onto this.
 void put(java.lang.String key, java.lang.String value)
          Set the given value to the given key.
 void remove(java.lang.String key)
          Remove the given key from the list
 void removeAll()
          Removes all keys from this primitive.
protected  void removeReferrer(OsmPrimitive referrer)
          Remove referrer.
 boolean reversedDirection()
           
abstract  PrimitiveData save()
          Save parameters of this primitive to the transport object
protected  void saveCommonAttributes(PrimitiveData data)
           
 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 methods
 void 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 setDisabledType(boolean isExplicit)
          Set binary property used internally by the filter mechanism.
 void setHiddenType(boolean isExplicit)
          Set binary property used internally by the filter mechanism.
 void setHighlighted(boolean highlighted)
           
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 in keys.
 void setOsmId(long id, int version)
          Sets the id and the version of this primitive if it is known to the OSM API.
 void setTimestamp(java.util.Date timestamp)
           
 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 updateDirectionFlags()
           
protected  void updateFlags(int flag, boolean value)
           
private  void updateFlagsNoLock(int flag, boolean value)
           
abstract  void updatePosition()
          Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)
private  void updateTagged()
           
abstract  void visit(Visitor visitor)
           
 void visitReferrers(Visitor visitor)
          Visits visitor for all referrers.
protected  boolean writeLock()
           
protected  void writeUnlock(boolean locked)
           
 
Methods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
cloneFrom, generateUniqueId, get, getChangesetId, getDisplayType, getId, getIgnoreCase, getKeys, getLocalName, getName, getPrimitiveId, getTimestamp, getUniqueId, getUser, getVersion, hasKey, hasKeys, hasSameTags, hasTag, hasTag, isDeleted, isIncomplete, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isUsable, isVisible, keySet, setModified
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
visit
 
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType
 

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

FLAG_DISABLED

protected static final int FLAG_DISABLED
An object can be disabled by the filter mechanism. Then it will show in a shade of gray on the map or it is completely hidden from the view. Disabled objects usually cannot be selected or modified while the filter is active.

See Also:
Constant Field Values

FLAG_HIDE_IF_DISABLED

protected static final int FLAG_HIDE_IF_DISABLED
This flag is only relevant if an object is disabled by the filter mechanism (i.e. FLAG_DISABLED is set). Then it indicates, whether it is completely hidden or just shown in gray color. When the primitive is not disabled, this flag should be unset as well (for efficient access).

See Also:
Constant Field Values

FLAG_DISABLED_TYPE

protected static final int FLAG_DISABLED_TYPE
Flag used internally by the filter mechanism.

See Also:
Constant Field Values

FLAG_HIDDEN_TYPE

protected static final int FLAG_HIDDEN_TYPE
Flag used internally by the filter mechanism.

See Also:
Constant Field Values

FLAG_HAS_DIRECTIONS

protected static final int FLAG_HAS_DIRECTIONS
This flag is set if the primitive is a way and according to the tags, the direction of the way is important. (e.g. one way street.)

See Also:
Constant Field Values

FLAG_TAGGED

protected static final int FLAG_TAGGED
If the primitive is tagged. Some trivial tags like source=* are ignored here.

See Also:
Constant Field Values

FLAG_DIRECTION_REVERSED

protected static final int FLAG_DIRECTION_REVERSED
This flag is only relevant if FLAG_HAS_DIRECTIONS is set. It shows, that direction of the arrows should be reversed. (E.g. oneway=-1.)

See Also:
Constant Field Values

FLAG_HIGHLIGHTED

protected static final int FLAG_HIGHLIGHTED
When hovering over ways and nodes in add mode, the "target" objects are visually highlighted. This flag indicates that the primitive is currently highlighted.

See Also:
Constant Field Values

isUsablePredicate

public static final Predicate<OsmPrimitive> isUsablePredicate
Some predicates, that describe conditions on primitives.


isSelectablePredicate

public static final Predicate<OsmPrimitive> isSelectablePredicate

nonDeletedPredicate

public static final Predicate<OsmPrimitive> nonDeletedPredicate

nonDeletedCompletePredicate

public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate

nonDeletedPhysicalPredicate

public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate

modifiedPredicate

public static final Predicate<OsmPrimitive> modifiedPredicate

nodePredicate

public static final Predicate<OsmPrimitive> nodePredicate

wayPredicate

public static final Predicate<OsmPrimitive> wayPredicate

relationPredicate

public static final Predicate<OsmPrimitive> relationPredicate

multipolygonPredicate

public static final Predicate<OsmPrimitive> multipolygonPredicate

allPredicate

public static final Predicate<OsmPrimitive> allPredicate

mappaintStyle

public StyleCache mappaintStyle

mappaintCacheIdx

public int mappaintCacheIdx

dataSet

private DataSet dataSet
the parent dataset


uninteresting

private static volatile java.util.Collection<java.lang.String> uninteresting

directionKeys

private static volatile SearchCompiler.Match directionKeys

reversedDirectionKeys

private static volatile SearchCompiler.Match reversedDirectionKeys

referrers

private java.lang.Object referrers
Constructor Detail

OsmPrimitive

protected OsmPrimitive(long id,
                       boolean allowNegativeId)
                throws java.lang.IllegalArgumentException
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 id
allowNegativeId -
Throws:
java.lang.IllegalArgumentException - thrown if id < 0 and allowNegativeId is false

OsmPrimitive

protected OsmPrimitive(long id,
                       int version,
                       boolean allowNegativeId)
                throws java.lang.IllegalArgumentException
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 -
version -
allowNegativeId -
Throws:
java.lang.IllegalArgumentException - thrown if id < 0 and allowNegativeId is false
Method Detail

getFilteredList

public static <T extends OsmPrimitive> java.util.List<T> getFilteredList(java.util.Collection<OsmPrimitive> list,
                                                                         java.lang.Class<T> type)
Replies the sub-collection of OsmPrimitives of type type present in another collection of OsmPrimitives. The result collection is a list. If list is null, replies an empty list.

Type Parameters:
T -
Parameters:
list - the original list
type - the type to filter for
Returns:
the sub-list of OSM primitives of type type

getFilteredSet

public static <T extends OsmPrimitive> java.util.LinkedHashSet<T> getFilteredSet(java.util.Collection<OsmPrimitive> set,
                                                                                 java.lang.Class<T> type)
Replies the sub-collection of OsmPrimitives of type type present in another collection of OsmPrimitives. The result collection is a set. If list is null, replies an empty set.

Type Parameters:
T -
Parameters:
list - the original collection
type - the type to filter for
Returns:
the sub-set of OSM primitives of type type

getReferrer

public static java.util.Set<OsmPrimitive> getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the collection of referring primitives for the primitives in primitives.

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

clearCachedStyle

public void clearCachedStyle()

setDataset

void setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods

Parameters:
dataSet -

getDataSet

public DataSet getDataSet()
Returns:
DataSet this primitive is part of.

checkDataset

public void checkDataset()
Throws exception if primitive is not part of the 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 interface IPrimitive
Overrides:
setOsmId in class AbstractPrimitive
Parameters:
id - the id. > 0 required
version - the version > 0 required
Throws:
java.lang.IllegalArgumentException - thrown if id <= 0
java.lang.IllegalArgumentException - thrown if version <= 0
DataIntegrityProblemException - If id is changed and primitive was already added to the dataset

clearOsmId

public void clearOsmId()
Clears the id and version known to the OSM API. The id and the version is set to 0. incomplete is set to false. It's preferred to use copy constructor with clearId set to true instead of calling this method. Caution: Do not use this method on primitives which are already added to a DataSet.

Overrides:
clearOsmId in class AbstractPrimitive
Throws:
DataIntegrityProblemException - If primitive was already added to the dataset

setUser

public void setUser(User user)
Description copied from class: AbstractPrimitive
Sets the user who has last touched this object.

Specified by:
setUser in interface IPrimitive
Overrides:
setUser in class AbstractPrimitive
Parameters:
user - the user

setChangesetId

public void setChangesetId(int changesetId)
                    throws java.lang.IllegalStateException,
                           java.lang.IllegalArgumentException
Description copied from class: AbstractPrimitive
Sets the changeset id of this primitive. Can't be set on a new primitive.

Specified by:
setChangesetId in interface IPrimitive
Overrides:
setChangesetId in class AbstractPrimitive
Parameters:
changesetId - the id. >= 0 required.
Throws:
java.lang.IllegalStateException - thrown if this primitive is new.
java.lang.IllegalArgumentException - thrown if id < 0

setTimestamp

public void setTimestamp(java.util.Date timestamp)
Specified by:
setTimestamp in interface IPrimitive
Overrides:
setTimestamp in class AbstractPrimitive

updateFlagsNoLock

private void updateFlagsNoLock(int flag,
                               boolean value)

updateFlags

protected final void updateFlags(int flag,
                                 boolean value)
Overrides:
updateFlags in class AbstractPrimitive

setDisabledState

public boolean setDisabledState(boolean hidden)
Make the primitive disabled (e.g. if a filter applies). To enable the primitive again, use unsetDisabledState.

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.


setDisabledType

public void setDisabledType(boolean isExplicit)
Set binary property used internally by the filter mechanism.


setHiddenType

public void setHiddenType(boolean isExplicit)
Set binary property used internally by the filter mechanism.


isDisabled

public boolean isDisabled()
Replies true, if this primitive is disabled. (E.g. a filter applies)


isDisabledAndHidden

public boolean isDisabledAndHidden()
Replies true, if this primitive is disabled and marked as completely hidden on the map.


getHiddenType

public boolean getHiddenType()
Get binary property used internally by the filter mechanism.


getDisabledType

public boolean getDisabledType()
Get binary property used internally by the filter mechanism.


isSelectable

public boolean isSelectable()

isDrawable

public boolean isDrawable()

setVisible

public void setVisible(boolean visible)
                throws java.lang.IllegalStateException
Description copied from class: AbstractPrimitive
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 interface IPrimitive
Overrides:
setVisible in class AbstractPrimitive
Throws:
java.lang.IllegalStateException - thrown if visible is set to false on an primitive with id==0
See Also:
AbstractPrimitive.isVisible()

setDeleted

public void setDeleted(boolean deleted)
Description copied from class: AbstractPrimitive
Sets whether this primitive is deleted or not. Also marks this primitive as modified if deleted is true.

Specified by:
setDeleted in interface IPrimitive
Overrides:
setDeleted in class AbstractPrimitive
Parameters:
deleted - true, if this primitive is deleted; false, otherwise

setIncomplete

protected 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 class AbstractPrimitive

isSelected

public boolean isSelected()

isMemberOfSelected

public boolean isMemberOfSelected()

setHighlighted

public void setHighlighted(boolean highlighted)

isHighlighted

public boolean isHighlighted()

getUninterestingKeys

public static java.util.Collection<java.lang.String> getUninterestingKeys()
Contains a list of "uninteresting" keys that do not make an object "tagged". Entries that end with ':' are causing a whole namespace to be considered "uninteresting". Only the first level namespace is considered. Initialized by isUninterestingKey()


isUninterestingKey

public static boolean isUninterestingKey(java.lang.String key)
Returns true if key is considered "uninteresting".


updateTagged

private void updateTagged()

isTagged

public boolean isTagged()
true if this object is considered "tagged". To be "tagged", an object must have one or more "interesting" tags. "created_by" and "source" are typically considered "uninteresting" and do not make an object "tagged".


updateDirectionFlags

private void updateDirectionFlags()

hasDirectionKeys

public boolean hasDirectionKeys()
true if this object has direction dependent tags (e.g. oneway)


reversedDirection

public boolean reversedDirection()

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 in keys. Old key/value pairs are removed. If keys is null, clears existing key/value pairs.

Specified by:
setKeys in interface Tagged
Overrides:
setKeys in class AbstractPrimitive
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 like AbstractPrimitive.remove(String).

Specified by:
put in interface Tagged
Overrides:
put in class AbstractPrimitive
Parameters:
key - The key, for which the value is to be set. Can be null, 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 list

Specified by:
remove in interface Tagged
Overrides:
remove in class AbstractPrimitive
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.

Specified by:
removeAll in interface Tagged
Overrides:
removeAll in class AbstractPrimitive

keysChangedImpl

protected final 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 class AbstractPrimitive

addReferrer

protected void addReferrer(OsmPrimitive referrer)
Add new referrer. If referrer is already included then no action is taken

Parameters:
referrer -

removeReferrer

protected void removeReferrer(OsmPrimitive referrer)
Remove referrer. No action is taken if referrer is not registered

Parameters:
referrer -

getReferrers

public final java.util.List<OsmPrimitive> getReferrers(boolean allowWithoutDataset)
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)

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()

visitReferrers

public void visitReferrers(Visitor visitor)

Visits visitor for all referrers.

Parameters:
visitor - the visitor. Ignored, if null.

isReferredByWays

public final boolean isReferredByWays(int n)
Return true, if this primitive is referred by at least n ways

Parameters:
n - Minimal number of ways to return true. Must be positive

visit

public abstract void visit(Visitor visitor)

cloneFrom

public 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


mergeFrom

public void mergeFrom(OsmPrimitive other)
Merges the technical and semantical attributes from other onto this. Both this and other must be new, or both must be assigned an OSM ID. If both this and other have an assigend OSM id, the IDs have to be the same.

Parameters:
other - the other primitive. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if other is null.
DataIntegrityProblemException - thrown if either this is new and other is not, or other is new and this is not
DataIntegrityProblemException - thrown if other isn't new and other.getId() != this.getId()

hasEqualSemanticAttributes

public boolean hasEqualSemanticAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their semantic attributes.
  1. equal id
  • both are complete or both are incomplete
  • both have the same tags
  • Parameters:
    other -
    Returns:
    true if this primitive and other are equal with respect to their semantic attributes.

    hasEqualTechnicalAttributes

    public boolean hasEqualTechnicalAttributes(OsmPrimitive other)
    Replies true if this primitive and other are equal with respect to their technical attributes. The attributes:
    1. deleted
  • modified
  • timestamp
  • version
  • visible
  • user have to be equal

    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 -

    save

    public abstract PrimitiveData save()
    Save parameters of this primitive to the transport object

    Returns:

    saveCommonAttributes

    protected void saveCommonAttributes(PrimitiveData data)

    getBBox

    public abstract BBox getBBox()

    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 class AbstractPrimitive

    equals

    public boolean equals(java.lang.Object obj)
    Equal, if the id (and class) is equal. An primitive is equal to its incomplete counter part.

    Overrides:
    equals in class java.lang.Object

    hashCode

    public final int hashCode()
    Return the id plus the class type encoded as hashcode or super's hashcode if id is 0. An primitive has the same hashcode as its incomplete counterpart.

    Overrides:
    hashCode in class java.lang.Object

    getDisplayName

    public abstract java.lang.String getDisplayName(NameFormatter formatter)
    Replies the display name of a primitive formatted by formatter

    Returns:
    the display name

    getTemplateKeys

    public java.util.Collection<java.lang.String> getTemplateKeys()
    Specified by:
    getTemplateKeys in interface TemplateEngineDataProvider

    getTemplateValue

    public java.lang.Object getTemplateValue(java.lang.String name,
                                             boolean special)
    Specified by:
    getTemplateValue in interface TemplateEngineDataProvider

    evaluateCondition

    public boolean evaluateCondition(SearchCompiler.Match condition)
    Specified by:
    evaluateCondition in interface TemplateEngineDataProvider

    getParentRelations

    public static java.util.Set<Relation> getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
    Replies the set of referring relations

    Returns:
    the set of referring relations


    JOSM