Input: Draw a tile bitmap from the x y and zoom level [CODESPLIT] public Bitmap drawTile ( int x , int y , int zoom ) { Bitmap bitmap ; if ( isIndexQuery ( ) ) { bitmap = drawTileQueryIndex ( x , y , zoom ) ; } else { bitmap = drawTileQueryAll ( x , y , zoom ) ; } return bitmap ; }


Input: Draw a tile bitmap from the x y and zoom level by querying features in the tile location [CODESPLIT] public Bitmap drawTileQueryIndex ( int x , int y , int zoom ) { // Get the web mercator bounding box BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; Bitmap bitmap = null ; // Query for geometries matching the bounds in the index FeatureIndexResults results = queryIndexedFeatures ( webMercatorBoundingBox ) ; try { long tileCount = results . count ( ) ; // Draw if at least one geometry exists if ( tileCount > 0 ) { if ( maxFeaturesPerTile == null || tileCount <= maxFeaturesPerTile . longValue ( ) ) { // Draw the tile bitmap bitmap = drawTile ( zoom , webMercatorBoundingBox , results ) ; } else if ( maxFeaturesTileDraw != null ) { // Draw the max features tile bitmap = maxFeaturesTileDraw . drawTile ( tileWidth , tileHeight , tileCount , results ) ; } } } finally { results . close ( ) ; } return bitmap ; }


Input: Query for feature result count in the x y and zoom [CODESPLIT] public long queryIndexedFeaturesCount ( int x , int y , int zoom ) { // Get the web mercator bounding box BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; // Query for the count of geometries matching the bounds in the index long count = queryIndexedFeaturesCount ( webMercatorBoundingBox ) ; return count ; }


Input: Query for feature result count in the bounding box [CODESPLIT] public long queryIndexedFeaturesCount ( BoundingBox webMercatorBoundingBox ) { // Query for geometries matching the bounds in the index FeatureIndexResults results = queryIndexedFeatures ( webMercatorBoundingBox ) ; long count = 0 ; try { count = results . count ( ) ; } finally { results . close ( ) ; } return count ; }


Input: Query for feature results in the x y and zoom level by querying features in the tile location [CODESPLIT] public FeatureIndexResults queryIndexedFeatures ( int x , int y , int zoom ) { // Get the web mercator bounding box BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; // Query for the geometries matching the bounds in the index return queryIndexedFeatures ( webMercatorBoundingBox ) ; }


Input: Query for feature results in the bounding box [CODESPLIT] public FeatureIndexResults queryIndexedFeatures ( BoundingBox webMercatorBoundingBox ) { // Create an expanded bounding box to handle features outside the tile // that overlap BoundingBox expandedQueryBoundingBox = expandBoundingBox ( webMercatorBoundingBox ) ; // Query for geometries matching the bounds in the index FeatureIndexResults results = indexManager . query ( expandedQueryBoundingBox , WEB_MERCATOR_PROJECTION ) ; return results ; }


Input: Create an expanded bounding box to handle features outside the tile that overlap [CODESPLIT] public BoundingBox expandBoundingBox ( BoundingBox boundingBox , Projection projection ) { BoundingBox expandedBoundingBox = boundingBox ; ProjectionTransform toWebMercator = projection . getTransformation ( ProjectionConstants . EPSG_WEB_MERCATOR ) ; if ( ! toWebMercator . isSameProjection ( ) ) { expandedBoundingBox = expandedBoundingBox . transform ( toWebMercator ) ; } expandedBoundingBox = expandBoundingBox ( expandedBoundingBox ) ; if ( ! toWebMercator . isSameProjection ( ) ) { ProjectionTransform fromWebMercator = toWebMercator . getInverseTransformation ( ) ; expandedBoundingBox = expandedBoundingBox . transform ( fromWebMercator ) ; } return expandedBoundingBox ; }


Input: Create an expanded bounding box to handle features outside the tile that overlap [CODESPLIT] public BoundingBox expandBoundingBox ( BoundingBox webMercatorBoundingBox , BoundingBox tileWebMercatorBoundingBox ) { // Create an expanded bounding box to handle features outside the tile // that overlap double minLongitude = TileBoundingBoxUtils . getLongitudeFromPixel ( tileWidth , webMercatorBoundingBox , tileWebMercatorBoundingBox , 0 - widthOverlap ) ; double maxLongitude = TileBoundingBoxUtils . getLongitudeFromPixel ( tileWidth , webMercatorBoundingBox , tileWebMercatorBoundingBox , tileWidth + widthOverlap ) ; double maxLatitude = TileBoundingBoxUtils . getLatitudeFromPixel ( tileHeight , webMercatorBoundingBox , tileWebMercatorBoundingBox , 0 - heightOverlap ) ; double minLatitude = TileBoundingBoxUtils . getLatitudeFromPixel ( tileHeight , webMercatorBoundingBox , tileWebMercatorBoundingBox , tileHeight + heightOverlap ) ; // Choose the most expanded longitudes and latitudes minLongitude = Math . min ( minLongitude , webMercatorBoundingBox . getMinLongitude ( ) ) ; maxLongitude = Math . max ( maxLongitude , webMercatorBoundingBox . getMaxLongitude ( ) ) ; minLatitude = Math . min ( minLatitude , webMercatorBoundingBox . getMinLatitude ( ) ) ; maxLatitude = Math . max ( maxLatitude , webMercatorBoundingBox . getMaxLatitude ( ) ) ; // Bound with the web mercator limits minLongitude = Math . max ( minLongitude , - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) ; maxLongitude = Math . min ( maxLongitude , ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) ; minLatitude = Math . max ( minLatitude , - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) ; maxLatitude = Math . min ( maxLatitude , ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) ; BoundingBox expandedBoundingBox = new BoundingBox ( minLongitude , minLatitude , maxLongitude , maxLatitude ) ; return expandedBoundingBox ; }


Input: 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 [CODESPLIT] public Bitmap drawTileQueryAll ( int x , int y , int zoom ) { BoundingBox boundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; Bitmap bitmap = null ; // Query for all features FeatureCursor cursor = featureDao . queryForAll ( ) ; try { int totalCount = cursor . getCount ( ) ; // Draw if at least one geometry exists if ( totalCount > 0 ) { if ( maxFeaturesPerTile == null || totalCount <= maxFeaturesPerTile ) { // Draw the tile bitmap bitmap = drawTile ( zoom , boundingBox , cursor ) ; } else if ( maxFeaturesTileDraw != null ) { // Draw the unindexed max features tile bitmap = maxFeaturesTileDraw . drawUnindexedTile ( tileWidth , tileHeight , totalCount , cursor ) ; } } } finally { cursor . close ( ) ; } return bitmap ; }


Input: When the simplify tolerance is set simplify the points to a similar curve with fewer points . [CODESPLIT] protected List < Point > simplifyPoints ( double simplifyTolerance , List < Point > points ) { List < Point > simplifiedPoints = null ; if ( simplifyGeometries ) { // Reproject to web mercator if not in meters if ( projection != null && ! projection . isUnit ( Units . METRES ) ) { ProjectionTransform toWebMercator = projection . getTransformation ( WEB_MERCATOR_PROJECTION ) ; points = toWebMercator . transform ( points ) ; } // Simplify the points simplifiedPoints = GeometryUtils . simplifyPoints ( points , simplifyTolerance ) ; // Reproject back to the original projection if ( projection != null && ! projection . isUnit ( Units . METRES ) ) { ProjectionTransform fromWebMercator = WEB_MERCATOR_PROJECTION . getTransformation ( projection ) ; simplifiedPoints = fromWebMercator . transform ( simplifiedPoints ) ; } } else { simplifiedPoints = points ; } return simplifiedPoints ; }


Input: Get the feature style for the feature row and geometry type [CODESPLIT] protected FeatureStyle getFeatureStyle ( FeatureRow featureRow ) { FeatureStyle featureStyle = null ; if ( featureTableStyles != null ) { featureStyle = featureTableStyles . getFeatureStyle ( featureRow ) ; } return featureStyle ; }


Input: Get the feature style for the feature row and geometry type [CODESPLIT] protected FeatureStyle getFeatureStyle ( FeatureRow featureRow , GeometryType geometryType ) { FeatureStyle featureStyle = null ; if ( featureTableStyles != null ) { featureStyle = featureTableStyles . getFeatureStyle ( featureRow , geometryType ) ; } return featureStyle ; }


Input: Get the point paint for the feature style or return the default paint [CODESPLIT] protected Paint getPointPaint ( FeatureStyle featureStyle ) { Paint paint = getFeatureStylePaint ( featureStyle , FeatureDrawType . CIRCLE ) ; if ( paint == null ) { paint = pointPaint ; } return paint ; }


Input: Get the line paint for the feature style or return the default paint [CODESPLIT] protected Paint getLinePaint ( FeatureStyle featureStyle ) { Paint paint = getFeatureStylePaint ( featureStyle , FeatureDrawType . STROKE ) ; if ( paint == null ) { paint = linePaint ; } return paint ; }


Input: Get the polygon paint for the feature style or return the default paint [CODESPLIT] protected Paint getPolygonPaint ( FeatureStyle featureStyle ) { Paint paint = getFeatureStylePaint ( featureStyle , FeatureDrawType . STROKE ) ; if ( paint == null ) { paint = polygonPaint ; } return paint ; }


Input: Get the polygon fill paint for the feature style or return the default paint [CODESPLIT] protected Paint getPolygonFillPaint ( FeatureStyle featureStyle ) { Paint paint = null ; boolean hasStyleColor = false ; if ( featureStyle != null ) { StyleRow style = featureStyle . getStyle ( ) ; if ( style != null ) { if ( style . hasFillColor ( ) ) { paint = getStylePaint ( style , FeatureDrawType . FILL ) ; } else { hasStyleColor = style . hasColor ( ) ; } } } if ( paint == null && ! hasStyleColor && fillPolygon ) { paint = polygonFillPaint ; } return paint ; }


Input: Get the feature style paint from cache or create and cache it [CODESPLIT] private Paint getFeatureStylePaint ( FeatureStyle featureStyle , FeatureDrawType drawType ) { Paint paint = null ; if ( featureStyle != null ) { StyleRow style = featureStyle . getStyle ( ) ; if ( style != null && style . hasColor ( ) ) { paint = getStylePaint ( style , drawType ) ; } } return paint ; }


Input: Get the style paint from cache or create and cache it [CODESPLIT] private Paint getStylePaint ( StyleRow style , FeatureDrawType drawType ) { Paint paint = featurePaintCache . getPaint ( style , drawType ) ; if ( paint == null ) { Color color = null ; Style paintStyle = null ; Float strokeWidth = null ; switch ( drawType ) { case CIRCLE : color = style . getColorOrDefault ( ) ; paintStyle = Style . FILL ; break ; case STROKE : color = style . getColorOrDefault ( ) ; paintStyle = Style . STROKE ; strokeWidth = this . density * ( float ) style . getWidthOrDefault ( ) ; break ; case FILL : color = style . getFillColor ( ) ; paintStyle = Style . FILL ; strokeWidth = this . density * ( float ) style . getWidthOrDefault ( ) ; break ; default : throw new GeoPackageException ( "Unsupported Draw Type: " + drawType ) ; } Paint stylePaint = new Paint ( ) ; stylePaint . setAntiAlias ( true ) ; stylePaint . setStyle ( paintStyle ) ; stylePaint . setColor ( color . getColorWithAlpha ( ) ) ; if ( strokeWidth != null ) { stylePaint . setStrokeWidth ( strokeWidth ) ; } synchronized ( featurePaintCache ) { paint = featurePaintCache . getPaint ( style , drawType ) ; if ( paint == null ) { featurePaintCache . setPaint ( style , drawType , stylePaint ) ; paint = stylePaint ; } } } return paint ; }


Input: 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 [CODESPLIT] protected Bitmap checkIfDrawn ( Bitmap bitmap ) { if ( isTransparent ( bitmap ) ) { bitmap . recycle ( ) ; bitmap = null ; } return bitmap ; }


Input: Get the paint for the style row and draw type [CODESPLIT] public Paint getPaint ( StyleRow styleRow , FeatureDrawType type ) { return getPaint ( styleRow . getId ( ) , type ) ; }


Input: Get the paint for the style row id and draw type [CODESPLIT] public Paint getPaint ( long styleId , FeatureDrawType type ) { Paint paint = null ; FeaturePaint featurePaint = getFeaturePaint ( styleId ) ; if ( featurePaint != null ) { paint = featurePaint . getPaint ( type ) ; } return paint ; }


Input: Set the paint for the style id and draw type [CODESPLIT] public void setPaint ( StyleRow styleRow , FeatureDrawType type , Paint paint ) { setPaint ( styleRow . getId ( ) , type , paint ) ; }


Input: Set the paint for the style id and draw type [CODESPLIT] public void setPaint ( long styleId , FeatureDrawType type , Paint paint ) { FeaturePaint featurePaint = getFeaturePaint ( styleId ) ; if ( featurePaint == null ) { featurePaint = new FeaturePaint ( ) ; paintCache . put ( styleId , featurePaint ) ; } featurePaint . setPaint ( type , paint ) ; }


Input: Cache the icon bitmap for the icon row [CODESPLIT] public Bitmap put ( IconRow iconRow , Bitmap bitmap ) { return put ( iconRow . getId ( ) , bitmap ) ; }


Input: Create or retrieve from cache an icon bitmap for the icon row [CODESPLIT] public static Bitmap createIcon ( IconRow icon , float density , IconCache iconCache ) { Bitmap iconImage = null ; if ( icon != null ) { if ( iconCache != null ) { iconImage = iconCache . get ( icon . getId ( ) ) ; } if ( iconImage == null ) { BitmapFactory . Options options = icon . getDataBounds ( ) ; int dataWidth = options . outWidth ; int dataHeight = options . outHeight ; double styleWidth = dataWidth ; double styleHeight = dataHeight ; double widthDensity = DisplayMetrics . DENSITY_DEFAULT ; double heightDensity = DisplayMetrics . DENSITY_DEFAULT ; if ( icon . getWidth ( ) != null ) { styleWidth = icon . getWidth ( ) ; double widthRatio = dataWidth / styleWidth ; widthDensity *= widthRatio ; if ( icon . getHeight ( ) == null ) { heightDensity = widthDensity ; } } if ( icon . getHeight ( ) != null ) { styleHeight = icon . getHeight ( ) ; double heightRatio = dataHeight / styleHeight ; heightDensity *= heightRatio ; if ( icon . getWidth ( ) == null ) { widthDensity = heightDensity ; } } options = new BitmapFactory . Options ( ) ; options . inDensity = ( int ) ( Math . min ( widthDensity , heightDensity ) + 0.5f ) ; options . inTargetDensity = ( int ) ( DisplayMetrics . DENSITY_DEFAULT * density + 0.5f ) ; iconImage = icon . getDataBitmap ( options ) ; if ( widthDensity != heightDensity ) { int width = ( int ) ( styleWidth * density + 0.5f ) ; int height = ( int ) ( styleHeight * density + 0.5f ) ; if ( width != iconImage . getWidth ( ) || height != iconImage . getHeight ( ) ) { Bitmap scaledBitmap = Bitmap . createScaledBitmap ( iconImage , width , height , false ) ; iconImage . recycle ( ) ; iconImage = scaledBitmap ; } } if ( iconCache != null ) { iconCache . put ( icon . getId ( ) , iconImage ) ; } } } return iconImage ; }


Input: { [CODESPLIT] @ Override protected FeatureTable createTable ( String tableName , List < FeatureColumn > columnList ) { return new FeatureTable ( tableName , columnList ) ; }


Input: { [CODESPLIT] @ Override protected FeatureColumn createColumn ( FeatureCursor cursor , int index , String name , String type , Long max , boolean notNull , int defaultValueIndex , boolean primaryKey ) { boolean geometry = name . equalsIgnoreCase ( geometryColumns . getColumnName ( ) ) ; GeometryType geometryType = null ; GeoPackageDataType dataType = null ; if ( geometry ) { geometryType = GeometryType . fromName ( type ) ; dataType = GeoPackageDataType . BLOB ; } else { dataType = GeoPackageDataType . fromName ( type ) ; } Object defaultValue = cursor . getValue ( defaultValueIndex , dataType ) ; FeatureColumn column = new FeatureColumn ( index , name , dataType , max , notNull , defaultValue , primaryKey , geometryType ) ; return column ; }


Input: { [CODESPLIT] @ Override public Iterator < FeatureRow > iterator ( ) { return new Iterator < FeatureRow > ( ) { @ Override public boolean hasNext ( ) { return ! geometryMetadata . isLast ( ) ; } @ Override public FeatureRow next ( ) { geometryMetadata . moveToNext ( ) ; FeatureRow featureRow = featureIndexer . getFeatureRow ( geometryMetadata ) ; return featureRow ; } } ; }


Input:
{ [CODESPLIT] @ Override public Iterable < Long > ids ( ) { return new Iterable < Long > ( ) { /**
             * {@inheritDoc}
             */ @ Override public Iterator < Long > iterator ( ) { return new Iterator < Long > ( ) { /**
                     * {@inheritDoc}
                     */ @ Override public boolean hasNext ( ) { return ! geometryMetadata . isLast ( ) ; } /**
                     * {@inheritDoc}
                     */ @ Override public Long next ( ) { geometryMetadata . moveToNext ( ) ; return featureIndexer . getGeometryMetadata ( geometryMetadata ) . getId ( ) ; } } ; } } ; }


Input: Wrap the content values names in quotes [CODESPLIT] public static ContentValues quoteWrap ( ContentValues values ) { ContentValues quoteValues = null ; if ( values != null ) { Map < String , Object > quoteMap = new HashMap <> ( ) ; for ( Map . Entry < String , Object > value : values . valueSet ( ) ) { quoteMap . put ( CoreSQLUtils . quoteWrap ( value . getKey ( ) ) , value . getValue ( ) ) ; } Parcel parcel = Parcel . obtain ( ) ; parcel . writeMap ( quoteMap ) ; parcel . setDataPosition ( 0 ) ; quoteValues = ContentValues . CREATOR . createFromParcel ( parcel ) ; parcel . recycle ( ) ; } return quoteValues ; }


Input: Create the final bitmap from the layers resets the layers [CODESPLIT] public Bitmap createBitmap ( ) { Bitmap bitmap = null ; Canvas canvas = null ; for ( int layer = 0 ; layer < 4 ; layer ++ ) { Bitmap layerBitmap = layeredBitmap [ layer ] ; if ( layerBitmap != null ) { if ( bitmap == null ) { bitmap = layerBitmap ; canvas = layeredCanvas [ layer ] ; } else { canvas . drawBitmap ( layerBitmap , new Matrix ( ) , null ) ; layerBitmap . recycle ( ) ; } layeredBitmap [ layer ] = null ; layeredCanvas [ layer ] = null ; } } return bitmap ; }


Input: Recycle the layered bitmaps [CODESPLIT] public void recycle ( ) { for ( int layer = 0 ; layer < 4 ; layer ++ ) { Bitmap bitmap = layeredBitmap [ layer ] ; if ( bitmap != null ) { bitmap . recycle ( ) ; layeredBitmap [ layer ] = null ; layeredCanvas [ layer ] = null ; } } }


Input: Get the bitmap for the layer index [CODESPLIT] private Bitmap getBitmap ( int layer ) { Bitmap bitmap = layeredBitmap [ layer ] ; if ( bitmap == null ) { createBitmapAndCanvas ( layer ) ; bitmap = layeredBitmap [ layer ] ; } return bitmap ; }


Input: Get the canvas for the layer index [CODESPLIT] private Canvas getCanvas ( int layer ) { Canvas canvas = layeredCanvas [ layer ] ; if ( canvas == null ) { createBitmapAndCanvas ( layer ) ; canvas = layeredCanvas [ layer ] ; } return canvas ; }


Input: Create a new empty Bitmap and Canvas [CODESPLIT] private void createBitmapAndCanvas ( int layer ) { layeredBitmap [ layer ] = Bitmap . createBitmap ( tileWidth , tileHeight , Bitmap . Config . ARGB_8888 ) ; layeredCanvas [ layer ] = new Canvas ( layeredBitmap [ layer ] ) ; }


Input: Get a Style Mapping DAO from a table name [CODESPLIT] private StyleMappingDao getMappingDao ( String tablePrefix , String featureTable ) { String tableName = tablePrefix + featureTable ; StyleMappingDao dao = null ; if ( geoPackage . isTable ( tableName ) ) { dao = new StyleMappingDao ( relatedTables . getUserDao ( tableName ) ) ; } return dao ; }


Input: Get a style DAO [CODESPLIT] public StyleDao getStyleDao ( ) { StyleDao styleDao = null ; if ( geoPackage . isTable ( StyleTable . TABLE_NAME ) ) { AttributesDao attributesDao = getGeoPackage ( ) . getAttributesDao ( StyleTable . TABLE_NAME ) ; styleDao = new StyleDao ( attributesDao ) ; relatedTables . setContents ( styleDao . getTable ( ) ) ; } return styleDao ; }


Input: Get a icon DAO [CODESPLIT] public IconDao getIconDao ( ) { IconDao iconDao = null ; if ( geoPackage . isTable ( IconTable . TABLE_NAME ) ) { iconDao = new IconDao ( relatedTables . getUserDao ( IconTable . TABLE_NAME ) ) ; relatedTables . setContents ( iconDao . getTable ( ) ) ; } return iconDao ; }


Input: Get the feature table default feature styles [CODESPLIT] public FeatureStyles getTableFeatureStyles ( String featureTable ) { FeatureStyles featureStyles = null ; Long id = contentsId . getId ( featureTable ) ; if ( id != null ) { Styles styles = getTableStyles ( featureTable , id ) ; Icons icons = getTableIcons ( featureTable , id ) ; if ( styles != null || icons != null ) { featureStyles = new FeatureStyles ( styles , icons ) ; } } return featureStyles ; }


Input: Get the feature table default styles [CODESPLIT] public Styles getTableStyles ( String featureTable ) { Styles styles = null ; Long id = contentsId . getId ( featureTable ) ; if ( id != null ) { styles = getTableStyles ( featureTable , id ) ; } return styles ; }


Input: Get the style of the feature table and geometry type [CODESPLIT] public StyleRow getTableStyle ( String featureTable , GeometryType geometryType ) { StyleRow styleRow = null ; Styles tableStyles = getTableStyles ( featureTable ) ; if ( tableStyles != null ) { styleRow = tableStyles . getStyle ( geometryType ) ; } return styleRow ; }


Input: Get the feature table default icons [CODESPLIT] public Icons getTableIcons ( String featureTable ) { Icons icons = null ; Long id = contentsId . getId ( featureTable ) ; if ( id != null ) { icons = getTableIcons ( featureTable , id ) ; } return icons ; }


Input: Get the icon of the feature table and geometry type [CODESPLIT] public IconRow getTableIcon ( String featureTable , GeometryType geometryType ) { IconRow iconRow = null ; Icons tableIcons = getTableIcons ( featureTable ) ; if ( tableIcons != null ) { iconRow = tableIcons . getIcon ( geometryType ) ; } return iconRow ; }


Input: Get the feature styles for the feature row [CODESPLIT] public FeatureStyles getFeatureStyles ( FeatureRow featureRow ) { return getFeatureStyles ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) ) ; }


Input: Get the feature styles for the feature table and feature id [CODESPLIT] public FeatureStyles getFeatureStyles ( String featureTable , long featureId ) { Styles styles = getStyles ( featureTable , featureId ) ; Icons icons = getIcons ( featureTable , featureId ) ; FeatureStyles featureStyles = null ; if ( styles != null || icons != null ) { featureStyles = new FeatureStyles ( styles , icons ) ; } return featureStyles ; }


Input: Get the feature style ( style and icon ) of the feature row with the provided geometry type searching in order : feature geometry type style or icon feature default style or icon table geometry type style or icon table default style or icon [CODESPLIT] public FeatureStyle getFeatureStyle ( FeatureRow featureRow , GeometryType geometryType ) { return getFeatureStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType ) ; }


Input: Get the feature style default ( style and icon ) of the feature row searching in order : feature default style or icon table default style or icon [CODESPLIT] public FeatureStyle getFeatureStyleDefault ( FeatureRow featureRow ) { return getFeatureStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null ) ; }


Input: Get the styles for the feature row [CODESPLIT] public Styles getStyles ( FeatureRow featureRow ) { return getStyles ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) ) ; }


Input: Get the style of the feature row with the provided geometry type searching in order : feature geometry type style feature default style table geometry type style table default style [CODESPLIT] public StyleRow getStyle ( FeatureRow featureRow , GeometryType geometryType ) { return getStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType ) ; }


Input: Get the default style of the feature row searching in order : feature default style table default style [CODESPLIT] public StyleRow getStyleDefault ( FeatureRow featureRow ) { return getStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null ) ; }


Input: Get the style of the feature searching in order : feature geometry type style feature default style table geometry type style table default style [CODESPLIT] public StyleRow getStyle ( String featureTable , long featureId , GeometryType geometryType ) { return getStyle ( featureTable , featureId , geometryType , true ) ; }


Input: Get the default style of the feature searching in order : feature default style table default style [CODESPLIT] public StyleRow getStyleDefault ( String featureTable , long featureId ) { return getStyle ( featureTable , featureId , null , true ) ; }


Input: Get the style of the feature searching in order : feature geometry type style feature default style when tableStyle enabled continue searching : table geometry type style table default style [CODESPLIT] public StyleRow getStyle ( String featureTable , long featureId , GeometryType geometryType , boolean tableStyle ) { StyleRow styleRow = null ; // Feature Style Styles styles = getStyles ( featureTable , featureId ) ; if ( styles != null ) { styleRow = styles . getStyle ( geometryType ) ; } if ( styleRow == null && tableStyle ) { // Table Style styleRow = getTableStyle ( featureTable , geometryType ) ; } return styleRow ; }


Input: Get the default style of the feature searching in order : feature default style when tableStyle enabled continue searching : table default style [CODESPLIT] public StyleRow getStyleDefault ( String featureTable , long featureId , boolean tableStyle ) { return getStyle ( featureTable , featureId , null , tableStyle ) ; }


Input: Get the icons for the feature row [CODESPLIT] public Icons getIcons ( FeatureRow featureRow ) { return getIcons ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) ) ; }


Input: Get the icon of the feature row with the provided geometry type searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public IconRow getIcon ( FeatureRow featureRow , GeometryType geometryType ) { return getIcon ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType ) ; }


Input: Get the default icon of the feature row searching in order : feature default icon table default icon [CODESPLIT] public IconRow getIconDefault ( FeatureRow featureRow ) { return getIcon ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null ) ; }


Input: Get the icon of the feature searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public IconRow getIcon ( String featureTable , long featureId , GeometryType geometryType ) { return getIcon ( featureTable , featureId , geometryType , true ) ; }


Input: Get the default icon of the feature searching in order : feature default icon table default icon [CODESPLIT] public IconRow getIconDefault ( String featureTable , long featureId ) { return getIcon ( featureTable , featureId , null , true ) ; }


Input: Get the icon of the feature searching in order : feature geometry type icon feature default icon when tableIcon enabled continue searching : table geometry type icon table default icon [CODESPLIT] public IconRow getIcon ( String featureTable , long featureId , GeometryType geometryType , boolean tableIcon ) { IconRow iconRow = null ; // Feature Icon Icons icons = getIcons ( featureTable , featureId ) ; if ( icons != null ) { iconRow = icons . getIcon ( geometryType ) ; } if ( iconRow == null && tableIcon ) { // Table Icon iconRow = getTableIcon ( featureTable , geometryType ) ; } return iconRow ; }


Input: Get the default icon of the feature searching in order : feature default icon when tableIcon enabled continue searching : table default icon [CODESPLIT] public IconRow getIconDefault ( String featureTable , long featureId , boolean tableIcon ) { return getIcon ( featureTable , featureId , null , tableIcon ) ; }


Input: Get the styles for feature id from the style mapping dao [CODESPLIT] private Styles getStyles ( long featureId , StyleMappingDao mappingDao ) { Styles styles = null ; if ( mappingDao != null ) { StyleDao styleDao = getStyleDao ( ) ; if ( styleDao != null ) { List < StyleMappingRow > styleMappingRows = mappingDao . queryByBaseFeatureId ( featureId ) ; if ( ! styleMappingRows . isEmpty ( ) ) { for ( StyleMappingRow styleMappingRow : styleMappingRows ) { StyleRow styleRow = styleDao . queryForRow ( styleMappingRow ) ; if ( styleRow != null ) { if ( styles == null ) { styles = new Styles ( ) ; } styles . setStyle ( styleRow , styleMappingRow . getGeometryType ( ) ) ; } } } } } return styles ; }


Input: Get the icons for feature id from the icon mapping dao [CODESPLIT] private Icons getIcons ( long featureId , StyleMappingDao mappingDao ) { Icons icons = null ; if ( mappingDao != null ) { IconDao iconDao = getIconDao ( ) ; if ( iconDao != null ) { List < StyleMappingRow > styleMappingRows = mappingDao . queryByBaseFeatureId ( featureId ) ; if ( ! styleMappingRows . isEmpty ( ) ) { for ( StyleMappingRow styleMappingRow : styleMappingRows ) { IconRow iconRow = iconDao . queryForRow ( styleMappingRow ) ; if ( iconRow != null ) { if ( icons == null ) { icons = new Icons ( ) ; } icons . setIcon ( iconRow , styleMappingRow . getGeometryType ( ) ) ; } } } } } return icons ; }


Input: Set the feature table default feature styles [CODESPLIT] public void setTableFeatureStyles ( String featureTable , FeatureStyles featureStyles ) { if ( featureStyles != null ) { setTableStyles ( featureTable , featureStyles . getStyles ( ) ) ; setTableIcons ( featureTable , featureStyles . getIcons ( ) ) ; } else { deleteTableFeatureStyles ( featureTable ) ; } }


Input: Set the feature table default styles [CODESPLIT] public void setTableStyles ( String featureTable , Styles styles ) { deleteTableStyles ( featureTable ) ; if ( styles != null ) { if ( styles . getDefault ( ) != null ) { setTableStyleDefault ( featureTable , styles . getDefault ( ) ) ; } for ( Entry < GeometryType , StyleRow > style : styles . getStyles ( ) . entrySet ( ) ) { setTableStyle ( featureTable , style . getKey ( ) , style . getValue ( ) ) ; } } }


Input: Set the feature table style for the geometry type [CODESPLIT] public void setTableStyle ( FeatureTable featureTable , GeometryType geometryType , StyleRow style ) { setTableStyle ( featureTable . getTableName ( ) , geometryType , style ) ; }


Input: Set the feature table style for the geometry type [CODESPLIT] public void setTableStyle ( String featureTable , GeometryType geometryType , StyleRow style ) { deleteTableStyle ( featureTable , geometryType ) ; if ( style != null ) { createTableStyleRelationship ( featureTable ) ; long featureContentsId = contentsId . getOrCreateId ( featureTable ) ; long styleId = getOrInsertStyle ( style ) ; StyleMappingDao mappingDao = getTableStyleMappingDao ( featureTable ) ; insertStyleMapping ( mappingDao , featureContentsId , styleId , geometryType ) ; } }


Input: Set the feature table default icons [CODESPLIT] public void setTableIcons ( String featureTable , Icons icons ) { deleteTableIcons ( featureTable ) ; if ( icons != null ) { if ( icons . getDefault ( ) != null ) { setTableIconDefault ( featureTable , icons . getDefault ( ) ) ; } for ( Entry < GeometryType , IconRow > icon : icons . getIcons ( ) . entrySet ( ) ) { setTableIcon ( featureTable , icon . getKey ( ) , icon . getValue ( ) ) ; } } }


Input: Set the feature table icon for the geometry type [CODESPLIT] public void setTableIcon ( FeatureTable featureTable , GeometryType geometryType , IconRow icon ) { setTableIcon ( featureTable . getTableName ( ) , geometryType , icon ) ; }


Input: Set the feature table icon for the geometry type [CODESPLIT] public void setTableIcon ( String featureTable , GeometryType geometryType , IconRow icon ) { deleteTableIcon ( featureTable , geometryType ) ; if ( icon != null ) { createTableIconRelationship ( featureTable ) ; long featureContentsId = contentsId . getOrCreateId ( featureTable ) ; long iconId = getOrInsertIcon ( icon ) ; StyleMappingDao mappingDao = getTableIconMappingDao ( featureTable ) ; insertStyleMapping ( mappingDao , featureContentsId , iconId , geometryType ) ; } }


Input: Set the feature styles for the feature row [CODESPLIT] public void setFeatureStyles ( FeatureRow featureRow , FeatureStyles featureStyles ) { setFeatureStyles ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , featureStyles ) ; }


Input: Set the feature styles for the feature table and feature id [CODESPLIT] public void setFeatureStyles ( String featureTable , long featureId , FeatureStyles featureStyles ) { if ( featureStyles != null ) { setStyles ( featureTable , featureId , featureStyles . getStyles ( ) ) ; setIcons ( featureTable , featureId , featureStyles . getIcons ( ) ) ; } else { deleteStyles ( featureTable , featureId ) ; deleteIcons ( featureTable , featureId ) ; } }


Input: Set the feature style ( style and icon ) of the feature row [CODESPLIT] public void setFeatureStyle ( FeatureRow featureRow , FeatureStyle featureStyle ) { setFeatureStyle ( featureRow , featureRow . getGeometryType ( ) , featureStyle ) ; }


Input: Set the feature style ( style and icon ) of the feature row for the specified geometry type [CODESPLIT] public void setFeatureStyle ( FeatureRow featureRow , GeometryType geometryType , FeatureStyle featureStyle ) { setFeatureStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType , featureStyle ) ; }


Input: Set the feature style default ( style and icon ) of the feature row [CODESPLIT] public void setFeatureStyleDefault ( FeatureRow featureRow , FeatureStyle featureStyle ) { setFeatureStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null , featureStyle ) ; }


Input: Set the feature style ( style and icon ) of the feature [CODESPLIT] public void setFeatureStyle ( String featureTable , long featureId , GeometryType geometryType , FeatureStyle featureStyle ) { if ( featureStyle != null ) { setStyle ( featureTable , featureId , geometryType , featureStyle . getStyle ( ) ) ; setIcon ( featureTable , featureId , geometryType , featureStyle . getIcon ( ) ) ; } else { deleteStyle ( featureTable , featureId , geometryType ) ; deleteIcon ( featureTable , featureId , geometryType ) ; } }


Input: Set the feature style ( style and icon ) of the feature [CODESPLIT] public void setFeatureStyleDefault ( String featureTable , long featureId , FeatureStyle featureStyle ) { setFeatureStyle ( featureTable , featureId , null , featureStyle ) ; }


Input: Set the styles for the feature row [CODESPLIT] public void setStyles ( FeatureRow featureRow , Styles styles ) { setStyles ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , styles ) ; }


Input: Set the styles for the feature table and feature id [CODESPLIT] public void setStyles ( String featureTable , long featureId , Styles styles ) { deleteStyles ( featureTable , featureId ) ; if ( styles != null ) { if ( styles . getDefault ( ) != null ) { setStyleDefault ( featureTable , featureId , styles . getDefault ( ) ) ; } for ( Entry < GeometryType , StyleRow > style : styles . getStyles ( ) . entrySet ( ) ) { setStyle ( featureTable , featureId , style . getKey ( ) , style . getValue ( ) ) ; } } }


Input: Set the style of the feature row [CODESPLIT] public void setStyle ( FeatureRow featureRow , StyleRow style ) { setStyle ( featureRow , featureRow . getGeometryType ( ) , style ) ; }


Input: Set the style of the feature row for the specified geometry type [CODESPLIT] public void setStyle ( FeatureRow featureRow , GeometryType geometryType , StyleRow style ) { setStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType , style ) ; }


Input: Set the default style of the feature row [CODESPLIT] public void setStyleDefault ( FeatureRow featureRow , StyleRow style ) { setStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null , style ) ; }


Input: Set the style of the feature [CODESPLIT] public void setStyle ( String featureTable , long featureId , GeometryType geometryType , StyleRow style ) { deleteStyle ( featureTable , featureId , geometryType ) ; if ( style != null ) { createStyleRelationship ( featureTable ) ; long styleId = getOrInsertStyle ( style ) ; StyleMappingDao mappingDao = getStyleMappingDao ( featureTable ) ; insertStyleMapping ( mappingDao , featureId , styleId , geometryType ) ; } }


Input: Set the default style of the feature [CODESPLIT] public void setStyleDefault ( String featureTable , long featureId , StyleRow style ) { setStyle ( featureTable , featureId , null , style ) ; }


Input: Set the icons for the feature row [CODESPLIT] public void setIcons ( FeatureRow featureRow , Icons icons ) { setIcons ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , icons ) ; }


Input: Set the icons for the feature table and feature id [CODESPLIT] public void setIcons ( String featureTable , long featureId , Icons icons ) { deleteIcons ( featureTable , featureId ) ; if ( icons != null ) { if ( icons . getDefault ( ) != null ) { setIconDefault ( featureTable , featureId , icons . getDefault ( ) ) ; } for ( Entry < GeometryType , IconRow > icon : icons . getIcons ( ) . entrySet ( ) ) { setIcon ( featureTable , featureId , icon . getKey ( ) , icon . getValue ( ) ) ; } } }


Input: Set the icon of the feature row [CODESPLIT] public void setIcon ( FeatureRow featureRow , IconRow icon ) { setIcon ( featureRow , featureRow . getGeometryType ( ) , icon ) ; }


Input: Set the icon of the feature row for the specified geometry type [CODESPLIT] public void setIcon ( FeatureRow featureRow , GeometryType geometryType , IconRow icon ) { setIcon ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType , icon ) ; }


Input: Set the default icon of the feature row [CODESPLIT] public void setIconDefault ( FeatureRow featureRow , IconRow icon ) { setIcon ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , null , icon ) ; }


Input: Get the icon of the feature searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public void setIcon ( String featureTable , long featureId , GeometryType geometryType , IconRow icon ) { deleteIcon ( featureTable , featureId , geometryType ) ; if ( icon != null ) { createIconRelationship ( featureTable ) ; long iconId = getOrInsertIcon ( icon ) ; StyleMappingDao mappingDao = getIconMappingDao ( featureTable ) ; insertStyleMapping ( mappingDao , featureId , iconId , geometryType ) ; } }


Input: Set the default icon of the feature [CODESPLIT] public void setIconDefault ( String featureTable , long featureId , IconRow icon ) { setIcon ( featureTable , featureId , null , icon ) ; }


Input: Get the style id either from the existing style or by inserting a new one [CODESPLIT] private long getOrInsertStyle ( StyleRow style ) { long styleId ; if ( style . hasId ( ) ) { styleId = style . getId ( ) ; } else { StyleDao styleDao = getStyleDao ( ) ; styleId = styleDao . create ( style ) ; } return styleId ; }


Input: Get the icon id either from the existing icon or by inserting a new one [CODESPLIT] private long getOrInsertIcon ( IconRow icon ) { long iconId ; if ( icon . hasId ( ) ) { iconId = icon . getId ( ) ; } else { IconDao iconDao = getIconDao ( ) ; iconId = iconDao . create ( icon ) ; } return iconId ; }


Input: Insert a style mapping row [CODESPLIT] private void insertStyleMapping ( StyleMappingDao mappingDao , long baseId , long relatedId , GeometryType geometryType ) { StyleMappingRow row = mappingDao . newRow ( ) ; row . setBaseId ( baseId ) ; row . setRelatedId ( relatedId ) ; row . setGeometryType ( geometryType ) ; mappingDao . insert ( row ) ; }


Input: Delete the feature table style for the geometry type [CODESPLIT] public void deleteTableStyle ( String featureTable , GeometryType geometryType ) { deleteTableMapping ( getTableStyleMappingDao ( featureTable ) , featureTable , geometryType ) ; }


Input: Delete the feature table icon for the geometry type [CODESPLIT] public void deleteTableIcon ( String featureTable , GeometryType geometryType ) { deleteTableMapping ( getTableIconMappingDao ( featureTable ) , featureTable , geometryType ) ; }


Input: Delete the table style mappings [CODESPLIT] private void deleteTableMappings ( StyleMappingDao mappingDao , String featureTable ) { if ( mappingDao != null ) { Long featureContentsId = contentsId . getId ( featureTable ) ; if ( featureContentsId != null ) { mappingDao . deleteByBaseId ( featureContentsId ) ; } } }


Input: Delete the table style mapping with the geometry type value [CODESPLIT] private void deleteTableMapping ( StyleMappingDao mappingDao , String featureTable , GeometryType geometryType ) { if ( mappingDao != null ) { Long featureContentsId = contentsId . getId ( featureTable ) ; if ( featureContentsId != null ) { mappingDao . deleteByBaseId ( featureContentsId , geometryType ) ; } } }


Input: Delete the feature row style for the geometry type [CODESPLIT] public void deleteStyle ( FeatureRow featureRow , GeometryType geometryType ) { deleteStyle ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType ) ; }


Input: Delete the feature row style for the geometry type [CODESPLIT] public void deleteStyle ( String featureTable , long featureId , GeometryType geometryType ) { deleteMapping ( getStyleMappingDao ( featureTable ) , featureId , geometryType ) ; }


Input: Delete the feature row icon for the geometry type [CODESPLIT] public void deleteIcon ( FeatureRow featureRow , GeometryType geometryType ) { deleteIcon ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) , geometryType ) ; }


Input: Delete the feature row icon for the geometry type [CODESPLIT] public void deleteIcon ( String featureTable , long featureId , GeometryType geometryType ) { deleteMapping ( getIconMappingDao ( featureTable ) , featureId , geometryType ) ; }


Input: Delete the style mapping with the geometry type value [CODESPLIT] private void deleteMapping ( StyleMappingDao mappingDao , long featureId , GeometryType geometryType ) { if ( mappingDao != null ) { mappingDao . deleteByBaseId ( featureId , geometryType ) ; } }


Input: Get all the unique style row ids the table maps to [CODESPLIT] public List < Long > getAllTableStyleIds ( String featureTable ) { List < Long > styleIds = null ; StyleMappingDao mappingDao = getTableStyleMappingDao ( featureTable ) ; if ( mappingDao != null ) { styleIds = mappingDao . uniqueRelatedIds ( ) ; } return styleIds ; }


Input: Get all the unique icon row ids the table maps to [CODESPLIT] public List < Long > getAllTableIconIds ( String featureTable ) { List < Long > iconIds = null ; StyleMappingDao mappingDao = getTableIconMappingDao ( featureTable ) ; if ( mappingDao != null ) { iconIds = mappingDao . uniqueRelatedIds ( ) ; } return iconIds ; }


Input: Get all the unique style row ids the features map to [CODESPLIT] public List < Long > getAllStyleIds ( String featureTable ) { List < Long > styleIds = null ; StyleMappingDao mappingDao = getStyleMappingDao ( featureTable ) ; if ( mappingDao != null ) { styleIds = mappingDao . uniqueRelatedIds ( ) ; } return styleIds ; }


Input: Get all the unique icon row ids the features map to [CODESPLIT] public List < Long > getAllIconIds ( String featureTable ) { List < Long > iconIds = null ; StyleMappingDao mappingDao = getIconMappingDao ( featureTable ) ; if ( mappingDao != null ) { iconIds = mappingDao . uniqueRelatedIds ( ) ; } return iconIds ; }


Input: Get the image bytes [CODESPLIT] public byte [ ] getImageBytes ( ) { byte [ ] bytes = null ; if ( imageBytes != null ) { bytes = imageBytes ; } else if ( outputStream != null ) { bytes = outputStream . toByteArray ( ) ; } return bytes ; }


Input: Flush the output stream and set the image bytes close the stream [CODESPLIT] public void flushStream ( ) { if ( outputStream != null ) { if ( imageBytes == null ) { imageBytes = outputStream . toByteArray ( ) ; } try { outputStream . close ( ) ; } catch ( IOException e ) { Log . w ( CoverageDataPngImage . class . getSimpleName ( ) , "Failed to close output stream" , e ) ; } } }


Input: Get the pixel at the coordinate [CODESPLIT] public int getPixel ( int x , int y ) { int pixel = - 1 ; if ( pixels == null ) { readPixels ( ) ; } if ( pixels != null ) { pixel = pixels [ y ] [ x ] ; } else { throw new GeoPackageException ( "Could not retrieve pixel value" ) ; } return pixel ; }


Input: Read all the pixels from the image [CODESPLIT] private void readPixels ( ) { if ( reader != null ) { pixels = new int [ reader . imgInfo . rows ] [ reader . imgInfo . cols ] ; int rowCount = 0 ; while ( reader . hasMoreRows ( ) ) { ImageLineInt row = reader . readRowInt ( ) ; int [ ] columnValues = new int [ reader . imgInfo . cols ] ; System . arraycopy ( row . getScanline ( ) , 0 , columnValues , 0 , columnValues . length ) ; pixels [ rowCount ++ ] = columnValues ; } reader . close ( ) ; } }


Input: { [CODESPLIT] @ Override public void onCreate ( SQLiteDatabase db ) { db . execSQL ( GeoPackageMetadata . CREATE_SQL ) ; db . execSQL ( TableMetadata . CREATE_SQL ) ; db . execSQL ( GeometryMetadata . CREATE_SQL ) ; }


Input: { [CODESPLIT] @ Override public void onUpgrade ( SQLiteDatabase db , int oldVersion , int newVersion ) { db . execSQL ( "DROP TABLE IF EXISTS " + GeometryMetadata . TABLE_NAME ) ; db . execSQL ( "DROP TABLE IF EXISTS " + TableMetadata . TABLE_NAME ) ; db . execSQL ( "DROP TABLE IF EXISTS " + GeoPackageMetadata . TABLE_NAME ) ; onCreate ( db ) ; }


Input: { [CODESPLIT] @ Override public Bitmap drawTile ( int zoom , BoundingBox boundingBox , List < FeatureRow > featureRow ) { FeatureTileCanvas canvas = new FeatureTileCanvas ( tileWidth , tileHeight ) ; ProjectionTransform transform = getProjectionToWebMercatorTransform ( featureDao . getProjection ( ) ) ; BoundingBox expandedBoundingBox = expandBoundingBox ( boundingBox ) ; boolean drawn = false ; for ( FeatureRow row : featureRow ) { if ( drawFeature ( zoom , boundingBox , expandedBoundingBox , transform , canvas , row ) ) { drawn = true ; } } Bitmap bitmap = null ; if ( drawn ) { bitmap = canvas . createBitmap ( ) ; bitmap = checkIfDrawn ( bitmap ) ; } else { canvas . recycle ( ) ; } return bitmap ; }


Input: Draw the feature on the canvas [CODESPLIT] private boolean drawFeature ( int zoom , BoundingBox boundingBox , BoundingBox expandedBoundingBox , ProjectionTransform transform , FeatureTileCanvas canvas , FeatureRow row ) { boolean drawn = false ; try { GeoPackageGeometryData geomData = row . getGeometry ( ) ; if ( geomData != null ) { Geometry geometry = geomData . getGeometry ( ) ; if ( geometry != null ) { GeometryEnvelope envelope = geomData . getOrBuildEnvelope ( ) ; BoundingBox geometryBoundingBox = new BoundingBox ( envelope ) ; BoundingBox transformedBoundingBox = geometryBoundingBox . transform ( transform ) ; if ( expandedBoundingBox . intersects ( transformedBoundingBox , true ) ) { double simplifyTolerance = TileBoundingBoxUtils . toleranceDistance ( zoom , tileWidth , tileHeight ) ; drawn = drawShape ( simplifyTolerance , boundingBox , transform , canvas , row , geometry ) ; } } } } catch ( Exception e ) { Log . e ( DefaultFeatureTiles . class . getSimpleName ( ) , "Failed to draw feature in tile. Table: " + featureDao . getTableName ( ) , e ) ; } return drawn ; }


Input: Draw the geometry on the canvas [CODESPLIT] private boolean drawShape ( double simplifyTolerance , BoundingBox boundingBox , ProjectionTransform transform , FeatureTileCanvas canvas , FeatureRow featureRow , Geometry geometry ) { boolean drawn = false ; GeometryType geometryType = geometry . getGeometryType ( ) ; FeatureStyle featureStyle = getFeatureStyle ( featureRow , geometryType ) ; switch ( geometryType ) { case POINT : Point point = ( Point ) geometry ; drawn = drawPoint ( boundingBox , transform , canvas , point , featureStyle ) ; break ; case LINESTRING : case CIRCULARSTRING : LineString lineString = ( LineString ) geometry ; Path linePath = new Path ( ) ; addLineString ( simplifyTolerance , boundingBox , transform , linePath , lineString ) ; drawn = drawLinePath ( canvas , linePath , featureStyle ) ; break ; case POLYGON : case TRIANGLE : Polygon polygon = ( Polygon ) geometry ; Path polygonPath = new Path ( ) ; addPolygon ( simplifyTolerance , boundingBox , transform , polygonPath , polygon ) ; drawn = drawPolygonPath ( canvas , polygonPath , featureStyle ) ; break ; case MULTIPOINT : MultiPoint multiPoint = ( MultiPoint ) geometry ; for ( Point pointFromMulti : multiPoint . getPoints ( ) ) { drawn = drawPoint ( boundingBox , transform , canvas , pointFromMulti , featureStyle ) || drawn ; } break ; case MULTILINESTRING : MultiLineString multiLineString = ( MultiLineString ) geometry ; Path multiLinePath = new Path ( ) ; for ( LineString lineStringFromMulti : multiLineString . getLineStrings ( ) ) { addLineString ( simplifyTolerance , boundingBox , transform , multiLinePath , lineStringFromMulti ) ; } drawn = drawLinePath ( canvas , multiLinePath , featureStyle ) ; break ; case MULTIPOLYGON : MultiPolygon multiPolygon = ( MultiPolygon ) geometry ; Path multiPolygonPath = new Path ( ) ; for ( Polygon polygonFromMulti : multiPolygon . getPolygons ( ) ) { addPolygon ( simplifyTolerance , boundingBox , transform , multiPolygonPath , polygonFromMulti ) ; } drawn = drawPolygonPath ( canvas , multiPolygonPath , featureStyle ) ; break ; case COMPOUNDCURVE : CompoundCurve compoundCurve = ( CompoundCurve ) geometry ; Path compoundCurvePath = new Path ( ) ; for ( LineString lineStringFromCompoundCurve : compoundCurve . getLineStrings ( ) ) { addLineString ( simplifyTolerance , boundingBox , transform , compoundCurvePath , lineStringFromCompoundCurve ) ; } drawn = drawLinePath ( canvas , compoundCurvePath , featureStyle ) ; break ; case POLYHEDRALSURFACE : case TIN : PolyhedralSurface polyhedralSurface = ( PolyhedralSurface ) geometry ; Path polyhedralSurfacePath = new Path ( ) ; for ( Polygon polygonFromPolyhedralSurface : polyhedralSurface . getPolygons ( ) ) { addPolygon ( simplifyTolerance , boundingBox , transform , polyhedralSurfacePath , polygonFromPolyhedralSurface ) ; } drawn = drawPolygonPath ( canvas , polyhedralSurfacePath , featureStyle ) ; break ; case GEOMETRYCOLLECTION : @ SuppressWarnings ( "unchecked" ) GeometryCollection < Geometry > geometryCollection = ( GeometryCollection ) geometry ; List < Geometry > geometries = geometryCollection . getGeometries ( ) ; for ( Geometry geometryFromCollection : geometries ) { drawn = drawShape ( simplifyTolerance , boundingBox , transform , canvas , featureRow , geometryFromCollection ) || drawn ; } break ; default : throw new GeoPackageException ( "Unsupported Geometry Type: " + geometry . getGeometryType ( ) . getName ( ) ) ; } return drawn ; }


Input: Draw the line path on the canvas [CODESPLIT] private boolean drawLinePath ( FeatureTileCanvas canvas , Path path , FeatureStyle featureStyle ) { Canvas lineCanvas = canvas . getLineCanvas ( ) ; Paint pathPaint = getLinePaint ( featureStyle ) ; lineCanvas . drawPath ( path , pathPaint ) ; return true ; }


Input: Draw the path on the canvas [CODESPLIT] private boolean drawPolygonPath ( FeatureTileCanvas canvas , Path path , FeatureStyle featureStyle ) { Canvas polygonCanvas = canvas . getPolygonCanvas ( ) ; Paint fillPaint = getPolygonFillPaint ( featureStyle ) ; if ( fillPaint != null ) { path . setFillType ( Path . FillType . EVEN_ODD ) ; polygonCanvas . drawPath ( path , fillPaint ) ; } Paint pathPaint = getPolygonPaint ( featureStyle ) ; polygonCanvas . drawPath ( path , pathPaint ) ; return true ; }


Input: Add the linestring to the path [CODESPLIT] private void addLineString ( double simplifyTolerance , BoundingBox boundingBox , ProjectionTransform transform , Path path , LineString lineString ) { List < Point > points = lineString . getPoints ( ) ; if ( points . size ( ) >= 2 ) { // Try to simplify the number of points in the LineString points = simplifyPoints ( simplifyTolerance , points ) ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { Point point = points . get ( i ) ; Point webMercatorPoint = transform . transform ( point ) ; float x = TileBoundingBoxUtils . getXPixel ( tileWidth , boundingBox , webMercatorPoint . getX ( ) ) ; float y = TileBoundingBoxUtils . getYPixel ( tileHeight , boundingBox , webMercatorPoint . getY ( ) ) ; if ( i == 0 ) { path . moveTo ( x , y ) ; } else { path . lineTo ( x , y ) ; } } } }


Input: Add the polygon on the canvas [CODESPLIT] private void addPolygon ( double simplifyTolerance , BoundingBox boundingBox , ProjectionTransform transform , Path path , Polygon polygon ) { List < LineString > rings = polygon . getRings ( ) ; if ( ! rings . isEmpty ( ) ) { // Add the polygon points LineString polygonLineString = rings . get ( 0 ) ; List < Point > polygonPoints = polygonLineString . getPoints ( ) ; if ( polygonPoints . size ( ) >= 2 ) { addRing ( simplifyTolerance , boundingBox , transform , path , polygonPoints ) ; // Add the holes for ( int i = 1 ; i < rings . size ( ) ; i ++ ) { LineString holeLineString = rings . get ( i ) ; List < Point > holePoints = holeLineString . getPoints ( ) ; if ( holePoints . size ( ) >= 2 ) { addRing ( simplifyTolerance , boundingBox , transform , path , holePoints ) ; } } } } }


Input: Draw the point on the canvas [CODESPLIT] private boolean drawPoint ( BoundingBox boundingBox , ProjectionTransform transform , FeatureTileCanvas canvas , Point point , FeatureStyle featureStyle ) { boolean drawn = false ; Point webMercatorPoint = transform . transform ( point ) ; float x = TileBoundingBoxUtils . getXPixel ( tileWidth , boundingBox , webMercatorPoint . getX ( ) ) ; float y = TileBoundingBoxUtils . getYPixel ( tileHeight , boundingBox , webMercatorPoint . getY ( ) ) ; if ( featureStyle != null && featureStyle . hasIcon ( ) ) { IconRow iconRow = featureStyle . getIcon ( ) ; Bitmap icon = getIcon ( iconRow ) ; int width = icon . getWidth ( ) ; int height = icon . getHeight ( ) ; if ( x >= 0 - width && x <= tileWidth + width && y >= 0 - height && y <= tileHeight + height ) { float anchorU = ( float ) iconRow . getAnchorUOrDefault ( ) ; float anchorV = ( float ) iconRow . getAnchorVOrDefault ( ) ; float left = x - ( anchorU * width ) ; float right = left + width ; float top = y - ( anchorV * height ) ; float bottom = top + height ; RectF destination = new RectF ( left , top , right , bottom ) ; Canvas iconCanvas = canvas . getIconCanvas ( ) ; iconCanvas . drawBitmap ( icon , null , destination , pointPaint ) ; drawn = true ; } } else if ( pointIcon != null ) { float width = this . density * pointIcon . getWidth ( ) ; float height = this . density * pointIcon . getHeight ( ) ; if ( x >= 0 - width && x <= tileWidth + width && y >= 0 - height && y <= tileHeight + height ) { Canvas iconCanvas = canvas . getIconCanvas ( ) ; float left = x - this . density * pointIcon . getXOffset ( ) ; float top = y - this . density * pointIcon . getYOffset ( ) ; RectF rect = new RectF ( left , top , left + width , top + height ) ; iconCanvas . drawBitmap ( pointIcon . getIcon ( ) , null , rect , pointPaint ) ; drawn = true ; } } else { Float radius = null ; if ( featureStyle != null ) { StyleRow styleRow = featureStyle . getStyle ( ) ; if ( styleRow != null ) { radius = this . density * ( float ) ( styleRow . getWidthOrDefault ( ) / 2.0f ) ; } } if ( radius == null ) { radius = this . density * pointRadius ; } if ( x >= 0 - radius && x <= tileWidth + radius && y >= 0 - radius && y <= tileHeight + radius ) { Paint pointPaint = getPointPaint ( featureStyle ) ; Canvas pointCanvas = canvas . getPointCanvas ( ) ; pointCanvas . drawCircle ( x , y , radius , pointPaint ) ; drawn = true ; } } return drawn ; }


Input: Get or create a feature row cache for the table name [CODESPLIT] public FeatureCache getCache ( String tableName ) { FeatureCache cache = tableCache . get ( tableName ) ; if ( cache == null ) { cache = new FeatureCache ( maxCacheSize ) ; tableCache . put ( tableName , cache ) ; } return cache ; }


Input: Remove the cached feature row [CODESPLIT] public FeatureRow remove ( FeatureRow featureRow ) { return remove ( featureRow . getTable ( ) . getTableName ( ) , featureRow . getId ( ) ) ; }


Input: Clear and resize all caches and update the max cache size [CODESPLIT] public void clearAndResize ( int maxCacheSize ) { setMaxCacheSize ( maxCacheSize ) ; for ( FeatureCache cache : tableCache . values ( ) ) { cache . clearAndResize ( maxCacheSize ) ; } }


Input: Get the cached table styles querying and caching if needed [CODESPLIT] public Styles getCachedTableStyles ( ) { Styles styles = cachedTableFeatureStyles . getStyles ( ) ; if ( styles == null ) { synchronized ( cachedTableFeatureStyles ) { styles = cachedTableFeatureStyles . getStyles ( ) ; if ( styles == null ) { styles = getTableStyles ( ) ; if ( styles == null ) { styles = new Styles ( ) ; } cachedTableFeatureStyles . setStyles ( styles ) ; } } } if ( styles . isEmpty ( ) ) { styles = null ; } return styles ; }


Input: Get the cached table icons querying and caching if needed [CODESPLIT] public Icons getCachedTableIcons ( ) { Icons icons = cachedTableFeatureStyles . getIcons ( ) ; if ( icons == null ) { synchronized ( cachedTableFeatureStyles ) { icons = cachedTableFeatureStyles . getIcons ( ) ; if ( icons == null ) { icons = getTableIcons ( ) ; if ( icons == null ) { icons = new Icons ( ) ; } cachedTableFeatureStyles . setIcons ( icons ) ; } } } if ( icons . isEmpty ( ) ) { icons = null ; } return icons ; }


Input: Get the feature style ( style and icon ) of the feature row with the provided geometry type searching in order : feature geometry type style or icon feature default style or icon table geometry type style or icon table default style or icon [CODESPLIT] public FeatureStyle getFeatureStyle ( FeatureRow featureRow , GeometryType geometryType ) { return getFeatureStyle ( featureRow . getId ( ) , geometryType ) ; }


Input: Get the feature style ( style and icon ) of the feature searching in order : feature geometry type style or icon feature default style or icon table geometry type style or icon table default style or icon [CODESPLIT] public FeatureStyle getFeatureStyle ( long featureId , GeometryType geometryType ) { FeatureStyle featureStyle = null ; StyleRow style = getStyle ( featureId , geometryType ) ; IconRow icon = getIcon ( featureId , geometryType ) ; if ( style != null || icon != null ) { featureStyle = new FeatureStyle ( style , icon ) ; } return featureStyle ; }


Input: Get the style of the feature row with the provided geometry type searching in order : feature geometry type style feature default style table geometry type style table default style [CODESPLIT] public StyleRow getStyle ( FeatureRow featureRow , GeometryType geometryType ) { return getStyle ( featureRow . getId ( ) , geometryType ) ; }


Input: Get the style of the feature searching in order : feature geometry type style feature default style table geometry type style table default style [CODESPLIT] public StyleRow getStyle ( long featureId , GeometryType geometryType ) { StyleRow styleRow = featureStyleExtension . getStyle ( tableName , featureId , geometryType , false ) ; if ( styleRow == null ) { // Table Style Styles styles = getCachedTableStyles ( ) ; if ( styles != null ) { styleRow = styles . getStyle ( geometryType ) ; } } return styleRow ; }


Input: Get the icon of the feature row with the provided geometry type searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public IconRow getIcon ( FeatureRow featureRow , GeometryType geometryType ) { return getIcon ( featureRow . getId ( ) , geometryType ) ; }


Input: Get the icon of the feature searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public IconRow getIcon ( long featureId , GeometryType geometryType ) { IconRow iconRow = featureStyleExtension . getIcon ( tableName , featureId , geometryType , false ) ; if ( iconRow == null ) { // Table Icon Icons icons = getCachedTableIcons ( ) ; if ( icons != null ) { iconRow = icons . getIcon ( geometryType ) ; } } return iconRow ; }


Input: Set the feature table style for the geometry type [CODESPLIT] public void setTableStyle ( GeometryType geometryType , StyleRow style ) { featureStyleExtension . setTableStyle ( tableName , geometryType , style ) ; clearCachedTableStyles ( ) ; }


Input: Set the feature table icon for the geometry type [CODESPLIT] public void setTableIcon ( GeometryType geometryType , IconRow icon ) { featureStyleExtension . setTableIcon ( tableName , geometryType , icon ) ; clearCachedTableIcons ( ) ; }


Input: Set the feature style ( style and icon ) of the feature row for the specified geometry type [CODESPLIT] public void setFeatureStyle ( FeatureRow featureRow , GeometryType geometryType , FeatureStyle featureStyle ) { featureStyleExtension . setFeatureStyle ( featureRow , geometryType , featureStyle ) ; }


Input: Set the feature style ( style and icon ) of the feature [CODESPLIT] public void setFeatureStyle ( long featureId , GeometryType geometryType , FeatureStyle featureStyle ) { featureStyleExtension . setFeatureStyle ( tableName , featureId , geometryType , featureStyle ) ; }


Input: Set the style of the feature row for the specified geometry type [CODESPLIT] public void setStyle ( FeatureRow featureRow , GeometryType geometryType , StyleRow style ) { featureStyleExtension . setStyle ( featureRow , geometryType , style ) ; }


Input: Set the style of the feature [CODESPLIT] public void setStyle ( long featureId , GeometryType geometryType , StyleRow style ) { featureStyleExtension . setStyle ( tableName , featureId , geometryType , style ) ; }


Input: Set the icon of the feature row for the specified geometry type [CODESPLIT] public void setIcon ( FeatureRow featureRow , GeometryType geometryType , IconRow icon ) { featureStyleExtension . setIcon ( featureRow , geometryType , icon ) ; }


Input: Get the icon of the feature searching in order : feature geometry type icon feature default icon table geometry type icon table default icon [CODESPLIT] public void setIcon ( long featureId , GeometryType geometryType , IconRow icon ) { featureStyleExtension . setIcon ( tableName , featureId , geometryType , icon ) ; }


Input: { [CODESPLIT] @ Override protected TileTable createTable ( String tableName , List < TileColumn > columnList ) { return new TileTable ( tableName , columnList ) ; }


Input: { [CODESPLIT] @ Override protected TileColumn createColumn ( TileCursor cursor , int index , String name , String type , Long max , boolean notNull , int defaultValueIndex , boolean primaryKey ) { GeoPackageDataType dataType = getDataType ( type ) ; Object defaultValue = cursor . getValue ( defaultValueIndex , dataType ) ; TileColumn column = new TileColumn ( index , name , dataType , max , notNull , defaultValue , primaryKey ) ; return column ; }


Input: Get a RTree Index Table DAO for the feature dao [CODESPLIT] public RTreeIndexTableDao getTableDao ( FeatureDao featureDao ) { GeoPackageConnection connection = getGeoPackage ( ) . getConnection ( ) ; UserCustomConnection userDb = new UserCustomConnection ( connection ) ; UserCustomTable userCustomTable = getRTreeTable ( featureDao . getTable ( ) ) ; UserCustomDao userCustomDao = new UserCustomDao ( geoPackage . getName ( ) , connection , userDb , userCustomTable ) ; return new RTreeIndexTableDao ( this , userCustomDao , featureDao ) ; }


Input: { [CODESPLIT] @ Override protected void executeSQL ( String sql , boolean trigger ) { if ( trigger ) { connection . execSQL ( sql ) ; } else { database . execSQL ( sql ) ; } }


Input: Set the width [CODESPLIT] public void setWidth ( Double width ) { if ( width != null && width < 0.0 ) { throw new GeoPackageException ( "Width must be greater than or equal to 0.0, invalid value: " + width ) ; } setValue ( getWidthColumnIndex ( ) , width ) ; }


Input: Set the height [CODESPLIT] public void setHeight ( Double height ) { if ( height != null && height < 0.0 ) { throw new GeoPackageException ( "Height must be greater than or equal to 0.0, invalid value: " + height ) ; } setValue ( getHeightColumnIndex ( ) , height ) ; }


Input: Get the derived width and height from the values and icon data scaled as needed [CODESPLIT] public double [ ] getDerivedDimensions ( ) { Double width = getWidth ( ) ; Double height = getHeight ( ) ; if ( width == null || height == null ) { BitmapFactory . Options options = getDataBounds ( ) ; int dataWidth = options . outWidth ; int dataHeight = options . outHeight ; if ( width == null ) { width = ( double ) dataWidth ; if ( height != null ) { width *= ( height / dataHeight ) ; } } if ( height == null ) { height = ( double ) dataHeight ; if ( width != null ) { height *= ( width / dataWidth ) ; } } } return new double [ ] { width , height } ; }


Input: Get the tile side ( width and height ) dimension based upon the display density scale [CODESPLIT] public static int tileLength ( float density ) { int length ; if ( density < HIGH_DENSITY ) { length = TILE_PIXELS_DEFAULT ; } else { length = TILE_PIXELS_HIGH ; } return length ; }


Input: Get the tile density based upon the display density scale and tile dimensions [CODESPLIT] public static float tileDensity ( float density , int tileWidth , int tileHeight ) { return tileDensity ( density , Math . min ( tileWidth , tileHeight ) ) ; }


Input: { [CODESPLIT] @ Override public boolean moveToNext ( ) { boolean hasNext = false ; currentPosition ++ ; if ( currentPosition < invalidPositions . size ( ) ) { int invalidPosition = invalidPositions . get ( currentPosition ) ; hasNext = cursor . moveToPosition ( invalidPosition ) ; } return hasNext ; }


Input: { [CODESPLIT] @ Override public TRow getRow ( ) { TRow row = cursor . getRow ( ) ; if ( row . hasId ( ) ) { for ( UserColumn column : blobColumns ) { readBlobValue ( row , column ) ; } } return row ; }


Input: Read the blob column value in chunks [CODESPLIT] private void readBlobValue ( UserRow row , UserColumn column ) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream ( ) ; try { byte [ ] blobChunk = new byte [ ] { 0 } ; for ( int i = 1 ; blobChunk . length > 0 ; i += CHUNK_SIZE ) { if ( i > 1 ) { byteStream . write ( blobChunk ) ; } blobChunk = new byte [ ] { } ; String query = "select substr(" + CoreSQLUtils . quoteWrap ( column . getName ( ) ) + ", " + i + ", " + CHUNK_SIZE + ") from " + CoreSQLUtils . quoteWrap ( dao . getTableName ( ) ) + " where " + CoreSQLUtils . quoteWrap ( row . getPkColumn ( ) . getName ( ) ) + " = " + row . getId ( ) ; Cursor blobCursor = dao . getDatabaseConnection ( ) . getDb ( ) . rawQuery ( query , null ) ; try { if ( blobCursor . moveToNext ( ) ) { blobChunk = blobCursor . getBlob ( 0 ) ; } } finally { blobCursor . close ( ) ; } } byte [ ] blob = byteStream . toByteArray ( ) ; row . setValue ( column . getIndex ( ) , blob ) ; } catch ( IOException e ) { Log . e ( UserInvalidCursor . class . getSimpleName ( ) , "Failed to read large blob value. Table: " + dao . getTableName ( ) + ", Column: " + column . getName ( ) + ", Position: " + getPosition ( ) , e ) ; } finally { IOUtils . closeQuietly ( byteStream ) ; } }


Input: { [CODESPLIT] @ Override public TRow getRow ( int [ ] columnTypes , Object [ ] values ) { return cursor . getRow ( columnTypes , values ) ; }


Input: { [CODESPLIT] @ Override public Object getValue ( int index , GeoPackageDataType dataType ) { return cursor . getValue ( index , dataType ) ; }


Input: { [CODESPLIT] @ Override public boolean moveToPosition ( int position ) { boolean moved = false ; if ( position < invalidPositions . size ( ) ) { currentPosition = position ; int invalidPosition = invalidPositions . get ( currentPosition ) ; moved = cursor . moveToPosition ( invalidPosition ) ; } return moved ; }


Input: { [CODESPLIT] @ Override protected UserCustomTable createTable ( String tableName , List < UserCustomColumn > columnList ) { return new UserCustomTable ( tableName , columnList ) ; }


Input: Read the table [CODESPLIT] public static UserCustomTable readTable ( GeoPackageConnection connection , String tableName ) { UserCustomTableReader tableReader = new UserCustomTableReader ( tableName ) ; UserCustomTable customTable = tableReader . readTable ( new UserCustomWrapperConnection ( connection ) ) ; return customTable ; }


Input: Set the color [CODESPLIT] public void setColor ( Color color ) { String hex = null ; Double opacity = null ; if ( color != null ) { hex = color . getColorHexShorthand ( ) ; opacity = new Double ( color . getOpacity ( ) ) ; } setColor ( hex ) ; setOpacity ( opacity ) ; }


Input: Get the color or default value [CODESPLIT] public Color getColorOrDefault ( ) { Color color = getColor ( ) ; if ( color == null ) { color = new Color ( ) ; } return color ; }


Input: Set the color [CODESPLIT] public void setFillColor ( Color color ) { String hex = null ; Double opacity = null ; if ( color != null ) { hex = color . getColorHexShorthand ( ) ; opacity = new Double ( color . getOpacity ( ) ) ; } setFillColor ( hex ) ; setFillOpacity ( opacity ) ; }


Input: Validate and adjust the color value [CODESPLIT] private String validateColor ( String color ) { String validated = color ; if ( color != null ) { if ( ! color . startsWith ( "#" ) ) { validated = "#" + color ; } if ( ! colorPattern . matcher ( validated ) . matches ( ) ) { throw new GeoPackageException ( "Color must be in hex format #RRGGBB or #RGB, invalid value: " + color ) ; } validated = validated . toUpperCase ( ) ; } return validated ; }


Input: Create a color from the hex color and opacity [CODESPLIT] private Color createColor ( String hexColor , Double opacity ) { Color color = null ; if ( hexColor != null || opacity != null ) { color = new Color ( ) ; if ( hexColor != null ) { color . setColor ( hexColor ) ; } if ( opacity != null ) { color . setOpacity ( opacity . floatValue ( ) ) ; } } return color ; }


Input: Get a GeoPackage Manager [CODESPLIT] public static GeoPackageManager getManager ( Context context ) { Thread . currentThread ( ) . setContextClassLoader ( GeoPackageManager . class . getClassLoader ( ) ) ; return new GeoPackageManagerImpl ( context ) ; }


Input: Prioritize the query location order . All types are placed at the front of the query order in the order they are given . Omitting a location leaves it at it s current priority location . [CODESPLIT] public void prioritizeQueryLocation ( Collection < FeatureIndexType > types ) { prioritizeQueryLocation ( types . toArray ( new FeatureIndexType [ types . size ( ) ] ) ) ; }


Input: Prioritize the query location order . All types are placed at the front of the query order in the order they are given . Omitting a location leaves it at it s current priority location . [CODESPLIT] public void prioritizeQueryLocation ( FeatureIndexType ... types ) { // Create a new query order set Set < FeatureIndexType > queryOrder = new LinkedHashSet <> ( ) ; for ( FeatureIndexType type : types ) { if ( type != FeatureIndexType . NONE ) { queryOrder . add ( type ) ; } } // Add any locations not provided to this method queryOrder . addAll ( indexLocationQueryOrder ) ; // Update the query order set indexLocationQueryOrder = queryOrder ; }


Input: Set the index location order overriding all previously set types [CODESPLIT] public void setIndexLocationOrder ( Collection < FeatureIndexType > types ) { setIndexLocationOrder ( types . toArray ( new FeatureIndexType [ types . size ( ) ] ) ) ; }


Input: Set the index location order overriding all previously set types [CODESPLIT] public void setIndexLocationOrder ( FeatureIndexType ... types ) { // Create a new query order set Set < FeatureIndexType > queryOrder = new LinkedHashSet <> ( ) ; for ( FeatureIndexType type : types ) { if ( type != FeatureIndexType . NONE ) { queryOrder . add ( type ) ; } } // Update the query order set indexLocationQueryOrder = queryOrder ; }


Input: Set the GeoPackage Progress [CODESPLIT] public void setProgress ( GeoPackageProgress progress ) { featureTableIndex . setProgress ( progress ) ; featureIndexer . setProgress ( progress ) ; rTreeIndexTableDao . setProgress ( progress ) ; }


Input: Index the feature tables for the index types [CODESPLIT] public int index ( boolean force , List < FeatureIndexType > types ) { int count = 0 ; for ( FeatureIndexType type : types ) { int typeCount = index ( type , force ) ; count = Math . max ( count , typeCount ) ; } return count ; }


Input: Index the feature table [CODESPLIT] public int index ( FeatureIndexType type , boolean force ) { if ( type == null ) { throw new GeoPackageException ( "FeatureIndexType is required to index" ) ; } int count = 0 ; switch ( type ) { case GEOPACKAGE : count = featureTableIndex . index ( force ) ; break ; case METADATA : count = featureIndexer . index ( force ) ; break ; case RTREE : boolean rTreeIndexed = rTreeIndexTableDao . has ( ) ; if ( ! rTreeIndexed || force ) { if ( rTreeIndexed ) { rTreeIndexTableDao . delete ( ) ; } rTreeIndexTableDao . create ( ) ; count = rTreeIndexTableDao . count ( ) ; } break ; default : throw new GeoPackageException ( "Unsupported FeatureIndexType: " + type ) ; } return count ; }


Input: Index the feature row for the index types . This method assumes that indexing has been completed and maintained as the last indexed time is updated . [CODESPLIT] public boolean index ( FeatureRow row , List < FeatureIndexType > types ) { boolean indexed = false ; for ( FeatureIndexType type : types ) { if ( index ( type , row ) ) { indexed = true ; } } return indexed ; }


Input: Index the feature row . This method assumes that indexing has been completed and maintained as the last indexed time is updated . [CODESPLIT] public boolean index ( FeatureIndexType type , FeatureRow row ) { boolean indexed = false ; if ( type == null ) { throw new GeoPackageException ( "FeatureIndexType is required to index" ) ; } switch ( type ) { case GEOPACKAGE : indexed = featureTableIndex . index ( row ) ; break ; case METADATA : indexed = featureIndexer . index ( row ) ; break ; case RTREE : // Updated by triggers, ignore for RTree indexed = true ; break ; default : throw new GeoPackageException ( "Unsupported FeatureIndexType: " + type ) ; } return indexed ; }


Input: Delete the feature index from the index types [CODESPLIT] public boolean deleteIndex ( Collection < FeatureIndexType > types ) { boolean deleted = false ; for ( FeatureIndexType type : types ) { if ( deleteIndex ( type ) ) { deleted = true ; } } return deleted ; }


Input: Delete the feature index for the feature row from the index types [CODESPLIT] public boolean deleteIndex ( FeatureRow row , List < FeatureIndexType > types ) { boolean deleted = false ; for ( FeatureIndexType type : types ) { if ( deleteIndex ( type , row ) ) { deleted = true ; } } return deleted ; }


Input: Delete the feature index for the geometry id from the index types [CODESPLIT] public boolean deleteIndex ( long geomId , List < FeatureIndexType > types ) { boolean deleted = false ; for ( FeatureIndexType type : types ) { if ( deleteIndex ( type , geomId ) ) { deleted = true ; } } return deleted ; }


Input: Delete the feature index for the geometry id [CODESPLIT] public boolean deleteIndex ( FeatureIndexType type , long geomId ) { if ( type == null ) { throw new GeoPackageException ( "FeatureIndexType is required to delete index" ) ; } boolean deleted = false ; switch ( type ) { case GEOPACKAGE : deleted = featureTableIndex . deleteIndex ( geomId ) > 0 ; break ; case METADATA : deleted = featureIndexer . deleteIndex ( geomId ) ; break ; case RTREE : // Updated by triggers, ignore for RTree deleted = true ; break ; default : throw new GeoPackageException ( "Unsupported FeatureIndexType: " + type ) ; } return deleted ; }


Input: Retain the feature index from the index types and delete the others [CODESPLIT] public boolean retainIndex ( FeatureIndexType type ) { List < FeatureIndexType > retain = new ArrayList < FeatureIndexType > ( ) ; retain . add ( type ) ; return retainIndex ( retain ) ; }


Input: Retain the feature index from the index types and delete the others [CODESPLIT] public boolean retainIndex ( Collection < FeatureIndexType > types ) { Set < FeatureIndexType > delete = new HashSet <> ( indexLocationQueryOrder ) ; delete . removeAll ( types ) ; return deleteIndex ( delete ) ; }


Input: Determine if the feature table is indexed [CODESPLIT] public boolean isIndexed ( ) { boolean indexed = false ; for ( FeatureIndexType type : indexLocationQueryOrder ) { indexed = isIndexed ( type ) ; if ( indexed ) { break ; } } return indexed ; }


Input: Get the indexed types that are currently indexed [CODESPLIT] public List < FeatureIndexType > getIndexedTypes ( ) { List < FeatureIndexType > indexed = new ArrayList <> ( ) ; for ( FeatureIndexType type : indexLocationQueryOrder ) { if ( isIndexed ( type ) ) { indexed . add ( type ) ; } } return indexed ; }


Input: Get the date last indexed [CODESPLIT] public Date getLastIndexed ( ) { Date lastIndexed = null ; for ( FeatureIndexType type : indexLocationQueryOrder ) { lastIndexed = getLastIndexed ( type ) ; if ( lastIndexed != null ) { break ; } } return lastIndexed ; }


Input: Query for all feature index results [CODESPLIT] public FeatureIndexResults query ( ) { FeatureIndexResults results = null ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : long count = featureTableIndex . count ( ) ; CloseableIterator < GeometryIndex > geometryIndices = featureTableIndex . query ( ) ; results = new FeatureIndexGeoPackageResults ( featureTableIndex , count , geometryIndices ) ; break ; case METADATA : Cursor geometryMetadata = featureIndexer . query ( ) ; results = new FeatureIndexMetadataResults ( featureIndexer , geometryMetadata ) ; break ; case RTREE : UserCustomCursor cursor = rTreeIndexTableDao . queryForAll ( ) ; results = new FeatureIndexRTreeResults ( rTreeIndexTableDao , cursor ) ; break ; default : FeatureCursor featureCursor = featureDao . queryForAll ( ) ; results = new FeatureIndexFeatureResults ( featureCursor ) ; } return results ; }


Input: Query for all feature index count [CODESPLIT] public long count ( ) { long count = 0 ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : count = featureTableIndex . count ( ) ; break ; case METADATA : count = featureIndexer . count ( ) ; break ; case RTREE : count = rTreeIndexTableDao . count ( ) ; break ; default : count = manualFeatureQuery . countWithGeometries ( ) ; } return count ; }


Input: Query for the feature index bounds [CODESPLIT] public BoundingBox getBoundingBox ( ) { BoundingBox bounds = null ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : bounds = featureTableIndex . getBoundingBox ( ) ; break ; case METADATA : bounds = featureIndexer . getBoundingBox ( ) ; break ; case RTREE : bounds = rTreeIndexTableDao . getBoundingBox ( ) ; break ; default : bounds = manualFeatureQuery . getBoundingBox ( ) ; } return bounds ; }


Input: Query for feature index results within the bounding box in the provided projection [CODESPLIT] public FeatureIndexResults query ( BoundingBox boundingBox , Projection projection ) { FeatureIndexResults results = null ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : long count = featureTableIndex . count ( boundingBox , projection ) ; CloseableIterator < GeometryIndex > geometryIndices = featureTableIndex . query ( boundingBox , projection ) ; results = new FeatureIndexGeoPackageResults ( featureTableIndex , count , geometryIndices ) ; break ; case METADATA : Cursor geometryMetadata = featureIndexer . query ( boundingBox , projection ) ; results = new FeatureIndexMetadataResults ( featureIndexer , geometryMetadata ) ; break ; case RTREE : UserCustomCursor cursor = rTreeIndexTableDao . query ( boundingBox , projection ) ; results = new FeatureIndexRTreeResults ( rTreeIndexTableDao , cursor ) ; break ; default : results = manualFeatureQuery . query ( boundingBox , projection ) ; } return results ; }


Input: Get the indexed type or throw an error if not indexed [CODESPLIT] private FeatureIndexType getIndexedType ( ) { FeatureIndexType indexType = FeatureIndexType . NONE ; // Check for an indexed type for ( FeatureIndexType type : indexLocationQueryOrder ) { if ( isIndexed ( type ) ) { indexType = type ; break ; } } return indexType ; }


Input: { [CODESPLIT] @ Override public boolean hasTile ( int x , int y , int zoom ) { // Get the bounding box of the requested tile BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; boolean hasTile = tileCreator . hasTile ( webMercatorBoundingBox ) ; return hasTile ; }


Input: { [CODESPLIT] @ Override public GeoPackageTile getTile ( int x , int y , int zoom ) { // Get the bounding box of the requested tile BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; GeoPackageTile tile = tileCreator . getTile ( webMercatorBoundingBox ) ; return tile ; }


Input: Get the internal storage file for the file path [CODESPLIT] public static File getInternalFile ( Context context , String filePath ) { File internalFile = null ; if ( filePath != null ) { internalFile = new File ( context . getFilesDir ( ) , filePath ) ; } else { internalFile = context . getFilesDir ( ) ; } return internalFile ; }


Input: Get the internal storage patch for the file path [CODESPLIT] public static String getInternalFilePath ( Context context , String filePath ) { return getInternalFile ( context , filePath ) . getAbsolutePath ( ) ; }


Input: Get the geometry type [CODESPLIT] public GeometryType getGeometryType ( ) { GeometryType geometryType = null ; String geometryTypeName = getGeometryTypeName ( ) ; if ( geometryTypeName != null ) { geometryType = GeometryType . fromName ( geometryTypeName ) ; } return geometryType ; }


Input: Set the geometry type [CODESPLIT] public void setGeometryType ( GeometryType geometryType ) { String geometryTypeName = null ; if ( geometryType != null ) { geometryTypeName = geometryType . getName ( ) ; } setValue ( getGeometryTypeNameColumnIndex ( ) , geometryTypeName ) ; }


Input: Determine if the url has bounding box variables [CODESPLIT] private boolean hasBoundingBox ( String url ) { String replacedUrl = replaceBoundingBox ( url , boundingBox ) ; boolean hasBoundingBox = ! replacedUrl . equals ( url ) ; return hasBoundingBox ; }


Input: Replace x y and z in the url [CODESPLIT] private String replaceXYZ ( String url , int z , long x , long y ) { url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_z ) , String . valueOf ( z ) ) ; url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_x ) , String . valueOf ( x ) ) ; url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_y ) , String . valueOf ( y ) ) ; return url ; }


Input: Determine if the url has x y or z variables [CODESPLIT] private boolean hasXYZ ( String url ) { String replacedUrl = replaceXYZ ( url , 0 , 0 , 0 ) ; boolean hasXYZ = ! replacedUrl . equals ( url ) ; return hasXYZ ; }


Input: Replace the bounding box coordinates in the url [CODESPLIT] private String replaceBoundingBox ( String url , int z , long x , long y ) { BoundingBox boundingBox = TileBoundingBoxUtils . getProjectedBoundingBox ( projection , x , y , z ) ; url = replaceBoundingBox ( url , boundingBox ) ; return url ; }


Input: Replace the url parts with the bounding box [CODESPLIT] private String replaceBoundingBox ( String url , BoundingBox boundingBox ) { url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_min_lat ) , String . valueOf ( boundingBox . getMinLatitude ( ) ) ) ; url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_max_lat ) , String . valueOf ( boundingBox . getMaxLatitude ( ) ) ) ; url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_min_lon ) , String . valueOf ( boundingBox . getMinLongitude ( ) ) ) ; url = url . replaceAll ( context . getString ( R . string . tile_generator_variable_max_lon ) , String . valueOf ( boundingBox . getMaxLongitude ( ) ) ) ; return url ; }


Input: { [CODESPLIT] @ Override protected byte [ ] createTile ( int z , long x , long y ) { byte [ ] bytes = null ; String zoomUrl = tileUrl ; // Replace x, y, and z if ( urlHasXYZ ) { long yRequest = y ; // If TMS, flip the y value if ( tms ) { yRequest = TileBoundingBoxUtils . getYAsOppositeTileFormat ( z , ( int ) y ) ; } zoomUrl = replaceXYZ ( zoomUrl , z , x , yRequest ) ; } // Replace bounding box if ( urlHasBoundingBox ) { zoomUrl = replaceBoundingBox ( zoomUrl , z , x , y ) ; } URL url ; try { url = new URL ( zoomUrl ) ; } catch ( MalformedURLException e ) { throw new GeoPackageException ( "Failed to download tile. URL: " + zoomUrl + ", z=" + z + ", x=" + x + ", y=" + y , e ) ; } HttpURLConnection connection = null ; try { connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . connect ( ) ; int responseCode = connection . getResponseCode ( ) ; if ( responseCode == HttpURLConnection . HTTP_MOVED_PERM || responseCode == HttpURLConnection . HTTP_MOVED_TEMP || responseCode == HttpURLConnection . HTTP_SEE_OTHER ) { String redirect = connection . getHeaderField ( "Location" ) ; connection . disconnect ( ) ; url = new URL ( redirect ) ; connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . connect ( ) ; } if ( connection . getResponseCode ( ) != HttpURLConnection . HTTP_OK ) { throw new GeoPackageException ( "Failed to download tile. URL: " + zoomUrl + ", z=" + z + ", x=" + x + ", y=" + y ) ; } InputStream geoPackageStream = connection . getInputStream ( ) ; bytes = GeoPackageIOUtils . streamBytes ( geoPackageStream ) ; } catch ( IOException e ) { throw new GeoPackageException ( "Failed to download tile. URL: " + zoomUrl + ", z=" + z + ", x=" + x + ", y=" + y , e ) ; } finally { if ( connection != null ) { connection . disconnect ( ) ; } } return bytes ; }


Input: { [CODESPLIT] @ Override public FeatureRow getRow ( int [ ] columnTypes , Object [ ] values ) { return new FeatureRow ( getTable ( ) , columnTypes , values ) ; }


Input: { [CODESPLIT] @ Override public Object getValue ( FeatureColumn column ) { Object value ; if ( column . isGeometry ( ) ) { value = getGeometry ( ) ; } else { value = super . getValue ( column ) ; } return value ; }


Input: Get the geometry [CODESPLIT] public GeoPackageGeometryData getGeometry ( ) { GeoPackageGeometryData geometry = null ; int columnIndex = getTable ( ) . getGeometryColumnIndex ( ) ; int type = getType ( columnIndex ) ; if ( type != FIELD_TYPE_NULL ) { byte [ ] geometryBytes = getBlob ( columnIndex ) ; if ( geometryBytes != null ) { geometry = new GeoPackageGeometryData ( geometryBytes ) ; } } return geometry ; }


Input: { [CODESPLIT] @ Override protected UserInvalidCursor < FeatureColumn , FeatureTable , FeatureRow , ? extends UserCursor < FeatureColumn , FeatureTable , FeatureRow > , ? extends UserDao < FeatureColumn , FeatureTable , FeatureRow , ? extends UserCursor < FeatureColumn , FeatureTable , FeatureRow > > > createInvalidCursor ( UserDao dao , UserCursor cursor , List < Integer > invalidPositions , List < FeatureColumn > blobColumns ) { return new FeatureInvalidCursor ( ( FeatureDao ) dao , ( FeatureCursor ) cursor , invalidPositions , blobColumns ) ; }


Input: Index the feature row . This method assumes that indexing has been completed and maintained as the last indexed time is updated . [CODESPLIT] public boolean index ( FeatureRow row ) { long geoPackageId = geometryMetadataDataSource . getGeoPackageId ( featureDao . getDatabase ( ) ) ; boolean indexed = index ( geoPackageId , row , true ) ; // Update the last indexed time updateLastIndexed ( db , geoPackageId ) ; return indexed ; }


Input: Index the feature table [CODESPLIT] private int indexTable ( ) { int count = 0 ; // Get or create the table metadata TableMetadataDataSource tableDs = new TableMetadataDataSource ( db ) ; TableMetadata metadata = tableDs . getOrCreate ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) ) ; // Delete existing index rows geometryMetadataDataSource . delete ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) ) ; long offset = 0 ; int chunkCount = 0 ; // Index all features while ( chunkCount >= 0 ) { FeatureCursor cursor = featureDao . queryForChunk ( chunkLimit , offset ) ; chunkCount = indexRows ( metadata . getGeoPackageId ( ) , cursor ) ; if ( chunkCount > 0 ) { count += chunkCount ; } offset += chunkLimit ; } // Update the last indexed time if ( progress == null || progress . isActive ( ) ) { updateLastIndexed ( db , metadata . getGeoPackageId ( ) ) ; } return count ; }


Input: Index the feature rows in the cursor [CODESPLIT] private int indexRows ( long geoPackageId , FeatureCursor cursor ) { int count = - 1 ; try { while ( ( progress == null || progress . isActive ( ) ) && cursor . moveToNext ( ) ) { if ( count < 0 ) { count ++ ; } try { FeatureRow row = cursor . getRow ( ) ; if ( row . isValid ( ) ) { boolean indexed = index ( geoPackageId , row , false ) ; if ( indexed ) { count ++ ; } if ( progress != null ) { progress . addProgress ( 1 ) ; } } } catch ( Exception e ) { Log . e ( FeatureIndexer . class . getSimpleName ( ) , "Failed to index feature. Table: " + featureDao . getTableName ( ) + ", Position: " + cursor . getPosition ( ) , e ) ; } } } finally { cursor . close ( ) ; } return count ; }


Input: Index the feature row [CODESPLIT] private boolean index ( long geoPackageId , FeatureRow row , boolean possibleUpdate ) { boolean indexed = false ; GeoPackageGeometryData geomData = row . getGeometry ( ) ; if ( geomData != null ) { // Get the envelope GeometryEnvelope envelope = geomData . getEnvelope ( ) ; // If no envelope, build one from the geometry if ( envelope == null ) { Geometry geometry = geomData . getGeometry ( ) ; if ( geometry != null ) { envelope = GeometryEnvelopeBuilder . buildEnvelope ( geometry ) ; } } // Create the new index row if ( envelope != null ) { GeometryMetadata metadata = geometryMetadataDataSource . populate ( geoPackageId , featureDao . getTableName ( ) , row . getId ( ) , envelope ) ; if ( possibleUpdate ) { geometryMetadataDataSource . createOrUpdate ( metadata ) ; } else { geometryMetadataDataSource . create ( metadata ) ; } indexed = true ; } } return indexed ; }


Input: Update the least indexed time [CODESPLIT] private void updateLastIndexed ( GeoPackageMetadataDb db , long geoPackageId ) { long indexedTime = ( new Date ( ) ) . getTime ( ) ; TableMetadataDataSource ds = new TableMetadataDataSource ( db ) ; if ( ! ds . updateLastIndexed ( geoPackageId , featureDao . getTableName ( ) , indexedTime ) ) { throw new GeoPackageException ( "Failed to update last indexed time. Table: GeoPackage Id: " + geoPackageId + ", Table: " + featureDao . getTableName ( ) + ", Last Indexed: " + indexedTime ) ; } }


Input: Delete the feature table index [CODESPLIT] public boolean deleteIndex ( ) { TableMetadataDataSource tableMetadataDataSource = new TableMetadataDataSource ( db ) ; boolean deleted = tableMetadataDataSource . delete ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) ) ; return deleted ; }


Input: Delete the index for the geometry id [CODESPLIT] public boolean deleteIndex ( long geomId ) { boolean deleted = geometryMetadataDataSource . delete ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) , geomId ) ; return deleted ; }


Input: Determine if the database table is indexed after database modifications [CODESPLIT] public boolean isIndexed ( ) { boolean indexed = false ; Date lastIndexed = getLastIndexed ( ) ; if ( lastIndexed != null ) { Contents contents = featureDao . getGeometryColumns ( ) . getContents ( ) ; Date lastChange = contents . getLastChange ( ) ; indexed = lastIndexed . equals ( lastChange ) || lastIndexed . after ( lastChange ) ; } return indexed ; }


Input: Get the date last indexed [CODESPLIT] public Date getLastIndexed ( ) { Date date = null ; TableMetadataDataSource ds = new TableMetadataDataSource ( db ) ; TableMetadata metadata = ds . get ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) ) ; if ( metadata != null ) { Long lastIndexed = metadata . getLastIndexed ( ) ; if ( lastIndexed != null ) { date = new Date ( lastIndexed ) ; } } return date ; }


Input: Query for all Geometry Metadata [CODESPLIT] public Cursor query ( ) { Cursor cursor = geometryMetadataDataSource . query ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) ) ; return cursor ; }


Input: Query for Geometry Metadata within the bounding box projected correctly [CODESPLIT] public Cursor query ( BoundingBox boundingBox ) { Cursor cursor = geometryMetadataDataSource . query ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) , boundingBox ) ; return cursor ; }


Input: Query for Geometry Metadata count within the bounding box projected correctly [CODESPLIT] public int count ( BoundingBox boundingBox ) { int count = geometryMetadataDataSource . count ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) , boundingBox ) ; return count ; }


Input: Query for Geometry Metadata within the Geometry Envelope [CODESPLIT] public Cursor query ( GeometryEnvelope envelope ) { Cursor cursor = geometryMetadataDataSource . query ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) , envelope ) ; return cursor ; }


Input: Query for Geometry Metadata count within the Geometry Envelope [CODESPLIT] public int count ( GeometryEnvelope envelope ) { int count = geometryMetadataDataSource . count ( featureDao . getDatabase ( ) , featureDao . getTableName ( ) , envelope ) ; return count ; }


Input: Query for Geometry Metadata within the bounding box in the provided projection [CODESPLIT] public Cursor query ( BoundingBox boundingBox , Projection projection ) { BoundingBox featureBoundingBox = getFeatureBoundingBox ( boundingBox , projection ) ; Cursor cursor = query ( featureBoundingBox ) ; return cursor ; }


Input: Query for Geometry Metadata count within the bounding box in the provided projection [CODESPLIT] public long count ( BoundingBox boundingBox , Projection projection ) { BoundingBox featureBoundingBox = getFeatureBoundingBox ( boundingBox , projection ) ; long count = count ( featureBoundingBox ) ; return count ; }


Input: Get the bounding box in the feature projection from the bounding box in the provided projection [CODESPLIT] private BoundingBox getFeatureBoundingBox ( BoundingBox boundingBox , Projection projection ) { ProjectionTransform projectionTransform = projection . getTransformation ( featureDao . getProjection ( ) ) ; BoundingBox featureBoundingBox = boundingBox . transform ( projectionTransform ) ; return featureBoundingBox ; }


Input: Get the Geometry Metadata for the current place in the cursor [CODESPLIT] public GeometryMetadata getGeometryMetadata ( Cursor cursor ) { GeometryMetadata geometryMetadata = GeometryMetadataDataSource . createGeometryMetadata ( cursor ) ; return geometryMetadata ; }


Input: Get the feature row for the current place in the cursor [CODESPLIT] public FeatureRow getFeatureRow ( Cursor cursor ) { GeometryMetadata geometryMetadata = getGeometryMetadata ( cursor ) ; FeatureRow featureRow = getFeatureRow ( geometryMetadata ) ; return featureRow ; }


Input: Get the feature row for the Geometry Metadata [CODESPLIT] public FeatureRow getFeatureRow ( GeometryMetadata geometryMetadata ) { long geomId = geometryMetadata . getId ( ) ; // Get the row or lock for reading FeatureRow row = featureRowSync . getRowOrLock ( geomId ) ; if ( row == null ) { // Query for the row and set in the sync try { row = featureDao . queryForIdRow ( geomId ) ; } finally { featureRowSync . setRow ( geomId , row ) ; } } return row ; }


Input: Query for the tile tables linked to a feature table and return tile DAOs to those tables [CODESPLIT] public List < TileDao > getTileDaosForFeatureTable ( String featureTable ) { List < TileDao > tileDaos = new ArrayList < TileDao > ( ) ; List < String > tileTables = getTileTablesForFeatureTable ( featureTable ) ; for ( String tileTable : tileTables ) { if ( geoPackage . isTileTable ( tileTable ) ) { TileDao tileDao = geoPackage . getTileDao ( tileTable ) ; tileDaos . add ( tileDao ) ; } } return tileDaos ; }


Input: Query for the feature tables linked to a tile table and return feature DAOs to those tables [CODESPLIT] public List < FeatureDao > getFeatureDaosForTileTable ( String tileTable ) { List < FeatureDao > featureDaos = new ArrayList < FeatureDao > ( ) ; List < String > featureTables = getFeatureTablesForTileTable ( tileTable ) ; for ( String featureTable : featureTables ) { if ( geoPackage . isFeatureTable ( featureTable ) ) { FeatureDao featureDao = geoPackage . getFeatureDao ( featureTable ) ; featureDaos . add ( featureDao ) ; } } return featureDaos ; }


Input: Get the bounding box for the feature tile generator from the provided and from the feature table [CODESPLIT] private static BoundingBox getBoundingBox ( GeoPackage geoPackage , FeatureTiles featureTiles , BoundingBox boundingBox , Projection projection ) { String tableName = featureTiles . getFeatureDao ( ) . getTableName ( ) ; boolean manualQuery = boundingBox == null ; BoundingBox featureBoundingBox = geoPackage . getBoundingBox ( projection , tableName , manualQuery ) ; if ( featureBoundingBox != null ) { if ( boundingBox == null ) { boundingBox = featureBoundingBox ; } else { boundingBox = boundingBox . overlap ( featureBoundingBox ) ; } } if ( boundingBox != null ) { boundingBox = featureTiles . expandBoundingBox ( boundingBox , projection ) ; } return boundingBox ; }


Input: { [CODESPLIT] @ Override public BoundingBox getBoundingBox ( int zoom ) { ProjectionTransform projectionToWebMercator = projection . getTransformation ( ProjectionConstants . EPSG_WEB_MERCATOR ) ; BoundingBox webMercatorBoundingBox = boundingBox . transform ( projectionToWebMercator ) ; TileGrid tileGrid = TileBoundingBoxUtils . getTileGrid ( webMercatorBoundingBox , zoom ) ; BoundingBox tileBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( tileGrid . getMinX ( ) , tileGrid . getMinY ( ) , zoom ) ; BoundingBox expandedBoundingBox = featureTiles . expandBoundingBox ( webMercatorBoundingBox , tileBoundingBox ) ; BoundingBox zoomBoundingBox = expandedBoundingBox . transform ( projectionToWebMercator . getInverseTransformation ( ) ) ; return zoomBoundingBox ; }


Input: { [CODESPLIT] @ Override protected void preTileGeneration ( ) { // Link the feature and tile table if they are in the same GeoPackage GeoPackage geoPackage = getGeoPackage ( ) ; String featureTable = featureTiles . getFeatureDao ( ) . getTableName ( ) ; String tileTable = getTableName ( ) ; if ( linkTables && geoPackage . isFeatureTable ( featureTable ) && geoPackage . isTileTable ( tileTable ) ) { FeatureTileTableLinker linker = new FeatureTileTableLinker ( geoPackage ) ; linker . link ( featureTable , tileTable ) ; } }


Input: { [CODESPLIT] @ Override protected byte [ ] createTile ( int z , long x , long y ) { byte [ ] tileData = featureTiles . drawTileBytes ( ( int ) x , ( int ) y , z ) ; return tileData ; }