Package com.massifmaps.datasources
Class GeoJSONVectorTileDataSource
java.lang.Object
com.massifmaps.datasources.TileDataSource
com.massifmaps.datasources.GeoJSONVectorTileDataSource
A tile data source that builds vector tiles from GeoJSON inputs.
-
Constructor Summary
ConstructorsConstructorDescriptionGeoJSONVectorTileDataSource(int minZoom, int maxZoom) Constructs a GeoJSONVectorTileDataSource object.
Note: EPSG3857 projection is used. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGeoJSONFeature(int layerIndex, Variant geoJSON) Sets the features of the specified layer.voidaddGeoJSONStringFeature(int layerIndex, String geoJSON) Sets the features of the specified layer.intcreateLayer(String name) Creates a new layer with specified name.voiddeleteLayer(int layerIndex) Deletes an existing layer.Returns the extent of the tiles in this data source.
The bounds are in coordinate system of the projection of the data source.floatReturns the default layer buffer in tile pixels.floatReturns the simplification tolerance in tile pixels.Loads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.voidremoveGeoJSONFeature(int layerIndex, Variant id) Sets the features of the specified layer.voidsetDefaultLayerBuffer(float tolerance) Sets the default layer buffer in tile pixels.voidsetLayerFeatureCollection(int layerIndex, Projection projection, FeatureCollection featureCollection) Sets the feature collection of the specified layer.voidsetLayerGeoJSON(int layerIndex, Variant geoJSON) Sets the features of the specified layer.voidsetLayerGeoJSONString(int layerIndex, String geoJSON) Sets the features of the specified layer.voidsetSimplifyTolerance(float tolerance) Sets the simplification tolerance in tile pixels.voidupdateGeoJSONFeature(int layerIndex, Variant geoJSON) Sets the features of the specified layer if it already exists.voidupdateGeoJSONStringFeature(int layerIndex, String geoJSON) Sets the features of the specified layer if it already exists.Methods inherited from class com.massifmaps.datasources.TileDataSource
buildTagValues, containsMetaDataKey, getContainerMetaData, getMaxOverzoomLevel, getMaxZoom, getMaxZoomWithOverzoom, getMetaData, getMetaDataElement, getMinZoom, getProjection, isMaxOverzoomLevelSet, notifyTilesChanged, setMaxOverzoomLevel, setMetaData, setMetaDataElement
-
Constructor Details
-
GeoJSONVectorTileDataSource
public GeoJSONVectorTileDataSource(int minZoom, int maxZoom) Constructs a GeoJSONVectorTileDataSource object.
Note: EPSG3857 projection is used.- Parameters:
minZoom- The minimum zoom level supported by this data source.maxZoom- The maximum zoom level supported by this data source.
-
-
Method Details
-
getSimplifyTolerance
public float getSimplifyTolerance()Returns the simplification tolerance in tile pixels.- Returns:
- The simplification tolerance in tile pixels.
-
setSimplifyTolerance
public void setSimplifyTolerance(float tolerance) Sets the simplification tolerance in tile pixels.- Parameters:
tolerance- The simplification tolerance in tile pixels. The default is 1.0. Use 0.0 to disable simplification.
-
getDefaultLayerBuffer
public float getDefaultLayerBuffer()Returns the default layer buffer in tile pixels.- Returns:
- The default layer buffer in tile pixels.
-
setDefaultLayerBuffer
public void setDefaultLayerBuffer(float tolerance) Sets the default layer buffer in tile pixels. This buffer value will be used for all layers created afterwards. -
createLayer
Creates a new layer with specified name.- Parameters:
name- The name for the layer.- Returns:
- The layer index of the created layer.
- Throws:
Exception- If an error occured during creation of the layer.IOException
-
setLayerGeoJSON
Sets the features of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson type variant that MUST contain single FeatureColletion element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
addGeoJSONFeature
Sets the features of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson type variant that MUST contain single Feature element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
updateGeoJSONFeature
Sets the features of the specified layer if it already exists.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson type variant that MUST contain single Feature element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
setLayerGeoJSONString
Sets the features of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson string that MUST contain single FeatureColletion element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
addGeoJSONStringFeature
Sets the features of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson string that MUST contain single Feature element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
updateGeoJSONStringFeature
Sets the features of the specified layer if it already exists.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.geoJSON- A geojson string that MUST contain single Feature element.- Throws:
Exception- If an error occured during updating the layer.IOException
-
removeGeoJSONFeature
Sets the features of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.id- id of the feature to remove.- Throws:
Exception- If an error occured during updating the layer.IOException
-
setLayerFeatureCollection
public void setLayerFeatureCollection(int layerIndex, Projection projection, FeatureCollection featureCollection) throws IOException Sets the feature collection of the specified layer.- Parameters:
layerIndex- The index of the layer. A layer with empty name will be created if it does not exist yet.projection- Projection for the features in featureCollection. Can be null if the coordinates are based on WGS84.featureCollection- The feature collection for the specified layer.- Throws:
Exception- If an error occured during updating the layer.IOException
-
deleteLayer
public void deleteLayer(int layerIndex) Deletes an existing layer.- Parameters:
layerIndex- The index of layer to delete.
-
getDataExtent
Description copied from class:TileDataSourceReturns the extent of the tiles in this data source.
The bounds are in coordinate system of the projection of the data source.- Overrides:
getDataExtentin classTileDataSource- Returns:
- The extent of the data source.
-
loadTile
Description copied from class:TileDataSourceLoads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.- Overrides:
loadTilein classTileDataSource- Parameters:
mapTile- The tile to load.- Returns:
- The tile data. If the tile is not available, null may be returned.
-