- remove swrenderer

- rearchitect:
 now that MapView is a ViewGroup and MapRenderer is the GLSurfaceView.
- lock/unlock proxy tiles properly to not be removed from cache while in use
This commit is contained in:
Hannes Janetzek
2012-09-16 19:26:53 +02:00
parent caea9cd7c9
commit a1317a9de5
81 changed files with 5271 additions and 5408 deletions

View File

@@ -16,7 +16,7 @@ package org.oscim.database;
import java.util.Map;
import org.oscim.view.mapgenerator.JobTile;
import org.oscim.view.generator.JobTile;
/**
*

View File

@@ -26,14 +26,14 @@ public interface IMapDatabaseCallback {
*
* @param layer
* the layer of the node.
* @param tags
* the tags of the node.
* @param latitude
* the latitude of the node.
* @param longitude
* the longitude of the node.
* @param tags
* the tags of the node.
*/
void renderPointOfInterest(byte layer, float latitude, float longitude, Tag[] tags);
void renderPointOfInterest(byte layer, Tag[] tags, float latitude, float longitude);
/**
* Renders water background for the current tile.
@@ -51,12 +51,21 @@ public interface IMapDatabaseCallback {
* the geographical coordinates of the way nodes in the order longitude/latitude.
* @param wayLength
* length of way data in wayNodes
* @param changed
* tags have changed since last call (just an optional hint)
* @param closed
* way is closed (means need to add endpoint == startpoint)
*/
void renderWay(byte layer, Tag[] tags, float[] wayNodes, short[] wayLength,
boolean changed);
boolean closed);
/**
* TBD: check if way will be rendered before decoding
*
* @param tags
* ...
* @param closed
* ...
* @return true if the way will be rendered (i.e. found match in RenderTheme)
*/
boolean checkWay(Tag[] tags, boolean closed);
}

View File

@@ -14,7 +14,6 @@
*/
package org.oscim.database;
import android.util.AttributeSet;
/**
@@ -66,6 +65,8 @@ public final class MapDatabaseFactory {
return new org.oscim.database.postgis.MapDatabase();
case PBMAP_READER:
return new org.oscim.database.pbmap.MapDatabase();
case OSCIMAP_READER:
return new org.oscim.database.oscimap.MapDatabase();
}

View File

@@ -37,4 +37,8 @@ public enum MapDatabases {
* ...
*/
PBMAP_READER,
/**
* ...
*/
OSCIMAP_READER,
}

View File

@@ -20,8 +20,8 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.oscim.core.LRUCache;
import org.oscim.database.mapfile.header.SubFileParameter;
import org.oscim.utils.LRUCache;
/**
* A cache for database index blocks with a fixed size and LRU policy.

View File

@@ -30,7 +30,7 @@ import org.oscim.database.QueryResult;
import org.oscim.database.mapfile.header.MapFileHeader;
import org.oscim.database.mapfile.header.MapFileInfo;
import org.oscim.database.mapfile.header.SubFileParameter;
import org.oscim.view.mapgenerator.JobTile;
import org.oscim.view.generator.JobTile;
/**
* A class for reading binary map files.
@@ -641,7 +641,7 @@ public class MapDatabase implements IMapDatabase {
// Integer.toString(mReadBuffer.readSignedInt())));
}
mapDatabaseCallback.renderPointOfInterest(layer, latitude, longitude, tags);
mapDatabaseCallback.renderPointOfInterest(layer, tags, latitude, longitude);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -62,7 +62,7 @@ import org.oscim.database.IMapDatabaseCallback;
import org.oscim.database.MapInfo;
import org.oscim.database.OpenResult;
import org.oscim.database.QueryResult;
import org.oscim.view.mapgenerator.JobTile;
import org.oscim.view.generator.JobTile;
import android.os.Environment;
import android.os.SystemClock;
@@ -604,7 +604,7 @@ public class MapDatabase implements IMapDatabase {
lastY = lat + lastY;
mMapGenerator.renderPointOfInterest(layer,
lastY / scale, lastX / scale, tags);
tags, lastY / scale, lastX / scale);
cnt += 2;
}
return cnt;

View File

@@ -580,7 +580,7 @@ public class Tags {
private static final String s_boutique = "boutique".intern();
private static final String s_boat_storage = "boat_storage".intern();
public final static Tag[] tags = {
public static final Tag[] tags = {
new Tag(s_building, s_yes, true), new Tag(s_highway, s_residential, true),
new Tag(s_highway, s_service, true), new Tag(s_waterway, s_stream, true),

View File

@@ -33,7 +33,7 @@ import org.oscim.database.IMapDatabaseCallback;
import org.oscim.database.MapInfo;
import org.oscim.database.OpenResult;
import org.oscim.database.QueryResult;
import org.oscim.view.mapgenerator.JobTile;
import org.oscim.view.generator.JobTile;
import org.postgresql.PGConnection;
import android.util.Log;
@@ -176,8 +176,8 @@ public class MapDatabase implements IMapDatabase {
Log.d(TAG, "no index: skip way");
continue;
} else if (mIndexPos == 1) {
mapDatabaseCallback.renderPointOfInterest((byte) 0, mCoords[1],
mCoords[0], mTags);
mapDatabaseCallback.renderPointOfInterest((byte) 0, mTags,
mCoords[1], mCoords[0]);
} else {
short[] idx = new short[mIndexPos];

View File

@@ -17,7 +17,6 @@ package org.oscim.database.test;
import java.util.Map;
import org.oscim.core.BoundingBox;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tag;
import org.oscim.core.Tile;
import org.oscim.database.IMapDatabase;
@@ -25,7 +24,7 @@ import org.oscim.database.IMapDatabaseCallback;
import org.oscim.database.MapInfo;
import org.oscim.database.OpenResult;
import org.oscim.database.QueryResult;
import org.oscim.view.mapgenerator.JobTile;
import org.oscim.view.generator.JobTile;
/**
*
@@ -35,7 +34,7 @@ public class MapDatabase implements IMapDatabase {
private final static String PROJECTION = "Mercator";
private float[] mCoords = new float[20];
private short[] mIndex = new short[2];
private short[] mIndex = new short[4];
// private Tag[] mTags = { new Tag("boundary", "administrative"), new Tag("admin_level", "2") };
private Tag[] mTags = { new Tag("natural", "water") };
private Tag[] mNameTags;
@@ -46,64 +45,13 @@ public class MapDatabase implements IMapDatabase {
private boolean mOpenFile = false;
// private static double radius = 6378137;
// private static double D2R = Math.PI / 180;
// private static double HALF_PI = Math.PI / 2;
@Override
public QueryResult executeQuery(JobTile tile, IMapDatabaseCallback mapDatabaseCallback) {
long cx = tile.pixelX + (Tile.TILE_SIZE >> 1);
long cy = tile.pixelY + (Tile.TILE_SIZE >> 1);
// float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100, tile.zoomLevel) * 1000000;
// float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100, tile.zoomLevel) * 1000000;
// float lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 100, tile.zoomLevel) * 1000000;
// float lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 100, tile.zoomLevel) * 1000000;
float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100,
tile.zoomLevel);
float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100,
tile.zoomLevel);
float lat1 = (float) MercatorProjection
.pixelYToLatitude(cy - 100, tile.zoomLevel);
float lat2 = (float) MercatorProjection
.pixelYToLatitude(cy + 100, tile.zoomLevel);
// double lonRadians = (D2R * lon1);
// double latRadians = (D2R * lat1);
// spherical mercator projection
// lon1 = (float) (radius * lonRadians);
// lat1 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
//
// lonRadians = (D2R * lon2);
// latRadians = (D2R * lat2);
//
// lon2 = (float) (radius * lonRadians);
// lat2 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
//
// mCoords[0] = lon1;
// mCoords[1] = lat1;
//
// mCoords[2] = lon2;
// mCoords[3] = lat1;
//
// mCoords[4] = lon2;
// mCoords[5] = lat2;
//
// mCoords[6] = lon1;
// mCoords[7] = lat2;
//
// mCoords[8] = lon1;
// mCoords[9] = lat1;
//
// mIndex[0] = 10;
lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 139, tile.zoomLevel) * 1000000;
lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 139, tile.zoomLevel) * 1000000;
lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 139, tile.zoomLevel) * 1000000;
lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 139, tile.zoomLevel) * 1000000;
float lat1 = -0.5f;
float lon1 = -0.5f;
float lat2 = Tile.TILE_SIZE - 0.5f;
float lon2 = Tile.TILE_SIZE - 0.5f;
mCoords[0] = lon1;
mCoords[1] = lat1;
@@ -120,12 +68,13 @@ public class MapDatabase implements IMapDatabase {
mCoords[8] = lon1;
mCoords[9] = lat1;
mIndex[0] = 10;
mIndex[0] = 8;
mIndex[1] = 2;
lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 119, tile.zoomLevel) * 1000000;
lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 119, tile.zoomLevel) * 1000000;
lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 119, tile.zoomLevel) * 1000000;
lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 119, tile.zoomLevel) * 1000000;
lon1 = 40;
lon2 = Tile.TILE_SIZE - 40;
lat1 = 40;
lat2 = Tile.TILE_SIZE - 40;
mCoords[10] = lon1;
mCoords[11] = lat1;
@@ -142,24 +91,26 @@ public class MapDatabase implements IMapDatabase {
mCoords[18] = lon1;
mCoords[19] = lat1;
mIndex[1] = 10;
mIndex[2] = 8;
mIndex[3] = 2;
mapDatabaseCallback.renderWay((byte) 0, mTags, mCoords, mIndex, true);
lon1 = (float) MercatorProjection.pixelXToLongitude(cx, tile.zoomLevel) * 1000000;
lat1 = (float) MercatorProjection.pixelXToLongitude(cx, tile.zoomLevel) * 1000000;
lon1 = Tile.TILE_SIZE / 2;
lat1 = Tile.TILE_SIZE / 2;
mNameTags = new Tag[2];
mNameTags[0] = new Tag("place", "city");
mNameTags[1] = new Tag("name", "check one check two, YO!");
mapDatabaseCallback.renderPointOfInterest((byte) 0, (int) lat1, (int) lon1,
mNameTags);
mNameTags[1] = new Tag("name", tile.toString());
mapDatabaseCallback.renderPointOfInterest((byte) 0, mNameTags, (int) lat1,
(int) lon1);
return QueryResult.SUCCESS;
}
@Override
public String getMapProjection() {
return PROJECTION;
return null; // PROJECTION;
}
@Override
@@ -185,8 +136,6 @@ public class MapDatabase implements IMapDatabase {
@Override
public void cancel() {
// TODO Auto-generated method stub
}
}