/** * Whether the tile is stale and should be refreshed. * <p/> * This method is called from {@link #draw(org.mapsforge.core.model.BoundingBox, byte, org.mapsforge.core.graphics.Canvas, org.mapsforge.core.model.Point)} to determine whether the tile needs to * be refreshed. * <p/> * A tile is considered stale if the timestamp of the layer's {@link #mapDataStore} is more recent than the * {@code bitmap}'s {@link org.mapsforge.core.graphics.TileBitmap#getTimestamp()}. * <p/> * When a tile has become stale, the layer will first display the tile referenced by {@code bitmap} and attempt to * obtain a fresh copy in the background. When a fresh copy becomes available, the layer will replace is and update * the cache. If a fresh copy cannot be obtained for whatever reason, the stale tile will continue to be used until * another {@code #draw(BoundingBox, byte, Canvas, Point)} operation requests it again. * * @param tile A tile. * @param bitmap The bitmap for {@code tile} currently held in the layer's cache. */ @Override protected boolean isTileStale(Tile tile, TileBitmap bitmap) { return this.mapDataStore.getDataTimestamp(tile) > bitmap.getTimestamp(); }
/** * Returns the timestamp of the data used to render a specific tile. * <p/> * If the tile uses data from multiple data stores, the most recent timestamp is returned. * * @param tile A tile. * @return the timestamp of the data used to render the tile */ @Override public long getDataTimestamp(Tile tile) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { return mdb.getDataTimestamp(tile); } } return 0; case RETURN_ALL: case DEDUPLICATE: long result = 0; for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { result = Math.max(result, mdb.getDataTimestamp(tile)); } } return result; } throw new IllegalStateException("Invalid data policy for multi map database"); }
renderContext.renderTheme.matchHillShadings(this, renderContext); bitmap = this.graphicFactory.createTileBitmap(rendererJob.tile.tileSize, rendererJob.hasAlpha); bitmap.setTimestamp(rendererJob.mapDataStore.getDataTimestamp(rendererJob.tile)); renderContext.canvasRasterer.setCanvasBitmap(bitmap); if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != renderContext.renderTheme.getMapBackground()) {
renderContext.renderTheme.matchHillShadings(this, renderContext); bitmap = this.graphicFactory.createTileBitmap(rendererJob.tile.tileSize, rendererJob.hasAlpha); bitmap.setTimestamp(rendererJob.mapDataStore.getDataTimestamp(rendererJob.tile)); renderContext.canvasRasterer.setCanvasBitmap(bitmap); if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != renderContext.renderTheme.getMapBackground()) {
/** * Whether the tile is stale and should be refreshed. * <p/> * This method is called from {@link #draw(org.mapsforge.core.model.BoundingBox, byte, org.mapsforge.core.graphics.Canvas, org.mapsforge.core.model.Point)} to determine whether the tile needs to * be refreshed. * <p/> * A tile is considered stale if the timestamp of the layer's {@link #mapDataStore} is more recent than the * {@code bitmap}'s {@link org.mapsforge.core.graphics.TileBitmap#getTimestamp()}. * <p/> * When a tile has become stale, the layer will first display the tile referenced by {@code bitmap} and attempt to * obtain a fresh copy in the background. When a fresh copy becomes available, the layer will replace is and update * the cache. If a fresh copy cannot be obtained for whatever reason, the stale tile will continue to be used until * another {@code #draw(BoundingBox, byte, Canvas, Point)} operation requests it again. * * @param tile A tile. * @param bitmap The bitmap for {@code tile} currently held in the layer's cache. */ @Override protected boolean isTileStale(Tile tile, TileBitmap bitmap) { return this.mapDataStore.getDataTimestamp(tile) > bitmap.getTimestamp(); }
/** * Returns the timestamp of the data used to render a specific tile. * <p/> * If the tile uses data from multiple data stores, the most recent timestamp is returned. * * @param tile A tile. * @return the timestamp of the data used to render the tile */ @Override public long getDataTimestamp(Tile tile) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { return mdb.getDataTimestamp(tile); } } return 0; case RETURN_ALL: case DEDUPLICATE: long result = 0; for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { result = Math.max(result, mdb.getDataTimestamp(tile)); } } return result; } throw new IllegalStateException("Invalid data policy for multi map database"); }
renderContext.renderTheme.matchHillShadings(this, renderContext); bitmap = this.graphicFactory.createTileBitmap(rendererJob.tile.tileSize, rendererJob.hasAlpha); bitmap.setTimestamp(rendererJob.mapDataStore.getDataTimestamp(rendererJob.tile)); renderContext.canvasRasterer.setCanvasBitmap(bitmap); if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != renderContext.renderTheme.getMapBackground()) {