Commit 9becd03c authored by Vytor Calixto's avatar Vytor Calixto 👾
Browse files

Código para o fetch das tiles

parent 50305908
...@@ -31,9 +31,33 @@ public class TilesProvider { ...@@ -31,9 +31,33 @@ public class TilesProvider {
} }
public void fetchTiles(Rect rect, int zoom){ public void fetchTiles(Rect rect, int zoom){
// String query = "SELECT x,y,image FROM tiles WHERE " + String query = "SELECT tilex,tiley,image FROM tiles WHERE " +
// "x >= " + rect.left + " AND x <= " + rect.right + "tilex >= " + rect.left + " AND tilex <= " + rect.right +
// " AND y >=" + rect.top + " AND y <= " + rect.bottom + " AND z = " + zoom; " AND tiley >=" + rect.top + " AND tiley <= " + rect.bottom + " AND zoom = " + zoom;
Cursor cursor;
cursor = tilesDb.rawQuery(query, null);
Hashtable<String, Tile> temp = new Hashtable<String, Tile>();
if(cursor.moveToFirst()) {
do {
int x = cursor.getInt(0);
int y = cursor.getInt(1);
// Checa se a tile não existe
Tile tile = tiles.get(x + ":" + y);
if(tile == null) {
byte[] img = cursor.getBlob(2);
Bitmap tileBitmap = BitmapFactory.decodeByteArray(img, 0, img.length);
tile = new Tile(x, y, tileBitmap);
}
temp.put(x + ":" + y, tile);
} while(cursor.moveToNext());
}
tiles.clear();
tiles = temp;
} }
public Hashtable<String, Tile> select(String[] selectTile) throws Exception { public Hashtable<String, Tile> select(String[] selectTile) throws Exception {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment