Package org.openstreetmap.josm.data.osm
Class Relation
java.lang.Object
org.openstreetmap.josm.data.osm.AbstractPrimitive
org.openstreetmap.josm.data.osm.OsmPrimitive
org.openstreetmap.josm.data.osm.Relation
- All Implemented Interfaces:
Comparable<IPrimitive>,IQuadBucketType,IFilterablePrimitive,IPrimitive,IRelation<RelationMember>,PrimitiveId,Stylable,Tagged,TemplateEngineDataProvider
A relation, having a set of tags and any number (0...n) of members.
- Since:
- 343
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BBox(package private) static final UniqueIdGeneratorprivate RelationMember[]Fields inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive
directionKeysFields 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, versionFields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionRelation()Create a new relation with id 0Relation(long id) Creates a new relation for the given id.Relation(long id, boolean allowNegative) Relation(long id, int version) Creates new relationCreate an identical clone of the argument (including the id) and links members to it.Constructs an identical clone of the argument and links members to it.Constructs an identical clone of the argument and links members to it. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(OsmPrimitiveVisitor visitor) Implementation of the visitor scheme.voidaccept(PrimitiveVisitor visitor) Makes the given visitor visit this primitive.voidaddMember(int index, RelationMember member) Adds the specified relation member at the specified index.voidaddMember(RelationMember member) Adds the specified relation member at the last position.protected voidaddToBBox(BBox box, Set<PrimitiveId> visited) If necessary, extend the bbox to contain this primitiveprivate voidChecks that members are part of the same dataset, and that they're not deleted.voidcloneFrom(OsmPrimitive osm, boolean copyMembers) Get and write all attributes from the parameter.booleanDetermines if this primitive semantically concerns an area.List<? extends OsmPrimitive>findRelationMembers(String role) Returns a list of relation members having the specified role.private voidFires theRelationMembersChangedEventto listeners.Returns the first member.getBBox()Fetches the bounding box of the primitive.Get child primitives that are referred by this primitive.Gets the type this primitive is displayed atReturns the unique identifier generator.Replies a collection with the incomplete children this relation refers to.getMember(int index) Returns the relation member at the specified index.longgetMemberId(int idx) Returns id of the member at given index.Replies the set ofOsmPrimitives referred to by at least one member of this relation.<T extends OsmPrimitive>
Collection<T>getMemberPrimitives(Class<T> tClass) Returns theOsmPrimitives of the specified type referred to by at least one member of this relation.Returns an unmodifiable list of theOsmPrimitives referred to by at least one member of this relation.Returns the set of roles used in this relation.Returns members of the relation.intReturns the number of members.getMembersFor(Collection<? extends OsmPrimitive> primitives) Obtains all members with member.member == primitivegetMemberType(int idx) Returns type of the member at given index.getRole(int idx) Returns role of the member at given index.getType()Gets the type of object represented by this object.booleanhasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly) booleanDetermines if at least one child primitive is incomplete.booleanTests if this primitive lies outside of the downloaded area of itsDataSet.protected voidkeysChangedImpl(Map<String, String> originalKeys) What to do, when the tags have changed by one of the tag-changing methods.Returns the last member.voidload(PrimitiveData data) Loads (clone) this primitive from provided PrimitiveDataremoveMember(int index) Removes member at specified position.voidremoveMembersFor(Collection<? extends OsmPrimitive> primitives) removes all members with member.member == primitivevoidremoveMembersFor(OsmPrimitive primitive) removes all members with member.member == primitivesave()Save parameters of this primitive to the transport objectprivate void(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.setMember(int index, RelationMember member) Replace member at position specified by index.voidsetMembers(List<RelationMember> members) Sets members of the relation.toString()voidCalled by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)Methods inherited from class org.openstreetmap.josm.data.osm.OsmPrimitive
addReferrer, checkDataset, checkDatasetNotReadOnly, clearCachedStyle, clearOsmMetadata, cloneFrom, declareCachedStyleUpToDate, equals, evaluateCondition, getCachedStyle, getDataSet, getFlagsAsString, getParentRelations, getReferrer, getReferrers, getReferrers, getTemplateKeys, getTemplateValue, hasAreaTags, hasEqualSemanticAttributes, hasEqualSemanticFlags, hasEqualTechnicalAttributes, hashCode, isCachedStyleUpToDate, isMemberOfSelected, isNodeReferredByWays, isOuterMemberOfSelected, isSelectable, isSelected, mergeFrom, put, referrers, remove, removeAll, removeReferrer, saveCommonAttributes, setCachedStyle, setChangesetId, setDisabledState, setHighlighted, setIncomplete, setKeys, setKeys, setModified, setOsmId, setPreserved, setUser, setVisible, unsetDisabledState, updateDirectionFlags, updateFlags, visitReferrers, visitReferrers, writeLock, writeUnlockMethods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
cloneFrom, doGet, get, getChangesetId, getDisabledType, getDiscardableKeys, getHiddenType, getId, getIgnoreCase, getInstant, getInterestingTags, getKeys, getNumKeys, getRawTimestamp, getUninterestingKeys, getUniqueId, getUser, getVersion, getWorkInProgressKeys, hasDirectionKeys, hasKey, hasKey, hasKeys, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isDrawable, isHighlighted, isIncomplete, isModified, isNew, isNewOrUndeleted, isPreserved, isReferrersDownloaded, isTagged, isTimestampEmpty, isUndeleted, isUninterestingKey, isUsable, isVisible, keys, keySet, putAll, reversedDirection, setDisabledType, setHiddenType, setInstant, setRawTimestamp, setReferrersDownloaded, updateFlagsChanged, visitKeysMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
getChangesetId, getDataSet, getId, getInstant, getInterestingTags, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getRawTimestamp, getReferrers, getReferrers, getStyleCacheSyncObject, getUser, getVersion, hasDirectionKeys, hasSameInterestingTags, isAnnotated, isDeleted, isDisabled, isDisabledAndHidden, isDrawable, isHighlighted, isIncomplete, isMemberOfSelected, isModified, isNewOrUndeleted, isOuterMemberOfSelected, isPreserved, isReferrersDownloaded, isSelectable, isSelected, isTagged, isTimestampEmpty, isUndeleted, isUsable, isVisible, reversedDirection, setChangesetId, setHighlighted, setInstant, setModified, setOsmId, setRawTimestamp, setReferrersDownloaded, setUser, setVisible, visitReferrersMethods inherited from interface org.openstreetmap.josm.data.osm.IRelation
compareTo, getDisplayName, isBoundary, isEmpty, isMultipolygon, isUsefulMethods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getUniqueId, isNewMethods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyleMethods inherited from interface org.openstreetmap.josm.data.osm.Tagged
get, getKeys, getNumKeys, hasKey, hasKeys, hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, keys, keySet, put, put, putAll, remove, removeAll, setKeys, visitKeys
-
Field Details
-
idGenerator
-
members
-
bbox
-
-
Constructor Details
-
Relation
Relation(long id, boolean allowNegative) -
Relation
public Relation()Create a new relation with id 0 -
Relation
Constructs an identical clone of the argument and links members to it. See #19885 for possible memory leaks.- Parameters:
clone- The relation to cloneclearMetadata- Iftrue, clears the OSM id and other metadata as defined byOsmPrimitive.clearOsmMetadata(). Iffalse, does nothingcopyMembers- whether to copy relation members too- Since:
- 16212
-
Relation
Constructs an identical clone of the argument and links members to it. See #19885 for possible memory leaks.- Parameters:
clone- The relation to cloneclearMetadata- Iftrue, clears the OSM id and other metadata as defined byOsmPrimitive.clearOsmMetadata(). Iffalse, does nothing
-
Relation
Create an identical clone of the argument (including the id) and links members to it. See #19885 for possible memory leaks.- Parameters:
clone- The relation to clone, including its id
-
Relation
Creates a new relation for the given id. If the id > 0, the way is marked as incomplete.- Parameters:
id- the id. > 0 required- Throws:
IllegalArgumentException- if id < 0
-
Relation
Creates new relation- Parameters:
id- the idversion- version number (positive integer)
-
-
Method Details
-
getMembers
Description copied from interface:IRelationReturns members of the relation.- Specified by:
getMembersin interfaceIRelation<RelationMember>- Returns:
- Members of the relation. Changes made in returned list are not mapped
back to the primitive, use
IRelation.setMembers(java.util.List<M>)to modify the members
-
setMembers
Description copied from interface:IRelationSets members of the relation.- Specified by:
setMembersin interfaceIRelation<RelationMember>- Parameters:
members- Can be null, in that case all members are removed
-
getMembersCount
Description copied from interface:IRelationReturns the number of members.- Specified by:
getMembersCountin interfaceIRelation<RelationMember>- Returns:
- number of members
-
getMember
Description copied from interface:IRelationReturns the relation member at the specified index.- Specified by:
getMemberin interfaceIRelation<RelationMember>- Parameters:
index- the index of the relation member- Returns:
- relation member at the specified index
-
addMember
Adds the specified relation member at the last position.- Parameters:
member- the member to add
-
addMember
Adds the specified relation member at the specified index.- Parameters:
member- the member to addindex- the index at which the specified element is to be inserted
-
setMember
Replace member at position specified by index.- Parameters:
index- index (positive integer)member- relation member to set- Returns:
- Member that was at the position
-
removeMember
Removes member at specified position.- Parameters:
index- index (positive integer)- Returns:
- Member that was at the position
-
getMemberId
Description copied from interface:IRelationReturns id of the member at given index.- Specified by:
getMemberIdin interfaceIRelation<RelationMember>- Parameters:
idx- member index- Returns:
- id of the member at given index
-
getRole
Description copied from interface:IRelationReturns role of the member at given index.- Specified by:
getRolein interfaceIRelation<RelationMember>- Parameters:
idx- member index- Returns:
- role of the member at given index
-
getMemberType
Description copied from interface:IRelationReturns type of the member at given index.- Specified by:
getMemberTypein interfaceIRelation<RelationMember>- Parameters:
idx- member index- Returns:
- type of the member at given index
-
accept
Description copied from class:OsmPrimitiveImplementation of the visitor scheme. Subclasses have to call the correct visitor function.- Specified by:
acceptin classOsmPrimitive- Parameters:
visitor- The visitor from which the visit() function must be called.
-
accept
Description copied from interface:IPrimitiveMakes the given visitor visit this primitive.- Specified by:
acceptin interfaceIPrimitive- Parameters:
visitor- visitor
-
cloneFrom
Description copied from class:OsmPrimitiveGet and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Overrides:
cloneFromin classOsmPrimitive- Parameters:
osm- other primitivecopyMembers- whether to copy child primitives too
-
load
Description copied from class:OsmPrimitiveLoads (clone) this primitive from provided PrimitiveData- Overrides:
loadin classOsmPrimitive- Parameters:
data- The object which should be cloned
-
save
Description copied from class:OsmPrimitiveSave parameters of this primitive to the transport object- Specified by:
savein classOsmPrimitive- Returns:
- The saved object data
-
toString
-
hasEqualSemanticAttributes
- Overrides:
hasEqualSemanticAttributesin classOsmPrimitive
-
firstMember
Returns the first member.- Returns:
- first member, or
null
-
lastMember
Returns the last member.- Returns:
- last member, or
null
-
removeMembersFor
removes all members with member.member == primitive- Parameters:
primitive- the primitive to check for
-
setDeleted
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 classOsmPrimitive- Parameters:
deleted- true, if this primitive is deleted; false, otherwise
-
getMembersFor
Obtains all members with member.member == primitive- Parameters:
primitives- the primitives to check for- Returns:
- all relation members for the given primitives
-
removeMembersFor
removes all members with member.member == primitive- Parameters:
primitives- the primitives to check for- Since:
- 5613
-
getMemberPrimitives
Replies the set ofOsmPrimitives referred to by at least one member of this relation.- Returns:
- the set of
OsmPrimitives referred to by at least one member of this relation - See Also:
-
getMemberPrimitives
Returns theOsmPrimitives of the specified type referred to by at least one member of this relation.- Type Parameters:
T- the type of the primitive- Parameters:
tClass- the type of the primitive- Returns:
- the primitives
-
getMemberPrimitivesList
Returns an unmodifiable list of theOsmPrimitives referred to by at least one member of this relation.- Specified by:
getMemberPrimitivesListin interfaceIRelation<RelationMember>- Returns:
- an unmodifiable list of the primitives
-
getChildren
Description copied from interface:IPrimitiveGet child primitives that are referred by this primitive.Relation: Members of the relationWay: Nodes used by the wayNode: None- Specified by:
getChildrenin interfaceIPrimitive- Specified by:
getChildrenin interfaceIRelation<RelationMember>- Returns:
- List of child primitives
-
getType
Description copied from interface:PrimitiveIdGets the type of object represented by this object. Note that this should return the base primitive type (OsmPrimitiveType.NODE,OsmPrimitiveType.WAY, andOsmPrimitiveType.RELATION).- Specified by:
getTypein interfacePrimitiveId- Returns:
- the object type
- See Also:
-
getDisplayType
Description copied from interface:IPrimitiveGets the type this primitive is displayed at- Specified by:
getDisplayTypein interfaceIPrimitive- Returns:
- A
OsmPrimitiveType
-
getBBox
Description copied from interface:IPrimitiveFetches the bounding box of the primitive. Since 17752, the returned bounding box might be immutable, i.e., modifying calls throw anUnsupportedOperationException.- Specified by:
getBBoxin interfaceIPrimitive- Specified by:
getBBoxin interfaceIQuadBucketType- Returns:
- Bounding box of the object
-
setBBox
-
addToBBox
Description copied from class:OsmPrimitiveIf necessary, extend the bbox to contain this primitive- Specified by:
addToBBoxin classOsmPrimitive- Parameters:
box- a bbox instancevisited- a set of visited members or null
-
updatePosition
Description copied from class:OsmPrimitiveCalled by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...)- Specified by:
updatePositionin classOsmPrimitive
-
setDataset
Description copied from class:OsmPrimitiveThis method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods- Overrides:
setDatasetin classOsmPrimitive- Parameters:
dataSet- the parent dataset
-
checkMembers
Checks that members are part of the same dataset, and that they're not deleted.- Throws:
DataIntegrityProblemException- if one the above conditions is not met
-
fireMembersChanged
Fires theRelationMembersChangedEventto listeners.- Throws:
DataIntegrityProblemException- if members are not valid- See Also:
-
hasIncompleteMembers
Description copied from interface:IRelationDetermines if at least one child primitive is incomplete.- Specified by:
hasIncompleteMembersin interfaceIRelation<RelationMember>- Returns:
- true if at least one child primitive is incomplete
-
getIncompleteMembers
Replies a collection with the incomplete children this relation refers to.- Specified by:
getIncompleteMembersin interfaceIRelation<RelationMember>- Returns:
- the incomplete children. Empty collection if no children are incomplete.
-
keysChangedImpl
Description copied from class:AbstractPrimitiveWhat to do, when the tags have changed by one of the tag-changing methods.- Overrides:
keysChangedImplin classOsmPrimitive- Parameters:
originalKeys- original tags
-
concernsArea
Description copied from class:OsmPrimitiveDetermines if this primitive semantically concerns an area.- Specified by:
concernsAreain classOsmPrimitive- Returns:
trueif this primitive semantically concerns an area, according to its type, geometry and tags,falseotherwise.
-
isOutsideDownloadArea
Description copied from class:OsmPrimitiveTests if this primitive lies outside of the downloaded area of itsDataSet.- Specified by:
isOutsideDownloadAreain classOsmPrimitive- Returns:
trueif this primitive lies outside of the downloaded area
-
getMemberRoles
Returns the set of roles used in this relation.- Returns:
- the set of roles used in this relation. Can be empty but never null
- Since:
- 7556
-
findRelationMembers
Description copied from interface:IRelationReturns a list of relation members having the specified role.- Specified by:
findRelationMembersin interfaceIRelation<RelationMember>- Parameters:
role- role- Returns:
- a list of relation members having the specified role
-
getIdGenerator
Description copied from class:AbstractPrimitiveReturns the unique identifier generator.- Specified by:
getIdGeneratorin classAbstractPrimitive- Returns:
- the unique identifier generator
-