public class

LocalVectorDataSource

extends VectorDataSource
java.lang.Object
   ↳ com.carto.datasources.VectorDataSource
     ↳ com.carto.datasources.LocalVectorDataSource

Class Overview

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.

Summary

Public Constructors
LocalVectorDataSource(Projection projection)
Constructs an LocalVectorDataSource object with no spatial index.
LocalVectorDataSource(Projection projection, LocalSpatialIndexType spatialIndexType)
Constructs an LocalVectorDataSource object with specified spatial index.
Public Methods
void add(VectorElement element)
Adds a vector element to the data source.
void addAll(VectorElementVector elements)
Adds multiple vector elements to the data source.
void addFeatureCollection(FeatureCollection featureCollection, Style style)
Loads all vector elements from specified feature collection by applying specified style.
void clear()
Clear the data source by removing all elements.
synchronized void delete()
VectorElementVector getAll()
Returns all vector elements added to this data source using add() and addAll() methods.
MapBounds getDataExtent()
Returns the extent of the data of this data source.
FeatureCollection getFeatureCollection()
Returns the elements of this data source as a feature collection.
GeometrySimplifier getGeometrySimplifier()
Returns the active geometry simplifier of the data source.
VectorData loadElements(CullState cullState)
Loads all the elements within the defined envelope.
boolean remove(VectorElement element)
Removes a vector element from the data source.
boolean removeAll(VectorElementVector elements)
Removes multiple vector elements from the data source.
void setAll(VectorElementVector elements)
Replaces all vector elements in the data source with the given list of vector elements.
void setGeometrySimplifier(GeometrySimplifier simplifier)
Attaches geometry simplifier to the data source.
[Expand]
Inherited Methods
From class com.carto.datasources.VectorDataSource
From class java.lang.Object

Public Constructors

public LocalVectorDataSource (Projection projection)

Constructs an LocalVectorDataSource object with no spatial index.

Parameters
projection The projection used by this data source.

public LocalVectorDataSource (Projection projection, LocalSpatialIndexType spatialIndexType)

Constructs an LocalVectorDataSource object with specified spatial index.

Parameters
projection The projection used by this data source.
spatialIndexType The spatial index type to use.

Public Methods

public void add (VectorElement element)

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.

public void addAll (VectorElementVector elements)

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.

public void addFeatureCollection (FeatureCollection featureCollection, Style style)

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.

public void clear ()

Clear the data source by removing all elements.

public synchronized void delete ()

public VectorElementVector 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.

public MapBounds getDataExtent ()

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 extent of the data source.

public FeatureCollection 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.

public GeometrySimplifier getGeometrySimplifier ()

Returns the active geometry simplifier of the data source.

Returns
  • The current geometry simplifier (can be null)

public VectorData loadElements (CullState cullState)

Loads all the elements within the defined envelope.

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.

public boolean remove (VectorElement element)

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.

public boolean removeAll (VectorElementVector elements)

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.

public void setAll (VectorElementVector elements)

Replaces all vector elements in the data source with the given list of vector elements.

Parameters
elements The list of new vector elements

public void setGeometrySimplifier (GeometrySimplifier simplifier)

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