serious refactor: TileLoader:

- no more duplication of TileLoaders for GWT ->
- decouple loadTile() from TileDataSource completed() call
- all TileDataSource MUST call completed(success) in any case now
This commit is contained in:
Hannes Janetzek
2014-03-09 05:43:38 +01:00
parent a8f46fdd8d
commit c24b4addfa
17 changed files with 216 additions and 658 deletions

View File

@@ -24,7 +24,7 @@ public class JeoTileLayer extends BitmapTileLayer {
}
@Override
protected boolean executeJob(MapTile tile) {
protected boolean loadTile(MapTile tile) {
// TODO Auto-generated method stub
return false;
}

View File

@@ -1,5 +1,9 @@
package org.oscim.layers;
import static org.oscim.tiling.ITileDataSink.QueryResult.FAILED;
import static org.oscim.tiling.ITileDataSink.QueryResult.SUCCESS;
import static org.oscim.tiling.ITileDataSink.QueryResult.TILE_NOT_FOUND;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -32,7 +36,7 @@ public class JeoTileSource extends TileSource {
return new ITileDataSource() {
@Override
public QueryResult executeQuery(MapTile tile, ITileDataSink sink) {
public void query(MapTile tile, ITileDataSink sink) {
log.debug("query {}", tile);
try {
Tile t = mTileDataset.read(tile.zoomLevel, tile.tileX,
@@ -40,20 +44,20 @@ public class JeoTileSource extends TileSource {
(1 << tile.zoomLevel) - 1 - tile.tileY);
if (t == null) {
log.debug("not found {}", tile);
return QueryResult.TILE_NOT_FOUND;
sink.completed(TILE_NOT_FOUND);
return;
}
Bitmap b = CanvasAdapter.g.decodeBitmap(new ByteArrayInputStream(t.getData()));
sink.setTileImage(b);
log.debug("success {}", tile);
return QueryResult.SUCCESS;
sink.completed(SUCCESS);
return;
} catch (IOException e) {
e.printStackTrace();
}
log.debug("fail {}", tile);
return QueryResult.FAILED;
sink.completed(FAILED);
}
@Override