Class FeatureTiles

  • Direct Known Subclasses:
    DefaultFeatureTiles

    public abstract class FeatureTiles
    extends Object
    Tiles generated from features
    Since:
    1.1.2
    Author:
    osbornb
    • Field Detail

      • WEB_MERCATOR_PROJECTION

        protected static final Projection WEB_MERCATOR_PROJECTION
        Web Mercator Projection
      • featureDao

        protected final FeatureDao featureDao
        Tile data access object
      • projection

        protected Projection projection
        Feature DAO Projection
      • indexManager

        protected FeatureIndexManager indexManager
        When not null, features are retrieved using a feature index
      • featureTableStyles

        protected FeatureTableStyles featureTableStyles
        Feature Style extension
      • tileWidth

        protected int tileWidth
        Tile height
      • tileHeight

        protected int tileHeight
        Tile height
      • compressFormat

        protected String compressFormat
        Compress format
      • pointRadius

        protected float pointRadius
        Point radius
      • pointPaint

        protected Paint pointPaint
        Point paint
      • pointIcon

        protected FeatureTilePointIcon pointIcon
        Optional point icon in place of a drawn circle
      • linePaint

        protected Paint linePaint
        Line paint
      • lineStrokeWidth

        protected float lineStrokeWidth
        Line stroke width
      • polygonPaint

        protected Paint polygonPaint
        Polygon paint
      • polygonStrokeWidth

        protected float polygonStrokeWidth
        Polygon stroke width
      • fillPolygon

        protected boolean fillPolygon
        Fill polygon flag
      • polygonFillPaint

        protected Paint polygonFillPaint
        Polygon fill paint
      • heightOverlap

        protected float heightOverlap
        Height overlapping pixels between tile images
      • widthOverlap

        protected float widthOverlap
        Width overlapping pixels between tile images
      • maxFeaturesPerTile

        protected Integer maxFeaturesPerTile
        Optional max features per tile. When more features than this value exist for creating a single tile, the tile is not created
      • simplifyGeometries

        protected boolean simplifyGeometries
        When true, geometries are simplified before being drawn. Default is true
      • geodesic

        protected boolean geodesic
        Draw geometries using geodesic lines
      • scale

        protected float scale
        Scale factor
    • Constructor Detail

      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao)
        Constructor
        Parameters:
        featureDao - feature dao
      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao,
                            boolean geodesic)
        Constructor
        Parameters:
        featureDao - feature dao
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao,
                            float scale)
        Constructor
        Parameters:
        featureDao - feature dao
        scale - scale factor
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao,
                            float scale,
                            boolean geodesic)
        Constructor
        Parameters:
        featureDao - feature dao
        scale - scale factor
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao,
                            int width,
                            int height)
        Constructor
        Parameters:
        featureDao - feature dao
        width - drawn tile width
        height - drawn tile height
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(FeatureDao featureDao,
                            int width,
                            int height,
                            boolean geodesic)
        Constructor
        Parameters:
        featureDao - feature dao
        width - drawn tile width
        height - drawn tile height
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            boolean geodesic)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            float scale)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        scale - scale factor
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            float scale,
                            boolean geodesic)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        scale - scale factor
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            int width,
                            int height)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        width - drawn tile width
        height - drawn tile height
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            int width,
                            int height,
                            boolean geodesic)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        width - drawn tile width
        height - drawn tile height
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            float scale,
                            int width,
                            int height)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        scale - scale factor
        width - drawn tile width
        height - drawn tile height
        Since:
        3.2.0
      • FeatureTiles

        public FeatureTiles​(GeoPackage geoPackage,
                            FeatureDao featureDao,
                            float scale,
                            int width,
                            int height,
                            boolean geodesic)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        geoPackage - GeoPackage
        featureDao - feature dao
        scale - scale factor
        width - drawn tile width
        height - drawn tile height
        geodesic - draw geometries using geodesic lines
        Since:
        6.6.5
    • Method Detail

      • close

        public void close()
        Close the feature tiles connection
        Since:
        6.1.2
      • calculateDrawOverlap

        public void calculateDrawOverlap()
        Call after making changes to the point icon, point radius, or paint stroke widths. Determines the pixel overlap between tiles
      • setScale

        public void setScale​(float scale)
        Set the scale
        Parameters:
        scale - scale factor
        Since:
        3.2.0
      • getScale

        public float getScale()
        Get the scale
        Returns:
        scale factor
        Since:
        3.2.0
      • setDrawOverlap

        public void setDrawOverlap​(float pixels)
        Manually set the width and height draw overlap
        Parameters:
        pixels - pixels
      • getWidthDrawOverlap

        public float getWidthDrawOverlap()
        Get the width draw overlap
        Returns:
        width draw overlap
      • setWidthDrawOverlap

        public void setWidthDrawOverlap​(float pixels)
        Manually set the width draw overlap
        Parameters:
        pixels - pixels
      • getHeightDrawOverlap

        public float getHeightDrawOverlap()
        Get the height draw overlap
        Returns:
        height draw overlap
      • setHeightDrawOverlap

        public void setHeightDrawOverlap​(float pixels)
        Manually set the height draw overlap
        Parameters:
        pixels - pixels
      • getFeatureDao

        public FeatureDao getFeatureDao()
        Get the feature DAO
        Returns:
        feature dao
      • isIndexQuery

        public boolean isIndexQuery()
        Is index query
        Returns:
        true if an index query
      • getIndexManager

        public FeatureIndexManager getIndexManager()
        Get the index manager
        Returns:
        index manager or null
        Since:
        6.1.2
      • setIndexManager

        public void setIndexManager​(FeatureIndexManager indexManager)
        Set the index
        Parameters:
        indexManager - index manager
        Since:
        6.1.2
      • getFeatureTableStyles

        public FeatureTableStyles getFeatureTableStyles()
        Get the feature table styles
        Returns:
        feature table styles
        Since:
        3.2.0
      • setFeatureTableStyles

        public void setFeatureTableStyles​(FeatureTableStyles featureTableStyles)
        Set the feature table styles
        Parameters:
        featureTableStyles - feature table styles
        Since:
        3.2.0
      • ignoreFeatureTableStyles

        public void ignoreFeatureTableStyles()
        Ignore the feature table styles within the GeoPackage
        Since:
        3.2.0
      • clearCache

        public void clearCache()
        Clear all caches
        Since:
        3.3.0
      • clearStylePaintCache

        public void clearStylePaintCache()
        Clear the style paint cache
        Since:
        3.3.0
      • setStylePaintCacheSize

        public void setStylePaintCacheSize​(int size)
        Set / resize the style paint cache size
        Parameters:
        size - new size
        Since:
        3.3.0
      • clearIconCache

        public void clearIconCache()
        Clear the icon cache
        Since:
        3.3.0
      • setIconCacheSize

        public void setIconCacheSize​(int size)
        Set / resize the icon cache size
        Parameters:
        size - new size
        Since:
        3.3.0
      • getTileWidth

        public int getTileWidth()
        Get the tile width
        Returns:
        tile width
      • setTileWidth

        public void setTileWidth​(int tileWidth)
        Set the tile width
        Parameters:
        tileWidth - tile width
      • getTileHeight

        public int getTileHeight()
        Get the tile height
        Returns:
        tile height
      • setTileHeight

        public void setTileHeight​(int tileHeight)
        Set the tile height
        Parameters:
        tileHeight - tile height
      • getCompressFormat

        public String getCompressFormat()
        Get the compress format
        Returns:
        compress format
      • setCompressFormat

        public void setCompressFormat​(String compressFormat)
        Set the compress format
        Parameters:
        compressFormat - compress format
      • getPointRadius

        public float getPointRadius()
        Get the point radius
        Returns:
        radius
      • setPointRadius

        public void setPointRadius​(float pointRadius)
        Set the point radius
        Parameters:
        pointRadius - point radius
      • getPointColor

        public Color getPointColor()
        Get point color
        Returns:
        color
      • setPointColor

        public void setPointColor​(Color pointColor)
        Set point color
        Parameters:
        pointColor - point color
      • setPointIcon

        public void setPointIcon​(FeatureTilePointIcon pointIcon)
        Set the point icon
        Parameters:
        pointIcon - point icon
      • getLineStrokeWidth

        public float getLineStrokeWidth()
        Get line stroke width
        Returns:
        width
      • setLineStrokeWidth

        public void setLineStrokeWidth​(float lineStrokeWidth)
        Set line stroke width
        Parameters:
        lineStrokeWidth - line stroke width
      • getLineColor

        public Color getLineColor()
        Get line color
        Returns:
        color
      • setLineColor

        public void setLineColor​(Color lineColor)
        Set line color
        Parameters:
        lineColor - line color
      • getPolygonStrokeWidth

        public float getPolygonStrokeWidth()
        Get polygon stroke width
        Returns:
        width
      • setPolygonStrokeWidth

        public void setPolygonStrokeWidth​(float polygonStrokeWidth)
        Set polygon stroke width
        Parameters:
        polygonStrokeWidth - polygon stroke width
      • getPolygonColor

        public Color getPolygonColor()
        Get polygon color
        Returns:
        color
      • setPolygonColor

        public void setPolygonColor​(Color polygonColor)
        Set polygon color
        Parameters:
        polygonColor - polygon color
      • isFillPolygon

        public boolean isFillPolygon()
        Is fill polygon
        Returns:
        true if fill polygon
      • setFillPolygon

        public void setFillPolygon​(boolean fillPolygon)
        Set the fill polygon
        Parameters:
        fillPolygon - fill polygon
      • getPolygonFillColor

        public Color getPolygonFillColor()
        Get polygon fill color
        Returns:
        color
      • setPolygonFillColor

        public void setPolygonFillColor​(Color polygonFillColor)
        Set polygon fill color
        Parameters:
        polygonFillColor - polygon fill color
      • getMaxFeaturesPerTile

        public Integer getMaxFeaturesPerTile()
        Get the max features per tile
        Returns:
        max features per tile or null
      • setMaxFeaturesPerTile

        public void setMaxFeaturesPerTile​(Integer maxFeaturesPerTile)
        Set the max features per tile. When more features are returned in a query to create a single tile, the tile is not created.
        Parameters:
        maxFeaturesPerTile - max features per tile
      • setMaxFeaturesTileDraw

        public void setMaxFeaturesTileDraw​(CustomFeaturesTile maxFeaturesTileDraw)
        Set the max features tile draw, used to draw tiles when more features for a single tile than the max at #getMaxFeaturesPerTile exist
        Parameters:
        maxFeaturesTileDraw - max features tile draw
        See Also:
        CustomFeaturesTile, custom features tile implementation
      • isSimplifyGeometries

        public boolean isSimplifyGeometries()
        Is the simplify geometries flag set? Default is true
        Returns:
        simplify geometries flag
        Since:
        2.0.0
      • setSimplifyGeometries

        public void setSimplifyGeometries​(boolean simplifyGeometries)
        Set the simplify geometries flag
        Parameters:
        simplifyGeometries - simplify geometries flag
        Since:
        2.0.0
      • isGeodesic

        public boolean isGeodesic()
        Are geometries drawn using geodesic lines? Default is false
        Returns:
        geodesic flag
        Since:
        6.6.5
      • setGeodesic

        public void setGeodesic​(boolean geodesic)
        Set the geodestic flag, true to draw geodesic geometries
        Parameters:
        geodesic - draw geodesic geometries flag
        Since:
        6.6.5
      • drawTileBytes

        public byte[] drawTileBytes​(int x,
                                    int y,
                                    int zoom)
        Draw the tile and get the bytes from the x, y, and zoom level
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        tile bytes, or null
      • drawTile

        public BufferedImage drawTile​(int x,
                                      int y,
                                      int zoom)
        Draw a tile image from the x, y, and zoom level
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        tile image, or null
      • drawTileQueryIndex

        public BufferedImage drawTileQueryIndex​(int x,
                                                int y,
                                                int zoom)
        Draw a tile image from the x, y, and zoom level by querying features in the tile location
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        drawn image, or null
      • queryIndexedFeaturesCount

        public long queryIndexedFeaturesCount​(int x,
                                              int y,
                                              int zoom)
        Query for feature result count in the x, y, and zoom
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        feature count
      • queryIndexedFeaturesCount

        public long queryIndexedFeaturesCount​(BoundingBox webMercatorBoundingBox)
        Query for feature result count in the bounding box
        Parameters:
        webMercatorBoundingBox - web mercator bounding box
        Returns:
        count
      • queryIndexedFeatures

        public FeatureIndexResults queryIndexedFeatures​(int x,
                                                        int y,
                                                        int zoom)
        Query for feature results in the x, y, and zoom
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        feature count
        Since:
        6.1.2
      • queryIndexedFeatures

        public FeatureIndexResults queryIndexedFeatures​(BoundingBox webMercatorBoundingBox)
        Query for feature results in the bounding box
        Parameters:
        webMercatorBoundingBox - web mercator bounding box
        Returns:
        geometry index results
        Since:
        6.1.2
      • expandBoundingBox

        public BoundingBox expandBoundingBox​(BoundingBox boundingBox,
                                             Projection projection)
        Create an expanded bounding box to handle features outside the tile that overlap
        Parameters:
        boundingBox - bounding box
        projection - bounding box projection
        Returns:
        bounding box
        Since:
        3.2.0
      • expandBoundingBox

        public BoundingBox expandBoundingBox​(BoundingBox webMercatorBoundingBox)
        Create an expanded bounding box to handle features outside the tile that overlap
        Parameters:
        webMercatorBoundingBox - web mercator bounding box
        Returns:
        bounding box
        Since:
        3.2.0
      • expandBoundingBox

        public BoundingBox expandBoundingBox​(BoundingBox webMercatorBoundingBox,
                                             BoundingBox tileWebMercatorBoundingBox)
        Create an expanded bounding box to handle features outside the tile that overlap
        Parameters:
        webMercatorBoundingBox - web mercator bounding box
        tileWebMercatorBoundingBox - tile web mercator bounding box
        Returns:
        bounding box
        Since:
        3.2.0
      • drawTileQueryAll

        public BufferedImage drawTileQueryAll​(int x,
                                              int y,
                                              int zoom)
        Draw a tile image from the x, y, and zoom level by querying all features. This could be very slow if there are a lot of features
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        drawn image, or null
      • createNewImage

        protected BufferedImage createNewImage()
        Create a new empty image
        Returns:
        image
      • getGraphics

        protected Graphics2D getGraphics​(BufferedImage image)
        Get a graphics for the image
        Parameters:
        image - buffered image
        Returns:
        graphics
      • getWebMercatorTransform

        protected GeometryTransform getWebMercatorTransform()
        Create a geometry transformation from the feature dao projection to Web Mercator
        Returns:
        transform
      • simplifyPoints

        protected List<Point> simplifyPoints​(double simplifyTolerance,
                                             List<Point> points)
        When the simplify tolerance is set, simplify the points to a similar curve with fewer points.
        Parameters:
        simplifyTolerance - simplify tolerance in meters
        points - ordered points
        Returns:
        simplified points
        Since:
        2.0.0
      • geodesicPath

        protected List<Point> geodesicPath​(double maxDistance,
                                           List<Point> points)
        When geodesic is enabled, create a geodesic path of points
        Parameters:
        maxDistance - max distance allowed between path points
        points - ordered points
        Returns:
        geodesic path points
        Since:
        6.6.5
      • getFeatureStyle

        protected FeatureStyle getFeatureStyle​(FeatureRow featureRow)
        Get the feature style for the feature row and geometry type
        Parameters:
        featureRow - feature row
        Returns:
        feature style
      • getFeatureStyle

        protected FeatureStyle getFeatureStyle​(FeatureRow featureRow,
                                               GeometryType geometryType)
        Get the feature style for the feature row and geometry type
        Parameters:
        featureRow - feature row
        geometryType - geometry type
        Returns:
        feature style
      • getIcon

        protected BufferedImage getIcon​(IconRow iconRow)
        Get the icon image from the icon row
        Parameters:
        iconRow - icon row
        Returns:
        icon image
      • getPointPaint

        protected Paint getPointPaint​(FeatureStyle featureStyle)
        Get the point paint for the feature style, or return the default paint
        Parameters:
        featureStyle - feature style
        Returns:
        paint
      • getLinePaint

        protected Paint getLinePaint​(FeatureStyle featureStyle)
        Get the line paint for the feature style, or return the default paint
        Parameters:
        featureStyle - feature style
        Returns:
        paint
      • getPolygonPaint

        protected Paint getPolygonPaint​(FeatureStyle featureStyle)
        Get the polygon paint for the feature style, or return the default paint
        Parameters:
        featureStyle - feature style
        Returns:
        paint
      • getPolygonFillPaint

        protected Paint getPolygonFillPaint​(FeatureStyle featureStyle)
        Get the polygon fill paint for the feature style, or return the default paint
        Parameters:
        featureStyle - feature style
        Returns:
        paint
      • isTransparent

        protected boolean isTransparent​(BufferedImage image)
        Determine if the image is transparent
        Parameters:
        image - image
        Returns:
        true if transparent
      • checkIfDrawn

        protected BufferedImage checkIfDrawn​(BufferedImage image)
        Check if the image was drawn upon (non null and not transparent). Return the same image if drawn, else return null
        Parameters:
        image - image
        Returns:
        drawn image or null
      • calculateStylePixelBounds

        public PixelBounds calculateStylePixelBounds()
        Calculate style pixel bounds
        Returns:
        pixel bounds
        Since:
        6.3.0
      • calculateStylePixelBounds

        public PixelBounds calculateStylePixelBounds​(float scale)
        Calculate style pixel bounds
        Parameters:
        scale - scale factor
        Returns:
        pixel bounds
        Since:
        6.3.0
      • drawTile

        public abstract BufferedImage drawTile​(int zoom,
                                               BoundingBox webMercatorBoundingBox,
                                               FeatureIndexResults results)
        Draw a tile image from geometry index results
        Parameters:
        zoom - zoom level
        webMercatorBoundingBox - web mercator bounding box
        results - feature index results
        Returns:
        image
        Since:
        6.1.2
      • drawTile

        public abstract BufferedImage drawTile​(int zoom,
                                               BoundingBox webMercatorBoundingBox,
                                               FeatureResultSet resultSet)
        Draw a tile image from feature geometries in the provided result set
        Parameters:
        zoom - zoom level
        webMercatorBoundingBox - web mercator bounding box
        resultSet - feature result set
        Returns:
        image
        Since:
        2.0.0
      • drawTile

        public abstract BufferedImage drawTile​(int zoom,
                                               BoundingBox webMercatorBoundingBox,
                                               List<FeatureRow> featureRow)
        Draw a tile image from the feature rows
        Parameters:
        zoom - zoom level
        webMercatorBoundingBox - web mercator bounding box
        featureRow - feature row
        Returns:
        image
        Since:
        2.0.0