- fix issue with hanging ui on clse when network is down
- add getters for rotation/compass enabled - cleanups
This commit is contained in:
parent
eace886f37
commit
76e1dcae7c
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.database;
|
package org.oscim.database;
|
||||||
|
|
||||||
|
|
||||||
import org.oscim.generator.JobTile;
|
import org.oscim.generator.JobTile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +56,8 @@ public interface IMapDatabase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the map file and destroys all internal caches. Has no effect if no
|
* Closes the map file and destroys all internal caches. Has no effect if no
|
||||||
* map file is currently opened.
|
* map file is currently opened. Should also force to close Socket so that
|
||||||
|
* thread cannot hang in socket.read
|
||||||
*/
|
*/
|
||||||
public abstract void close();
|
public abstract void close();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ import android.util.Log;
|
|||||||
/**
|
/**
|
||||||
* @author Hannes Janetzek
|
* @author Hannes Janetzek
|
||||||
* @note
|
* @note
|
||||||
* 1. MapWorker calls TileGenerator.execute to load a tile.
|
* 1. The MapWorkers call TileGenerator.execute() to load a tile.
|
||||||
* 2. The tile data will be loaded from current MapDatabase
|
* 2. The tile data will be loaded from current MapDatabase
|
||||||
* 3. MapDatabase calls the IMapDatabaseCallback functions
|
* 3. MapDatabase calls the IMapDatabaseCallback functions
|
||||||
* implemented by TileGenerator for WAY and POI items.
|
* implemented by TileGenerator for WAY and POI items.
|
||||||
@ -65,10 +65,14 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
public static final byte STROKE_MAX_ZOOM_LEVEL = 17;
|
public static final byte STROKE_MAX_ZOOM_LEVEL = 17;
|
||||||
|
|
||||||
private static RenderTheme renderTheme;
|
private static RenderTheme renderTheme;
|
||||||
|
private static int renderLevels;
|
||||||
|
private static DebugSettings debug;
|
||||||
|
|
||||||
|
// current MapDatabase used by this TileGenerator
|
||||||
private IMapDatabase mMapDatabase;
|
private IMapDatabase mMapDatabase;
|
||||||
|
|
||||||
private MapTile mCurrentTile;
|
// currently processed tile
|
||||||
|
private MapTile mTile;
|
||||||
|
|
||||||
// coordinates of the currently processed way
|
// coordinates of the currently processed way
|
||||||
private float[] mCoords;
|
private float[] mCoords;
|
||||||
@ -83,15 +87,12 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
private TextItem mLabels;
|
private TextItem mLabels;
|
||||||
|
|
||||||
private int mDrawingLayer;
|
private int mDrawingLayer;
|
||||||
private int mLevels;
|
|
||||||
|
|
||||||
private float mStrokeScale = 1.0f;
|
private float mStrokeScale = 1.0f;
|
||||||
|
|
||||||
private RenderInstruction[] mRenderInstructions = null;
|
private RenderInstruction[] mRenderInstructions = null;
|
||||||
|
|
||||||
//private final String TAG_WATER = "water".intern();
|
//private final MapView mMapView;
|
||||||
|
|
||||||
private final MapView mMapView;
|
|
||||||
|
|
||||||
private final Tag[] debugTagBox = { new Tag("debug", "box") };
|
private final Tag[] debugTagBox = { new Tag("debug", "box") };
|
||||||
private final Tag[] debugTagWay = { new Tag("debug", "way") };
|
private final Tag[] debugTagWay = { new Tag("debug", "way") };
|
||||||
@ -105,9 +106,9 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
private float mPoiX, mPoiY;
|
private float mPoiX, mPoiY;
|
||||||
private int mPriority;
|
private int mPriority;
|
||||||
|
|
||||||
|
// replacement for variable value tags that should not be matched by RenderTheme
|
||||||
private final static Tag mTagEmptyName = new Tag(Tag.TAG_KEY_NAME, null, false);
|
private final static Tag mTagEmptyName = new Tag(Tag.TAG_KEY_NAME, null, false);
|
||||||
private final static Tag mTagEmptyHouseNr = new Tag(Tag.TAG_KEY_HOUSE_NUMBER, null, false);
|
private final static Tag mTagEmptyHouseNr = new Tag(Tag.TAG_KEY_HOUSE_NUMBER, null, false);
|
||||||
|
|
||||||
private Tag mTagName;
|
private Tag mTagName;
|
||||||
private Tag mTagHouseNr;
|
private Tag mTagHouseNr;
|
||||||
|
|
||||||
@ -116,6 +117,11 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
public static void setRenderTheme(RenderTheme theme) {
|
public static void setRenderTheme(RenderTheme theme) {
|
||||||
renderTheme = theme;
|
renderTheme = theme;
|
||||||
|
renderLevels = theme.getLevels();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDebugSettings(DebugSettings debugSettings) {
|
||||||
|
debug = debugSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +129,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
* the MapView
|
* the MapView
|
||||||
*/
|
*/
|
||||||
public TileGenerator(MapView mapView) {
|
public TileGenerator(MapView mapView) {
|
||||||
mMapView = mapView;
|
// mMapView = mapView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
@ -135,25 +141,18 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
if (mMapDatabase == null)
|
if (mMapDatabase == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
tile = mCurrentTile = (MapTile) jobTile;
|
tile = mTile = (MapTile) jobTile;
|
||||||
DebugSettings debugSettings = mMapView.getDebugSettings();
|
|
||||||
|
|
||||||
mDebugDrawPolygons = !debugSettings.mDisablePolygons;
|
mDebugDrawPolygons = !debug.mDisablePolygons;
|
||||||
mDebugDrawUnmatched = debugSettings.mDrawUnmatchted;
|
mDebugDrawUnmatched = debug.mDrawUnmatchted;
|
||||||
|
|
||||||
if (tile.layers != null) {
|
if (tile.layers != null) {
|
||||||
// should be fixed now.
|
// should be fixed now.
|
||||||
Log.d(TAG, "XXX tile already loaded " + tile + " " + tile.state);
|
Log.d(TAG, "BUG tile already loaded " + tile + " " + tile.state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLevels = TileGenerator.renderTheme.getLevels();
|
|
||||||
|
|
||||||
// limit stroke scale at z=17
|
|
||||||
// if (tile.zoomLevel < STROKE_MAX_ZOOM_LEVEL)
|
|
||||||
setScaleStrokeWidth(tile.zoomLevel);
|
setScaleStrokeWidth(tile.zoomLevel);
|
||||||
// else
|
|
||||||
// setScaleStrokeWidth(STROKE_MAX_ZOOM_LEVEL);
|
|
||||||
|
|
||||||
// account for area changes with latitude
|
// account for area changes with latitude
|
||||||
mProjectionScaleFactor = 0.5f + 0.5f * (
|
mProjectionScaleFactor = 0.5f + 0.5f * (
|
||||||
@ -162,20 +161,6 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
mLayers = new Layers();
|
mLayers = new Layers();
|
||||||
|
|
||||||
//Log.d(TAG, "loading: " + tile);
|
|
||||||
// 180 degree angle in building
|
|
||||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 68728 && tile.tileY == 42634))
|
|
||||||
|
|
||||||
// bad bad poly!
|
|
||||||
// if ((tile.zoomLevel != 17) || (tile.tileX == 69767 && tile.tileY == 47236))
|
|
||||||
//g: [X:69165, Y:42344, Z:17]
|
|
||||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 69165 && tile.tileY == 42344))
|
|
||||||
|
|
||||||
// tram/service elements rendered as buildnig with vts
|
|
||||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 68744 && tile.tileY == 42650))
|
|
||||||
|
|
||||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 68736 && tile.tileY == 42653))
|
|
||||||
|
|
||||||
if (mMapDatabase.executeQuery(tile, this) != QueryResult.SUCCESS) {
|
if (mMapDatabase.executeQuery(tile, this) != QueryResult.SUCCESS) {
|
||||||
//Log.d(TAG, "Failed loading: " + tile);
|
//Log.d(TAG, "Failed loading: " + tile);
|
||||||
mLayers.clear();
|
mLayers.clear();
|
||||||
@ -188,7 +173,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debugSettings.mDrawTileFrames) {
|
if (debug.mDrawTileFrames) {
|
||||||
mTagName = new Tag("name", tile.toString(), false);
|
mTagName = new Tag("name", tile.toString(), false);
|
||||||
mPoiX = Tile.TILE_SIZE >> 1;
|
mPoiX = Tile.TILE_SIZE >> 1;
|
||||||
mPoiY = 10;
|
mPoiY = 10;
|
||||||
@ -201,7 +186,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
mIndices[0] = 10;
|
mIndices[0] = 10;
|
||||||
|
|
||||||
mCoords = debugBoxCoords;
|
mCoords = debugBoxCoords;
|
||||||
mDrawingLayer = 10 * mLevels;
|
mDrawingLayer = 10 * renderLevels;
|
||||||
TileGenerator.renderTheme.matchWay(this, debugTagBox, (byte) 0, false, true);
|
TileGenerator.renderTheme.matchWay(this, debugTagBox, (byte) 0, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +234,11 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
private boolean mRenderBuildingModel;
|
private boolean mRenderBuildingModel;
|
||||||
|
|
||||||
|
// Replace tags that should not be matched by value in RenderTheme
|
||||||
|
// to avoid caching RenderInstructions for each way of the same type
|
||||||
|
// only with different name.
|
||||||
|
// Maybe this should be done within RenderTheme, also allowing
|
||||||
|
// to set these replacement rules in theme file.
|
||||||
private boolean filterTags(Tag[] tags) {
|
private boolean filterTags(Tag[] tags) {
|
||||||
mRenderBuildingModel = false;
|
mRenderBuildingModel = false;
|
||||||
|
|
||||||
@ -260,7 +250,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
} else if (tags[i].key == Tag.TAG_KEY_HOUSE_NUMBER) {
|
} else if (tags[i].key == Tag.TAG_KEY_HOUSE_NUMBER) {
|
||||||
mTagHouseNr = tags[i];
|
mTagHouseNr = tags[i];
|
||||||
tags[i] = mTagEmptyHouseNr;
|
tags[i] = mTagEmptyHouseNr;
|
||||||
} else if (mCurrentTile.zoomLevel >= 17 &&
|
} else if (mTile.zoomLevel >= 17 &&
|
||||||
key == Tag.TAG_KEY_BUILDING) {
|
key == Tag.TAG_KEY_BUILDING) {
|
||||||
mRenderBuildingModel = true;
|
mRenderBuildingModel = true;
|
||||||
}
|
}
|
||||||
@ -270,17 +260,17 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
// ---------------- MapDatabaseCallback -----------------
|
// ---------------- MapDatabaseCallback -----------------
|
||||||
@Override
|
@Override
|
||||||
public void renderPointOfInterest(byte layer, Tag[] tags, float latitude,
|
public void renderPointOfInterest(byte layer, Tag[] tags,
|
||||||
float longitude) {
|
float latitude, float longitude) {
|
||||||
|
|
||||||
// reset state
|
// reset state
|
||||||
mTagName = null;
|
mTagName = null;
|
||||||
mTagHouseNr = null;
|
mTagHouseNr = null;
|
||||||
|
|
||||||
//if (mMapProjection != null) {
|
//if (mMapProjection != null) {
|
||||||
// long x = mCurrentTile.pixelX;
|
// long x = mTile.pixelX;
|
||||||
// long y = mCurrentTile.pixelY + Tile.TILE_SIZE;
|
// long y = mTile.pixelY + Tile.TILE_SIZE;
|
||||||
// long z = Tile.TILE_SIZE << mCurrentTile.zoomLevel;
|
// long z = Tile.TILE_SIZE << mTile.zoomLevel;
|
||||||
//
|
//
|
||||||
// double divx, divy;
|
// double divx, divy;
|
||||||
// long dx = (x - (z >> 1));
|
// long dx = (x - (z >> 1));
|
||||||
@ -297,10 +287,6 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
// mPoiX = (float) (longitude / divx - dx);
|
// mPoiX = (float) (longitude / divx - dx);
|
||||||
// double sinLat = Math.sin(latitude * PI180);
|
// double sinLat = Math.sin(latitude * PI180);
|
||||||
// mPoiY = (float) (Math.log((1.0 + sinLat) / (1.0 - sinLat)) * divy + dy);
|
// mPoiY = (float) (Math.log((1.0 + sinLat) / (1.0 - sinLat)) * divy + dy);
|
||||||
//
|
|
||||||
// // TODO remove this, only used for mapsforge maps
|
|
||||||
// if (mPoiX < -10 || mPoiX > Tile.TILE_SIZE + 10 || mPoiY < -10
|
|
||||||
// || mPoiY > Tile.TILE_SIZE + 10)
|
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
//} else {
|
//} else {
|
||||||
@ -313,7 +299,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
// Log.d(TAG, "renderPointOfInterest: " + mTagName);
|
// Log.d(TAG, "renderPointOfInterest: " + mTagName);
|
||||||
|
|
||||||
// mNodeRenderInstructions =
|
// mNodeRenderInstructions =
|
||||||
TileGenerator.renderTheme.matchNode(this, tags, mCurrentTile.zoomLevel);
|
TileGenerator.renderTheme.matchNode(this, tags, mTile.zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mClosed;
|
private boolean mClosed;
|
||||||
@ -334,23 +320,12 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
if (!filterTags(tags))
|
if (!filterTags(tags))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// mProjected = false;
|
mDrawingLayer = getValidLayer(layer) * renderLevels;
|
||||||
// mSimplify = 0.5f;
|
|
||||||
// if (closed) {
|
|
||||||
// if (mCurrentTile.zoomLevel < 14)
|
|
||||||
// mSimplify = 0.5f;
|
|
||||||
// else
|
|
||||||
// mSimplify = 0.2f;
|
|
||||||
// if (tags.length == 1 && TAG_WATER == (tags[0].value))
|
|
||||||
// mSimplify = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
mDrawingLayer = getValidLayer(layer) * mLevels;
|
|
||||||
mCoords = coords;
|
mCoords = coords;
|
||||||
mIndices = indices;
|
mIndices = indices;
|
||||||
|
|
||||||
mRenderInstructions = TileGenerator.renderTheme.matchWay(this, tags,
|
mRenderInstructions = TileGenerator.renderTheme.matchWay(this, tags,
|
||||||
(byte) (mCurrentTile.zoomLevel + 0), closed, true);
|
(byte) (mTile.zoomLevel + 0), closed, true);
|
||||||
|
|
||||||
if (mRenderInstructions == null && mDebugDrawUnmatched)
|
if (mRenderInstructions == null && mDebugDrawUnmatched)
|
||||||
debugUnmatched(closed, tags);
|
debugUnmatched(closed, tags);
|
||||||
@ -380,7 +355,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
public boolean checkWay(Tag[] tags, boolean closed) {
|
public boolean checkWay(Tag[] tags, boolean closed) {
|
||||||
|
|
||||||
mRenderInstructions = TileGenerator.renderTheme.matchWay(this, tags,
|
mRenderInstructions = TileGenerator.renderTheme.matchWay(this, tags,
|
||||||
(byte) (mCurrentTile.zoomLevel + 0), closed, false);
|
(byte) (mTile.zoomLevel + 0), closed, false);
|
||||||
|
|
||||||
return mRenderInstructions != null;
|
return mRenderInstructions != null;
|
||||||
}
|
}
|
||||||
@ -426,7 +401,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
int numLayer = mDrawingLayer + level;
|
int numLayer = mDrawingLayer + level;
|
||||||
|
|
||||||
if (mRenderBuildingModel) {
|
if (mRenderBuildingModel) {
|
||||||
//Log.d(TAG, "add buildings: " + mCurrentTile + " " + mPriority);
|
//Log.d(TAG, "add buildings: " + mTile + " " + mPriority);
|
||||||
if (mLayers.extrusionLayers == null)
|
if (mLayers.extrusionLayers == null)
|
||||||
mLayers.extrusionLayers = new ExtrusionLayer(0);
|
mLayers.extrusionLayers = new ExtrusionLayer(0);
|
||||||
|
|
||||||
@ -553,9 +528,9 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
//
|
//
|
||||||
// float[] coords = mCoords;
|
// float[] coords = mCoords;
|
||||||
//
|
//
|
||||||
// long x = mCurrentTile.pixelX;
|
// long x = mTile.pixelX;
|
||||||
// long y = mCurrentTile.pixelY + Tile.TILE_SIZE;
|
// long y = mTile.pixelY + Tile.TILE_SIZE;
|
||||||
// long z = Tile.TILE_SIZE << mCurrentTile.zoomLevel;
|
// long z = Tile.TILE_SIZE << mTile.zoomLevel;
|
||||||
// float min = mSimplify;
|
// float min = mSimplify;
|
||||||
//
|
//
|
||||||
// double divx, divy = 0;
|
// double divx, divy = 0;
|
||||||
|
@ -70,8 +70,8 @@ public class MapView extends RelativeLayout {
|
|||||||
public static final boolean testRegionZoom = false;
|
public static final boolean testRegionZoom = false;
|
||||||
private static final boolean debugDatabase = false;
|
private static final boolean debugDatabase = false;
|
||||||
|
|
||||||
public boolean enableRotation = false;
|
public boolean mRotationEnabled = false;
|
||||||
public boolean enableCompass = false;
|
public boolean mCompassEnabled = false;
|
||||||
public boolean enablePagedFling = false;
|
public boolean enablePagedFling = false;
|
||||||
|
|
||||||
private final MapViewPosition mMapViewPosition;
|
private final MapViewPosition mMapViewPosition;
|
||||||
@ -82,8 +82,6 @@ public class MapView extends RelativeLayout {
|
|||||||
private final TouchHandler mTouchEventHandler;
|
private final TouchHandler mTouchEventHandler;
|
||||||
private final Compass mCompass;
|
private final Compass mCompass;
|
||||||
|
|
||||||
//private MapDatabases mMapDatabaseType;
|
|
||||||
|
|
||||||
private TileManager mTileManager;
|
private TileManager mTileManager;
|
||||||
private final OverlayManager mOverlayManager;
|
private final OverlayManager mOverlayManager;
|
||||||
|
|
||||||
@ -96,9 +94,8 @@ public class MapView extends RelativeLayout {
|
|||||||
|
|
||||||
private MapOptions mMapOptions;
|
private MapOptions mMapOptions;
|
||||||
private IMapDatabase mMapDatabase;
|
private IMapDatabase mMapDatabase;
|
||||||
|
|
||||||
private DebugSettings debugSettings;
|
|
||||||
private String mRenderTheme;
|
private String mRenderTheme;
|
||||||
|
private DebugSettings mDebugSettings;
|
||||||
|
|
||||||
private boolean mClearTiles;
|
private boolean mClearTiles;
|
||||||
|
|
||||||
@ -141,8 +138,6 @@ public class MapView extends RelativeLayout {
|
|||||||
|
|
||||||
MapActivity mapActivity = (MapActivity) context;
|
MapActivity mapActivity = (MapActivity) context;
|
||||||
|
|
||||||
debugSettings = new DebugSettings(false, false, false, false);
|
|
||||||
|
|
||||||
mMapViewPosition = new MapViewPosition(this);
|
mMapViewPosition = new MapViewPosition(this);
|
||||||
mMapPosition = new MapPosition();
|
mMapPosition = new MapPosition();
|
||||||
|
|
||||||
@ -160,6 +155,9 @@ public class MapView extends RelativeLayout {
|
|||||||
|
|
||||||
mMapWorkers = new MapWorker[mNumMapWorkers];
|
mMapWorkers = new MapWorker[mNumMapWorkers];
|
||||||
|
|
||||||
|
mDebugSettings = new DebugSettings(false, false, false, false);
|
||||||
|
TileGenerator.setDebugSettings(mDebugSettings);
|
||||||
|
|
||||||
for (int i = 0; i < mNumMapWorkers; i++) {
|
for (int i = 0; i < mNumMapWorkers; i++) {
|
||||||
TileGenerator tileGenerator = new TileGenerator(this);
|
TileGenerator tileGenerator = new TileGenerator(this);
|
||||||
mMapWorkers[i] = new MapWorker(i, mJobQueue, tileGenerator, mTileManager);
|
mMapWorkers[i] = new MapWorker(i, mJobQueue, tileGenerator, mTileManager);
|
||||||
@ -181,7 +179,7 @@ public class MapView extends RelativeLayout {
|
|||||||
|
|
||||||
mMapZoomControls = new MapZoomControls(mapActivity, this);
|
mMapZoomControls = new MapZoomControls(mapActivity, this);
|
||||||
mMapZoomControls.setShowMapZoomControls(true);
|
mMapZoomControls.setShowMapZoomControls(true);
|
||||||
enableRotation = true;
|
mRotationEnabled = true;
|
||||||
|
|
||||||
//mOverlayManager.add(new GenericOverlay(this, new GridOverlay(this)));
|
//mOverlayManager.add(new GenericOverlay(this, new GridOverlay(this)));
|
||||||
mOverlayManager.add(new BuildingOverlay(this));
|
mOverlayManager.add(new BuildingOverlay(this));
|
||||||
@ -224,13 +222,6 @@ public class MapView extends RelativeLayout {
|
|||||||
mGLView.requestRender();
|
mGLView.requestRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return the map database which is used for reading map files.
|
|
||||||
// */
|
|
||||||
// public IMapDatabase getMapDatabase() {
|
|
||||||
// return mMapDatabase;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current position and zoom level of this MapView.
|
* @return the current position and zoom level of this MapView.
|
||||||
*/
|
*/
|
||||||
@ -239,7 +230,7 @@ public class MapView extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void enableRotation(boolean enable) {
|
public void enableRotation(boolean enable) {
|
||||||
enableRotation = enable;
|
mRotationEnabled = enable;
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
enableCompass(false);
|
enableCompass(false);
|
||||||
@ -247,10 +238,10 @@ public class MapView extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void enableCompass(boolean enable) {
|
public void enableCompass(boolean enable) {
|
||||||
if (enable == this.enableCompass)
|
if (enable == mCompassEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.enableCompass = enable;
|
mCompassEnabled = enable;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
enableRotation(false);
|
enableRotation(false);
|
||||||
@ -261,6 +252,14 @@ public class MapView extends RelativeLayout {
|
|||||||
mCompass.disable();
|
mCompass.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCompassEnabled() {
|
||||||
|
return mCompassEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getRotationEnabled() {
|
||||||
|
return mRotationEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||||
// mMapZoomControls.onMapViewTouchEvent(motionEvent.getAction()
|
// mMapZoomControls.onMapViewTouchEvent(motionEvent.getAction()
|
||||||
@ -305,7 +304,8 @@ public class MapView extends RelativeLayout {
|
|||||||
* the new DebugSettings for this MapView.
|
* the new DebugSettings for this MapView.
|
||||||
*/
|
*/
|
||||||
public void setDebugSettings(DebugSettings debugSettings) {
|
public void setDebugSettings(DebugSettings debugSettings) {
|
||||||
this.debugSettings = debugSettings;
|
mDebugSettings = debugSettings;
|
||||||
|
TileGenerator.setDebugSettings(debugSettings);
|
||||||
clearAndRedrawMap();
|
clearAndRedrawMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ public class MapView extends RelativeLayout {
|
|||||||
* @return the debug settings which are used in this MapView.
|
* @return the debug settings which are used in this MapView.
|
||||||
*/
|
*/
|
||||||
public DebugSettings getDebugSettings() {
|
public DebugSettings getDebugSettings() {
|
||||||
return debugSettings;
|
return mDebugSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMapOptions() {
|
public Map<String, String> getMapOptions() {
|
||||||
@ -488,27 +488,20 @@ public class MapView extends RelativeLayout {
|
|||||||
mapWorkersProceed();
|
mapWorkersProceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
||||||
// // super.onLayout(changed, left, top, right, bottom);
|
|
||||||
// mMapZoomControls.onLayout(changed, left, top, right, bottom);
|
|
||||||
// }
|
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
for (MapWorker mapWorker : mMapWorkers) {
|
for (MapWorker mapWorker : mMapWorkers) {
|
||||||
mapWorker.pause();
|
mapWorker.pause();
|
||||||
mapWorker.interrupt();
|
mapWorker.interrupt();
|
||||||
|
|
||||||
|
mapWorker.getTileGenerator().getMapDatabase().close();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// FIXME this hangs badly sometimes,
|
|
||||||
// just let it crash...
|
|
||||||
mapWorker.join(10000);
|
mapWorker.join(10000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// restore the interrupted status
|
// restore the interrupted status
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
TileGenerator tileGenerator = mapWorker.getTileGenerator();
|
|
||||||
tileGenerator.getMapDatabase().close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +514,7 @@ public class MapView extends RelativeLayout {
|
|||||||
mJobQueue.clear();
|
mJobQueue.clear();
|
||||||
mapWorkersPause(true);
|
mapWorkersPause(true);
|
||||||
|
|
||||||
if (this.enableCompass)
|
if (this.mCompassEnabled)
|
||||||
mCompass.disable();
|
mCompass.disable();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -530,7 +523,7 @@ public class MapView extends RelativeLayout {
|
|||||||
Log.d(TAG, "onResume");
|
Log.d(TAG, "onResume");
|
||||||
mapWorkersProceed();
|
mapWorkersProceed();
|
||||||
|
|
||||||
if (this.enableCompass)
|
if (this.mCompassEnabled)
|
||||||
mCompass.enable();
|
mCompass.enable();
|
||||||
|
|
||||||
mPausing = false;
|
mPausing = false;
|
||||||
@ -669,17 +662,6 @@ public class MapView extends RelativeLayout {
|
|||||||
return new GeoPoint(mMapPosition.lat, mMapPosition.lon);
|
return new GeoPoint(mMapPosition.lat, mMapPosition.lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
||||||
// // TODO Auto-generated method stub
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void onMeasure()) {
|
|
||||||
// // TODO Auto-generated method stub
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// /**
|
// /**
|
||||||
// * Sets the visibility of the zoom controls.
|
// * Sets the visibility of the zoom controls.
|
||||||
// *
|
// *
|
||||||
|
@ -475,7 +475,7 @@ public class MapViewPosition {
|
|||||||
double dx = mx / mScale;
|
double dx = mx / mScale;
|
||||||
double dy = my / mScale;
|
double dy = my / mScale;
|
||||||
|
|
||||||
if (mMapView.enableRotation || mMapView.enableCompass) {
|
if (mMapView.mRotationEnabled || mMapView.mCompassEnabled) {
|
||||||
double rad = Math.toRadians(mRotation);
|
double rad = Math.toRadians(mRotation);
|
||||||
double rcos = Math.cos(rad);
|
double rcos = Math.cos(rad);
|
||||||
double rsin = Math.sin(rad);
|
double rsin = Math.sin(rad);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user