Package com.massifmaps.datasources
Class LocalVectorDataSource
java.lang.Object
com.massifmaps.datasources.VectorDataSource
com.massifmaps.datasources.LocalVectorDataSource
A modifiable vector data source that keeps all the elements in the local memory.
Optionally vector elements can be kept in a spatial index and only the visible elements get rendered.
There can be a small delay before previously invisible elements become visible after view changes.
This makes it suitable for cases where there are a large number of static vector elements.
The draw order of vector elements within the data source is undefined.
Optionally vector elements can be kept in a spatial index and only the visible elements get rendered.
There can be a small delay before previously invisible elements become visible after view changes.
This makes it suitable for cases where there are a large number of static vector elements.
The draw order of vector elements within the data source is undefined.
-
Constructor Summary
ConstructorsConstructorDescriptionLocalVectorDataSource(Projection projection) Constructs an LocalVectorDataSource object with no spatial index.LocalVectorDataSource(Projection projection, int spatialIndexType) Constructs an LocalVectorDataSource object with specified spatial index. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(VectorElement element) Adds a vector element to the data source.voidaddAll(VectorElementVector elements) Adds multiple vector elements to the data source.voidaddFeatureCollection(FeatureCollection featureCollection, Style style) Loads all vector elements from specified feature collection by applying specified style.voidclear()Clear the data source by removing all elements.getAll()Returns all vector elements added to this data source using add() and addAll() methods.Returns the extent of the data of this data source.
The bounds are in coordinate system of the projection of the data source.Returns the elements of this data source as a feature collection.Returns the active geometry simplifier of the data source.loadElements(CullState cullState) Loads all the elements within the defined envelope.booleanremove(VectorElement element) Removes a vector element from the data source.booleanremoveAll(VectorElementVector elements) Removes multiple vector elements from the data source.voidsetAll(VectorElementVector elements) Replaces all vector elements in the data source with the given list of vector elements.voidsetGeometrySimplifier(GeometrySimplifier simplifier) Attaches geometry simplifier to the data source.Methods inherited from class com.massifmaps.datasources.VectorDataSource
getProjection, notifyElementsChanged
-
Constructor Details
-
LocalVectorDataSource
Constructs an LocalVectorDataSource object with no spatial index.- Parameters:
projection- The projection used by this data source.
-
LocalVectorDataSource
Constructs an LocalVectorDataSource object with specified spatial index.- Parameters:
projection- The projection used by this data source.spatialIndexType- The spatial index type to use.
-
-
Method Details
-
clear
public void clear()Clear the data source by removing all elements. -
getAll
Returns all vector elements added to this data source using add() and addAll() methods.- Returns:
- A vector containing all the vector elements in this data source.
-
setAll
Replaces all vector elements in the data source with the given list of vector elements.- Parameters:
elements- The list of new vector elements
-
add
Adds a vector element to the data source. The vector element's coordinates are expected to be
in the data source's projection's coordinate system. The order in which the elements are added has
no effect on the order they get rendered.- Parameters:
element- The vector element to be added.
-
addAll
Adds multiple vector elements to the data source. The vector elements' coordinates are expected to be
in the data source's projection's coordinate system. The order in which the elements are added has
no effect on the order they get rendered.- Parameters:
elements- A list of vector elements to be added.
-
remove
Removes a vector element from the data source.- Parameters:
element- The vector element to be removed.- Returns:
- True if the vector element existed in the data source.
-
removeAll
Removes multiple vector elements from the data source.- Parameters:
elements- A list of vector elements to be removed.- Returns:
- True if all listed elements were removed. False otherwise.
-
getGeometrySimplifier
Returns the active geometry simplifier of the data source.- Returns:
- The current geometry simplifier (can be null)
-
setGeometrySimplifier
Attaches geometry simplifier to the data source. If the specified simplifier is null, detaches any active simplifier.- Parameters:
simplifier- The new geometry simplifier to use (can be null).
-
getFeatureCollection
Returns the elements of this data source as a feature collection. The feature collection can be then serialized as a GeoJSON, for example.- Returns:
- The feature collection containing all data source elements.
-
addFeatureCollection
Loads all vector elements from specified feature collection by applying specified style.- Parameters:
featureCollection- The feature collection to load elements from.style- The geometry collection style to use. Only elements compatible with style are created.
-
getDataExtent
Description copied from class:VectorDataSourceReturns the extent of the data of this data source.
The bounds are in coordinate system of the projection of the data source.- Overrides:
getDataExtentin classVectorDataSource- Returns:
- The extent of the data source.
-
loadElements
Description copied from class:VectorDataSourceLoads all the elements within the defined envelope.- Overrides:
loadElementsin classVectorDataSource- Parameters:
cullState- State for describing view parameters and conservative view envelope.- Returns:
- The vector of loaded vector elements. If no elements are available, null may be returned.
-