Package org.openstreetmap.josm.data.osm
Interface OsmData<O extends IPrimitive,N extends INode,W extends IWay<N>,R extends IRelation<?>>
-
- Type Parameters:
O
- the base type of OSM primitivesN
- type representing OSM nodesW
- type representing OSM waysR
- type representing OSM relations
- All Known Implementing Classes:
DataSet
,VectorDataSet
public interface OsmData<O extends IPrimitive,N extends INode,W extends IWay<N>,R extends IRelation<?>> extends Data, Lockable
Abstraction ofDataSet
. This class holds OSM data but does not rely on implementation types, allowing plugins to define their own representation of OSM data if needed.- Since:
- 13764
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addHighlightUpdateListener(HighlightUpdateListener listener)
Adds a listener that gets notified whenever way segment / virtual nodes highlights change.void
addPrimitive(O primitive)
Adds a primitive.void
addSelected(java.util.Collection<? extends PrimitiveId> selection)
Adds the primitives inselection
to the current selection and notifies allDataSelectionListener
.void
addSelected(PrimitiveId... osm)
Adds the primitives inosm
to the current selection and notifies allDataSelectionListener
.void
addSelectionListener(DataSelectionListener listener)
Add a listener that listens to selection changes in this specific data set.default java.util.Collection<O>
allModifiedPrimitives()
Returns a collection containing all modified primitives.default java.util.Collection<O>
allNonDeletedCompletePrimitives()
Returns a collection containing all not-deleted complete primitives.default java.util.Collection<O>
allNonDeletedPhysicalPrimitives()
Returns a collection containing all not-deleted complete physical primitives.default java.util.Collection<O>
allNonDeletedPrimitives()
Returns a collection containing all not-deleted primitives.default java.util.Collection<O>
allPreservedPrimitives()
Returns a collection containing all primitives preserved from filtering.default java.util.Collection<O>
allPrimitives()
Returns a collection containing all primitives of the dataset.void
clear()
Removes all primitives.default void
clearHighlightedVirtualNodes()
clear all highlights of virtual nodesdefault void
clearHighlightedWaySegments()
clear all highlights of way segmentsvoid
clearMappaintCache()
Clear the mappaint cache for this DataSet.void
clearSelection()
Clears the current selection.void
clearSelection(java.util.Collection<? extends PrimitiveId> list)
Removes the selection from every value in the collection.void
clearSelection(PrimitiveId... osm)
Removes the selection from every value in the collection.boolean
containsNode(N n)
Determines if the given node can be retrieved in the data set through its bounding box.boolean
containsRelation(R r)
Determines if the given relation can be retrieved in the data set through its bounding box.boolean
containsWay(W w)
Determines if the given way can be retrieved in the data set through its bounding box.java.util.Collection<O>
getAllSelected()
Replies an unmodifiable collection of primitives currently selected in this dataset, including deleted ones.default ProjectionBounds
getDataSourceBoundingBox()
Returns the data sources bounding box.DownloadPolicy
getDownloadPolicy()
Get the download policy.java.util.Collection<WaySegment>
getHighlightedVirtualNodes()
Returns an unmodifiable collection of *WaySegments* whose virtual nodes should be highlighted.java.util.Collection<WaySegment>
getHighlightedWaySegments()
Returns an unmodifiable collection of WaySegments that should be highlighted.java.lang.String
getName()
Returns the name of this data set (optional).java.util.Collection<N>
getNodes()
Replies an unmodifiable collection of nodes in this datasetdefault O
getPrimitiveById(long id, OsmPrimitiveType type)
Returns a primitive with a given id from the data set.O
getPrimitiveById(PrimitiveId primitiveId)
Returns a primitive with a given id from the data set.<T extends O>
java.util.Collection<T>getPrimitives(java.util.function.Predicate<? super O> predicate)
Gets a filtered collection of primitives matching the given predicate.java.util.concurrent.locks.Lock
getReadLock()
Returns the lock used for reading.java.util.Collection<R>
getRelations()
Replies an unmodifiable collection of relations in this datasetdefault java.util.Collection<O>
getSelected()
Replies an unmodifiable collection of primitives currently selected in this dataset, except deleted ones.default java.util.Collection<N>
getSelectedNodes()
Returns selected nodes.default java.util.Collection<R>
getSelectedRelations()
Returns selected relations.default java.util.Collection<W>
getSelectedWays()
Returns selected ways.UploadPolicy
getUploadPolicy()
Get the upload policy.java.lang.String
getVersion()
Replies the API version this dataset was created from.java.util.Collection<W>
getWays()
Replies an unmodifiable collection of ways in this datasetdefault boolean
isModified()
Replies true if there is at least one primitive in this dataset withIPrimitive.isModified()
==true
.boolean
isSelected(O osm)
Determines whether the given primitive is selected or notvoid
removeHighlightUpdateListener(HighlightUpdateListener listener)
Removes a listener that was added withaddHighlightUpdateListener(HighlightUpdateListener)
void
removeSelectionListener(DataSelectionListener listener)
Remove a listener that listens to selection changes in this specific data set.java.util.List<N>
searchNodes(BBox bbox)
Searches for nodes in the given bounding box.java.util.List<R>
searchRelations(BBox bbox)
Searches for relations in the given bounding box.java.util.List<W>
searchWays(BBox bbox)
Searches for ways in the given bounding box.boolean
selectionEmpty()
Determines whether the selection is empty or notvoid
setDownloadPolicy(DownloadPolicy downloadPolicy)
Sets the download policy.void
setHighlightedVirtualNodes(java.util.Collection<WaySegment> waySegments)
set what virtual nodes should be highlighted.void
setHighlightedWaySegments(java.util.Collection<WaySegment> waySegments)
set what virtual ways should be highlighted.void
setName(java.lang.String name)
Sets the name of this data set.void
setSelected(java.util.Collection<? extends PrimitiveId> selection)
Sets the current selection to the primitives inselection
and notifies allDataSelectionListener
.void
setSelected(PrimitiveId... osm)
Sets the current selection to the primitives inosm
and notifies allDataSelectionListener
.void
setUploadPolicy(UploadPolicy uploadPolicy)
Sets the upload policy.void
toggleSelected(java.util.Collection<? extends PrimitiveId> osm)
Toggles the selected state of the given collection of primitives.void
toggleSelected(PrimitiveId... osm)
Toggles the selected state of the given collection of primitives.-
Methods inherited from interface org.openstreetmap.josm.data.Data
getDataSourceArea, getDataSourceBounds, getDataSources
-
-
-
-
Method Detail
-
getVersion
java.lang.String getVersion()
Replies the API version this dataset was created from. May be null.- Returns:
- the API version this dataset was created from. May be null.
-
getName
java.lang.String getName()
Returns the name of this data set (optional).- Returns:
- the name of this data set. Can be
null
- Since:
- 12718
-
setName
void setName(java.lang.String name)
Sets the name of this data set.- Parameters:
name
- the new name of this data set. Can benull
to reset it- Since:
- 12718
-
addPrimitive
void addPrimitive(O primitive)
Adds a primitive.- Parameters:
primitive
- the primitive
-
clear
void clear()
Removes all primitives.
-
searchNodes
java.util.List<N> searchNodes(BBox bbox)
Searches for nodes in the given bounding box.- Parameters:
bbox
- the bounding box- Returns:
- List of nodes in the given bbox. Can be empty but not null
-
containsNode
boolean containsNode(N n)
Determines if the given node can be retrieved in the data set through its bounding box. Useful for dataset consistency test.- Parameters:
n
- The node to search- Returns:
true
ifn
can be retrieved in this data set,false
otherwise
-
searchWays
java.util.List<W> searchWays(BBox bbox)
Searches for ways in the given bounding box.- Parameters:
bbox
- the bounding box- Returns:
- List of ways in the given bbox. Can be empty but not null
-
containsWay
boolean containsWay(W w)
Determines if the given way can be retrieved in the data set through its bounding box. Useful for dataset consistency test.- Parameters:
w
- The way to search- Returns:
true
ifw
can be retrieved in this data set,false
otherwise
-
searchRelations
java.util.List<R> searchRelations(BBox bbox)
Searches for relations in the given bounding box.- Parameters:
bbox
- the bounding box- Returns:
- List of relations in the given bbox. Can be empty but not null
-
containsRelation
boolean containsRelation(R r)
Determines if the given relation can be retrieved in the data set through its bounding box. Useful for dataset consistency test.- Parameters:
r
- The relation to search- Returns:
true
ifr
can be retrieved in this data set,false
otherwise
-
getPrimitiveById
default O getPrimitiveById(long id, OsmPrimitiveType type)
Returns a primitive with a given id from the data set. null, if no such primitive exists- Parameters:
id
- uniqueId of the primitive. Might be < 0 for newly created primitivestype
- the type of the primitive. Must not be null.- Returns:
- the primitive
- Throws:
java.lang.NullPointerException
- if type is null
-
getPrimitiveById
O getPrimitiveById(PrimitiveId primitiveId)
Returns a primitive with a given id from the data set. null, if no such primitive exists- Parameters:
primitiveId
- type and uniqueId of the primitive. Might be < 0 for newly created primitives- Returns:
- the primitive
-
getPrimitives
<T extends O> java.util.Collection<T> getPrimitives(java.util.function.Predicate<? super O> predicate)
Gets a filtered collection of primitives matching the given predicate.- Type Parameters:
T
- The primitive type.- Parameters:
predicate
- The predicate to match- Returns:
- The list of primitives.
- Since:
- 10590
-
getNodes
java.util.Collection<N> getNodes()
Replies an unmodifiable collection of nodes in this dataset- Returns:
- an unmodifiable collection of nodes in this dataset
-
getWays
java.util.Collection<W> getWays()
Replies an unmodifiable collection of ways in this dataset- Returns:
- an unmodifiable collection of ways in this dataset
-
getRelations
java.util.Collection<R> getRelations()
Replies an unmodifiable collection of relations in this dataset- Returns:
- an unmodifiable collection of relations in this dataset
-
allPrimitives
default java.util.Collection<O> allPrimitives()
Returns a collection containing all primitives of the dataset.- Returns:
- A collection containing all primitives of the dataset. Data is not ordered
-
allNonDeletedPrimitives
default java.util.Collection<O> allNonDeletedPrimitives()
Returns a collection containing all not-deleted primitives.- Returns:
- A collection containing all not-deleted primitives.
- See Also:
AbstractPrimitive.isDeleted()
-
allNonDeletedCompletePrimitives
default java.util.Collection<O> allNonDeletedCompletePrimitives()
Returns a collection containing all not-deleted complete primitives.- Returns:
- A collection containing all not-deleted complete primitives.
- See Also:
AbstractPrimitive.isDeleted()
,AbstractPrimitive.isIncomplete()
-
allNonDeletedPhysicalPrimitives
default java.util.Collection<O> allNonDeletedPhysicalPrimitives()
Returns a collection containing all not-deleted complete physical primitives.- Returns:
- A collection containing all not-deleted complete physical primitives (nodes and ways).
- See Also:
AbstractPrimitive.isDeleted()
,AbstractPrimitive.isIncomplete()
-
allModifiedPrimitives
default java.util.Collection<O> allModifiedPrimitives()
Returns a collection containing all modified primitives.- Returns:
- A collection containing all modified primitives.
- See Also:
AbstractPrimitive.isModified()
-
allPreservedPrimitives
default java.util.Collection<O> allPreservedPrimitives()
Returns a collection containing all primitives preserved from filtering.- Returns:
- A collection containing all primitives preserved from filtering.
- Since:
- 13309
- See Also:
AbstractPrimitive.isPreserved()
-
getDownloadPolicy
DownloadPolicy getDownloadPolicy()
Get the download policy.- Returns:
- the download policy
- Since:
- 13453
- See Also:
setDownloadPolicy(DownloadPolicy)
-
setDownloadPolicy
void setDownloadPolicy(DownloadPolicy downloadPolicy)
Sets the download policy.- Parameters:
downloadPolicy
- the download policy. Must not be null- Since:
- 13453
- See Also:
getUploadPolicy()
-
getUploadPolicy
UploadPolicy getUploadPolicy()
Get the upload policy.- Returns:
- the upload policy
- See Also:
setUploadPolicy(UploadPolicy)
-
setUploadPolicy
void setUploadPolicy(UploadPolicy uploadPolicy)
Sets the upload policy.- Parameters:
uploadPolicy
- the upload policy. Must not be null- See Also:
getUploadPolicy()
-
getReadLock
java.util.concurrent.locks.Lock getReadLock()
Returns the lock used for reading.- Returns:
- the lock used for reading
-
getHighlightedVirtualNodes
java.util.Collection<WaySegment> getHighlightedVirtualNodes()
Returns an unmodifiable collection of *WaySegments* whose virtual nodes should be highlighted. WaySegments are used to avoid having to create a VirtualNode class that wouldn't have much purpose otherwise.- Returns:
- unmodifiable collection of WaySegments
-
getHighlightedWaySegments
java.util.Collection<WaySegment> getHighlightedWaySegments()
Returns an unmodifiable collection of WaySegments that should be highlighted.- Returns:
- unmodifiable collection of WaySegments
-
clearHighlightedVirtualNodes
default void clearHighlightedVirtualNodes()
clear all highlights of virtual nodes
-
clearHighlightedWaySegments
default void clearHighlightedWaySegments()
clear all highlights of way segments
-
setHighlightedVirtualNodes
void setHighlightedVirtualNodes(java.util.Collection<WaySegment> waySegments)
set what virtual nodes should be highlighted. Requires a Collection of *WaySegments* to avoid a VirtualNode class that wouldn't have much use otherwise.- Parameters:
waySegments
- Collection of way segments
-
setHighlightedWaySegments
void setHighlightedWaySegments(java.util.Collection<WaySegment> waySegments)
set what virtual ways should be highlighted.- Parameters:
waySegments
- Collection of way segments
-
addHighlightUpdateListener
void addHighlightUpdateListener(HighlightUpdateListener listener)
Adds a listener that gets notified whenever way segment / virtual nodes highlights change.- Parameters:
listener
- The Listener- Since:
- 12014
-
removeHighlightUpdateListener
void removeHighlightUpdateListener(HighlightUpdateListener listener)
Removes a listener that was added withaddHighlightUpdateListener(HighlightUpdateListener)
- Parameters:
listener
- The Listener- Since:
- 12014
-
getSelected
default java.util.Collection<O> getSelected()
Replies an unmodifiable collection of primitives currently selected in this dataset, except deleted ones. May be empty, but not null.When iterating through the set it is ordered by the order in which the primitives were added to the selection.
- Returns:
- unmodifiable collection of primitives
-
getAllSelected
java.util.Collection<O> getAllSelected()
Replies an unmodifiable collection of primitives currently selected in this dataset, including deleted ones. May be empty, but not null.When iterating through the set it is ordered by the order in which the primitives were added to the selection.
- Returns:
- unmodifiable collection of primitives
-
getSelectedNodes
default java.util.Collection<N> getSelectedNodes()
Returns selected nodes.- Returns:
- selected nodes
-
getSelectedWays
default java.util.Collection<W> getSelectedWays()
Returns selected ways.- Returns:
- selected ways
-
getSelectedRelations
default java.util.Collection<R> getSelectedRelations()
Returns selected relations.- Returns:
- selected relations
-
selectionEmpty
boolean selectionEmpty()
Determines whether the selection is empty or not- Returns:
- whether the selection is empty or not
-
isSelected
boolean isSelected(O osm)
Determines whether the given primitive is selected or not- Parameters:
osm
- the primitive- Returns:
- whether
osm
is selected or not
-
toggleSelected
void toggleSelected(java.util.Collection<? extends PrimitiveId> osm)
Toggles the selected state of the given collection of primitives.- Parameters:
osm
- The primitives to toggle
-
toggleSelected
void toggleSelected(PrimitiveId... osm)
Toggles the selected state of the given collection of primitives.- Parameters:
osm
- The primitives to toggle
-
setSelected
void setSelected(java.util.Collection<? extends PrimitiveId> selection)
Sets the current selection to the primitives inselection
and notifies allDataSelectionListener
.- Parameters:
selection
- the selection
-
setSelected
void setSelected(PrimitiveId... osm)
Sets the current selection to the primitives inosm
and notifies allDataSelectionListener
.- Parameters:
osm
- the primitives to set.null
values are ignored for now, but this may be removed in the future.
-
addSelected
void addSelected(java.util.Collection<? extends PrimitiveId> selection)
Adds the primitives inselection
to the current selection and notifies allDataSelectionListener
.- Parameters:
selection
- the selection
-
addSelected
void addSelected(PrimitiveId... osm)
Adds the primitives inosm
to the current selection and notifies allDataSelectionListener
.- Parameters:
osm
- the primitives to add
-
clearSelection
void clearSelection(PrimitiveId... osm)
Removes the selection from every value in the collection.- Parameters:
osm
- The collection of ids to remove the selection from.
-
clearSelection
void clearSelection(java.util.Collection<? extends PrimitiveId> list)
Removes the selection from every value in the collection.- Parameters:
list
- The collection of ids to remove the selection from.
-
clearSelection
void clearSelection()
Clears the current selection.
-
addSelectionListener
void addSelectionListener(DataSelectionListener listener)
Add a listener that listens to selection changes in this specific data set.- Parameters:
listener
- The listener.- See Also:
removeSelectionListener(DataSelectionListener)
,To add a global listener.
-
removeSelectionListener
void removeSelectionListener(DataSelectionListener listener)
Remove a listener that listens to selection changes in this specific data set.- Parameters:
listener
- The listener.- See Also:
addSelectionListener(DataSelectionListener)
-
getDataSourceBoundingBox
default ProjectionBounds getDataSourceBoundingBox()
Returns the data sources bounding box.- Returns:
- the data sources bounding box
-
clearMappaintCache
void clearMappaintCache()
Clear the mappaint cache for this DataSet.- Since:
- 13420
-
isModified
default boolean isModified()
Replies true if there is at least one primitive in this dataset withIPrimitive.isModified()
==true
.- Returns:
- true if there is at least one primitive in this dataset with
IPrimitive.isModified()
==true
.
-
-