Package org.openstreetmap.josm.data.osm
Class DataSet
java.lang.Object
org.openstreetmap.josm.data.osm.DataSet
- All Implemented Interfaces:
Data,Lockable,OsmData<OsmPrimitive,,Node, Way, Relation> ProjectionChangeListener
public final class DataSet
extends Object
implements OsmData<OsmPrimitive,Node,Way,Relation>, ProjectionChangeListener
DataSet is the data behind the application. It can consists of only a few points up to the whole
osm database. DataSet's can be merged together, saved, (up/down/disk)loaded etc.
Note that DataSet is not an osm-primitive and so has no key association but a few members to
store some information.
Dataset is threadsafe - accessing Dataset simultaneously from different threads should never
lead to data corruption or ConcurrentModificationException. However when for example one thread
removes primitive and other thread try to add another primitive referring to the removed primitive,
DataIntegrityException will occur.
To prevent such situations, read/write lock is provided. While read lock is used, it's guaranteed that
Dataset will not change. Sample usage:
ds.getReadLock().lock();
try {
// .. do something with dataset
} finally {
ds.getReadLock().unlock();
}
Write lock should be used in case of bulk operations. In addition to ensuring that other threads can't
use dataset in the middle of modifications it also stops sending of dataset events. That's good for performance
reasons - GUI can be updated after all changes are done.
Sample usage:
ds.beginUpdate()
try {
// .. do modifications
} finally {
ds.endUpdate();
}
Note that it is not necessary to call beginUpdate/endUpdate for every dataset modification - dataset will get locked
automatically.
Note that locks cannot be upgraded - if one threads use read lock and and then write lock, dead lock will occur - see #5814 for
sample ticket-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Storage<OsmPrimitive>private Areaprivate final List<AbstractDatasetChangedEvent>Holding bin for changeset tag information, to be applied when or if this is ever uploaded.private final ConflictCollectionprivate Set<OsmPrimitive>The current selected primitives.private final ListenerList<DataSourceListener>A list of listeners that listen to DataSource changes on this layerprivate final Collection<DataSource>All data sources of this DataSet.private DownloadPolicyprivate List<GpxData.XMLNamespace>Used to temporarily store namespaces from the GPX file in case the user converts back and forth.private Collection<WaySegment>private Collection<WaySegment>private final ListenerList<HighlightUpdateListener>private final AtomicBooleanFlag used to know if the dataset should not be editableprivate final CopyOnWriteArrayList<DataSetListener>private final ReadWriteLockprivate shortprivate static final intMaximum number of events to kept between beginUpdate/endUpdate.private static final intMaximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)private Stringprivate final Map<PrimitiveId,OsmPrimitive> private Stringprivate final LinkedList<Collection<? extends OsmPrimitive>>History of selections - shared by plugins and SelectionListDialogprivate final ListenerList<DataSelectionListener>A list of listeners that listen to selection changes on this layer.private final ObjectThe mutex lock that is used to synchronize selection changes.private final QuadBucketPrimitiveStore<Node,Way, Relation> private intprivate UploadPolicyprivate StringThe API version that created this data set, if any. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeSetTag(String k, String v) Adds a new changeset tag.voidAdds a new data set listener.booleanaddDataSource(DataSource source) Adds a new data source.voidaddDataSourceListener(DataSourceListener listener) Adds a listener that gets notified whenever the data sources changebooleanaddDataSources(Collection<DataSource> sources) Adds new data sources.voidAdds a listener that gets notified whenever way segment / virtual nodes highlights change.voidaddPrimitive(OsmPrimitive primitive) Adds a primitive to the dataset.voidaddPrimitiveRecursive(OsmPrimitive primitive) Adds recursively a primitive, and all its children, to the dataset.voidaddSelected(Collection<? extends PrimitiveId> selection) Adds the primitives inselectionto the current selection and notifies allDataSelectionListener.private voidaddSelected(Stream<? extends PrimitiveId> stream) voidaddSelected(PrimitiveId... osm) Adds the primitives inosmto the current selection and notifies allDataSelectionListener.voidaddSelectionListener(DataSelectionListener listener) Add a listener that listens to selection changes in this specific data set.voidCan be called before bigger changes on dataset.private voidChecks the dataset is modifiable (not read-only).voidCleanups all deleted primitives (really delete them from the dataset).voidclear()Removes all primitives from the dataset and resets the currently selected primitives to the empty collection.voidClear the mappaint cache for this DataSet.voidClears the current selection.voidclearSelection(Collection<? extends PrimitiveId> list) Removes the selection from every value in the collection.private voidclearSelection(Stream<? extends PrimitiveId> stream) voidclearSelection(PrimitiveId... osm) Removes the selection from every value in the collection.voidClears selection history listClones the specified primitives into this data set.booleancontainsNode(Node n) Determines if the given node can be retrieved in the data set through its bounding box.booleanDetermines if the given relation can be retrieved in the data set through its bounding box.booleancontainsWay(Way w) Determines if the given way can be retrieved in the data set through its bounding box.voidMarks all "invisible" objects as deleted.private static voidprivate booleanDo a selection change.voidMust be called after a previous call tobeginUpdate()to fire change events.(package private) voidfireChangesetIdChanged(OsmPrimitive primitive, int oldChangesetId, int newChangesetId) private voidprivate void(package private) void(package private) void(package private) voidfireNodeMoved(Node node, LatLon newCoor, EastNorth eastNorth) (package private) voidfirePrimitiveFlagsChanged(OsmPrimitive primitive) (package private) voidfirePrimitivesAdded(Collection<? extends OsmPrimitive> added, boolean wasIncomplete) (package private) voidfirePrimitivesRemoved(Collection<? extends OsmPrimitive> removed, boolean wasComplete) (package private) void(package private) voidfireTagsChanged(OsmPrimitive prim, Map<String, String> originalKeys) (package private) voidfireWayNodesChanged(Way way) Replies an unmodifiable collection of primitives currently selected in this dataset, including deleted ones.Replies the map of changeset tags to be applied when or if this is ever uploaded.Replies the set of conflicts currently managed in this layer.Returns the total area of downloaded data (the "yellow rectangles").Returns the data sources bounding box.Replies the list of data source bounds.Returns the collection of data sources.Get the download policy.Gets the GPX (XML) namespaces if this DataSet was created from a GPX fileReturns an unmodifiable collection of *WaySegments* whose virtual nodes should be highlighted.Returns an unmodifiable collection of WaySegments that should be highlighted.Returns the way selected last or null if no way primitives were selected or selection is empty.shortReturns mappaint cache index for this DataSet.getName()Returns the name of this data set (optional).getNodes()Replies an unmodifiable collection of nodes in this datasetgetPrimitiveById(PrimitiveId primitiveId) Returns a primitive with a given id from the data set.private OsmPrimitivegetPrimitiveByIdChecked(PrimitiveId primitiveId) Show message and stack trace in log in case primitive is not found<T extends OsmPrimitive>
Collection<T>getPrimitives(Predicate<? super OsmPrimitive> predicate) Gets a filtered collection of primitives matching the given predicate.Returns the lock used for reading.Replies an unmodifiable collection of relations in this datasetReturns an optional remark about this data set (used by Overpass API).Returns selected nodes and ways.LinkedList<Collection<? extends OsmPrimitive>>Replies the history of JOSM selectionsGet the upload policy.Replies the API version this dataset was created from.getWays()Replies an unmodifiable collection of ways in this datasetvoidInvalidates the internal cache of projected east/north coordinates.booleanisEmpty()Determines if this Dataset contains no primitives.booleanisLocked()Determines if this is read-only/locked (thus it cannot be modified).booleanReplies true if there is at least one primitive in this dataset withIPrimitive.isModified()==true.booleanisSelected(OsmPrimitive osm) Determines whether the given primitive is selected or notvoidlock()Enables the read-only/locked mode.voidMoves all primitives and datasources from DataSet "from" to this DataSet.voidmergeFrom(DataSet from, ProgressMonitor progressMonitor) Moves all primitives and datasources from DataSet "from" to this DataSet.voidprojectionChanged(Projection oldValue, Projection newValue) voidRemoves a data set listener.voidremoveDataSourceListener(DataSourceListener listener) Removes a listener that gets notified whenever the data sources changevoidRemoves a listener that was added withOsmData.addHighlightUpdateListener(HighlightUpdateListener)(package private) voidremovePrimitive(OsmPrimitive primitive) voidremovePrimitive(PrimitiveId primitiveId) Removes a primitive from the dataset.private voidremovePrimitiveFromStorage(OsmPrimitive primitive) private voidremovePrimitiveImpl(OsmPrimitive primitive) voidremovePrimitives(Collection<PrimitiveId> primitiveIds) Removes primitives from the dataset.voidremovePrimitives(PrimitiveId... primitiveIds) Removes primitives from the dataset.voidremoveSelectionListener(DataSelectionListener listener) Remove a listener that listens to selection changes in this specific data set.booleanReplies true if there is at least one primitive in this dataset which requires to be uploaded to server.searchNodes(BBox bbox) Searches for nodes in the given bounding box.searchPrimitives(BBox bbox) Searches for all primitives in the given bounding boxsearchRelations(BBox bbox) Searches for relations in the given bounding box.searchWays(BBox bbox) Searches for ways in the given bounding box.booleanDetermines whether the selection is empty or notvoidsetDownloadPolicy(DownloadPolicy downloadPolicy) Sets the download policy.voidsetGPXNamespaces(List<GpxData.XMLNamespace> gpxNamespaces) Sets the GPX (XML) namespacesvoidsetHighlightedVirtualNodes(Collection<WaySegment> waySegments) set what virtual nodes should be highlighted.voidsetHighlightedWaySegments(Collection<WaySegment> waySegments) set what virtual ways should be highlighted.voidSets the name of this data set.voidSets an optional remark about this data set (used by Overpass API).voidsetSelected(Collection<? extends PrimitiveId> selection) Sets the current selection to the primitives inselectionand notifies allDataSelectionListener.private voidsetSelected(Stream<? extends PrimitiveId> stream) voidsetSelected(PrimitiveId... osm) Sets the current selection to the primitives inosmand notifies allDataSelectionListener.voidsetUploadPolicy(UploadPolicy uploadPolicy) Sets the upload policy.voidsetVersion(String version) Sets the API version this dataset was created from.voidtoggleSelected(Collection<? extends PrimitiveId> osm) Toggles the selected state of the given collection of primitives.private voidtoggleSelected(Stream<? extends PrimitiveId> stream) voidtoggleSelected(PrimitiveId... osm) Toggles the selected state of the given collection of primitives.unlinkNodeFromWays(Node node) Removes all references from ways in this dataset to a particular node.unlinkPrimitiveFromRelations(OsmPrimitive primitive) removes all references from relations in this dataset to this primitiveunlinkReferencesToPrimitive(OsmPrimitive referencedPrimitive) Removes all references from other primitives to the referenced primitive.voidunlock()Disables the read-only/locked mode.voidPerforms the update runnable betweenbeginUpdate()/endUpdate()calls.<T,R> R Performs the update function betweenbeginUpdate()/endUpdate()calls.<R> RPerforms the update supplier betweenbeginUpdate()/endUpdate()calls.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.osm.OsmData
allModifiedPrimitives, allNonDeletedCompletePrimitives, allNonDeletedPhysicalPrimitives, allNonDeletedPrimitives, allPreservedPrimitives, allPrimitives, clearHighlightedVirtualNodes, clearHighlightedWaySegments, getPrimitiveById, getSelected, getSelectedNodes, getSelectedRelations, getSelectedWays
-
Field Details
-
MAX_SINGLE_EVENTS
Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)- See Also:
-
MAX_EVENTS
Maximum number of events to kept between beginUpdate/endUpdate. When more events are created, that simple DatasetChangedEvent is sent)- See Also:
-
store
-
allPrimitives
-
primitivesMap
-
listeners
-
highlightedVirtualNodes
-
highlightedWaySegments
-
highlightUpdateListeners
-
updateCount
-
cachedEvents
-
name
-
downloadPolicy
-
uploadPolicy
-
isReadOnly
Flag used to know if the dataset should not be editable -
lock
-
selectionLock
The mutex lock that is used to synchronize selection changes. -
currentSelectedPrimitives
The current selected primitives. This is always a unmodifiable set. The set should be ordered in the order in which the primitives have been added to the selection. -
selectionListeners
A list of listeners that listen to selection changes on this layer. -
cachedDataSourceArea
-
cachedDataSourceBounds
-
dataSources
All data sources of this DataSet. -
dataSourceListeners
A list of listeners that listen to DataSource changes on this layer -
conflicts
-
mappaintCacheIdx
-
remark
-
gpxNamespaces
Used to temporarily store namespaces from the GPX file in case the user converts back and forth. Will not be saved to .osm files, but that's not necessary because GPX files won't automatically be overridden after that. -
selectionHistory
History of selections - shared by plugins and SelectionListDialog -
version
The API version that created this data set, if any. -
changeSetTags
Holding bin for changeset tag information, to be applied when or if this is ever uploaded.
-
-
Constructor Details
-
DataSet
public DataSet()Constructs a newDataSet. -
DataSet
Creates a newDataSet.- Parameters:
copyFrom- An otherDataSetto copy the contents of this dataset from.- Since:
- 10346
-
DataSet
Constructs a newDataSetinitially filled with the given primitives.- Parameters:
osmPrimitives- primitives to add to this data set- Since:
- 12726
-
-
Method Details
-
clonePrimitives
public Map<OsmPrimitive,OsmPrimitive> clonePrimitives(Iterable<Node> nodes, Iterable<Way> ways, Iterable<Relation> relations) Clones the specified primitives into this data set.- Parameters:
nodes- nodes to cloneways- ways to clonerelations- relations to clone- Returns:
- the map of cloned primitives indexed by their original version
- Since:
- 18001
-
addDataSource
Adds a new data source.- Parameters:
source- data source to add- Returns:
trueif the collection changed as a result of the call- Since:
- 11626
-
addDataSources
Adds new data sources.- Parameters:
sources- data sources to add- Returns:
trueif the collection changed as a result of the call- Since:
- 11626
-
getReadLock
Description copied from interface:OsmDataReturns the lock used for reading.- Specified by:
getReadLockin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- the lock used for reading
-
getSelectionHistory
Replies the history of JOSM selections- Returns:
- list of history entries
-
clearSelectionHistory
Clears selection history list -
getVersion
Description copied from interface:OsmDataReplies the API version this dataset was created from. May be null.- Specified by:
getVersionin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- the API version this dataset was created from. May be null.
-
setVersion
Sets the API version this dataset was created from.- Parameters:
version- the API version, i.e. "0.6"- Throws:
IllegalStateException- if the dataset is read-only
-
getDownloadPolicy
Description copied from interface:OsmDataGet the download policy.- Specified by:
getDownloadPolicyin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- the download policy
- See Also:
-
setDownloadPolicy
Description copied from interface:OsmDataSets the download policy.- Specified by:
setDownloadPolicyin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
downloadPolicy- the download policy. Must not be null- See Also:
-
getUploadPolicy
Description copied from interface:OsmDataGet the upload policy.- Specified by:
getUploadPolicyin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- the upload policy
- See Also:
-
setUploadPolicy
Description copied from interface:OsmDataSets the upload policy.- Specified by:
setUploadPolicyin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
uploadPolicy- the upload policy. Must not be null- See Also:
-
getChangeSetTags
Replies the map of changeset tags to be applied when or if this is ever uploaded.- Returns:
- the map of changeset tags
- See Also:
-
addChangeSetTag
Adds a new changeset tag.- Parameters:
k- Keyv- Value- See Also:
-
getPrimitives
public <T extends OsmPrimitive> Collection<T> getPrimitives(Predicate<? super OsmPrimitive> predicate) Description copied from interface:OsmDataGets a filtered collection of primitives matching the given predicate.- Specified by:
getPrimitivesin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Type Parameters:
T- The primitive type.- Parameters:
predicate- The predicate to match- Returns:
- The list of primitives.
-
getNodes
Description copied from interface:OsmDataReplies an unmodifiable collection of nodes in this dataset -
searchNodes
Description copied from interface:OsmDataSearches for nodes in the given bounding box.- Specified by:
searchNodesin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
bbox- the bounding box- Returns:
- List of nodes in the given bbox. Can be empty but not null
-
getWays
Description copied from interface:OsmDataReplies an unmodifiable collection of ways in this dataset -
searchWays
Description copied from interface:OsmDataSearches for ways in the given bounding box.- Specified by:
searchWaysin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
bbox- the bounding box- Returns:
- List of ways in the given bbox. Can be empty but not null
-
searchRelations
Description copied from interface:OsmDataSearches for relations in the given bounding box.- Specified by:
searchRelationsin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
bbox- the bounding box- Returns:
- List of relations in the given bbox. Can be empty but not null
-
searchPrimitives
Searches for all primitives in the given bounding box- Parameters:
bbox- the bounding box- Returns:
- List of primitives in the given bbox. Can be empty but not null
- Since:
- 15891
-
getRelations
Description copied from interface:OsmDataReplies an unmodifiable collection of relations in this dataset- Specified by:
getRelationsin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- an unmodifiable collection of relations in this dataset
-
containsNode
Determines if the given node can be retrieved in the data set through its bounding box. Useful for dataset consistency test. For efficiency reasons this method does not lock the dataset, you have to lock it manually.- Specified by:
containsNodein interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
n- The node to search- Returns:
trueifncan be retrieved in this data set,falseotherwise- Since:
- 7501
-
containsWay
Determines if the given way can be retrieved in the data set through its bounding box. Useful for dataset consistency test. For efficiency reasons this method does not lock the dataset, you have to lock it manually.- Specified by:
containsWayin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
w- The way to search- Returns:
trueifwcan be retrieved in this data set,falseotherwise- Since:
- 7501
-
containsRelation
Determines if the given relation can be retrieved in the data set through its bounding box. Useful for dataset consistency test. For efficiency reasons this method does not lock the dataset, you have to lock it manually.- Specified by:
containsRelationin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
r- The relation to search- Returns:
trueifrcan be retrieved in this data set,falseotherwise- Since:
- 7501
-
addPrimitive
Adds a primitive to the dataset.- Specified by:
addPrimitivein interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
primitive- the primitive.- Throws:
IllegalStateException- if the dataset is read-only
-
addPrimitiveRecursive
Adds recursively a primitive, and all its children, to the dataset.- Parameters:
primitive- the primitive.- Throws:
IllegalStateException- if the dataset is read-only- Since:
- 17981
-
removePrimitive
Removes a primitive from the dataset. This method only removes the primitive from the respective collection of primitives managed by this dataset, i.e. fromstore.nodes,store.ways, orstore.relations. References from other primitives to this primitive are left unchanged.- Parameters:
primitiveId- the id of the primitive- Throws:
IllegalStateException- if the dataset is read-only
-
removePrimitives
Removes primitives from the dataset. This method only removes the primitives from the respective collection of primitives managed by this dataset, i.e. fromstore.nodes,store.ways, orstore.relations. References from other primitives to this primitive are left unchanged.- Parameters:
primitiveIds- the ids of the primitive- Throws:
IllegalStateException- if the dataset is read-only- Since:
- 18724
-
removePrimitives
Removes primitives from the dataset. This method only removes the primitives from the respective collection of primitives managed by this dataset, i.e. fromstore.nodes,store.ways, orstore.relations. References from other primitives to this primitive are left unchanged.- Parameters:
primitiveIds- the ids of the primitive- Throws:
IllegalStateException- if the dataset is read-only- Since:
- 18724
-
removePrimitiveImpl
-
removePrimitiveFromStorage
-
removePrimitive
-
addSelectionListener
Description copied from interface:OsmDataAdd a listener that listens to selection changes in this specific data set.- Specified by:
addSelectionListenerin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
listener- The listener.- See Also:
-
removeSelectionListener
Description copied from interface:OsmDataRemove a listener that listens to selection changes in this specific data set.- Specified by:
removeSelectionListenerin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
listener- The listener.- See Also:
-
getSelectedNodesAndWays
Returns selected nodes and ways.- Returns:
- selected nodes and ways
-
getLastSelectedWay
Returns the way selected last or null if no way primitives were selected or selection is empty.- Returns:
- last way in selection or null
- Since:
- 18468
-
getHighlightedVirtualNodes
Description copied from interface:OsmDataReturns 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.- Specified by:
getHighlightedVirtualNodesin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- unmodifiable collection of WaySegments
-
getHighlightedWaySegments
Description copied from interface:OsmDataReturns an unmodifiable collection of WaySegments that should be highlighted.- Specified by:
getHighlightedWaySegmentsin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- unmodifiable collection of WaySegments
-
addHighlightUpdateListener
Description copied from interface:OsmDataAdds a listener that gets notified whenever way segment / virtual nodes highlights change.- Specified by:
addHighlightUpdateListenerin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
listener- The Listener
-
removeHighlightUpdateListener
Description copied from interface:OsmDataRemoves a listener that was added withOsmData.addHighlightUpdateListener(HighlightUpdateListener)- Specified by:
removeHighlightUpdateListenerin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
listener- The Listener
-
addDataSourceListener
Adds a listener that gets notified whenever the data sources change- Parameters:
listener- The listener- Since:
- 15609
- See Also:
-
removeDataSourceListener
Removes a listener that gets notified whenever the data sources change- Parameters:
listener- The listener- Since:
- 15609
- See Also:
-
getAllSelected
Description copied from interface:OsmDataReplies 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.
- Specified by:
getAllSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- unmodifiable collection of primitives
-
selectionEmpty
Description copied from interface:OsmDataDetermines whether the selection is empty or not- Specified by:
selectionEmptyin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- whether the selection is empty or not
-
isSelected
Description copied from interface:OsmDataDetermines whether the given primitive is selected or not- Specified by:
isSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- the primitive- Returns:
- whether
osmis selected or not
-
setHighlightedVirtualNodes
Description copied from interface:OsmDataset what virtual nodes should be highlighted. Requires a Collection of *WaySegments* to avoid a VirtualNode class that wouldn't have much use otherwise.- Specified by:
setHighlightedVirtualNodesin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
waySegments- Collection of way segments
-
setHighlightedWaySegments
Description copied from interface:OsmDataset what virtual ways should be highlighted.- Specified by:
setHighlightedWaySegmentsin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
waySegments- Collection of way segments
-
setSelected
Description copied from interface:OsmDataSets the current selection to the primitives inselectionand notifies allDataSelectionListener.- Specified by:
setSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
selection- the selection
-
setSelected
Description copied from interface:OsmDataSets the current selection to the primitives inosmand notifies allDataSelectionListener.- Specified by:
setSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- the primitives to set.nullvalues are ignored for now, but this may be removed in the future.
-
setSelected
-
addSelected
Description copied from interface:OsmDataAdds the primitives inselectionto the current selection and notifies allDataSelectionListener.- Specified by:
addSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
selection- the selection
-
addSelected
Description copied from interface:OsmDataAdds the primitives inosmto the current selection and notifies allDataSelectionListener.- Specified by:
addSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- the primitives to add
-
addSelected
-
clearSelection
Description copied from interface:OsmDataRemoves the selection from every value in the collection.- Specified by:
clearSelectionin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- The collection of ids to remove the selection from.
-
clearSelection
Description copied from interface:OsmDataRemoves the selection from every value in the collection.- Specified by:
clearSelectionin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
list- The collection of ids to remove the selection from.
-
clearSelection
Description copied from interface:OsmDataClears the current selection.- Specified by:
clearSelectionin interfaceOsmData<OsmPrimitive,Node, Way, Relation>
-
clearSelection
-
toggleSelected
Description copied from interface:OsmDataToggles the selected state of the given collection of primitives.- Specified by:
toggleSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- The primitives to toggle
-
toggleSelected
Description copied from interface:OsmDataToggles the selected state of the given collection of primitives.- Specified by:
toggleSelectedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
osm- The primitives to toggle
-
toggleSelected
-
doSelectionChange
private boolean doSelectionChange(Function<Set<OsmPrimitive>, DataSelectionListener.SelectionChangeEvent> command) Do a selection change.This is the only method that changes the current selection state.
- Parameters:
command- A generator that generates theDataSelectionListener.SelectionChangeEventfor the given base set of currently selected primitives.- Returns:
- true iff the command did change the selection.
- Since:
- 12048
-
getDataSourceArea
Description copied from interface:DataReturns the total area of downloaded data (the "yellow rectangles").- Specified by:
getDataSourceAreain interfaceData- Returns:
- Area object encompassing downloaded data.
-
getDataSourceBounds
Description copied from interface:DataReplies the list of data source bounds.
Dataset maintains a list of data sources which have been merged into the data set. Each of these sources can optionally declare a bounding box of the data it supplied to the dataset.
This method replies the list of defined (non
null) bounding boxes.- Specified by:
getDataSourceBoundsin interfaceData- Returns:
- the list of data source bounds. An empty list, if no non-null data source bounds are defined.
-
getDataSources
Description copied from interface:DataReturns the collection of data sources.- Specified by:
getDataSourcesin interfaceData- Returns:
- the collection of data sources.
-
getPrimitiveById
Description copied from interface:OsmDataReturns a primitive with a given id from the data set. null, if no such primitive exists- Specified by:
getPrimitiveByIdin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Parameters:
primitiveId- type and uniqueId of the primitive. Might be < 0 for newly created primitives- Returns:
- the primitive
-
getPrimitiveByIdChecked
Show message and stack trace in log in case primitive is not found- Parameters:
primitiveId- primitive id to look for- Returns:
- Primitive by id.
-
deleteWay
-
unlinkNodeFromWays
Removes all references from ways in this dataset to a particular node.- Parameters:
node- the node- Returns:
- The set of ways that have been modified
- Throws:
IllegalStateException- if the dataset is read-only
-
unlinkPrimitiveFromRelations
removes all references from relations in this dataset to this primitive- Parameters:
primitive- the primitive- Returns:
- The set of relations that have been modified
- Throws:
IllegalStateException- if the dataset is read-only
-
unlinkReferencesToPrimitive
Removes all references from other primitives to the referenced primitive.- Parameters:
referencedPrimitive- the referenced primitive- Returns:
- The set of primitives that have been modified
- Throws:
IllegalStateException- if the dataset is read-only
-
isModified
Description copied from interface:OsmDataReplies true if there is at least one primitive in this dataset withIPrimitive.isModified()==true.- Specified by:
isModifiedin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- true if there is at least one primitive in this dataset with
IPrimitive.isModified()==true.
-
requiresUploadToServer
Replies true if there is at least one primitive in this dataset which requires to be uploaded to server.- Returns:
- true if there is at least one primitive in this dataset which requires to be uploaded to server
- Since:
- 13161
-
addDataSetListener
Adds a new data set listener.- Parameters:
dsl- The data set listener to add
-
removeDataSetListener
Removes a data set listener.- Parameters:
dsl- The data set listener to remove
-
beginUpdate
Can be called before bigger changes on dataset. Events are disabled untilendUpdate().DataSetListener.dataChanged(DataChangedEvent event)event is triggered after end of changes
Typical use case should look like this:ds.beginUpdate(); try { ... } finally { ds.endUpdate(); }- See Also:
-
endUpdate
Must be called after a previous call tobeginUpdate()to fire change events.
Typical use case should look like this:ds.beginUpdate(); try { ... } finally { ds.endUpdate(); }- See Also:
-
update
Performs the update runnable betweenbeginUpdate()/endUpdate()calls.- Parameters:
runnable- update action- Since:
- 16187
-
update
Performs the update function betweenbeginUpdate()/endUpdate()calls.- Type Parameters:
T- argument typeR- result type- Parameters:
function- update functiont- function argument- Returns:
- function result
- Since:
- 16187
-
update
Performs the update supplier betweenbeginUpdate()/endUpdate()calls.- Type Parameters:
R- result type- Parameters:
supplier- update supplier- Returns:
- supplier result
- Since:
- 16187
-
fireEventToListeners
-
fireEvent
-
firePrimitivesAdded
-
firePrimitivesRemoved
-
fireTagsChanged
-
fireRelationMembersChanged
-
fireNodeMoved
-
fireWayNodesChanged
-
fireChangesetIdChanged
-
firePrimitiveFlagsChanged
-
fireFilterChanged
void fireFilterChanged() -
fireHighlightingChanged
void fireHighlightingChanged() -
invalidateEastNorthCache
Invalidates the internal cache of projected east/north coordinates. This method can be invoked after the globally configured projection method changed. -
cleanupDeletedPrimitives
Cleanups all deleted primitives (really delete them from the dataset). -
clear
Removes all primitives from the dataset and resets the currently selected primitives to the empty collection. Also notifies selection change listeners if necessary.- Specified by:
clearin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Throws:
IllegalStateException- if the dataset is read-only
-
deleteInvisible
Marks all "invisible" objects as deleted. These objects should be always marked as deleted when downloaded from the server. They can be undeleted later if necessary.- Throws:
IllegalStateException- if the dataset is read-only
-
mergeFrom
Moves all primitives and datasources from DataSet "from" to this DataSet.- Parameters:
from- The source DataSet
-
mergeFrom
Moves all primitives and datasources from DataSet "from" to this DataSet.- Parameters:
from- The source DataSetprogressMonitor- The progress monitor- Throws:
IllegalStateException- if the dataset is read-only
-
getConflicts
Replies the set of conflicts currently managed in this layer.- Returns:
- the set of conflicts currently managed in this layer
- Since:
- 12672
-
getName
Description copied from interface:OsmDataReturns the name of this data set (optional). -
setName
Description copied from interface:OsmDataSets the name of this data set. -
projectionChanged
- Specified by:
projectionChangedin interfaceProjectionChangeListener
-
getDataSourceBoundingBox
Description copied from interface:OsmDataReturns the data sources bounding box.- Specified by:
getDataSourceBoundingBoxin interfaceOsmData<OsmPrimitive,Node, Way, Relation> - Returns:
- the data sources bounding box
-
getMappaintCacheIndex
Returns mappaint cache index for this DataSet. If theAbstractPrimitive.mappaintCacheIdxis not equal to the DataSet mappaint cache index, this means the cache for that primitive is out of date.- Returns:
- mappaint cache index
- Since:
- 13420
-
clearMappaintCache
Description copied from interface:OsmDataClear the mappaint cache for this DataSet.- Specified by:
clearMappaintCachein interfaceOsmData<OsmPrimitive,Node, Way, Relation>
-
lock
Description copied from interface:LockableEnables the read-only/locked mode. -
unlock
Description copied from interface:LockableDisables the read-only/locked mode. -
isLocked
Description copied from interface:LockableDetermines if this is read-only/locked (thus it cannot be modified). -
checkModifiable
Checks the dataset is modifiable (not read-only).- Throws:
IllegalStateException- if the dataset is read-only
-
getRemark
Returns an optional remark about this data set (used by Overpass API).- Returns:
- a remark about this data set, or
null - Since:
- 14219
-
setRemark
Sets an optional remark about this data set (used by Overpass API).- Parameters:
remark- a remark about this data set, ornull- Since:
- 14219
-
getGPXNamespaces
Gets the GPX (XML) namespaces if this DataSet was created from a GPX file- Returns:
- the GPXNamespaces or
null
-
setGPXNamespaces
Sets the GPX (XML) namespaces- Parameters:
gpxNamespaces- the GPXNamespaces to set
-
isEmpty
Determines if this Dataset contains no primitives.- Returns:
- true if this Dataset contains no primitives
- Since:
- 14835
-