Class GeoJSONVectorTileDataSource

java.lang.Object
com.massifmaps.datasources.TileDataSource
com.massifmaps.datasources.GeoJSONVectorTileDataSource

public class GeoJSONVectorTileDataSource extends TileDataSource
A tile data source that builds vector tiles from GeoJSON inputs.
  • 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

      public int createLayer(String name) throws IOException
      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

      public void setLayerGeoJSON(int layerIndex, Variant geoJSON) throws IOException
      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

      public void addGeoJSONFeature(int layerIndex, Variant geoJSON) throws IOException
      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

      public void updateGeoJSONFeature(int layerIndex, Variant geoJSON) throws IOException
      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

      public void setLayerGeoJSONString(int layerIndex, String geoJSON) throws IOException
      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

      public void addGeoJSONStringFeature(int layerIndex, String geoJSON) throws IOException
      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

      public void updateGeoJSONStringFeature(int layerIndex, String geoJSON) throws IOException
      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

      public void removeGeoJSONFeature(int layerIndex, Variant id) throws IOException
      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

      public MapBounds getDataExtent()
      Description copied from class: TileDataSource
      Returns the extent of the tiles in this data source.
      The bounds are in coordinate system of the projection of the data source.
      Overrides:
      getDataExtent in class TileDataSource
      Returns:
      The extent of the data source.
    • loadTile

      public TileData loadTile(MapTile mapTile)
      Description copied from class: TileDataSource
      Loads the specified tile.
      Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.
      Overrides:
      loadTile in class TileDataSource
      Parameters:
      mapTile - The tile to load.
      Returns:
      The tile data. If the tile is not available, null may be returned.