Class FeatureTiles

  • Direct Known Subclasses:
    DefaultFeatureTiles

    public abstract class FeatureTiles
    extends Object
    Tiles drawn from or linked to features. Used to query features and optionally draw tiles from those features.
    • Field Detail

      • WGS_84_PROJECTION

        protected static final Projection WGS_84_PROJECTION
        WGS84 Projection
      • WEB_MERCATOR_PROJECTION

        protected static final Projection WEB_MERCATOR_PROJECTION
        Web Mercator Projection
      • context

        protected final Context context
        Context
      • 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 width
      • tileHeight

        protected int tileHeight
        Tile height
      • 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
      • density

        protected float density
        Tile density based upon the device-independent pixels TileUtils.TILE_DP
    • Constructor Detail

      • FeatureTiles

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

        public FeatureTiles​(Context context,
                            FeatureDao featureDao,
                            float density)
        Constructor
        Parameters:
        context - context
        featureDao - feature dao
        density - display density: DisplayMetrics.density
        Since:
        3.2.0
      • FeatureTiles

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

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

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

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

        public FeatureTiles​(Context context,
                            GeoPackage geoPackage,
                            FeatureDao featureDao,
                            float density,
                            int width,
                            int height)
        Constructor, auto creates the index manager for indexed tables and feature styles for styled tables
        Parameters:
        context - context
        geoPackage - GeoPackage
        featureDao - feature dao
        density - display density: DisplayMetrics.density
        width - drawn tile width
        height - drawn tile height
        Since:
        3.2.0
    • Method Detail

      • close

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

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

        public void setDensity​(float density)
        Set the density
        Parameters:
        density - density
        Since:
        3.2.0
      • getDensity

        public float getDensity()
        Get the density
        Returns:
        density
        Since:
        3.2.0
      • setDrawOverlap

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

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

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

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

        public void setHeightDrawOverlap​(float pixels)
        Manually set the height draw overlap
        Parameters:
        pixels - overlap 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:
        1.1.0
      • setIndexManager

        public void setIndexManager​(FeatureIndexManager indexManager)
        Set the index
        Parameters:
        indexManager - index manager
        Since:
        1.1.0
      • 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.2.0
      • setStylePaintCacheSize

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

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

        public void setIconCacheSize​(int size)
        Set / resize the icon cache size
        Parameters:
        size - new size
        Since:
        3.2.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 Bitmap.CompressFormat getCompressFormat()
        Get the compress format
        Returns:
        compress format
      • setCompressFormat

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

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

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

        public Paint getPointPaint()
        Get point paint
        Returns:
        point paint
      • setPointPaint

        public void setPointPaint​(Paint pointPaint)
        Set the point paint
        Parameters:
        pointPaint - point paint
      • setPointIcon

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

        public Paint getLinePaintCopy()
        Get a copy of the line paint, must call setLinePaint(Paint) to update the paint
        Returns:
        line paint
        Since:
        3.2.0
      • setLinePaint

        public void setLinePaint​(Paint linePaint)
        Set the line paint
        Parameters:
        linePaint - line paint
      • getLineStrokeWidth

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

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

        public int getLineColor()
        Get line color
        Returns:
        color
        Since:
        3.2.0
      • setLineColor

        public void setLineColor​(int lineColor)
        Set line color
        Parameters:
        lineColor - line color
        Since:
        3.2.0
      • getLineAlpha

        public int getLineAlpha()
        Get line alpha
        Returns:
        alpha
        Since:
        3.2.0
      • setLineAlpha

        public void setLineAlpha​(int lineAlpha)
        Set line alpha
        Parameters:
        lineAlpha - line alpha
        Since:
        3.2.0
      • getPolygonPaintCopy

        public Paint getPolygonPaintCopy()
        Get a copy of the polygon paint, must call setPolygonPaint(Paint) to update the paint
        Returns:
        polygon paint
        Since:
        3.2.0
      • setPolygonPaint

        public void setPolygonPaint​(Paint polygonPaint)
        Set the polygon paint
        Parameters:
        polygonPaint - polygon paint
      • getPolygonStrokeWidth

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

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

        public int getPolygonColor()
        Get polygon color
        Returns:
        color
        Since:
        3.2.0
      • setPolygonColor

        public void setPolygonColor​(int polygonColor)
        Set polygon color
        Parameters:
        polygonColor - polygon color
        Since:
        3.2.0
      • getPolygonAlpha

        public int getPolygonAlpha()
        Get polygon alpha
        Returns:
        alpha
        Since:
        3.2.0
      • setPolygonAlpha

        public void setPolygonAlpha​(int polygonAlpha)
        Set polygon alpha
        Parameters:
        polygonAlpha - polygon alpha
        Since:
        3.2.0
      • isFillPolygon

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

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

        public Paint getPolygonFillPaintCopy()
        Get the polygon fill paint
        Returns:
        polygon fill paint
        Since:
        3.2.0
      • setPolygonFillPaint

        public void setPolygonFillPaint​(Paint polygonFillPaint)
        Set the polygon fill paint
        Parameters:
        polygonFillPaint - polygon fill paint
      • getPolygonFillColor

        public int getPolygonFillColor()
        Get polygon fill color
        Returns:
        color
        Since:
        3.2.0
      • setPolygonFillColor

        public void setPolygonFillColor​(int polygonFillColor)
        Set polygon fill color
        Parameters:
        polygonFillColor - polygon fill color
        Since:
        3.2.0
      • getPolygonFillAlpha

        public int getPolygonFillAlpha()
        Get polygon fill alpha
        Returns:
        alpha
        Since:
        3.2.0
      • setPolygonFillAlpha

        public void setPolygonFillAlpha​(int polygonFillAlpha)
        Set polygon fill alpha
        Parameters:
        polygonFillAlpha - polygon fill alpha
        Since:
        3.2.0
      • getMaxFeaturesPerTile

        public Integer getMaxFeaturesPerTile()
        Get the max features per tile
        Returns:
        max features per tile or null
        Since:
        1.1.0
      • 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
        Since:
        1.1.0
      • 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
        Since:
        1.1.0
        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
      • 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 Bitmap drawTile​(int x,
                               int y,
                               int zoom)
        Draw a tile bitmap from the x, y, and zoom level
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        tile bitmap, or null
      • drawTileQueryIndex

        public Bitmap drawTileQueryIndex​(int x,
                                         int y,
                                         int zoom)
        Draw a tile bitmap 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 bitmap, 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
        Since:
        1.1.0
      • queryIndexedFeaturesCount

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

        public FeatureIndexResults queryIndexedFeatures​(int x,
                                                        int y,
                                                        int zoom)
        Query for feature results in the x, y, and zoom level by querying features in the tile location
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        feature index results
        Since:
        3.2.0
      • queryIndexedFeatures

        public FeatureIndexResults queryIndexedFeatures​(BoundingBox webMercatorBoundingBox)
        Query for feature results in the bounding box
        Parameters:
        webMercatorBoundingBox - web mercator bounding box
        Returns:
        feature index results
        Since:
        1.1.0
      • 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 Bitmap drawTileQueryAll​(int x,
                                       int y,
                                       int zoom)
        Draw a tile bitmap 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 bitmap, or null
      • createNewBitmap

        protected Bitmap createNewBitmap()
        Create a new empty Bitmap
        Returns:
        bitmap
      • getWgs84ToWebMercatorTransform

        protected ProjectionTransform getWgs84ToWebMercatorTransform()
        Create a projection transformation from WGS84 to Web Mercator
        Returns:
        transform
      • getProjectionToWebMercatorTransform

        protected GeometryTransform getProjectionToWebMercatorTransform​(Projection projection)
        Create a projection transformation from provided projection to Web Mercator
        Parameters:
        projection - projection from
        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
      • 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 Bitmap getIcon​(IconRow iconRow)
        Get the icon bitmap from the icon row
        Parameters:
        iconRow - icon row
        Returns:
        icon bitmap
      • 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​(Bitmap bitmap)
        Determine if the bitmap is a transparent image (must be in expected tile dimensions)
        Parameters:
        bitmap - bitmap
        Returns:
        true if transparent
      • checkIfDrawn

        protected Bitmap checkIfDrawn​(Bitmap bitmap)
        Check if the bitmap was drawn upon (non null and not transparent). Return the same bitmap if drawn, else recycle non null bitmaps and return null
        Parameters:
        bitmap - bitmap
        Returns:
        drawn bitmap or null
      • drawTile

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

        public abstract Bitmap drawTile​(int zoom,
                                        BoundingBox webMercatorBoundingBox,
                                        FeatureCursor cursor)
        Draw a tile bitmap from feature geometries in the provided cursor
        Parameters:
        zoom - zoom level
        webMercatorBoundingBox - web mercator bounding box
        cursor - feature cursor
        Returns:
        tile
        Since:
        2.0.0
      • drawTile

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